【转载】将数据存储到SmartObject中
根据对K2 Blackpearl的一定了解,SmartObject可以帮助我们完成一些数据持久化的工作,以下是将表单中的数据存储到SmartObject中的相关代码,SmartObject的结构我就不一一赘述了,相信你能看懂的。
这些代码SDK中也有,在此贴出来,希望有大虾可以予小弟以指点。
//将表单中的数据存储到SmartObject中
private void SaveData(int argProcInstanceID)
{
SourceCode.SmartObjects.Client.SmartObjectClientServer socs = new SourceCode.SmartObjects.Client.SmartObjectClientServer();
// build a connection string
SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder connectionString = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();
connectionString.Authenticate = true;
connectionString.Host = System.Configuration.ConfigurationManager.AppSettings["K2Server"];
connectionString.Integrated = true;
connectionString.IsPrimaryLogin = true;
connectionString.Port = Convert.ToUInt32(System.Configuration.ConfigurationManager.AppSettings["HostServicePort"]);
//connectionString.UserID = "your user name";
//connectionString.Password = "your password";
connectionString.WindowsDomain = "dahanis";
connectionString.SecurityLabelName = "K2";
// open a K2 Server connection
socs.CreateConnection();
socs.Connection.Open(connectionString.ToString());
try
{
// get a handle to the 'SODHFKSQ' SmartObject
SourceCode.SmartObjects.Client.SmartObject so = socs.GetSmartObject("so_DHFKSQ");
// specify which method will be called
so.MethodToExecute = "Create";
// specify input parameters for the method
so.Properties["ProInstanceID"].Value = argProcInstanceID.ToString();
so.Properties["Folio"].Value = Folio.Text.Trim();
so.Properties["ApplyEmployee"].Value = ApplyEmployee.Text.Trim();
so.Properties["ApplyAmount"].Value = ApplyAmount.Text.Trim();
so.Properties["ApplyDate"].Value = ApplyDate.Text.Trim();
so.Properties["HigherLevelApprover"].Value = HigherLevelApprover.Text.Trim();
so.Properties["FinanceApprover"].Value = FinanceApprover.Text.Trim();
// call the method
socs.ExecuteScalar(so);
// note: if a method of type 'list' was specified, then the 'ExecuteList' method should be called
// serverName.ExecuteList(smartObject);
}
catch(Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
socs.Connection.Close();
}
private void SaveData(int argProcInstanceID)
{
SourceCode.SmartObjects.Client.SmartObjectClientServer socs = new SourceCode.SmartObjects.Client.SmartObjectClientServer();
// build a connection string
SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder connectionString = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();
connectionString.Authenticate = true;
connectionString.Host = System.Configuration.ConfigurationManager.AppSettings["K2Server"];
connectionString.Integrated = true;
connectionString.IsPrimaryLogin = true;
connectionString.Port = Convert.ToUInt32(System.Configuration.ConfigurationManager.AppSettings["HostServicePort"]);
//connectionString.UserID = "your user name";
//connectionString.Password = "your password";
connectionString.WindowsDomain = "dahanis";
connectionString.SecurityLabelName = "K2";
// open a K2 Server connection
socs.CreateConnection();
socs.Connection.Open(connectionString.ToString());
try
{
// get a handle to the 'SODHFKSQ' SmartObject
SourceCode.SmartObjects.Client.SmartObject so = socs.GetSmartObject("so_DHFKSQ");
// specify which method will be called
so.MethodToExecute = "Create";
// specify input parameters for the method
so.Properties["ProInstanceID"].Value = argProcInstanceID.ToString();
so.Properties["Folio"].Value = Folio.Text.Trim();
so.Properties["ApplyEmployee"].Value = ApplyEmployee.Text.Trim();
so.Properties["ApplyAmount"].Value = ApplyAmount.Text.Trim();
so.Properties["ApplyDate"].Value = ApplyDate.Text.Trim();
so.Properties["HigherLevelApprover"].Value = HigherLevelApprover.Text.Trim();
so.Properties["FinanceApprover"].Value = FinanceApprover.Text.Trim();
// call the method
socs.ExecuteScalar(so);
// note: if a method of type 'list' was specified, then the 'ExecuteList' method should be called
// serverName.ExecuteList(smartObject);
}
catch(Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
socs.Connection.Close();
}
}
标签:
K2 black pearl
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix