本文整理汇总了C#中Connection.ImpersonateUser方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.ImpersonateUser方法的具体用法?C# Connection.ImpersonateUser怎么用?C# Connection.ImpersonateUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection.ImpersonateUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetWorklistItems
public Worklist GetWorklistItems(String searchTerm, Int32 skip, Int32 take, Dictionary<WCField, WCSortOrder> sorts, String impersonateUser)
{
using (var k2Connection = new Connection())
{
ConnectionSetup k2Setup = new ConnectionSetup();
k2Setup.ConnectionString = Properties.Settings.Default.WorkflowServerConnectionString;
k2Connection.Open(k2Setup);
if (!String.IsNullOrEmpty(impersonateUser))
k2Connection.ImpersonateUser("K2:" + impersonateUser);
var workCriteria = new WorklistCriteria { NoData = true, Platform = "ASP" };
if (!string.IsNullOrEmpty(searchTerm))
{
String searchTermFormat = String.Format("%{0}%", searchTerm);
//String searchTermFormat = String.Format("% / % / % / % / %{0}%", searchTerm);
workCriteria.AddFilterField(WCLogical.StartBracket, WCField.None, WCCompare.Equal, null); // (
workCriteria.AddFilterField(WCField.ActivityName, WCCompare.Like, searchTermFormat); // ...
workCriteria.AddFilterField(WCLogical.Or, WCField.EventName, WCCompare.Like, searchTermFormat); // OR ...
workCriteria.AddFilterField(WCLogical.Or, WCField.ProcessFolio, WCCompare.Like, searchTermFormat); // OR ...
workCriteria.AddFilterField(WCLogical.EndBracket, WCField.None, WCCompare.Equal, null); // )
//workCriteria.AddFilterField(WCField.ProcessFolio, WCCompare.Like, searchTermFormat);
}
// No AND required - seems like bug - this bit gets put in a different bit of the query K2 creates.
// Hide allocated items like the SharePoint K2 worlist does by default.
workCriteria.AddFilterField(WCField.WorklistItemStatus, WCCompare.NotEqual, WorklistStatus.Allocated);
workCriteria.StartIndex = skip;
workCriteria.Count = take;
foreach (KeyValuePair<WCField,WCSortOrder> sort in sorts)
{
workCriteria.AddSortField(sort.Key, sort.Value);
}
Worklist k2Worklist = k2Connection.OpenWorklist(workCriteria);
return k2Worklist;
}
}
示例2: StartProcess
/// <summary>
/// 调用k2的dll,生成流程
/// <param name="dataFields">开启流程所需数据</param>
/// <param name="processName">流程名称</param>
/// </summary>
public static int StartProcess(string processName, Dictionary<string, string> dataFields, string objectId, string folio, string userName)
{
int processInstId = 0;
Connection k2Connection = new Connection();
try
{
k2Connection.Open(ConfigurationBase.Web.K2Server, ConfigurationBase.Web.K2LoginString);
k2Connection.ImpersonateUser(userName);
//创建实例
ProcessInstance processInst = k2Connection.CreateProcessInstance(processName);
processInstId = processInst.ID;
if (!string.IsNullOrEmpty(folio))
{
processInst.Folio = folio;
}
#region 赋值datafields
foreach (string key in dataFields.Keys)
{
if (processInst.DataFields[key] != null)
{
processInst.DataFields[key].Value = dataFields[key];
}
}
#endregion
}
finally
{
if (k2Connection != null)
{
k2Connection.Close();
}
}
return processInstId;
}
示例3: ApprovalProcess
/// <summary>
/// 审批流程
/// </summary>
/// <param name="userName"></param>
/// <param name="sn"></param>
/// <param name="actionString"></param>
/// <param name="memo"></param>
/// <param name="dataFields"></param>
public WorklistItem ApprovalProcess(string userName, string sn, string actionString, string memo, Dictionary<string, string> dataFields)
{
Connection k2Connection = new Connection();
try
{
k2Connection.Open(ConfigurationBase.Web.K2Server, ConfigurationBase.Web.K2LoginString);
k2Connection.ImpersonateUser(userName);
//根据SN打开工作项
WorklistItem workList = k2Connection.OpenWorklistItem(sn);
if (workList != null)
{
#region 更新Datafield
if (dataFields != null && dataFields.Count > 0)
{
ProcessInstance currentProcessInst = k2Connection.OpenProcessInstance(workList.ProcessInstance.ID);
//更新Datafields
foreach (string key in dataFields.Keys)
{
if (currentProcessInst.DataFields[key] != null)
{
if (currentProcessInst.DataFields[key].Value!= dataFields[key])
{
currentProcessInst.DataFields[key].Value = dataFields[key];
}
}
}
currentProcessInst.Update();
}
#endregion
#region 审批任务
//批量审批没有actionString,默认第一个操作
if (string.IsNullOrEmpty(actionString))
{
if (workList.Actions[0].Name == REJECTACTION)
{
workList.GotoActivity("流程未通过");
}
else if (workList.Actions[0].Name == UNDOACTION)
{
workList.GotoActivity("流程撤销");
}
else
{
workList.Actions[0].Execute();
}
}
else
{
//执行匹配的操作
if (actionString == UNDOACTION)
{
workList.GotoActivity("流程撤销");
}
else if (actionString == REJECTACTION)
{
workList.GotoActivity("流程未通过");
}
else
{
bool isExcuted = false;
for (int i = 0; i < workList.Actions.Count; i++)
{
if (workList.Actions[i].Name == actionString)
{
workList.Actions[i].Execute();
isExcuted = true;
break;
}
}
}
}
#endregion
}
return workList;
}
catch (Exception)
{
return null;
}
finally
{
if (k2Connection != null)
{
k2Connection.Close();
}
}
}
示例4: ApproveK2Process
public ResultModel ApproveK2Process(string sn, int loginId, string actionString, string memo, Dictionary<string, string> dataFields, out string activityName, out string processCode, out int procInstID)
{
Connection k2Connect = null;
WorklistItem workList = null;
ResultModel jr = new ResultModel() { Code = ResultCode.Fail };
activityName = string.Empty;
processCode = string.Empty;
procInstID = 0;
try
{
k2Connect = new Connection();
k2Connect.Open(ConfigurationManager.AppSettings["K2Server"], ConfigurationManager.AppSettings["K2LoginString"]);
k2Connect.ImpersonateUser(SecurityLable(loginId.ToString()));
workList = k2Connect.OpenWorklistItem(sn);
if (workList != null)
{
#region 更新Datafield
if (dataFields != null && dataFields.Count > 0)
{
ProcessInstance CurrentProcessInst = workList.ProcessInstance;
//更新Datafields
foreach (string key in dataFields.Keys)
{
if (CurrentProcessInst.DataFields[key] != null)
{
if (CurrentProcessInst.DataFields[key].Value.ToString() != dataFields[key])
{
CurrentProcessInst.DataFields[key].Value = dataFields[key];
}
}
}
}
#endregion
#region 审批任务
//批量审批没有actionString,默认第一个操作
if (string.IsNullOrEmpty(actionString))
{
if (workList.Actions[0].Name == REJECTACTION)
{
workList.GotoActivity("流程未通过");
}
else if (workList.Actions[0].Name == UNDOACTION)
{
workList.GotoActivity("流程撤销");
}
else
{
workList.Actions[0].Execute();
}
}
else
{
//执行匹配的操作
if (actionString == UNDOACTION)
{
workList.GotoActivity("流程撤销");
}
else if (actionString == REJECTACTION)
{
workList.GotoActivity("流程未通过");
}
else
{
bool isExcute = false;
for (int i = 0; i < workList.Actions.Count; i++)
{
if (workList.Actions[i].Name == actionString)
{
workList.Actions[i].Execute();
isExcute = true;
break;
}
}
if (!isExcute)
{
jr.Code = ResultCode.Fail;
jr.Msg = string.Format("Action:{0}错误", actionString);
return jr;
}
}
}
#endregion
jr.Code = ResultCode.Sucess;
jr.Msg = "";
activityName = workList.ActivityInstanceDestination.Name;
processCode = workList.ProcessInstance.DataFields["ProcessCode"].Value.ToString();
procInstID = workList.ProcessInstance.ID;
}
}
catch (Exception ex)
{
jr.Msg = ex.Message;
}
finally
{
if (workList != null)
{
//.........这里部分代码省略.........
示例5: StartProcess
public ResultModel StartProcess(string processName, int loginId, string objectId, string folio, Dictionary<string, string> dataFields,out int procInstId)
{
Connection k2Connect = null;
WorklistItem workList = null;
ResultModel jr = new ResultModel() { Code = ResultCode.Fail };
procInstId = 0;
try
{
k2Connect = new Connection();
k2Connect.Open(ConfigurationManager.AppSettings["K2Server"], ConfigurationManager.AppSettings["K2LoginString"]);
k2Connect.ImpersonateUser(SecurityLable(loginId.ToString()));
//创建实例
ProcessInstance ProcessInst = k2Connect.CreateProcessInstance(processName);
if (!string.IsNullOrEmpty(folio))
{
ProcessInst.Folio = folio;
}
#region //赋值datafields
foreach (string key in dataFields.Keys)
{
if (ProcessInst.DataFields[key] != null)
{
ProcessInst.DataFields[key].Value = dataFields[key];
}
}
#endregion
k2Connect.StartProcessInstance(ProcessInst);
procInstId = ProcessInst.ID;
jr.Code = ResultCode.Sucess;
jr.Msg = procInstId.ToString();
}
catch (Exception ex)
{
jr.Msg = ex.Message;
}
finally
{
if (workList != null)
{
if (workList.Status == WorklistStatus.Open)
{
try
{
k2Connect.RevertUser();
workList.Release();
}
catch { }
}
}
if (k2Connect != null)
k2Connect.Close();
}
return jr;
//var result = (new K2Service.K2Service()).StartProcess(processCode, loginId, objectId, folio, jsonData, ConfigurationManager.AppSettings["APIKEY"]);
}
示例6: ReAssign
public ResultModel ReAssign(string sn, int assignFrom, int assignTo, out string activityName, out string processCode, out int procInstID)
{
Connection k2Connect = null;
WorklistItem workList = null;
ResultModel jr = new ResultModel() { Code = ResultCode.Fail };
activityName = string.Empty;
processCode = string.Empty;
procInstID = 0;
try
{
k2Connect = new Connection();
k2Connect.Open(ConfigurationManager.AppSettings["K2Server"], ConfigurationManager.AppSettings["K2LoginString"]);
k2Connect.ImpersonateUser(SecurityLable(assignFrom.ToString()));
workList = k2Connect.OpenWorklistItem(sn);
if (workList != null )
{
workList.Redirect(SecurityLable(assignTo.ToString()));
jr.Code = ResultCode.Sucess;
jr.Msg = "";
activityName = workList.ActivityInstanceDestination.Name;
processCode = workList.ProcessInstance.DataFields["ProcessCode"].Value.ToString();
procInstID = workList.ProcessInstance.ID;
}
}
catch (Exception ex)
{
jr.Msg = ex.Message;
}
finally
{
if (workList != null)
{
if (workList.Status == WorklistStatus.Open)
{
try
{
k2Connect.RevertUser();
workList.Release();
}
catch { }
}
}
if (k2Connect != null)
k2Connect.Close();
}
return jr;
}
示例7: GetWorklistItems
public DataTable GetWorklistItems(Dictionary<string, object> properties, Dictionary<string, object> parameters)
{
bool impersonate = false;
string impersonateUser = "";
ConnectionSetup connectSetup = new ConnectionSetup();
connectSetup.ConnectionString = _connectionString;
if (properties.ContainsKey("UserName"))
{
if (!(string.IsNullOrEmpty(properties["UserName"].ToString())))
{
connectSetup.ConnectionString = _connectionstringImpersonate;
impersonateUser = properties["UserName"].ToString();
impersonate = true;
}
else
connectSetup.ConnectionString = _connectionString;
}
WorklistCriteria criteria = null;
if (properties.Count > 0)
criteria = GetWorklistCriteria(properties);
Connection cnn = new Connection();
try
{
cnn.Open(connectSetup);
if (impersonate)
cnn.ImpersonateUser(impersonateUser);
DataTable dt = GetResultTable();
Worklist worklist;
if ((criteria != null) && (criteria.Filters.GetLength(0) > 0))
worklist = cnn.OpenWorklist(criteria);
else
worklist = cnn.OpenWorklist();
foreach (WorklistItem item in worklist)
{
DataRow row = dt.NewRow();
row["AllocatedUser"] = item.AllocatedUser;
row["Data"] = item.Data;
row["ID"] = item.ID;
row["Link"] = "<hyperlink><link>" + HttpUtility.HtmlEncode(item.Data) + "</link><display>Open</display></hyperlink>";
row["SerialNumber"] = item.SerialNumber;
row["Status"] = item.Status;
row["ActivityID"] = item.ActivityInstanceDestination.ActID;
row["ActivityInstanceID"] = item.ActivityInstanceDestination.ActInstID;
row["ActivityName"] = item.ActivityInstanceDestination.Name;
row["Priority"] = item.ActivityInstanceDestination.Priority;
row["StartDate"] = item.EventInstance.StartDate;
row["ActivityInstanceDestinationID"] = item.ActivityInstanceDestination.ID;
row["ProcessInstanceID"] = item.ProcessInstance.ID;
row["ProcessFullName"] = item.ProcessInstance.FullName;
row["ProcessName"] = item.ProcessInstance.Name;
row["Folio"] = item.ProcessInstance.Folio;
row["EventInstanceName"] = item.EventInstance.Name;
dt.Rows.Add(row);
}
if (impersonate)
cnn.RevertUser();
cnn.Close();
cnn.Dispose();
return dt;
}
catch (Exception ex)
{
throw ex;
}
}
示例8: WhoAmI
public void WhoAmI()
{
if (GetBoolProperty(Constants.SOProperties.Identity.UserWindowsImpersonation))
{
System.Security.Principal.WindowsIdentity.Impersonate(IntPtr.Zero);
}
string k2imp = GetStringProperty(Constants.SOProperties.Identity.K2ImpersonateUser, false);
ServiceObject serviceObject = ServiceBroker.Service.ServiceObjects[0];
serviceObject.Properties.InitResultTable();
DataTable results = ServiceBroker.ServicePackage.ResultTable;
using (Connection k2Con = new Connection())
{
k2Con.Open(K2ClientConnectionSetup);
if (!string.IsNullOrEmpty(k2imp))
{
k2Con.ImpersonateUser(k2imp);
}
DataRow dr = results.NewRow();
dr[Constants.SOProperties.Identity.FQN] = k2Con.User.FQN;
dr[Constants.SOProperties.Identity.IdentityDescription] = k2Con.User.Description;
dr[Constants.SOProperties.Identity.IdentityDisplayName] = k2Con.User.DisplayName;
dr[Constants.SOProperties.Identity.UserEmail] = k2Con.User.Email;
dr[Constants.SOProperties.Identity.UserManager] = k2Con.User.Manager;
dr[Constants.SOProperties.Identity.UserName] = k2Con.User.Name;
dr[Constants.SOProperties.Identity.UserUserLabel] = k2Con.User.UserLabel;
dr[Constants.SOProperties.Identity.CallingFQN] = CallingFQN;
results.Rows.Add(dr);
k2Con.Close();
}
}
示例9: GetWorkflowItems
public List<WorkflowItem> GetWorkflowItems(String searchTerm, Int32 skip, Int32 take, Dictionary<WCField, WCSortOrder> sorts, String impersonateUser, out Int32 count, out Int32 totalCount, List<Tuple<String, String, String>> extraFilters)
{
Tuple<String, String, String> cobEF = null;
Tuple<String, String, String> yearEF = null;
Tuple<String, String, String> descEF = null;
Tuple<String, String, String> insdEF = null;
Tuple<String, String, String> bkrEF = null;
Tuple<String, String, String> uwrEF = null;
Tuple<String, String, String> actEF = null;
if (extraFilters != null)
{
cobEF = extraFilters.FirstOrDefault(f => f.Item1 == "COBId");
yearEF = extraFilters.FirstOrDefault(f => f.Item1 == "AccountYear");
descEF = extraFilters.FirstOrDefault(f => f.Item1 == "Description");
insdEF = extraFilters.FirstOrDefault(f => f.Item1 == "InsuredName");
bkrEF = extraFilters.FirstOrDefault(f => f.Item1 == "BrokerPseudonym");
uwrEF = extraFilters.FirstOrDefault(f => f.Item1 == "UnderwriterCode");
actEF = extraFilters.FirstOrDefault(f => f.Item1 == "Activity");
}
String cobExtraFilter = cobEF == null ? String.Empty : cobEF.Item3;
Int32 yearParse;
Int32? yearExtraFilter = null;
if (Int32.TryParse(yearEF == null ? String.Empty : yearEF.Item3, out yearParse))
yearExtraFilter = yearParse;
String descExtraFilter = descEF == null ? String.Empty : descEF.Item3;
String insdExtraFilter = insdEF == null ? String.Empty : insdEF.Item3;
String bkrExtraFilter = bkrEF == null ? String.Empty : bkrEF.Item3;
String uwrExtraFilter = uwrEF == null ? String.Empty : uwrEF.Item3;
String actExtraFilter = actEF == null ? String.Empty : actEF.Item3;
List<WorkflowItem> retArray = new List<WorkflowItem>();
using (var k2Connection = new Connection())
{
ConnectionSetup k2Setup = new ConnectionSetup();
k2Setup.ConnectionString = Properties.Settings.Default.WorkflowServerConnectionString;
k2Connection.Open(k2Setup);
if (!String.IsNullOrEmpty(impersonateUser))
k2Connection.ImpersonateUser(impersonateUser);
var workCriteria = new WorklistCriteria { NoData = true, Platform = "ASP" };
//String propertyFilter = String.Format("% / {0} / {1} / % / %{2}%", uwrExtraFilter, searchTerm);
String propertyFilter = String.Format("% / {0} / {1}%{2} / % / {3}",
String.IsNullOrEmpty(uwrExtraFilter) ? "%" : uwrExtraFilter,
cobExtraFilter,
yearExtraFilter == null ? String.Empty : yearExtraFilter.ToString().Substring(2),
String.IsNullOrEmpty(insdExtraFilter) ? "%" : "%" + insdExtraFilter + "%");
if (!string.IsNullOrEmpty(searchTerm))
{
String searchTermFormat = String.Format("%{0}%", searchTerm);
//if (extraFilters.Count > 0)
workCriteria.AddFilterField(WCLogical.StartBracket, WCField.None, WCCompare.Equal, null); // (
workCriteria.AddFilterField(WCLogical.StartBracket, WCField.None, WCCompare.Equal, null); // (
workCriteria.AddFilterField(WCField.ActivityName, WCCompare.Like, searchTermFormat); // ...
workCriteria.AddFilterField(WCLogical.Or, WCField.ProcessData, "BPC", WCCompare.Equal, searchTerm); // OR ...
workCriteria.AddFilterField(WCLogical.Or, WCField.EventName, WCCompare.Like, searchTermFormat); // OR ...
workCriteria.AddFilterField(WCLogical.Or, WCField.ProcessFolio, WCCompare.Like, searchTermFormat); // OR ...
workCriteria.AddFilterField(WCLogical.EndBracket, WCField.None, WCCompare.Equal, null); // )
if (extraFilters.Count > 0)
{
workCriteria.AddFilterField(WCLogical.And, WCField.None, WCCompare.Equal, null); // AND
workCriteria.AddFilterField(WCLogical.StartBracket, WCField.None, WCCompare.Equal, null); // (
workCriteria.AddFilterField(WCField.ProcessFolio, WCCompare.Like, propertyFilter); // ...
workCriteria.AddFilterField(WCLogical.EndBracket, WCField.None, WCCompare.Equal, null); // )
}
if (!String.IsNullOrEmpty(actExtraFilter))
// TODO: OR event name?
//workCriteria.AddFilterField(WCField.EventName, WCCompare.Equal, actExtraFilter); // ...
workCriteria.AddFilterField(WCLogical.And, WCField.ActivityName, WCCompare.Equal, actExtraFilter); // ...
//if (extraFilters.Count > 0)
workCriteria.AddFilterField(WCLogical.EndBracket, WCField.None, WCCompare.Equal, null); // )
//workCriteria.AddFilterField(WCField., WCField.None, WCCompare.Equal, null);
}
else
{
if (extraFilters.Count > 0)
{
workCriteria.AddFilterField(WCField.ProcessFolio, WCCompare.Like, propertyFilter);
}
if (!String.IsNullOrEmpty(actExtraFilter))
workCriteria.AddFilterField(WCLogical.And, WCField.ActivityName, WCCompare.Equal , actExtraFilter); // ...
}
// No AND required - seems like bug - this bit gets put in a different bit of the query K2 creates.
// Hide allocated items like the SharePoint K2 worlist does by default.
// workCriteria.AddFilterField(WCField.WorklistItemStatus, WCCompare.NotEqual, WorklistStatus.Allocated);
//workCriteria.AddSortField(WCField.ActivityStartDate, WCSortOrder.Descending);
//.........这里部分代码省略.........
示例10: GetWorkflowItemBySN
public WorkflowItem GetWorkflowItemBySN(string serialNumber, String impersonateUser)
{
using (var k2Connection = new Connection())
{
ConnectionSetup k2Setup = new ConnectionSetup();
k2Setup.ConnectionString = Properties.Settings.Default.WorkflowServerConnectionString;
k2Connection.Open(k2Setup);
if (!String.IsNullOrEmpty(impersonateUser))
k2Connection.ImpersonateUser(impersonateUser);
var workCriteria = new WorklistCriteria { NoData = true, Platform = "ASP" };
if (!string.IsNullOrEmpty(serialNumber))
{
workCriteria.AddFilterField(WCField.SerialNumber, WCCompare.Equal, serialNumber);
}
Worklist k2Worklist = k2Connection.OpenWorklist(workCriteria);
WorkflowItem retItem = null;
foreach (WorklistItem item in k2Worklist)
{
retItem = new WorkflowItem(item);
}
// now that we have the workflow item get the count of the related documents
if ((retItem!=null)&&(!string.IsNullOrEmpty(retItem.PolicyID)))
{
using (DocumentService.DocumentServiceClient client = new DocumentService.DocumentServiceClient())
{
retItem.RelatedDocumentCount = client.GetDocumentsCountForPolicy(retItem.PolicyID);
}
}
return retItem;
}
}
示例11: GetWorklistItemBySN
public WorklistItem GetWorklistItemBySN(string serialNumber, String impersonateUser)
{
using (var k2Connection = new Connection())
{
ConnectionSetup k2Setup = new ConnectionSetup();
k2Setup.ConnectionString = Properties.Settings.Default.WorkflowServerConnectionString;
k2Connection.Open(k2Setup);
if (!String.IsNullOrEmpty(impersonateUser))
k2Connection.ImpersonateUser(impersonateUser);
return k2Connection.OpenWorklistItem(serialNumber);
}
}
示例12: Execute
//.........这里部分代码省略.........
xmlItem.AppendChild(xmlName);
xmlName = EntityDoc.CreateElement("UserFQN");
xmlName.InnerText = originatorUserEntity["domainname"] != null ? originatorUserEntity["domainname"].ToString() : "";
xmlItem.AppendChild(xmlName);
xmlName = EntityDoc.CreateElement("UserDisplayName");
xmlName.InnerText = originatorUserEntity["fullname"] != null ? originatorUserEntity["fullname"].ToString() : "";
xmlItem.AppendChild(xmlName);
//Add Item to main doc
EntElement.AppendChild(xmlItem);
EntityDoc.AppendChild(EntElement);
//Release node objects
EntElement = null;
xmlName = null;
#endregion Create XML Context
conn = new Connection();
//procInst = new ProcessInstance();
try
{
ConnectionSetup connectSetup = new ConnectionSetup();
connectSetup.ConnectionString = K2WorkflowServerConnectionString;
conn.Open(connectSetup);
if (originatorUserEntity != null && originatorUserEntity["domainname"] != null)
{
conn.ImpersonateUser(originatorUserEntity["domainname"].ToString());
}
//Create new process instance
procInst = conn.CreateProcessInstance(K2ProcessName);
//Set CRM context field value
if (!string.IsNullOrEmpty(K2ContextXMLDataField))
{
try
{
procInst.XmlFields[K2ContextXMLDataField].Value = EntityDoc.OuterXml.ToString();
}
catch (Exception ex)
{
System.Diagnostics.EventLog.WriteEntry("SourceCode.Logging.Extension.EventLogExtension", "K2 CRM Plugin - Entity Name - " + context.PrimaryEntityName.ToString() + " - " + "Error writing to XMLField " + K2ContextXMLDataField + " :::: " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
}
}
if (!string.IsNullOrEmpty(K2EntityIdDataField))
{
try
{
procInst.DataFields[K2EntityIdDataField].Value = context.PrimaryEntityId;
}
catch (Exception ex)
{
System.Diagnostics.EventLog.WriteEntry("SourceCode.Logging.Extension.EventLogExtension", "K2 CRM Plugin - Entity Name - " + context.PrimaryEntityName.ToString() + " - " + "Error writing to DataField " + K2EntityIdDataField + " :::: " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
}
}
if (!string.IsNullOrEmpty(K2EntityNameDataField))
{
try
示例13: LoadWorklistItem
internal DataTable LoadWorklistItem(string serialNumber)
{
if (string.IsNullOrEmpty(serialNumber))
throw new ArgumentException("Value must not be null or empty.", "serialNumer");
try
{
DataTable dt = GetResultTable();
DataRow row = dt.NewRow();
ConnectionSetup cnnSetup = new ConnectionSetup();
cnnSetup.ConnectionString = this._execSettings.ConnectionString;
using (Connection cnn = new Connection())
{
cnn.Open(cnnSetup);
if (this._execSettings.UseImpersonation)
cnn.ImpersonateUser(this._execSettings.ImpersonateUser);
WorklistItem item = cnn.OpenWorklistItem(serialNumber);
if (item != null)
{
PopulateDataRow(item, row);
dt.Rows.Add(row);
}
cnn.Close();
}
return dt;
}
catch (Exception ex)
{
throw ex;
}
}
示例14: GetWorklistItems
internal DataTable GetWorklistItems(Dictionary<string, object> properties, Dictionary<string, object> parameters)
{
try
{
DataTable dt = GetResultTable();
WorklistCriteria criteria = GetWorklistCriteria(properties);
ConnectionSetup cnnSetup = new ConnectionSetup();
cnnSetup.ConnectionString = this._execSettings.ConnectionString;
using (Connection cnn = new Connection())
{
cnn.Open(cnnSetup);
if (this._execSettings.UseImpersonation)
cnn.ImpersonateUser(this._execSettings.ImpersonateUser);
Worklist worklist;
if ((criteria != null) && (criteria.Filters.GetLength(0) > 0))
worklist = cnn.OpenWorklist(criteria);
else
worklist = cnn.OpenWorklist();
foreach (WorklistItem item in worklist)
{
DataRow row = dt.NewRow();
PopulateDataRow(item, row);
dt.Rows.Add(row);
}
cnn.Close();
}
return dt;
}
catch (Exception ex)
{
throw ex;
}
}
示例15: GetWorklistItemBySN
public WorklistItem GetWorklistItemBySN(string serialNumber, String impersonateUser)
{
// if the serial number is null or empty we do not want to do any of this
if (!string.IsNullOrEmpty(serialNumber))
{
using (var k2Connection = new Connection())
{
ConnectionSetup k2Setup = new ConnectionSetup();
k2Setup.ConnectionString = Properties.Settings.Default.WorkflowServerConnectionString;
k2Connection.Open(k2Setup);
if (!String.IsNullOrEmpty(impersonateUser))
k2Connection.ImpersonateUser(impersonateUser);
return k2Connection.OpenWorklistItem(serialNumber);
}
}
return null;
}