标签:
1、新建一个纯类,命名空间是:
namespace SimPerfect.CSAControlLibrary.CSAControls
2、实现两个构造函数:无参和传Candy参数
public CDealProcess() { InitMe(); } public CDealProcess(Candy parentCandy) { this.ParentCandy = parentCandy; InitMe(); }
3、编写InitMe()方法初始化控件属性:
private void InitMe() { base.SetDragMode(1); base.SetControlName("控件名称"); base.SetControlDefaultSize(315, 975);//默认大小 }
4、重写RefreshMe()方法并进行异步消息事件的注册
public override void RefreshMe() { base.RefreshMe(); if (this.ParentCandy != null && this.ParentCandy.BindPebble != null) { ParentCandy.BindPebble.Event_PebbleRunSQLInvokeIDWithReturn -= new Pebble.EVENT_PebbleRunSQLInvokeIDWithReturn(BindPebble_Event_PebbleRunSQLInvokeIDWithReturn); ParentCandy.BindPebble.Event_PebbleRunSQLInvokeIDWithReturn += new Pebble.EVENT_PebbleRunSQLInvokeIDWithReturn(BindPebble_Event_PebbleRunSQLInvokeIDWithReturn); } }
5、重写UpdateMe()方法
public override void UpdateMe() { base.UpdateMe(); FreshList(); }
6、编写异步消息处理方法
public void BindPebble_Event_PebbleRunSQLInvokeIDWithReturn(string InvokeID, System.Xml.XmlElement resultXMLInfo) { DataExchange dataExchange = new DataExchange(); DataRows dataRows = dataExchange.ProcessReceivedData(resultXMLInfo); switch (InvokeID) { case "**********": //处理返回xml的函数 break; } }
7、给DTE发送消息的方法
//发送查询命令 private void SendQueryCommand(string strSQL, string commandType) { if (ParentCandy != null) { if (ParentCandy.BindPebble != null) { ParentCandy.BindPebble.Method_DTESQLCommand(strSQL, commandType, false); } } }
8、重写OnResize(EventArgs e)调整界面位置
protected override void OnResize(EventArgs e) { base.OnResize(e); }
1、 获取工单ID
在很多CSA控件操作中都需要操作工单ID,这时候可以通过以下两个方法实现工单ID的获取:
(1)绑定一个Pabble,Pabble中需要选择Order对象的Order.ID属性,并通过如下代码获取
m_OrderID = ParentCandy.BindPebble.GetFieldValue("Order.ID");
(2)直接通过工单的P_Order获取
m_OrderID = ParentCandy.BindPebble.AllPebbles["P_Order"].GetFieldValue("Order.ID");
2、GET、SET其他PABBLE信息,需要先判断PABBLE是否存在否则会报错。
if (ParentCandy.BindPebble.AllPebbles.ContainsKey("P_Order")) { ParentCandy.BindPebble.AllPebbles["P_Order"].SetFieldValue("Order.HandleType.ID", _Value); }
1、发送Pabble内容:
string newPabble = "<Pebble ID=\"\" Name=\"P_DealProcess\" Command=\"New\"><Field Name=\"DealProcess.ID\" /></Pebble>"; ParentCandy.BindPebble.Method_DTEPebbleCommand(newPabble, "new_DealProcessID");
2、解析方法:
case "new_DealProcessID": m_ProcessID = RegxID(resultXMLInfo.InnerXml,"<Object ID=\"(.*?)\" />"); m_ProcessID = m_ProcessID.Replace("<Object ID=\"", "").Replace("\" />", ""); if (string.IsNullOrEmpty(m_ProcessID)) { MessageBox.Show("服务器开小差了,请重新点击新增!", "提示", MessageBoxButtons.OK); return; } else { //根据取到的ID,进行业务处理 } break;
private string m_EmployeeWorkID = Commonuse.mSystemDataObjects.AgentWorkID; private string m_EmployeeID = Commonuse.mSystemDataObjects.AgentID;
1、首先定义变量
在CSABaseControl基类中新加属性
例如上传附件的控件:
//CAttachFiles public string CAF_FTPServerIP = "";//工单上传下载附件的FTP服务器地址 public string CAF_FTPUserID = "";//工单上传下载附件FTP服务器登录的用户名 public string CAF_FTPPassword = "";//工单上传下载附件FTP服务器登录密码 public string CAF_FileLimit = "";//附件大小限制
2、自定义CSA控件重写OnControlPropertiesAdded方法获取父类CSABaseControl中的变量
public override void OnControlPropertiesAdded(Dictionary<string, Pebble> pebbles) { base.OnControlPropertiesAdded(pebbles); //重新赋值 FTPServerIP = CAF_FTPServerIP; FTPUserID = CAF_FTPUserID; FTPPassword = CAF_FTPPassword; FileLimit = CAF_FileLimit; }
3、配置在工单编辑器中显示,在CSABaseControl基类中添加如下配置:
//初始化控件属性 private void InitCSAControlPropertyInfos() { if (ParentCandy.IsEdit) { CSAControlPropertyInfos.Clear(); //最后一个参数表示需要对哪个控件生效。 AddCSAControlProperty("CAF_FTPServerIP", "", DEF_ControlPropertyValueType.ShortTextBoxValue, "FTP服务器IP", "CWorkSheetAttachedFile"); AddCSAControlProperty("CAF_FTPUserID", "", DEF_ControlPropertyValueType.ShortTextBoxValue, "FTP服务器用户名", "CWorkSheetAttachedFile"); AddCSAControlProperty("CAF_FTPPassword", "", DEF_ControlPropertyValueType.ShortTextBoxValue, "FTP服务器密码", "CWorkSheetAttachedFile"); AddCSAControlProperty("CAF_FileLimit", "", DEF_ControlPropertyValueType.ShortTextBoxValue, "附件大小限制", "CWorkSheetAttachedFile"); AddCSAControlProperty("CF_FTPServerIP","",DEF_ControlPropertyValueType.ShortTextBoxValue,"FTP服务器IP","CFAX"); AddCSAControlProperty("CF_FTPUserID","",DEF_ControlPropertyValueType.ShortTextBoxValue,"FTP服务器用户名","CFAX"); AddCSAControlProperty("CF_FTPPassword","",DEF_ControlPropertyValueType.ShortTextBoxValue,"FTP服务器密码","CFAX"); } }
4、在基类的数据传递方法中加上属性值
/// <summary> /// 运行时,控件执行的方法 /// </summary> /// <param name="pebbles"></param> public virtual void OnControlPropertiesAdded(Dictionary<string, Pebble> pebbles) { foreach (CSAControlProperty controlProperty in CSAControlPropertyInfos) { switch (controlProperty.Name) { //CFAX case "CF_FTPServerIP": CF_FTPServerIP = controlProperty.Value; break; case "CF_FTPUserID": CF_FTPUserID = controlProperty.Value; break; case "CF_FTPPassword": CF_FTPPassword = controlProperty.Value; break; case "CF_IVRNum": CF_IVRNum = controlProperty.Value; break; }
}
标签:
原文地址:http://www.cnblogs.com/jhli/p/5912001.html