public virtual object OpenOrCreateGroup(HttpContext context) { YZRequest request = new YZRequest(context); string uid = YZAuthHelper.LoginUserAccount; string peeraccount = request.GetString("peeraccount"); P2PGroup.P2PGroup group; using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { Folder folder = this.CreateGroupFolder(provider, cn, String.Format("{0}_{1}", uid, peeraccount), ""); group = P2PGroupManager.TryGetGroup(provider, cn, uid, peeraccount); if (group == null) { string userName1; string userName2; using (BPMConnection bpmcn = new BPMConnection()) { bpmcn.WebOpen(); userName1 = User.FromAccount(bpmcn, uid).ShortName; userName2 = User.FromAccount(bpmcn, peeraccount).ShortName; } group = new P2PGroup.P2PGroup() { Account1 = uid, Account2 = peeraccount, UserName1 = userName1, UserName2 = userName2, FolderID = folder.FolderID, CreateBy = uid, CreateAt = DateTime.Now }; P2PGroupManager.Insert(provider, cn, group); } } } using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); return(new { resName = group.GetGroupName(cn, uid), groupid = group.GroupID, folderid = group.FolderID }); } }
public static BPMObjectNameCollection GetNotifyUsers(YZResourceType resType, string resId) { BPMObjectNameCollection uids = new BPMObjectNameCollection(); switch (resType) { case YZResourceType.Group: using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { MemberCollection members = GroupManager.GetGroupMembers(provider, cn, Int32.Parse(resId)); foreach (Member member in members) { uids.Add(member.UID); } } } break; case YZResourceType.SingleChat: using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { P2PGroup.P2PGroup group = P2PGroupManager.GetGroup(provider, cn, Int32.Parse(resId)); uids.Add(group.Account1); uids.Add(group.Account2); } } break; case YZResourceType.Task: using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { uids = NotifyManager.GetNotifyUsersTaskSocial(provider, cn, Int32.Parse(resId)); } } break; } return(uids); }
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; } }