CRM2011內(nèi)部使用手冊(cè)V10_第1頁(yè)
CRM2011內(nèi)部使用手冊(cè)V10_第2頁(yè)
CRM2011內(nèi)部使用手冊(cè)V10_第3頁(yè)
CRM2011內(nèi)部使用手冊(cè)V10_第4頁(yè)
CRM2011內(nèi)部使用手冊(cè)V10_第5頁(yè)
已閱讀5頁(yè),還剩34頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、CRM2011系統(tǒng)V1.0使用手冊(cè)36目 錄第一章 客戶端常用函數(shù)(rt_common.js)11.1 概述11.2 腳本文件rt_common.js11.2.1 rt_refresh11.2.2 rt_getResponse11.2.3 rt_getJSON21.2.4 rt_retrieveRecord21.2.5 rt_retrieveRecords21.2.6 rt_disable_all31.2.7 rt_forceSubmit31.2.8 rt_getRibbonStatusByApprovalstatus41.2.9 rt_doButtonMethod41.2.10 rt_set

2、CustomerLookup51.2.11 rt_setLookup61.2.12 rt_entityReferenceToLookup61.2.13 rt_clear_data61.2.14 rt_flowDisabled71.2.15 rt_getParentFormStatusValue71.3 腳本文件rt_lookup.js81.3.1 rt_lookup81.3.2 rt_lookupDepart81.3.3 rt_lookupCustomerEntity8第二章 服務(wù)器端基礎(chǔ)類(mon.dll)92.1 常用數(shù)據(jù)庫(kù)操作類92.1.1 Config類92.1.2 DataBase類

3、和IDataBase接口102.1.3 DataBaseManager類122.1.4 PersisitBroker類132.2 Crm常用幫助類132.2.1 CrmCommand類132.2.4 UserData類142.2.5 Logging類152.3 IFlowAction 接口172.4 實(shí)體拷貝19第三章 Plugin公用類說(shuō)明213.1 概述213.2 公用類說(shuō)明213.2.1 Cast 類213.2.2 Exp 類213.2.3 EntityQuery 類223.2.4 EntityManager 類223.2.5 PluginUtils 類23第四章 系統(tǒng)基礎(chǔ)實(shí)體的使用24

4、4.1 簽核流程配置244.2 重復(fù)性記錄檢測(cè)274.3 自動(dòng)編號(hào)284.4 系統(tǒng)參數(shù)29第五章 Excel導(dǎo)入配置305.1 概述305.2 操作步驟30第一章 客戶端常用函數(shù)(rt_common.js)1.1 概述1. 本章講述客戶端常用的函數(shù),這些函數(shù)是瑞泰開(kāi)發(fā)者為方便高效開(kāi)發(fā)而封裝的一些通用的工具。1.2 腳本文件rt_common.js1.2.1 rt_refresh定義: function rt_refresh()參數(shù):用途: 刷新當(dāng)前CRM頁(yè)面操作步驟:1. 示例代碼如下:rt_refresh();1.2.2 rt_getResponse定義:function rt_getRes

5、ponse(serverUrl) 參數(shù):serverUrl:ajax同步調(diào)用的服務(wù)端Url 用途: 同步調(diào)用服務(wù)端并獲取返回值操作步驟:1. 在客戶端調(diào)用該函數(shù):var serverUrl = tocol + / + window.location.host + / + window.Xrm.Page.context.getOrgUniqueName();var returnStr=getResponse(serverUrl);1.2.3 rt_getJSON定義:function rt_getJSON(serverUrl) 參數(shù):serverUrl:aj

6、ax同步調(diào)用的服務(wù)端Url 用途: 同步調(diào)用服務(wù)端,獲取返回值JSON操作步驟:1. 在客戶端調(diào)用該函數(shù):var serverUrl = tocol + / + window.location.host + / + window.Xrm.Page.context.getOrgUniqueName();var returnStr=getResponse(serverUrl);1.2.4 rt_retrieveRecord定義:function rt_retrieveRecord(id,odataSetName) 參數(shù):id: 實(shí)體主鍵值odataSetNam

7、e:實(shí)體名稱+Set用途: 通過(guò)OData的方式讀取數(shù)據(jù)(同步)操作步驟:1. 在客戶端調(diào)用該函數(shù),示例代碼如下:var obj=rt_retrieveRecord(Xrm.Page.data.entity.getId(),AccountSet);If(obj!=null) Xrm.Page.data.entity.attributes.get(“new_name”).setValue(obj.Name);1.2.5 rt_retrieveRecords定義:function rt_retrieveRecords(filter, odataSetName)參數(shù): filter:過(guò)濾條件(指定為

8、在集合中返回記錄計(jì)算結(jié)果必須為 true 的表達(dá)式或函數(shù)) odataSetName:實(shí)體名稱+Set用途:通過(guò)OData的方式讀取多條數(shù)據(jù)(同步)操作步驟:1. 示例代碼如下:Var wlbu=rt_retrieveRecords(new_child_buid/Id eq (guid + Xrm.Page.getAttribute(new_return_buid).getValue()0.id + ) and new_type/Value eq 5, new_bu_relationshipSet);if (wlbu != null & wlbu.results != null & wlbu.

9、results.length 0) rt_setLookup(new_ls_buid, rt_entityReferenceToLookup(wlbu.results0.new_main_buid), false);else rt_setLookup(new_ls_buid, rt_entityReferenceToLookup(order.new_CreateOrg), false);1.2.6 rt_disable_all定義:function rt_disable_all() 參數(shù):用途: 禁用頁(yè)面上的所有控件(iframe,subgrid子網(wǎng)格除外)操作步驟:1. 在客戶端調(diào)用該函數(shù):

10、if(Xrm.Page.data.entity.attributes.get(new_approvalstatus).getValue() != 1) rt_disable_all();1.2.7 rt_forceSubmit定義:function rt_forceSubmit() 參數(shù):用途: CRM表單數(shù)據(jù)中禁用的表單字段的值不會(huì)被post到服務(wù)器導(dǎo)致在表單更新的時(shí)候不能更新被禁用的字段的值,該方法可以強(qiáng)制表單所有字段被提交,包括被禁用的字段。操作步驟:1. 直接在客戶端調(diào)用該函數(shù),如:rt_forceSubmit();1.2.8 rt_getRibbonStatusByApprovals

11、tatus定義:function rt_getRibbonStatusByApprovalstatus參數(shù):用途: 根據(jù)new_approvalstatus設(shè)置Ribbon的狀態(tài),主要在配置Ribbon的時(shí)候使用操作步驟: 1. 打開(kāi)實(shí)體的customizations.xml文件,找到配置節(jié),如: 1.2.9 rt_doButtonMethod 定義:function rt_doButtonMethod(actiontype)參數(shù): actiontype:要執(zhí)行的自定義的動(dòng)作名用途: Ribbon自定義按鈕的統(tǒng)一調(diào)用函數(shù),主要在配置Ribbon的時(shí)候使用操作步驟:1. 打開(kāi)實(shí)體的customi

12、zations.xml文件,找到配置節(jié),如: 1.2.10 rt_setCustomerLookup定義:function rt_setCustomerLookup(lookup, customerfunction)參數(shù):lookup:lookup控件的名稱customerfunction:待執(zhí)行的自定義函數(shù)用途: 設(shè)置自定義Lookup查找功能操作步驟:1.示例代碼如下:rt_setCustomerLookup(new_orderid,salesOrderLookup);functionsalesOrderLookup()varwhere=;where=where+andnew_status

13、=9;varret=window.showModalDialog(./RekTecWeb/common/SalesOrderLookupSingle.aspx?where=+where,window,dialogWidth:600px;dialogHeight:540px;);varobj;if(ret=)obj=null;returnfalse;elseobj=eval(ret);if(obj!=null)rt_setLookup(new_orderid,obj,false);varorder=rt_getFieldValue(obj0.id,new_om_SalesOrder);if(or

14、der!=null)setSalesOrderRelateField(order);returntrue; 1.2.11 rt_setLookup定義:function rt_setLookup(lookup, value, disabled)參數(shù):lookup:lookup控件的名稱value: 值disabled:狀態(tài)用途:設(shè)定自定義Lookup值和狀態(tài)操作步驟:1. 參考1.2.5的示例代碼1.2.12 rt_entityReferenceToLookup定義:function rt_entityReferenceToLookup(value)參數(shù):value: 值用途:將EntityR

15、eference的json對(duì)象轉(zhuǎn)成Lookup操作步驟:1. 參考1.2.5的示例代碼1.2.13 rt_clear_data定義:function rt_clear_data(fields)參數(shù): fields:需要清除值的表單字段名用途: 清空表單字段的數(shù)據(jù)操作步驟:1. 直接在客戶端調(diào)用該函數(shù), 示例代碼如下:rt_clear_data(new_partner,new_account,new_conference,new_assessselectform,new_contracttype,new_announcementdate,new_receivedriskmargin,new_re

16、ceivedauctiondepositamount);1.2.14 rt_flowDisabled定義:function rt_flowDisabled() 參數(shù):用途: 在簽核流程中判斷是表單否包含new_approvalstatus字段來(lái)判斷是主檔還是明細(xì),如果有new_approvalstatus字段則調(diào)用rt_flowDisabledField()函數(shù)判斷簽核流程是否已完成并禁用相應(yīng)字段操作步驟:1. 直接在客戶端調(diào)用該函數(shù), 示例代碼如下:rt_flowDisabled();1.2.15 rt_getParentFormStatusValue定義:function rt_getPa

17、rentFormStatusValue(fieldName)參數(shù):fieldName:父實(shí)體表單上狀態(tài)字段的名稱用途: 獲取父實(shí)體表單上狀態(tài)字段的值,通常用于明細(xì)實(shí)體獲取主檔表單上的字段的值操作步驟:1. 直接在客戶端調(diào)用該函數(shù), 示例代碼如下:var status=rt_getParentFormStatusValue(“new_approvalstatus”);1.3 腳本文件rt_lookup.js1.3.1 rt_lookup定義:function rt_lookup(controlName, entityName, fetchXml, layoutXml) 參數(shù):controlNam

18、e: 過(guò)濾的字段名稱entityName: 實(shí)體名稱fetchXml: 構(gòu)造的FetchXMLlayoutXml: 構(gòu)造的LayoutXML用途: 對(duì)標(biāo)準(zhǔn)Lookup處理函數(shù)封裝,其他自定義的Lookup均調(diào)用此函數(shù)操作步驟:1.3.2 rt_lookupDepart定義:function rt_lookupDepart(depart) 參數(shù):depart: 業(yè)務(wù)部門字段名稱(例如:省公司,省辦事處之類)用途: 對(duì)標(biāo)準(zhǔn)Lookup處理函數(shù)封裝,其他自定義的Lookup均調(diào)用此函數(shù)操作步驟:1. 直接在客戶端調(diào)用該函數(shù), 示例代碼如下:function form_onload() rt_look

19、upDepart(“new_depart”);1.3.3 rt_lookupCustomerEntity定義:function rt_lookupCustomerEntity(entityName,subField, mainField,sub2mainField)參數(shù):entityName: 要查詢的實(shí)體名稱subField: 子字段的名稱mainField: 父字段的名稱sub2mainField: 查詢實(shí)體中父字段的名稱用途: 關(guān)聯(lián)字段過(guò)濾查詢(例如省份過(guò)濾城市,城市過(guò)濾區(qū)縣)操作步驟:1. 直接在客戶端調(diào)用該函數(shù), 示例代碼如下:/省份過(guò)濾城市function new_province

20、id_onchange() rt_lookupCustomerEntity(new_city,new_cityid,new_provinceid,new_provinceid);第二章 服務(wù)器端基礎(chǔ)類(mon.dll)2.1 常用數(shù)據(jù)庫(kù)操作類2.1.1 Config類定義: public class Config.用途:操作RekTec.Crm.Config.xml配置文件主要成員:1. private void Load()使用IO操作讀取RekTec.Crm.Config.xml配置文件2. public void Save()將修改后的XML配置文檔保存到文件中3. public str

21、ing GetValueByName(string name)根據(jù)在配置文件中配置的SQL連接字符串名稱來(lái)獲取對(duì)應(yīng)的數(shù)據(jù)庫(kù)連接字符串,示例如下: private static Config _config = new Config(); public static IDataBase GetDataBase(string type) string connect = string.Empty; try connect = _config.GetValueByName(type); catch connect = string.Empty; if (connect != null & conne

22、ct != string.Empty) return new OleDataBase(connect); else return new DataBase(); 2.1.2 DataBase類和IDataBase接口定義:public class DataBase : IDataBase.public interface IDataBase用途:提供常用的數(shù)據(jù)庫(kù)操作主要成員:DataBase類實(shí)現(xiàn)了IDataBase 接口,包括對(duì)數(shù)據(jù)操作的常用方法。public class CrmData / 僅為部分CrmData類代碼 private IDataBase _db; private IDat

23、aBase _defaultDb; public CrmData() _db = new DataBase(); protected IDataBase Db get if (_db = null) _db = new DataBase(); return _db; set _db = value; protected IDataBase DefaultDb get if (_defaultDb = null) _defaultDb = new DataBase(new Config().connectionStringDefault); return _defaultDb; set _def

24、aultDb = value; 1. 執(zhí)行SQL查詢語(yǔ)句,如:public void Execute(string sqlText)public System.Data.DataTable Query(string sql)public System.Data.DataSet QueryDataSet(string sql)public object QueryScalar(string sql)2. 執(zhí)行存儲(chǔ)過(guò)程,如:public string ExecuteProc(string procName, string paramValue)public object ExecuteProc(s

25、tring procName, object paramsValue)具體參數(shù)描述可以查看源碼的注釋示例代碼: public class AssessApplyForm:CrmData public AssessApplyForm(IDataBase db) : base(db) public AssessApplyForm() : base() public string Submit(string id) try string sqlmain = string.Format(update new_assetproject set new_assessmentstatus = 1 where

26、 deletionstatecode=0 and new_assetprojectid=(SELECT new_assetproject FROM new_assessapplyform WHERE new_assessapplyformid=0)?, id); this.Db.Execute(sqlmain); return string.Empty; catch (Exception ex) _log.LogException(ex); return ex.Message; 2.1.3 DataBaseManager類定義: public class DataBaseManager.用途:

27、獲取在RekTec.Crm.Config.xml配置文件中配置的的連接字符串對(duì)應(yīng)的IDataBase接口實(shí)例主要成員:1. public static IDataBase GetDataBase(string type) string connect = string.Empty; try connect = _config.GetValueByName(type); catch connect = string.Empty; if (connect != null & connect != string.Empty) return new OleDataBase(connect); else

28、 return new DataBase(); 參數(shù)type為RekTec.Crm.Config.xml 配置的連接字符串名稱,配置文件參考: 2.1.4 PersisitBroker類定義: public class PersisitBroker.用途:提供通用的對(duì)象的CRUD(創(chuàng)建、讀取、修改、刪除)操作主要成員:1. 構(gòu)造函數(shù)(1) public PersisitBroker()無(wú)參的構(gòu)造函數(shù),默認(rèn)為當(dāng)前用戶操作(2) public PersisitBroker(bool isUseAdminAccount)指定為管理員操作(3) public PersisitBroker(string

29、 orgname)支持多組織的數(shù)據(jù)庫(kù),默認(rèn)為當(dāng)前用戶操作(4) public PersisitBroker(string orgname ,bool isUseAdminAccount)支持多組織的數(shù)據(jù)庫(kù),指定為管理員操作2. 用戶ID(1) public Guid GetCurrenUserId() 獲取當(dāng)前用戶ID(2) public Guid GetAdminUserId() 獲取CRM管理員ID3. CRUD(創(chuàng)建、讀取、修改、刪除)操作(1) public Guid Create(Microsoft.Xrm.Sdk.Entity obj, OwnerType ot)創(chuàng)建操作,在數(shù)據(jù)庫(kù)

30、創(chuàng)建一條數(shù)據(jù)(2) public void Update(Microsoft.Xrm.Sdk.Entity obj, OwnerType ot)更新操作,在數(shù)據(jù)庫(kù)更新一條數(shù)據(jù)(3) public void Delete(string typeName, string id) typeName:實(shí)體名稱刪除操作,根據(jù)主鍵來(lái)刪除指定實(shí)體的數(shù)據(jù)(4) public void DeleteByWhere(string typeName, string where)根據(jù)where條件來(lái)刪除指定實(shí)體的數(shù)據(jù)(5) public T Retrieve(string typeName, string id) w

31、here T : Microsoft.Xrm.Sdk.Entity, new() 讀取操作,根據(jù)主鍵來(lái)獲取指定實(shí)體的數(shù)據(jù)(6) public T Retrieve(string typeName, string strSql, Dictionary paramList) where T : Microsoft.Xrm.Sdk.Entity, new()根據(jù)指定的Sql獲取結(jié)果集中的第一條數(shù)據(jù)(7) public IList RetrieveMultiple(string typeName, string sql) where T : Microsoft.Xrm.Sdk.Entity, new(

32、) 根據(jù)指定的Sql獲取指定實(shí)體的多條數(shù)據(jù)(8) public IList RetrieveMultiple(string typeName, string sql, Dictionary paramList) where T : Microsoft.Xrm.Sdk.Entity, new() 根據(jù)指定的Sql 和 指定的參數(shù) 獲取指定實(shí)體的多條數(shù)據(jù)(9) public IList RetrieveMultiple(string typeName, string sql, Dictionary paramList, string orderby, int pageSize, int pageI

33、ndex,out int recordCount) where T : Microsoft.Xrm.Sdk.Entity, new() 根據(jù)指定的Sql、指定的參數(shù)、指定的排序規(guī)則和指定的頁(yè)數(shù) 獲取指定實(shí)體的多條數(shù)據(jù)4. 數(shù)據(jù)庫(kù)操作的公共方法(1) public void OpenDb()打開(kāi)數(shù)據(jù)庫(kù)(2) public void CloseDb()關(guān)閉數(shù)據(jù)庫(kù)(3) public void BeginTransaction()打開(kāi)事務(wù)(4) public void Commit()提交事務(wù)(5) public void Rollback()回滾事務(wù)5. CRM的公共方法(1) public vo

34、id Assign(string entityName, string entityId, string ownerid, OwnerType ot)通過(guò)SQL語(yǔ)句更新OwnerID限制條件:1)實(shí)體不能有關(guān)聯(lián)子實(shí)體需要更新 2)不能有相關(guān)的工作流需要執(zhí)行 3)不能有Assign相關(guān)的Plugin(2) public void InActive(string typeName, string id)通過(guò)SQL語(yǔ)句禁用實(shí)體數(shù)據(jù)(3) public void Active(string typeName, string id)通過(guò)SQL語(yǔ)句啟用實(shí)體數(shù)據(jù)示例代碼:請(qǐng)參考 Crm常用幫

35、助類2.2.1 CrmCommand類定義: public class CrmCommand .用途:供各個(gè)功能調(diào)用的基礎(chǔ)類,包含IOrganizationService 和 DataBase 的定義主要成員:1. private IOrganizationService _service;獲取一個(gè)IOrganizationService實(shí)例部分參照代碼: private IOrganizationService _service; public IOrganizationService OrganizationService get if (_service = null) CrmServi

36、ceHelper h = new CrmServiceHelper(); _service = h.GetOrganizationService(); return _service; 2. 獲取一個(gè)RekTecContext實(shí)例 public RekTec.Crm.Entity.RekTecContext OrganizationServiceContext get return new RekTec.Crm.Entity.RekTecContext(this.OrganizationService); 3. private PersisitBroker _broker;提供通用的對(duì)象的CR

37、UD操作4. public Guid GetCurrenUserId()獲取當(dāng)前登錄用戶的ID5. public Guid GetAdminUserId()獲取當(dāng)前CRM管理員的ID6. public void LogException(Exception ex)記錄異常日志信息7. public void LogError(string errorMessage)記錄錯(cuò)誤日志信息示例代碼: public class PackageInCommand : CrmCommand / / 構(gòu)造函數(shù) / public PackageInCommand() / / 構(gòu)造函數(shù) / / public Pa

38、ckageInCommand(PersisitBroker broker) this.Broker = broker; / / 創(chuàng)建入庫(kù) / / 待入庫(kù)數(shù)據(jù) public void CreatePackageIn(string packageid, int packageinquantity, string warehouse, string memo) try this.Broker.OpenDb(); this.Broker.BeginTransaction(); new_packagein entity = new new_packagein(); new_package package

39、 = this.Broker.Retrieve(new_package, packageid); if (package != null) entity.new_package = new Microsoft.Xrm.Sdk.EntityReference(new_package.EntityLogicalName, new Guid(packageid); entity.new_seq = package.new_seq; entity.new_name = package.new_name; entity.new_seqtext = package.new_seqtext; entity.

40、new_partsname = package.new_partsname; entity.new_weight = (package.new_weight / package.new_quantity) * packageinquantity; entity.new_quantity = package.new_quantity; entity.new_packgeunit = package.new_packgeunit; entity.new_packagequantity = packageinquantity; entity.new_warehouse = new Microsoft

41、.Xrm.Sdk.EntityReference(new_warehouse, new Guid(warehouse); entity.new_memo = memo; entity.new_shipquantity = 0; entity.new_validquantity = packageinquantity; entity.new_salerorder = package.new_salesorder; entity.new_salesorderproduct = package.new_salesorderproduct; entity.new_product = package.new_product; /創(chuàng)建入庫(kù) this.Broker.C

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論