/// <summary> /// 获取当前审批者列表(包括委托) /// </summary> /// <param name="ApproverUser"></param> public static List <ApprovalWorklistItem> GetCurrentUserWorkListItem(string ApproverUser) { Connection connection = GetK2Connection(); try { ImpersonateUser(connection, ApproverUser); List <ApprovalWorklistItem> ApprovalWorklistItemList = new List <ApprovalWorklistItem>(); //获取审批列表添加条件 SourceCode.Workflow.Client.WorklistCriteria criteria = new SourceCode.Workflow.Client.WorklistCriteria(); criteria.Platform = "ASP"; //添加流程文件类别条件 criteria.AddFilterField(SourceCode.Workflow.Client.WCLogical.And, SourceCode.Workflow.Client.WCField.ProcessFolder, SourceCode.Workflow.Client.WCCompare.Equal, GetK2ProcessFolder()); //添加审批者的列表 criteria.AddFilterField(SourceCode.Workflow.Client.WCLogical.And, SourceCode.Workflow.Client.WCField.WorklistItemOwner, "Me", SourceCode.Workflow.Client.WCCompare.Equal, SourceCode.Workflow.Client.WCWorklistItemOwner.Me); //添加审批者委托的列表 //criteria.AddFilterField(SourceCode.Workflow.Client.WCLogical.Or, SourceCode.Workflow.Client.WCField.WorklistItemOwner, "Other", SourceCode.Workflow.Client.WCCompare.Equal, SourceCode.Workflow.Client.WCWorklistItemOwner.Other); Worklist worklist = connection.OpenWorklist(criteria); if (worklist != null && worklist.Count > 0) { foreach (SourceCode.Workflow.Client.WorklistItem item in worklist) { var work = new ApprovalWorklistItem(); work.SN = item.SerialNumber; work.ProcInstID = item.ProcessInstance.ID.ToString(); work.ProcessName = item.ProcessInstance.Name.Substring(4, item.ProcessInstance.Name.Length - 4); work.Folio = item.ProcessInstance.Folio; work.StartDate = item.ActivityInstanceDestination.StartDate.ToString("yyyy-MM-dd HH:mm:ss"); work.CurActivityName = item.ActivityInstanceDestination.Name; work.URL = item.Data; ApprovalWorklistItemList.Add(work); } ApprovalWorklistItemList.OrderByDescending(a => a.StartDate); } return(ApprovalWorklistItemList); } catch (Exception ex) { throw new K2Exception(ex.ToString()); } finally { // 关闭连接 if (connection != null) { connection.Close(); } } }
/// <summary> /// Create worklist class summary. /// </summary> /// <param name="worklistClass"></param> /// <returns></returns> public WorklistClassSummary CreateClassSummary(Type worklistClass) { var ptgClass = Worklist.GetProcedureTypeGroupClass(worklistClass); return(new WorklistClassSummary( Worklist.GetClassName(worklistClass), Worklist.GetDisplayName(worklistClass), Worklist.GetCategory(worklistClass), Worklist.GetDescription(worklistClass), ptgClass == null ? null : ptgClass.Name, ptgClass == null ? null : TerminologyTranslator.Translate(ptgClass), Worklist.GetSupportsReportingStaffRoleFilter(worklistClass))); }
/// <summary> /// Constructor. /// </summary> /// <param name="worklist"></param> /// <param name="wqc"></param> /// <param name="countQuery"></param> public WorklistQueryArgs(Worklist worklist, IWorklistQueryContext wqc, bool countQuery) { this.Worklist = worklist; this.QueryContext = wqc; this.FilterCriteria = worklist.GetFilterCriteria(wqc); // init base class Initialize( worklist.GetProcedureStepSubclasses(), worklist.GetInvariantCriteria(wqc), countQuery ? null : worklist.GetProjection(), wqc.Page); }
internal IEnumerable <Diagnostic> BindAndAnalyzeCFG() { _worklist = new Worklist <BoundBlock>(BindBlock); PhpCompilation.ReferenceManager manager = _compilation.GetBoundReferenceManager(); this.WalkRoutines(this.EnqueueRoutine); this.WalkTypes(this.EnqueueFieldsInitializer); this.ProcessWorklist(); if (!completedDiagnostics) { this.AnalyzeandDiagnoseRoutines(); } return(_diagnostics.AsEnumerable()); }
public Object[] GetUserWorklistItems(String searchTerm, Int32 skip, Int32 take, Dictionary <WCField, WCSortOrder> sorts, out Int32 count, out Int32 totalCount) { List <Object> o = new List <Object>(); Worklist wl = WorkItemData.GetWorklistItems(searchTerm, skip, take, sorts, HttpContext.Current.User.Identity.Name); foreach (WorklistItem a in wl) { DateTime StartDate; try { if ((a.ActivityInstanceDestination.DataFields["SLAStartDate"].Value != null) && (a.ActivityInstanceDestination.DataFields["SLAStartDate"].ValueType == DataType.TypeDate)) { StartDate = (DateTime)a.ActivityInstanceDestination.DataFields["SLAStartDate"].Value; } else { StartDate = a.ActivityInstanceDestination.StartDate; } } catch { StartDate = a.ActivityInstanceDestination.StartDate; } // get the information from the folio string folio = a.ProcessInstance.Folio; string[] foliofields = folio.Split('/'); string PolicyID = string.Empty; string Insured = string.Empty; if (foliofields.Length > 2) { PolicyID = foliofields[2].Trim(); } if (foliofields.Length > 4) { Insured = foliofields[4].Trim(); } o.Add(new { a.SerialNumber, a.ActivityInstanceDestination.Name, a.ProcessInstance.Folio, PolicyID, Insured, StartDate, a.AllocatedUser }); } // This number represents a count taking into account a datatables filter. // Not using this kind of filter?, so will always be total? count = wl.TotalCount; // Total records before filter totalCount = wl.TotalCount; return(o.ToArray()); }
public WorkflowItem GetWorkflowItemBySN(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); } var workCriteria = new WorklistCriteria { NoData = false, 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); } } return(null); }
/// <summary> /// Create worklist summary. /// </summary> /// <param name="worklist"></param> /// <param name="context"></param> /// <returns></returns> public WorklistAdminSummary CreateWorklistSummary(Worklist worklist, IPersistenceContext context) { var isStatic = Worklist.GetIsStatic(worklist.GetClass()); var staffAssembler = new StaffAssembler(); var groupAssembler = new StaffGroupAssembler(); return(new WorklistAdminSummary( isStatic ? null : worklist.GetRef(), isStatic ? Worklist.GetDisplayName(worklist.GetClass()) : worklist.Name, isStatic ? Worklist.GetDescription(worklist.GetClass()) : worklist.Description, CreateClassSummary(worklist.GetClass()), worklist.Owner.IsStaffOwner ? staffAssembler.CreateStaffSummary(worklist.Owner.Staff, context) : null, worklist.Owner.IsGroupOwner ? groupAssembler.CreateSummary(worklist.Owner.Group) : null)); }
public WorklistSummary GetWorklistSummary(Worklist worklist, IPersistenceContext context) { StaffAssembler staffAssembler = new StaffAssembler(); StaffGroupAssembler groupAssembler = new StaffGroupAssembler(); return(new WorklistSummary( worklist.GetRef(), worklist.Name, worklist.Description, worklist.ClassName, Worklist.GetCategory(worklist.GetClass()), Worklist.GetDisplayName(worklist.GetClass()), worklist.Owner.IsStaffOwner ? staffAssembler.CreateStaffSummary(worklist.Owner.Staff, context) : null, worklist.Owner.IsGroupOwner ? groupAssembler.CreateSummary(worklist.Owner.Group) : null)); }
private SourceCompiler(PhpCompilation compilation, PEModuleBuilder moduleBuilder, bool emittingPdb, DiagnosticBag diagnostics, CancellationToken cancellationToken) { Contract.ThrowIfNull(compilation); Contract.ThrowIfNull(diagnostics); _compilation = compilation; _moduleBuilder = moduleBuilder; _emittingPdb = emittingPdb; _diagnostics = diagnostics; _cancellationToken = cancellationToken; // parallel worklist algorithm _worklist = new Worklist <BoundBlock>(AnalyzeBlock); // semantic model }
private SourceCompiler(PhpCompilation compilation, PEModuleBuilder moduleBuilder, bool emittingPdb, DiagnosticBag diagnostics) { Contract.ThrowIfNull(compilation); Contract.ThrowIfNull(moduleBuilder); Contract.ThrowIfNull(diagnostics); _compilation = compilation; _moduleBuilder = moduleBuilder; _emittingPdb = emittingPdb; _diagnostics = diagnostics; // parallel worklist algorithm _worklist = new Worklist<BoundBlock>(AnalyzeBlock); // semantic model }
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); 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); // ) } // 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); } }
//impersonating another user samples public static void ImpersonateSamples() { //we will wrap the connection into a using statement to ensure it is disposed properly using (Connection K2Conn = new Connection()) { //you must first establish a connection with the current credentials (or specific credentials) before you can impersonate K2Conn.Open("[servername]"); //once you have connected to K2, you can impersonate another user, PROVIDED that the connected account //has the "Impersonate" permission on the K2 environment K2Conn.ImpersonateUser("[securityLabelName]:[username]"); //example: K2Conn.ImpersonateUser("K2:domain\username"); //now that you have impersonated a user, you can perform actiosn on behalf of that user. here we will retrieve that user's worklist Worklist K2WL = K2Conn.OpenWorklist(); //do something with the impersonated user's worklist //when you are done impersonating, you can revert to the original user account K2Conn.RevertUser(); } }
private void ActionWorklistitem() { string processInstanceId = base.GetStringProperty(Constants.SOProperties.ClientWorklist.ProcessId, true); string activityName = base.GetStringProperty(Constants.SOProperties.ClientWorklist.ActivityName, true); string actionName = base.GetStringProperty(Constants.SOProperties.ClientWorklist.ActionName, true); using (Connection k2Con = new Connection()) { k2Con.Open(base.K2ClientConnectionSetup); WorklistCriteria wc = new WorklistCriteria(); wc.Platform = base.Platform; wc.AddFilterField(WCField.ProcessID, WCCompare.Equal, processInstanceId); wc.AddFilterField(WCLogical.And, WCField.ActivityName, WCCompare.Equal, activityName); Worklist wl = k2Con.OpenWorklist(wc); if (wl.TotalCount == 0) { throw new ApplicationException("No worklist item found with those criteria."); } if (wl.TotalCount > 1) { throw new ApplicationException("More than one worklist item found with those criteria."); } foreach (SourceCode.Workflow.Client.Action a in wl[0].Actions) { if (string.Compare(a.Name, actionName, true) == 0) { a.Execute(); k2Con.Close(); return; } } k2Con.Close(); throw new ApplicationException("Failed to find the action specified. Worklist item was found."); } }
private void ActionWorklistitem() { string processInstanceId = base.GetStringProperty(Constants.SOProperties.ClientWorklist.ProcessId, true); string activityName = base.GetStringProperty(Constants.SOProperties.ClientWorklist.ActivityName, true); string actionName = base.GetStringProperty(Constants.SOProperties.ClientWorklist.ActionName, true); using (Connection k2Con = this.ServiceBroker.K2Connection.GetWorkflowClientConnection()) { WorklistCriteria wc = new WorklistCriteria(); wc.Platform = base.Platform; wc.AddFilterField(WCField.ProcessID, WCCompare.Equal, processInstanceId); wc.AddFilterField(WCLogical.And, WCField.ActivityName, WCCompare.Equal, activityName); Worklist wl = k2Con.OpenWorklist(wc); if (wl.TotalCount == 0) { throw new ApplicationException(Resources.NoWorklistItemFound); } if (wl.TotalCount > 1) { throw new ApplicationException(Resources.MoreThanOneWorklistItemFound); } foreach (SourceCode.Workflow.Client.Action a in wl[0].Actions) { if (string.Compare(a.Name, actionName, true) == 0) { a.Execute(); k2Con.Close(); return; } } k2Con.Close(); throw new ApplicationException(Resources.FailedToFindTheAction); } }
public LoadStaffGroupEditorFormDataResponse LoadStaffGroupEditorFormData(LoadStaffGroupEditorFormDataRequest request) { var allStaff = PersistenceContext.GetBroker <IStaffBroker>().FindAll(false); var worklistClasses = WorklistAdminService.ListClassesHelper(null, null, false); // grab the persistent worklists var broker = PersistenceContext.GetBroker <IWorklistBroker>(); var persistentClassNames = CollectionUtils.Select(worklistClasses, t => !Worklist.GetIsStatic(t)) .ConvertAll(t => Worklist.GetClassName(t)); var adminWorklists = broker.Find(null, false, persistentClassNames, null); var staffAssembler = new StaffAssembler(); var worklistAssembler = new WorklistAssembler(); return(new LoadStaffGroupEditorFormDataResponse( CollectionUtils.Map(allStaff, (Staff staff) => staffAssembler.CreateStaffSummary(staff, PersistenceContext)), CollectionUtils.Map(adminWorklists, (Worklist worklist) => worklistAssembler.GetWorklistSummary(worklist, PersistenceContext)) )); }
public static List <WorklistTicket> GetTickets(Guid OrgId, int DeptId, int UserId, string statusMode, string status, string role, bool IsTechAdmin, bool IsUseWorkDaysTimer, int page, int limit) { DataTable tickets = null; Worklist.QueryFilter _qFilter = new Worklist.QueryFilter(); if (!string.IsNullOrEmpty(statusMode)) { Worklist.TicketStatusMode ticketStatusMode; if (Enum.TryParse <Worklist.TicketStatusMode>(statusMode, true, out ticketStatusMode)) { _qFilter.TicketStatus = ticketStatusMode; } Worklist.SortMode ticketSortMode; if (Enum.TryParse <Worklist.SortMode>(role, true, out ticketSortMode)) { _qFilter.Sort = ticketSortMode; } int queueId; if (int.TryParse(status, out queueId)) { _qFilter.TechnicianId = queueId; } tickets = Worklist.SelectTicketsByFilter(OrgId, DeptId, UserId, _qFilter, IsTechAdmin); } else { role = role ?? ""; bool isUser = role.Contains("user"); bool isAltTech = role.Contains("alt_tech"); role = isAltTech ? role.Replace("alt_tech", "") : role; bool isTech = role.Contains("tech"); status = status == null ? "" : status.Replace("_", ""); tickets = Worklist.SelectTicketsByFilter(OrgId, DeptId, UserId, isUser, isTech, isAltTech, status, IsTechAdmin); } return((new WorklistTickets(tickets)).Skip(page * limit).Take(limit).ToList()); }
//opening worklist sample public static void OpenWorklistSamples() { //you must open a K2 connection first. We will wrap the K2 connection into a using statement to ensure that it is closed using (Connection K2Conn = new Connection()) { K2Conn.Open("[servername]"); //retrieve the entire worklist for the current user Worklist K2WList = K2Conn.OpenWorklist(); //or retrieve the worklist for a specific platform ("platform" not really used that often anymore). The default platform for worklist items is ASP Worklist K2WList1 = K2Conn.OpenWorklist("ASP"); //or retrieve the worklist for a specific platform and a user managed by the current user. //This requires that the reporting structure is set up correctly in the underlying user provider (Active Directory or custom user manager) Worklist K2WList2 = K2Conn.OpenWorklist("ASP", @"[domain\username]"); //you can also retrieve the worklist with a criteria filter. OpenWorklist can be an expensive operation, so use criteria to perform server-side filtering of the worklist //for large worklists you should always use criteria to reduce the size of the worklist that is returned to the client WorklistCriteria K2Crit = new WorklistCriteria(); //you can set up various combinations of filters and sorts in the criteria object. Refer to the product documentation for more samples //here, we are filtering for all workflows for the project K2Learning where the priority equals 1. We want to sort the task list by workflow start date K2Crit.AddFilterField(WCField.ProcessFolder, WCCompare.Equal, "[FolderName]"); K2Crit.AddFilterField(WCLogical.And, WCField.ProcessPriority, WCCompare.Equal, 1); K2Crit.AddSortField(WCField.ProcessStartDate, WCSortOrder.Descending); Worklist K2WList3 = K2Conn.OpenWorklist(K2Crit); int numberOfTasks = K2WList.TotalCount; //once you have retrieved the worklist, you can iterate over the worklist items in the worklist foreach (WorklistItem K2WLItem in K2WList) { string serialNumber = K2WLItem.SerialNumber; string status = K2WLItem.Status.ToString(); //to access more information, drill down into the relevant object contained in the worklist item string Folio = K2WLItem.ProcessInstance.Folio; } } }
public static Worklist GetAllWorkItem(string Account) { using (Connection conn = new Connection()) { Worklist retitem = null; try { conn.Open(K2ServerName, GetConnString()); conn.RevertUser(); conn.ImpersonateUser(Account); retitem = conn.OpenWorklist(); } catch { throw; } finally { conn.Close(); } return(retitem); } }
public static Worklist GetWorklistItem(string account) { using (Connection conn = new Connection()) { Worklist wlt = null; try { conn.Open(K2ServerName, GetConnString()); conn.RevertUser(); conn.ImpersonateUser(account); wlt = conn.OpenWorklist(); } catch { throw; } finally { conn.Close(); } return(wlt); } }
public static List <Type> ListClassesHelper(List <string> classNames, List <string> categories, bool includeStatic) { var worklistClasses = (IEnumerable <Type>)WorklistFactory.Instance.ListWorklistClasses(true); // optionally filter classes by class name if (classNames != null && classNames.Count > 0) { worklistClasses = worklistClasses.Where(t => classNames.Contains(Worklist.GetClassName(t))); } // optionally filter classes by category if (categories != null && categories.Count > 0) { worklistClasses = worklistClasses.Where(t => categories.Contains(Worklist.GetCategory(t))); } // optionally exclude static if (!includeStatic) { worklistClasses = worklistClasses.Where(t => !Worklist.GetIsStatic(t)); } // manually exclude some classes based on workflow settings var workflowConfig = new WorkflowConfigurationReader(); if (!workflowConfig.EnableInterpretationReviewWorkflow) { worklistClasses = worklistClasses.Where(t => !_interpretationReviewClasses.Contains(Worklist.GetClassName(t))); } if (!workflowConfig.EnableTranscriptionReviewWorkflow) { worklistClasses = worklistClasses.Where(t => !_transcriptionReviewClasses.Contains(Worklist.GetClassName(t))); } return(worklistClasses.ToList()); }
private GetWorklistEditFormChoicesResponse GetWorklistEditFormChoices(GetWorklistEditFormChoicesRequest request) { var response = new GetWorklistEditFormChoicesResponse(); var assembler = new WorklistAdminAssembler(); response.WorklistClasses = CollectionUtils.Map <Type, WorklistClassSummary>( ListClassesHelper(null, null, false), assembler.CreateClassSummary); var staffAssembler = new StaffAssembler(); response.StaffChoices = CollectionUtils.Map <Staff, StaffSummary>( this.PersistenceContext.GetBroker <IStaffBroker>().FindAll(false), item => staffAssembler.CreateStaffSummary(item, PersistenceContext)); var staffGroupAssembler = new StaffGroupAssembler(); response.GroupSubscriberChoices = CollectionUtils.Map <StaffGroup, StaffGroupSummary>( this.PersistenceContext.GetBroker <IStaffGroupBroker>().FindAll(false), staffGroupAssembler.CreateSummary); var facilityAssembler = new FacilityAssembler(); response.FacilityChoices = CollectionUtils.Map <Facility, FacilitySummary>( this.PersistenceContext.GetBroker <IFacilityBroker>().FindAll(false), facilityAssembler.CreateFacilitySummary); var departmentAssembler = new DepartmentAssembler(); response.DepartmentChoices = CollectionUtils.Map( this.PersistenceContext.GetBroker <IDepartmentBroker>().FindAll(false), (Department item) => departmentAssembler.CreateSummary(item, PersistenceContext)); var locationAssembler = new LocationAssembler(); response.PatientLocationChoices = CollectionUtils.Map <Location, LocationSummary>( this.PersistenceContext.GetBroker <ILocationBroker>().FindAll(false), locationAssembler.CreateLocationSummary); response.OrderPriorityChoices = EnumUtils.GetEnumValueList <OrderPriorityEnum>(PersistenceContext); response.PatientClassChoices = EnumUtils.GetEnumValueList <PatientClassEnum>(PersistenceContext); response.CurrentServerConfigurationRequiresTimeFilter = Worklist.CurrentServerConfigurationRequiresTimeFilter(); response.CurrentServerConfigurationMaxSpanDays = Worklist.CurrentServerConfigurationMaxSpanDays(); // add extra data iff editing a user-defined worklist (bug #4871) if (request.UserDefinedWorklist) { response.OwnerGroupChoices = CollectionUtils.Map <StaffGroup, StaffGroupSummary>( this.CurrentUserStaff.ActiveGroups, // only current user's active staff groups should be choosable staffGroupAssembler.CreateSummary); } var proceduerTypesAssembler = new ProcedureTypeAssembler(); response.ProcedureTypeChoices = CollectionUtils.Map <ProcedureType, ProcedureTypeSummary>( this.PersistenceContext.GetBroker <IProcedureTypeBroker>().FindAll(false), proceduerTypesAssembler.CreateSummary); return(response); }
/// <summary> /// Creates an instance of <see cref="AnalysisVisitor"/> that can analyse a block. /// </summary> /// <param name="worklist">The worklist to be used to enqueue next blocks.</param> internal AnalysisVisitor(Worklist<BoundBlock> worklist) { _worklist = worklist; }
/// <summary> /// Update specified worklist from detail. /// </summary> /// <param name="worklist"></param> /// <param name="detail"></param> /// <param name="updateSubscribers"></param> /// <param name="context"></param> public void UpdateWorklist(Worklist worklist, WorklistAdminDetail detail, bool updateSubscribers, IPersistenceContext context) { worklist.Name = detail.Name; worklist.Description = detail.Description; // do not update the worklist.Owner here!!! - once set, it should never be updated // procedure types UpdateFilter(worklist.ProcedureTypeFilter, detail.ProcedureTypes, summary => context.Load <ProcedureType>(summary.ProcedureTypeRef, EntityLoadFlags.Proxy)); // procedure groups UpdateFilter(worklist.ProcedureTypeGroupFilter, detail.ProcedureTypeGroups, summary => context.Load <ProcedureTypeGroup>(summary.ProcedureTypeGroupRef, EntityLoadFlags.Proxy)); // facilities UpdateFilter(worklist.FacilityFilter, detail.Facilities, summary => context.Load <Facility>(summary.FacilityRef, EntityLoadFlags.Proxy)); worklist.FacilityFilter.IncludeWorkingFacility = detail.FilterByWorkingFacility; worklist.FacilityFilter.IsEnabled = worklist.FacilityFilter.Values.Count > 0 || worklist.FacilityFilter.IncludeWorkingFacility; // departments UpdateFilter(worklist.DepartmentFilter, detail.Departments, summary => context.Load <Department>(summary.DepartmentRef, EntityLoadFlags.Proxy)); // patient classes UpdateFilter(worklist.PatientClassFilter, detail.PatientClasses, summary => EnumUtils.GetEnumValue <PatientClassEnum>(summary, context)); // patient locations UpdateFilter(worklist.PatientLocationFilter, detail.PatientLocations, summary => context.Load <Location>(summary.LocationRef, EntityLoadFlags.Proxy)); // order priorities UpdateFilter(worklist.OrderPriorityFilter, detail.OrderPriorities, summary => EnumUtils.GetEnumValue <OrderPriorityEnum>(summary, context)); // ordering practitioners UpdateFilter(worklist.OrderingPractitionerFilter, detail.OrderingPractitioners, summary => context.Load <ExternalPractitioner>(summary.PractitionerRef, EntityLoadFlags.Proxy)); // portable if (detail.Portabilities != null) { // put them into a set to guarantee uniqueness, in case the client sent a non-unique list var set = new HashedSet <bool>(detail.Portabilities); // it only makes sense to enable this filter if the set contains exactly one value (true or false, but not both) worklist.PortableFilter.IsEnabled = set.Count == 1; worklist.PortableFilter.Value = CollectionUtils.FirstElement(set, false); } var start = CreateTimePoint(detail.StartTime); var end = CreateTimePoint(detail.EndTime); if (start != null || end != null) { worklist.TimeFilter.Value = new WorklistTimeRange(start, end); worklist.TimeFilter.IsEnabled = true; } else { worklist.TimeFilter.IsEnabled = false; } // process subscriptions if (updateSubscribers) { worklist.StaffSubscribers.Clear(); worklist.StaffSubscribers.AddAll( CollectionUtils.Map(detail.StaffSubscribers, (StaffSummary summary) => context.Load <Staff>(summary.StaffRef, EntityLoadFlags.Proxy))); worklist.GroupSubscribers.Clear(); worklist.GroupSubscribers.AddAll( CollectionUtils.Map(detail.GroupSubscribers, (StaffGroupSummary summary) => context.Load <StaffGroup>(summary.StaffGroupRef, EntityLoadFlags.Proxy))); } // If the worklist supports staff role filters, process the filters provided. if (Worklist.GetSupportsReportingStaffRoleFilter(worklist.GetClass())) { var reportingWorklist = worklist.As <ReportingWorklist>(); UpdateFilter(reportingWorklist.InterpretedByStaffFilter, detail.InterpretedByStaff, context); UpdateFilter(reportingWorklist.TranscribedByStaffFilter, detail.TranscribedByStaff, context); UpdateFilter(reportingWorklist.VerifiedByStaffFilter, detail.VerifiedByStaff, context); UpdateFilter(reportingWorklist.SupervisedByStaffFilter, detail.SupervisedByStaff, context); } }
public void IniciarWorklist() { Worklist worklist = new Worklist(8005, "QRSCP"); }
/// <summary> /// 供代理服务使用 /// </summary> public static void DelegateWorkList() { try { //删除已经过期的代理规则 K2DBHelper.DeleteExpiredDelegations(); //获取有效的代理规则 DataTable DelegationRules = K2DBHelper.GetActiveDelegations().Tables[0]; if (DelegationRules != null && DelegationRules.Rows.Count > 0) { using (Connection conn = new Connection()) { try { ConnectionSetup conSetup = GetConnectionSetup(); conn.Open(conSetup); foreach (DataRow DelegateRule in DelegationRules.Rows) { //获取被代理人的WorkList conn.ImpersonateUser(DelegateRule["FromUserAD"].ToString()); Worklist delegateFromWorkList = conn.OpenWorklist(); if (delegateFromWorkList != null && delegateFromWorkList.Count > 0) { foreach (WorklistItem listItem in delegateFromWorkList) { //选择状态为Available和Open状态的任务 if (listItem.Status == WorklistStatus.Available || listItem.Status == WorklistStatus.Open) { //获取该任务的主流程实例ID int parentProcInstID = K2DBHelper.GetRootParentsID(listItem.ProcessInstance.ID); //获取该任务的主流程实例 ProcessInstance inst = conn.OpenProcessInstance(parentProcInstID); //代理规则中设置的主流程的名称 string delagetionType = DelegateRule["ProcessFullName"].ToString(); //如果代理规则设置的流程名称为All或等主流程的名称 if (delagetionType.Equals("ALL", StringComparison.InvariantCultureIgnoreCase) || delagetionType.Equals(inst.FullName, StringComparison.InvariantCultureIgnoreCase)) { bool ContainsTargetUser = false; string targetUserSL = SecurityLabelName + ":" + DelegateRule["ToUserAD"].ToString(); //重置任务状态为Available,只有Available状态下的任务才有权限代理 listItem.Release(); //判断该任务是否已经代理给targetUser foreach (Destination destuser in listItem.DelegatedUsers) { if (destuser.Name.Equals(targetUserSL, StringComparison.InvariantCultureIgnoreCase)) { ContainsTargetUser = true; break; } } if (!ContainsTargetUser) { //如果该任务是其它人代理给sourceUser的,则sourceUser不能再次代理给targetUser,即禁止传递代理 DataTable DelegationLog = K2DBHelper.GetDelegationsLog(listItem.SerialNumber).Tables[0]; foreach (DataRow dr in DelegationLog.Rows) { if (DelegateRule["FromUserAD"].ToString().Equals(dr["ToUser"].ToString(), StringComparison.InvariantCultureIgnoreCase)) { ContainsTargetUser = true; break; } } } if (!ContainsTargetUser) { Destination dest = new Destination(); dest.DestinationType = DestinationType.User; for (int i = 0; i < listItem.Actions.Count; i++) { dest.AllowedActions.Add(listItem.Actions[i].Name); } dest.Name = targetUserSL; //任务代理 listItem.Delegate(dest); //Todo:给代理人邮件 //Todo:添加代理历史记录 K2DBHelper.AddDelegationsLog(listItem.ProcessInstance.ID, parentProcInstID, listItem.SerialNumber, DelegateRule["FromUserAD"].ToString(), DelegateRule["ToUserAD"].ToString(), "Server"); } } } } } conn.RevertUser(); } } catch { // TODO: throw? throw; } finally { try { conn.RevertUser(); } catch { throw; } if (conn != null) { conn.Close(); } } } } } catch { // TODO: throw? throw; } }
/// <summary> /// Create worklist detail. /// </summary> /// <param name="worklist"></param> /// <param name="context"></param> /// <returns></returns> public WorklistAdminDetail CreateWorklistDetail(Worklist worklist, IPersistenceContext context) { var detail = new WorklistAdminDetail(worklist.GetRef(), worklist.Name, worklist.Description, CreateClassSummary(worklist.GetClass())); var staffAssembler = new StaffAssembler(); var staffGroupAssembler = new StaffGroupAssembler(); detail.OwnerStaff = worklist.Owner.IsStaffOwner ? staffAssembler.CreateStaffSummary(worklist.Owner.Staff, context) : null; detail.OwnerGroup = worklist.Owner.IsGroupOwner ? staffGroupAssembler.CreateSummary(worklist.Owner.Group) : null; // proc types var ptAssembler = new ProcedureTypeAssembler(); detail.ProcedureTypes = GetFilterSummary(worklist.ProcedureTypeFilter, item => ptAssembler.CreateSummary(item)); // proc type groups var ptgAssembler = new ProcedureTypeGroupAssembler(); detail.ProcedureTypeGroups = GetFilterSummary(worklist.ProcedureTypeGroupFilter, item => ptgAssembler.GetProcedureTypeGroupSummary(item, context)); // facilities var facilityAssembler = new FacilityAssembler(); detail.Facilities = GetFilterSummary(worklist.FacilityFilter, item => facilityAssembler.CreateFacilitySummary(item)); detail.FilterByWorkingFacility = worklist.FacilityFilter.IsEnabled && worklist.FacilityFilter.IncludeWorkingFacility; // departments var departmentAssembler = new DepartmentAssembler(); detail.Departments = GetFilterSummary(worklist.DepartmentFilter, item => departmentAssembler.CreateSummary(item, context)); // patient class detail.PatientClasses = GetFilterSummary(worklist.PatientClassFilter, item => EnumUtils.GetEnumValueInfo(item)); // location var locationAssembler = new LocationAssembler(); detail.PatientLocations = GetFilterSummary(worklist.PatientLocationFilter, item => locationAssembler.CreateLocationSummary(item)); // order priority detail.OrderPriorities = GetFilterSummary(worklist.OrderPriorityFilter, item => EnumUtils.GetEnumValueInfo(item)); // ordering prac var practitionerAssembler = new ExternalPractitionerAssembler(); detail.OrderingPractitioners = GetFilterSummary(worklist.OrderingPractitionerFilter, item => practitionerAssembler.CreateExternalPractitionerSummary(item, context)); // portable if (worklist.PortableFilter.IsEnabled) { detail.Portabilities = new List <bool> { worklist.PortableFilter.Value }; } // time window if (worklist.TimeFilter.IsEnabled && worklist.TimeFilter.Value != null) { if (worklist.TimeFilter.Value.Start != null) { detail.StartTime = CreateTimePointContract(worklist.TimeFilter.Value.Start); } if (worklist.TimeFilter.Value.End != null) { detail.EndTime = CreateTimePointContract(worklist.TimeFilter.Value.End); } } detail.StaffSubscribers = CollectionUtils.Map(worklist.StaffSubscribers, (Staff staff) => staffAssembler.CreateStaffSummary(staff, context)); detail.GroupSubscribers = CollectionUtils.Map(worklist.GroupSubscribers, (StaffGroup group) => staffGroupAssembler.CreateSummary(group)); // Some ReportingWorklists can support staff role filters, if that is true for this worklist, // add those filters to the WorklistAdminDetail if (Worklist.GetSupportsReportingStaffRoleFilter(worklist.GetClass())) { var reportingWorklist = worklist.As <ReportingWorklist>(); detail.InterpretedByStaff = GetFilterSummary(reportingWorklist.InterpretedByStaffFilter, context); detail.TranscribedByStaff = GetFilterSummary(reportingWorklist.TranscribedByStaffFilter, context); detail.VerifiedByStaff = GetFilterSummary(reportingWorklist.VerifiedByStaffFilter, context); detail.SupervisedByStaff = GetFilterSummary(reportingWorklist.SupervisedByStaffFilter, context); } return(detail); }
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> insdEF = 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"); insdEF = extraFilters.FirstOrDefault(f => f.Item1 == "InsuredName"); 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 insdExtraFilter = insdEF == null ? String.Empty : insdEF.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} / % / {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); 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 != null && 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); // ... } workCriteria.AddFilterField(WCLogical.EndBracket, WCField.None, WCCompare.Equal, null); // ) } else { if (extraFilters != null && 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.StartIndex = skip; workCriteria.Count = take; foreach (KeyValuePair <WCField, WCSortOrder> sort in sorts) { workCriteria.AddSortField(sort.Key, sort.Value); } Worklist k2Worklist = k2Connection.OpenWorklist(workCriteria); foreach (WorklistItem item in k2Worklist) { retArray.Add(new WorkflowItem(item)); } count = k2Worklist.TotalCount; // Total records before filter totalCount = k2Worklist.TotalCount; return(retArray); } }
public static List <WorklistTicket> GetTickets(ApiUser hdUser, Guid OrgId, int DeptId, int UserId, string status, string role, string Class, string account, string location, string project, bool IsTechAdmin, bool IsUseWorkDaysTimer, string sort_order, string sort_by, string search = "", int page = 0, int limit = 25, DateTime?start_date = null, DateTime?end_date = null) { string tkts = ""; if (!string.IsNullOrWhiteSpace(search) && Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Integration.Azure.Search.Enabled) { tkts = bigWebApps.bigWebDesk.Data.Tickets.SearchTicketsInAzure(hdUser.OrganizationId, hdUser.DepartmentId, false, search); /*if (string.IsNullOrEmpty(tkts)) * { * return new List<WorklistTicket>(); * //tkts = "0"; * } */ } Worklist.QueryFilter _qFilter = new Worklist.QueryFilter(); if (string.IsNullOrEmpty(role) || role.ToLower() == "all") { role = "notset"; } if (!string.IsNullOrEmpty(status)) { string originalstatus = status; status = status.Replace(",", "").Replace("_", "").ToLowerInvariant(); Worklist.TicketStatusMode ticketStatusMode; if (Enum.TryParse <Worklist.TicketStatusMode>(status, true, out ticketStatusMode)) { _qFilter.TicketStatus = ticketStatusMode; } else { if (originalstatus.Contains(",")) { string statuses = originalstatus.Replace("_", "").ToLowerInvariant(); string status_query = string.Empty; foreach (string _status in statuses.Split(',')) { switch (_status.ToLower()) { case "closed": status_query += " OR tkt.status='Closed' "; break; case "open": status_query += " OR tkt.status='Open' "; break; case "onhold": status_query += " OR tkt.status='On Hold' "; break; case "partsonorder": status_query += " OR tkt.status='Parts On Order' "; break; case "waiting": status_query += " OR (tkt.status='Open' AND tkt.WaitingDate is not null) "; break; } } if (!string.IsNullOrEmpty(status_query)) { _qFilter.SQLWhere = " AND (" + status_query.Substring(3) + ")"; } } else { switch (status) { case "waiting": _qFilter.TicketStatus = Worklist.TicketStatusMode.OpenWaitingOnResponse; break; case "newmessages": switch (role) { case "tech": _qFilter.ShowNewMessages = Worklist.NewMessagesMode.User; break; case "user": _qFilter.ShowNewMessages = Worklist.NewMessagesMode.Technician; break; default: _qFilter.ShowNewMessages = Worklist.NewMessagesMode.UserAndTech; break; } ; break; case "closed": _qFilter.TicketStatus = Worklist.TicketStatusMode.Close; break; } } } } Worklist.SortMode ticketSortMode; if (Enum.TryParse <Worklist.SortMode>(role, true, out ticketSortMode)) { _qFilter.Sort = ticketSortMode; } else { switch (role) { case "tech": _qFilter.Sort = Worklist.SortMode.MyTickets; break; case "user": _qFilter.Sort = Worklist.SortMode.MyTicketsAsUser; break; case "alt_tech": _qFilter.Sort = Worklist.SortMode.MyTicketsAsAlternateTech; break; } } int queueId; if (int.TryParse(Class, out queueId)) { _qFilter.TechnicianId = queueId; Class = ""; } if (!string.IsNullOrEmpty(Class)) { int class_id = 0; if (int.TryParse(Class, out class_id)) { if (class_id > 0) { _qFilter.SQLWhere += " AND tkt.class_id = " + class_id; } } else { _qFilter.SQLWhere += " AND dbo.fxGetFullClassName(" + DeptId.ToString() + ", tkt.class_id) like '%" + Class + "%'"; } } if (!string.IsNullOrEmpty(account)) { int account_id = 0; if (int.TryParse(account, out account_id)) { if (account_id != 0) { _qFilter.AccountId = account_id; } } else { _qFilter.SQLWhere += " AND (ISNULL(acct.vchName, CASE WHEN ISNULL(tkt.btNoAccount, 0) = 0 THEN co.company_name ELSE '' END) like '%" + account + "%')"; } } if (!string.IsNullOrEmpty(project)) { int project_id = 0; if (int.TryParse(project, out project_id)) { if (project_id != 0) { _qFilter.ProjectID = project_id; } } else { _qFilter.SQLWhere += " AND dbo.fxGetFullProjectName(" + DeptId.ToString() + ", tkt.ProjectID) like '%" + project + "%'"; } } if (!string.IsNullOrEmpty(location)) { int location_id = 0; if (int.TryParse(location, out location_id)) { if (location_id != 0) { _qFilter.AccountLocationId = location_id; } } else { _qFilter.SQLWhere += " AND dbo.fxGetUserLocationName(" + DeptId.ToString() + ", tkt.LocationId) like '%" + location + "%'"; } } if (start_date.HasValue) { if (start_date.Value.TimeOfDay.TotalSeconds > 0) { start_date = start_date.Value.Date; } _qFilter.SQLWhere += string.Format(" AND tkt.CreateTime >= '{0}'", start_date.Value.ToString("yyyy-MM-dd hh:mm:ss")); } if (end_date.HasValue) { if (end_date.Value.TimeOfDay.TotalSeconds == 0) { end_date = end_date.Value.Date.AddDays(1).AddSeconds(-1); } _qFilter.SQLWhere += string.Format(" AND tkt.CreateTime <= '{0}'", end_date.Value.ToString("yyyy-MM-dd hh:mm:ss")); } Instance_Config config = new Instance_Config(hdUser); if (!string.IsNullOrWhiteSpace(search)) { string _query = ""; if (!string.IsNullOrEmpty(tkts)) { _query += " AND (tkt.Id IN (" + tkts + ")"; } else { _query += " AND (tkt.subject LIKE '%" + search + "%' OR ISNULL(tlip2.CountFoundInitPost, 0) > 0 OR tkt.note LIKE '%" + search + "%' OR ISNULL(tlcn2.CountFoundClosureNotes, 0) > 0"; _qFilter.SQLJoin += " LEFT OUTER JOIN (SELECT TId, COUNT(*) AS CountFoundInitPost FROM TicketLogs WHERE DId=" + hdUser.DepartmentId + " AND vchType = 'Initial Post' AND vchNote LIKE '%" + search + "%' GROUP BY TId) tlip2 ON tlip2.TId = tkt.Id " + "LEFT OUTER JOIN (SELECT TId, COUNT(*) AS CountFoundClosureNotes FROM TicketLogs WHERE DId=" + hdUser.DepartmentId + " AND vchType = 'Closed' AND vchNote LIKE '%" + search + "%' GROUP BY TId) tlcn2 ON tlcn2.TId = tkt.Id "; } if (config.SerialNumber) { _query += " OR tkt.SerialNumber LIKE '%" + search + "%'"; } _query += ")"; _qFilter.SQLWhere += _query; } limit = limit <= 0 ? 25 : limit; page = page < 0 ? 0 : page; string pager = string.Format(" OFFSET ({0} * {1}) ROWS FETCH NEXT {1} ROWS ONLY ", page, limit); _qFilter.PageIndex = page; if (sort_by != "days_old") { _qFilter.SortColumnIndex = 0; _qFilter.IsSortColumnDesc = "desc" == sort_order; _qFilter.SortColumnSQLAlias = sort_by ?? "CreateTime"; } bigWebApps.bigWebDesk.UserAuth userAuth = new bigWebApps.bigWebDesk.UserAuth { Role = hdUser.Role, OrgID = hdUser.OrganizationId, lngDId = hdUser.DepartmentId, tintTicketTimer = hdUser.tintTicketTimer, lngUId = hdUser.UserId, InstanceID = hdUser.InstanceId //ee.strGSUserRootLocationId //ee.sintGSUserType }; //Use global filters bool useGlobalFilters = hdUser.Role != bigWebApps.bigWebDesk.UserAuth.UserRole.Administrator && (role == "notset" || role == "tech"); bool limitToAssignedTickets = (useGlobalFilters) ? GlobalFilters.IsFilterEnabled(hdUser.OrganizationId, hdUser.DepartmentId, UserId, GlobalFilters.FilterState.LimitToAssignedTickets) : false; if (limitToAssignedTickets) { _qFilter.SQLWhere += " AND tkt.technician_id=" + UserId.ToString(); _qFilter.SQLJoin += " LEFT OUTER JOIN TicketAssignment AS TA2 ON TA2.DepartmentId=" + hdUser.DepartmentId + " AND TA2.TicketId = tkt.Id AND TA2.UserId = " + UserId + " AND TA2.AssignmentType = " + ((int)Ticket.TicketAssignmentType.Technician).ToString() + " AND TA2.IsPrimary = 0 AND TA2.StopDate IS NULL"; } //Use global filters if (useGlobalFilters) { _qFilter.SQLWhere += GlobalFilters.GlobalFiltersSqlWhere(userAuth, config, "tkt.", "tlj2.", "SupGroupID", null); } //(limitToAssignedTickets ? "TA2." : null //bigWebApps.bigWebDesk.Data.Worklist.Filter m_Filter = new bigWebApps.bigWebDesk.Data.Worklist.Filter(tt.DepartmentId, tt.UserId, true, tt.OrganizationId); //bool shortMode = true; //Worklist.ColumnsSetting m_ColSet = shortMode ? new Worklist.ColumnsSetting("0,2", tt.DepartmentId, tt.UserId, config.AccountManager && config.LocationTracking, tt.OrganizationId) : // new Worklist.ColumnsSetting(tt.DepartmentId, tt.UserId, config.AccountManager && config.LocationTracking, tt.OrganizationId); //if sherpadesk //DataTable dt = Worklist.SelectTicketsByFilter(ee, config, m_ColSet, m_Filter, _qFilter, false, FilesSources.AzureFileService, limit); DataTable dt = Worklist.SelectTicketsByFilter(OrgId, DeptId, UserId, _qFilter, IsTechAdmin, pager); if (dt != null) { //var config = new Instance_Config() dt.Columns.Add(new DataColumn("DaysOldSort", typeof(long))); dt.Columns.Add(new DataColumn("DaysOlds", typeof(string))); foreach (DataRow dr in dt.Rows) { int min = Utils.GetDaysOldInMinutes(OrgId, DeptId, IsUseWorkDaysTimer, dr.GetString("Status"), dr.Get <DateTime>("CreateTime"), dr.Get <DateTime?>("ClosedTime") ?? DateTime.UtcNow); dr["DaysOldSort"] = min; dr["DaysOlds"] = bigWebApps.bigWebDesk.Functions.DisplayDateDuration(min, config.BusinessDayLength, true); } } IEnumerable <WorklistTicket> wrklisttickets = new WorklistTickets(dt); return(wrklisttickets.ToList()); }
public ExpressionAnalysis(Worklist<BoundBlock> worklist, ISemanticModel model) : base(worklist) { Contract.ThrowIfNull(model); _model = model; }
//opening and completing a worklist item samples public static void OpenWorklistItemSamples() { //you must open a K2 connection first. We will wrap the K2 connection into a using statement to ensure that it is closed using (Connection K2Conn = new Connection()) { K2Conn.Open("[servername]"); //to open a worklist item you require at least the item's serial number //opening a worklist item without any overrides will automatically set the item's status to "Opened" by the connected user. WorklistItem K2WListItem = K2Conn.OpenWorklistItem("[serialnumber]"); //once you have opened the item, you can read data from the item or update data in the workflow string oldFolio = K2WListItem.ProcessInstance.Folio; K2WListItem.ProcessInstance.Folio = "[NewFolio]"; K2WListItem.ProcessInstance.DataFields["[String DataField Name]"].Value = "[updatedvalue]"; //to update the process without completing the task, call Update as follows. //to update the worklist item and finish the task, you must call the Action.Execute method //the workflow will then continue executing according to the action selected //warning: you must select one of the available actiosn for the current task, otherwise an error will be reported K2WListItem.Actions["[ActionName]"].Execute(); //to get the available actions for the task, query the Actions collection foreach (SourceCode.Workflow.Client.Action action in K2WListItem.Actions) { //do something with the actions. Normally, you would output the available actions into a drop-down list //or perhaps generate new button controls for each available action } //if you have want to open a worklist item from a managed user's tasklist, you need to use the OpenManagedWorklistItem method: K2WListItem = K2Conn.OpenManagedWorklistItem("[managedUserUsername]", "[serialNumber]"); //if you are openeing another user's worklist item that was delegated to the current account with Out of Office, you need //to use the OpenSharedWorklistItem method K2WListItem = K2Conn.OpenSharedWorklistItem("[originalUserName]", "[managedUserName]", "[serialNumber]"); //if you do not have the serial number, you can iterate over the worklist to open a worklist item //note: returning the worklist and iterating over the list can be an expensive operation //for the purposes of this exercise we will check if the worklist item folio is a specific value. A more efficient way would be to set up a //worklist criteria filter to filter the tasks based on the folio we are looking for Worklist K2WList = K2Conn.OpenWorklist(); //once you have retrived the worklist, you can iterate over the worklist items in the worklist foreach (WorklistItem K2WLItem in K2WList) { if (K2WLItem.ProcessInstance.Folio == "[somefolio]") { //you must open the worklist item before you can update it or complete it K2WLItem.Open(); K2WLItem.ProcessInstance.Folio = "[NewFolio]"; K2WLItem.ProcessInstance.DataFields["[SomeDataField]"].Value = "[updatedvalue]"; //to update the worklist item and finish it, you must call the Action.Execute method //the workflow will then continue executing accoridng to the action selected K2WLItem.Actions["[ActionName]"].Execute(); } } } }
public List <IIFWorklistItem> ListIIFWorklistItem(IIFWorklistItem_Filter filter) { List <IIFWorklistItem> result = new List <IIFWorklistItem>(); Dictionary <int, List <IIFWorklistItem> > dictWfItem = new Dictionary <int, List <IIFWorklistItem> >(); using (Connection k2Con = new Connection()) { k2Con.Open(this.AppConfig.K2Server); if (filter != null) { if (!string.IsNullOrEmpty(filter.Destination)) { k2Con.ImpersonateUser(filter.Destination); } } WorklistCriteria worklistCriteria = new WorklistCriteria(); worklistCriteria.Platform = "ASP"; worklistCriteria.AddFilterField(WCField.ProcessFullName, WCCompare.Equal, "IIF\\PAM"); worklistCriteria.AddFilterField(WCLogical.Or, WCField.ProcessFullName, WCCompare.Equal, "IIF\\CM"); worklistCriteria.AddFilterField(WCLogical.Or, WCField.WorklistItemOwner, "Me", WCCompare.Equal, WCWorklistItemOwner.Me); worklistCriteria.AddFilterField(WCLogical.Or, WCField.WorklistItemOwner, "Other", WCCompare.Equal, WCWorklistItemOwner.Other); Worklist worklist = k2Con.OpenWorklist(worklistCriteria); foreach (WorklistItem item in worklist) { IIFWorklistItem newData = new IIFWorklistItem(); newData.K2ProcessId = item.ProcessInstance.ID; newData.SN = item.SerialNumber; newData.K2CurrentActivityName = item.ActivityInstanceDestination.DisplayName; if (!dictWfItem.ContainsKey(newData.K2ProcessId)) { dictWfItem.Add(newData.K2ProcessId, new List <IIFWorklistItem>()); } newData.SharedUserFQN = item.AllocatedUser; dictWfItem[newData.K2ProcessId].Add(newData); } } if (dictWfItem.Count > 0) { string conStringIIF = this.AppConfig.IIFConnectionString; using (SqlConnection con = new SqlConnection(conStringIIF)) { con.Open(); string queryInValue = string.Empty; foreach (int k2ProcessId in dictWfItem.Keys) { if (string.IsNullOrEmpty(queryInValue)) { queryInValue = k2ProcessId.ToString(); } else { queryInValue = queryInValue + ", " + k2ProcessId.ToString(); } } string query = "SELECT [K2ProcessId], [Id]"; query = query + ", [MDocTypeId], [MDocTypeName], [MProductTypeId], [MProductTypeName]"; query = query + ", [ProjectCode], [CustomerName], [SubmitDate], [CMNumber]"; query = query + ", [IsInRevise]"; query = query + ", [MWorkflowStatusId], [MWorkflowStatusName]"; query = query + ", [ModifiedBy], [ModifiedOn]"; query = query + " FROM [dbo].[Vw_SubmissionList]"; query = query + " WHERE [K2ProcessId] IN ("; query = query + queryInValue; query = query + " )"; using (SqlCommand cmd = con.CreateCommand()) { cmd.CommandType = CommandType.Text; #region Filter if (filter != null) { if (filter.SubmitDate_FROM.HasValue) { query = query + " AND CONVERT(DATE, [SubmitDate]) >= @SubmitDate_FROM"; cmd.Parameters.Add(this.NewSqlParameter("SubmitDate_FROM", SqlDbType.Date, filter.SubmitDate_FROM)); } if (filter.SubmitDate_TO.HasValue) { query = query + " AND CONVERT(DATE, [SubmitDate]) <= @SubmitDate_TO"; cmd.Parameters.Add(this.NewSqlParameter("SubmitDate_TO", SqlDbType.Date, filter.SubmitDate_TO)); } if (!string.IsNullOrEmpty(filter.ProjectCode_LIKE)) { query = query + " AND [ProjectCode] LIKE '%' + @ProjectCode_LIKE + '%'"; cmd.Parameters.Add(this.NewSqlParameter("ProjectCode_LIKE", SqlDbType.VarChar, filter.ProjectCode_LIKE)); } if (!string.IsNullOrEmpty(filter.CustomerName_LIKE)) { query = query + " AND [CustomerName] LIKE '%' + @CustomerName_LIKE + '%'"; cmd.Parameters.Add(this.NewSqlParameter("CustomerName_LIKE", SqlDbType.VarChar, filter.CustomerName_LIKE)); } if (filter.ProductTypeId.HasValue) { query = query + " AND [MProductTypeId] = @ProductTypeId"; cmd.Parameters.Add(this.NewSqlParameter("ProductTypeId", SqlDbType.Int, filter.ProductTypeId)); } if (filter.MDocTypeId.HasValue) { query = query + " AND [MDocTypeId] = @MDocTypeId"; cmd.Parameters.Add(this.NewSqlParameter("MDocTypeId", SqlDbType.VarChar, filter.MDocTypeId.Value)); } if (!string.IsNullOrEmpty(filter.CMNumber_LIKE)) { query = query + " AND [CMNumber] LIKE '%' + @CMNumber_LIKE + '%'"; cmd.Parameters.Add(this.NewSqlParameter("CMNumber_LIKE", SqlDbType.VarChar, filter.CMNumber_LIKE)); } } #endregion cmd.CommandText = query; using (SqlDataReader dr = cmd.ExecuteReader()) { int indexOf_K2ProcessId = dr.GetOrdinal("K2ProcessId"); int indexOf_Id = dr.GetOrdinal("Id"); int indexOf_MDocTypeId = dr.GetOrdinal("MDocTypeId"); int indexOf_MDocTypeName = dr.GetOrdinal("MDocTypeName"); int indexOf_MProductTypeId = dr.GetOrdinal("MProductTypeId"); int indexOf_MProductTypeName = dr.GetOrdinal("MProductTypeName"); int indexOf_ProjectCode = dr.GetOrdinal("ProjectCode"); int indexOf_CustomerName = dr.GetOrdinal("CustomerName"); int indexOf_SubmitDate = dr.GetOrdinal("SubmitDate"); int indexOf_CMNumber = dr.GetOrdinal("CMNumber"); int indexOf_IsInRevise = dr.GetOrdinal("IsInRevise"); int indexOf_MWorkflowStatusId = dr.GetOrdinal("MWorkflowStatusId"); int indexOf_MWorkflowStatusName = dr.GetOrdinal("MWorkflowStatusName"); int indexOf_ModifiedBy = dr.GetOrdinal("ModifiedBy"); int indexOf_ModifiedOn = dr.GetOrdinal("ModifiedOn"); while (dr.Read()) { int k2ProcessId = dr.GetInt32(indexOf_K2ProcessId); if (dictWfItem.ContainsKey(k2ProcessId)) { foreach (IIFWorklistItem data in dictWfItem[k2ProcessId]) { Logger.Error("DocumentId: " + dr.GetInt64(indexOf_Id)); Logger.Error("MDocTypeId: " + dr.GetInt32(indexOf_MDocTypeId)); Logger.Error("MDocTypeName: " + dr.GetNullableString(indexOf_MDocTypeName)); Logger.Error("ProductTypeId: " + dr.GetInt32(indexOf_MProductTypeId)); Logger.Error("ProductTypeName: " + dr.GetNullableString(indexOf_MProductTypeName)); Logger.Error("ProjectCode: " + dr.GetNullableString(indexOf_ProjectCode)); Logger.Error("CustomerName: " + dr.GetNullableString(indexOf_CustomerName)); //Logger.Error("SubmitDate: " + dr.GetDateTime(indexOf_SubmitDate)); Logger.Error("CMNumber: " + dr.GetNullableString(indexOf_CMNumber)); Logger.Error("IsInRevise: " + dr.GetBoolean(indexOf_IsInRevise)); Logger.Error("WorkflowStatusId: " + dr.GetInt32(indexOf_MWorkflowStatusId)); Logger.Error("WorkflowStatusName: " + dr.GetNullableString(indexOf_MWorkflowStatusName)); Logger.Error("ModifiedBy: " + dr.GetNullableString(indexOf_ModifiedBy)); //Logger.Error("ModifiedOn: " + dr.GetDateTime(indexOf_ModifiedOn)); data.DocumentId = dr.GetInt64(indexOf_Id); data.MDocTypeId = dr.GetInt32(indexOf_MDocTypeId); data.MDocTypeName = dr.GetNullableString(indexOf_MDocTypeName); data.ProductTypeId = dr.GetInt32(indexOf_MProductTypeId); data.ProductTypeName = dr.GetNullableString(indexOf_MProductTypeName); data.ProjectCode = dr.GetNullableString(indexOf_ProjectCode); data.CustomerName = dr.GetNullableString(indexOf_CustomerName); try { data.SubmitDate = dr.GetDateTime(indexOf_SubmitDate); } catch { } data.CMNumber = dr.GetNullableString(indexOf_CMNumber); data.IsInRevise = dr.GetBoolean(indexOf_IsInRevise); data.WorkflowStatusId = dr.GetInt32(indexOf_MWorkflowStatusId); data.WorkflowStatusName = dr.GetNullableString(indexOf_MWorkflowStatusName); data.ModifiedBy = dr.GetNullableString(indexOf_ModifiedBy); try { data.ModifiedOn = dr.GetDateTime(indexOf_ModifiedOn); } catch { } if ((data.K2CurrentActivityName.ToUpper() == "Submit MoM BoD".ToUpper()) || (data.K2CurrentActivityName.ToUpper() == "Submit MoM BoC".ToUpper())) { data.TaskListStatus = "Responded (Risk Team)"; } else { data.TaskListStatus = data.WorkflowStatusName; } result.Add(data); } } } } } con.Close(); } } return(result); }
/// <summary> /// Gets a count of the number of worklist items in the specified worklist. /// </summary> /// <param name="worklist"></param> /// <param name="wqc"></param> /// <returns></returns> /// <remarks> /// Subclasses may override this method but in most cases this should not be necessary. /// </remarks> public virtual int CountWorklistItems(Worklist worklist, IWorklistQueryContext wqc) { var query = BuildWorklistQuery(new WorklistQueryArgs(worklist, wqc, true)); return(DoQueryCount(query)); }