public virtual JObject SearchProcess(HttpContext context) { YZRequest request = new YZRequest(context); string keyword = request.GetString("kwd", null); string uid = YZAuthHelper.LoginUserAccount; BPMProcessCollection processes; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); processes = cn.SearchProcess(null, BPMPermision.Execute, keyword, true, 100); } //将数据转化为Json集合 JObject rv = new JObject(); rv[YZJsonProperty.total] = processes.Count; JArray children = new JArray(); rv[YZJsonProperty.children] = children; using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { foreach (BPMProcess process in processes) { if (!process.Property.MobileInitiation) { continue; } JObject item = new JObject(); children.Add(item); item["ProcessName"] = process.Name; item["Active"] = process.Active; item["ProcessVersion"] = process.Version.ToString(2); item["Description"] = process.Property.Description; item["RelatedFile"] = process.Property.RelatedFile; item["ShortName"] = process.Property.ShortName; item["Color"] = process.Property.Color; if (String.IsNullOrEmpty(process.Property.ShortName)) { item["ShortName"] = YZStringHelper.GetProcessDefaultShortName(process.Name); } item["Favorited"] = FavoriteManager.HasFavorited(provider, cn, uid, YZResourceType.Process, process.Name); } } } return(rv); }
public virtual JObject GetRecentlyProcess(HttpContext context) { YZRequest request = new YZRequest(context); int top = request.GetInt32("top", 48); BPMProcessCollection processes; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); processes = cn.GetRecentlyProcess(true, top); } //将数据转化为Json集合 JObject rv = new JObject(); rv[YZJsonProperty.total] = processes.Count; JArray children = new JArray(); rv[YZJsonProperty.children] = children; foreach (BPMProcess process in processes) { if (!process.Property.MobileInitiation) { continue; } JObject item = new JObject(); children.Add(item); item["ProcessName"] = process.Name; item["Active"] = process.Active; item["ProcessVersion"] = process.Version.ToString(2); item["Description"] = process.Property.Description; item["RelatedFile"] = process.Property.RelatedFile; item["ShortName"] = process.Property.ShortName; item["Color"] = process.Property.Color; if (String.IsNullOrEmpty(process.Property.ShortName)) { item["ShortName"] = YZStringHelper.GetProcessDefaultShortName(process.Name); } } return(rv); }
protected virtual JObject Serialize(BPMConnection cn, BPMTaskListCollection tasks, int rowcount) { JObject rv = new JObject(); //将数据转化为Json集合 rv[YZJsonProperty.total] = rowcount; JArray children = new JArray(); rv[YZJsonProperty.children] = children; foreach (BPMTaskListItem task in tasks) { JObject item = new JObject(); children.Add(item); string stepDisplayName = BPMProcStep.GetStepDisplayName(task.StepName); item["StepID"] = task.StepID; item["TaskID"] = task.TaskID; item["SerialNum"] = task.SerialNum; item["ProcessName"] = task.ProcessName; item["ProcessVersion"] = task.ProcessVersion.ToString(2); item["OwnerAccount"] = task.OwnerAccount; item["OwnerDisplayName"] = task.OwnerDisplayName; item["AgentAccount"] = task.AgentAccount; item["AgentDisplayName"] = task.AgentDisplayName; item["CreateAt"] = task.CreateAt; item["NodeName"] = stepDisplayName; item["ReceiveAt"] = task.ReceiveAt; item["Share"] = task.Share; item["TimeoutFirstNotifyDate"] = task.TimeoutFirstNotifyDate; item["TimeoutDeadline"] = task.TimeoutDeadline; item["TimeoutNotifyCount"] = task.TimeoutNotifyCount; item["Description"] = task.Description; if (task.Progress != -1) { item["Progress"] = task.Progress; } try { string memberFullName = PositionManager.MemberFullNameFromID(cn, task.OwnerPositionID); OU ou = Member.GetParentOU(cn, memberFullName, null); item["Owner"] = String.Format("{0}/{1}", task.OwnerDisplayName, ou.Name); } catch (Exception) { item["Owner"] = task.OwnerDisplayName; } try { ProcessProperty property = BPMProcess.GetProcessProperty(cn, task.ProcessName, task.ProcessVersion); item["ShortName"] = property.ShortName; item["Color"] = property.Color; if (String.IsNullOrEmpty(property.ShortName)) { item["ShortName"] = YZStringHelper.GetProcessDefaultShortName(task.ProcessName); } } catch (Exception) { item["Color"] = this._deletedProcessColor; item["ShortName"] = YZStringHelper.GetProcessDefaultShortName(task.ProcessName); } JObject perm = new JObject(); item["perm"] = perm; perm["Share"] = task.Share; } return(rv); }
public virtual JObject GetHistoryTasks(HttpContext context) { YZRequest request = new YZRequest(context); HistoryTaskType taskType = request.GetEnum <HistoryTaskType>("HistoryTaskType", HistoryTaskType.AllAccessable); int year = request.GetString("byYear", "1") == "0" ? -1 : request.GetInt32("Year", DateTime.Today.Year); //获得数据 JObject rv = new JObject(); string taskTableFilter; string stepTableFilter; using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { taskTableFilter = this.GetFilterStringHistoryTaskTaskTable(request, provider); stepTableFilter = this.GetFilterStringHistoryTaskStep(request, provider); } using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); int rowcount; BPMTaskCollection tasks = cn.GetHistoryTasks(year, taskType, taskTableFilter, stepTableFilter, null, request.Start, request.Limit, out rowcount); rv[YZJsonProperty.total] = rowcount; JArray children = new JArray(); rv[YZJsonProperty.children] = children; foreach (BPMTask task in tasks) { JObject item = new JObject(); children.Add(item); item["TaskID"] = task.TaskID; item["SerialNum"] = task.SerialNum; item["ProcessName"] = task.ProcessName; item["ProcessVersion"] = task.ProcessVersion.ToString(2); item["OwnerAccount"] = task.OwnerAccount; item["OwnerDisplayName"] = task.OwnerDisplayName; item["AgentAccount"] = task.AgentAccount; item["AgentDisplayName"] = task.AgentDisplayName; item["CreateAt"] = task.CreateAt; item["State"] = YZJsonHelper.GetTaskStateJObject(cn, task.TaskState, task.TaskID); item["Description"] = task.Description; try { ProcessProperty property = BPMProcess.GetProcessProperty(cn, task.ProcessName, task.ProcessVersion); item["ShortName"] = property.ShortName; item["Color"] = property.Color; if (String.IsNullOrEmpty(property.ShortName)) { item["ShortName"] = YZStringHelper.GetProcessDefaultShortName(task.ProcessName); } } catch (Exception) { item["Color"] = this._deletedProcessColor; item["ShortName"] = YZStringHelper.GetProcessDefaultShortName(task.ProcessName); } } } return(rv); }
protected virtual void PostProcessNotifyTopic(IYZDbProvider provider, IDbConnection cn, BPMConnection bpmcn, string loginUserAccount, DataRow row, bool countUsers) { JObject jExt = new JObject(); row["ext"] = jExt; YZResourceType resType = (YZResourceType)Enum.Parse(typeof(YZResourceType), Convert.ToString(row["resType"]), true); row["resType"] = resType.ToString(); if (row.Table.Columns.Contains("uid")) { string uid = Convert.ToString(row["uid"]); User user = User.TryGetUser(bpmcn, uid); jExt["UserShortName"] = user == null ? uid : user.ShortName; } switch (resType) { case YZResourceType.Task: BPMTask task = BPMTask.Load(bpmcn, Int32.Parse(Convert.ToString(row["resId"]))); ProcessProperty property = BPMProcess.GetProcessProperty(bpmcn, task.ProcessName, task.ProcessVersion); string owner = YZStringHelper.GetUserShortName(task.OwnerAccount, task.OwnerDisplayName); row["resName"] = String.Format(Resources.YZStrings.All_BPM_Task_Title_FMT, owner, task.ProcessName); jExt["ProcessName"] = task.ProcessName; jExt["Owner"] = owner; jExt["Color"] = property.Color; jExt["ShortName"] = property.ShortName; if (String.IsNullOrEmpty(property.ShortName)) { jExt["ShortName"] = YZStringHelper.GetProcessDefaultShortName(task.ProcessName); } break; case YZResourceType.Group: Group.Group group = GroupManager.GetGroup(provider, cn, Int32.Parse(Convert.ToString(row["resId"]))); row["resName"] = group.Name; jExt["GroupType"] = group.GroupType; jExt["ImageFileID"] = group.ImageFileID; if (countUsers) { jExt["MemberCount"] = GroupManager.GetGroupMemberCount(provider, cn, group.GroupID); } break; case YZResourceType.SingleChat: P2PGroup.P2PGroup p2pGroup = P2PGroupManager.GetGroup(provider, cn, Int32.Parse(Convert.ToString(row["resId"]))); row["resName"] = p2pGroup.GetGroupName(bpmcn, loginUserAccount); jExt["P2PPeerAccount"] = p2pGroup.GetPeerAccount(loginUserAccount); jExt["FolderID"] = p2pGroup.FolderID; break; case YZResourceType.TaskApproved: row["resName"] = Resources.YZStrings.Aspx_Message_Title_Approved; break; case YZResourceType.TaskRejected: row["resName"] = Resources.YZStrings.Aspx_Message_Title_Rejected; break; default: break; } }
public virtual JObject GetFavoriteProcesses(HttpContext context) { //System.Threading.Thread.Sleep(3000); YZRequest request = new YZRequest(context); string path = request.GetString("path", null); BPMPermision perm = request.GetEnum <BPMPermision>("perm", BPMPermision.Execute); string uid = YZAuthHelper.LoginUserAccount; FavoriteCollection favirites; using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { favirites = FavoriteManager.GetFavorites(provider, cn, uid, YZResourceType.Process); } } BPMProcessCollection processes; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); processes = cn.GetProcessList(path, favirites.ResIDs, perm); } //将数据转化为Json集合 JObject rv = new JObject(); rv[YZJsonProperty.total] = processes.Count; JArray children = new JArray(); rv[YZJsonProperty.children] = children; foreach (BPMProcess process in processes) { if (!process.Property.MobileInitiation) { continue; } JObject item = new JObject(); children.Add(item); item["ProcessName"] = process.Name; item["Active"] = process.Active; item["ProcessVersion"] = process.Version.ToString(2); item["Description"] = process.Property.Description; item["RelatedFile"] = process.Property.RelatedFile; item["ShortName"] = process.Property.ShortName; item["Color"] = process.Property.Color; if (String.IsNullOrEmpty(process.Property.ShortName)) { item["ShortName"] = YZStringHelper.GetProcessDefaultShortName(process.Name); } } return(rv); }