public virtual JObject Public(HttpContext context) { YZRequest request = new YZRequest(context); this.ApproveCheck(context); int taskid = request.GetInt32("TaskID"); JObject jPost = request.GetPostData <JObject>(); string comments = (string)jPost["comments"]; BPMObjectNameCollection accounts = jPost["uids"].ToObject <BPMObjectNameCollection>(); UserCollection users = new UserCollection(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); foreach (string account in accounts) { User user = BPMTask.Public(cn, taskid, account); users.Add(user); } JObject rv = new JObject(); rv[YZJsonProperty.success] = true; rv["UserNameList"] = YZStringHelper.GetUserNameListString(users); return(rv); } }
public virtual JObject InviteIndicate(HttpContext context) { YZRequest request = new YZRequest(context); this.ApproveCheck(context); int taskid = request.GetInt32("TaskID"); JObject jPost = request.GetPostData <JObject>(); string comments = (string)jPost["comments"]; BPMObjectNameCollection accounts = jPost["uids"].ToObject <BPMObjectNameCollection>(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); BPMTask task = BPMTask.Load(cn, taskid); UserCollection users = BPMTask.InviteIndicate(cn, taskid, accounts, comments); JObject rv = new JObject(); rv[YZJsonProperty.success] = true; rv["SN"] = task.SerialNum; rv["UserNameList"] = YZStringHelper.GetUserNameListString(users); return(rv); } }
public virtual JObject Jump(HttpContext context) { YZRequest request = new YZRequest(context); this.ApproveCheck(context); int stepid = request.GetInt32("StepID", -1); int taskid = request.GetInt32("TaskID"); string toStepName = request.GetString("ToStepName"); JObject jPost = request.GetPostData <JObject>(); string comments = (string)jPost["comments"]; string formdata = (string)jPost["formdata"]; List <int> fromStepIDs = jPost["fromStepIDs"].ToObject <List <int> >(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); //移动审批不保存表单数据 if (!String.IsNullOrEmpty(formdata)) { BPMProcess.Post(cn, formdata); } BPMProcStep step = BPMTask.Jump(cn, taskid, stepid, fromStepIDs.ToArray(), toStepName, comments); JObject rv = new JObject(); rv[YZJsonProperty.success] = true; rv["StepName"] = step.NodeName; rv["UserFriendlyName"] = YZStringHelper.GetUserFriendlyName(step.RecipientAccount, step.RecipientFullName); return(rv); } }
public virtual JObject Transfer(HttpContext context) { YZRequest request = new YZRequest(context); this.ApproveCheck(context); int stepid = request.GetInt32("StepID"); string memberFullName = request.GetString("MemberFullName"); JObject jPost = request.GetPostData <JObject>(); string comments = (string)jPost["comments"]; string formdata = (string)jPost["formdata"]; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); //移动审批不保存表单数据 if (!String.IsNullOrEmpty(formdata)) { BPMProcess.Post(cn, formdata); } User user = BPMProcStep.Transfer(cn, stepid, memberFullName, comments); JObject rv = new JObject(); rv[YZJsonProperty.success] = true; rv["UserFriendlyName"] = user.FriendlyName; return(rv); } }
public virtual JObject ReActive(HttpContext context) { YZRequest request = new YZRequest(context); int taskid = request.GetInt32("TaskID"); JObject jPost = request.GetPostData <JObject>(); string comments = (string)jPost["comments"]; List <int> toStepIDs = jPost["toStepIDs"].ToObject <List <int> >(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); BPMStepCollection newSteps = BPMTask.ReActive(cn, taskid, toStepIDs.ToArray(), comments); List <string> to = new List <string>(); foreach (BPMProcStep step in newSteps) { to.Add(String.Format("{0}[{1}]", step.NodeName, YZStringHelper.GetUserFriendlyName(step.RecipientAccount, step.RecipientFullName))); } JObject rv = new JObject(); rv[YZJsonProperty.success] = true; rv["tosteps"] = String.Join(";", to.ToArray()); return(rv); } }
public virtual JObject SaveRole(HttpContext context) { YZRequest request = new YZRequest(context); string mode = request.GetString("mode"); JObject data = request.GetPostData <JObject>(); Role role = data["Role"].ToObject <Role>(); BPMObjectNameCollection members = data["Members"].ToObject <BPMObjectNameCollection>(); Role newRole = null; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); if (mode == "edit") { newRole = Role.UpdateRole(cn, request.GetString("fullname"), role, members); } else { newRole = OU.AddRole(cn, request.GetString("parentou"), role, members); } } return(this.SerializeOUObject(newRole)); }
public virtual JObject MemberFromFullNames(HttpContext context) { YZRequest request = new YZRequest(context); JArray jPost = request.GetPostData <JArray>(); BPMObjectNameCollection memberfullnames = jPost.ToObject <BPMObjectNameCollection>(); JObject rv = new JObject(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); foreach (string memberfullname in memberfullnames) { Member member = Member.TryGetMember(cn, memberfullname); if (member == null) { continue; } User user = member.GetUser(cn); //已删除和禁用的用户不显示 if (user == null || user.Disabled) { continue; } rv[memberfullname] = this.JObjectFromMember(member, user); } } return(rv); }
public virtual void MoveOUObjects(HttpContext context) { YZRequest request = new YZRequest(context); string src = request.GetString("src"); string tag = request.GetString("tag"); bool copy = request.GetBool("copy"); JObject post = request.GetPostData <JObject>(); BPMObjectNameCollection roles = post["roles"].ToObject <BPMObjectNameCollection>(); BPMObjectNameCollection members = post["members"].ToObject <BPMObjectNameCollection>(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); if (copy) { OU.CopyRoleAndMembers(cn, src, tag, roles, members); } else { OU.MoveRoleAndMembers(cn, src, tag, roles, members); } } }
public virtual JObject AddExistUsers(HttpContext context) { YZRequest request = new YZRequest(context); string parentou = request.GetString("parentou"); JArray post = request.GetPostData <JArray>(); BPMObjectNameCollection accounts = post.ToObject <BPMObjectNameCollection>(); JObject rv = new JObject(); JArray added = new JArray(); rv["added"] = added; try { using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); foreach (string account in accounts) { OU.AddMember(cn, parentou, account); added.Add(account); } } } catch (Exception e) { rv[YZJsonProperty.success] = false; rv[YZJsonProperty.errorMessage] = e.Message; } return(rv); }
public virtual void SaveUserInfo(HttpContext context) { YZRequest request = new YZRequest(context); string account = YZAuthHelper.LoginUserAccount; JArray @params = request.GetPostData <JArray>(); JObject jUserInfo = (JObject)@params[0]; User userNew = jUserInfo.ToObject <User>(request.Serializer); Type userType = typeof(User); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); User user = User.FromAccount(cn, account); foreach (KeyValuePair <string, JToken> kv in jUserInfo) { if (NameCompare.EquName(kv.Key, "Account")) { continue; } System.Reflection.PropertyInfo prop = userType.GetProperty(kv.Key); if (prop != null) { prop.SetValue(user, prop.GetValue(userNew, null), null); } } User.Update(cn, account, user); } }
public virtual JObject ReturnToInitiator(HttpContext context) { YZRequest request = new YZRequest(context); this.ApproveCheck(context); int taskid = request.GetInt32("TaskID"); JObject jPost = request.GetPostData <JObject>(); string comments = (string)jPost["comments"]; string formdata = (string)jPost["formdata"]; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); //移动审批不保存表单数据 if (!String.IsNullOrEmpty(formdata)) { BPMProcess.Post(cn, formdata); } User user = BPMTask.RecedeRestart(cn, taskid, comments); JObject rv = new JObject(); rv[YZJsonProperty.success] = true; rv["UserFriendlyName"] = user.FriendlyName; return(rv); } }
public virtual JObject UserFromUIDs(HttpContext context) { YZRequest request = new YZRequest(context); JArray jPost = request.GetPostData <JArray>(); BPMObjectNameCollection uids = jPost.ToObject <BPMObjectNameCollection>(); JObject rv = new JObject(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); foreach (string uid in uids) { User user = User.TryGetUser(cn, uid); //已删除和禁用的用户不显示 if (user == null || user.Disabled) { continue; } rv[uid] = this.JObjectFromMember(new Member(), user); } } return(rv); }
public virtual void SaveTimeSheet(HttpContext context) { YZRequest request = new YZRequest(context); string mode = request.GetString("mode"); string sheetName = request.GetString("sheetName", mode == "new", null); JArray @params = request.GetPostData <JArray>(); TimeSheet timesheet = @params[0].ToObject <TimeSheet>(request.Serializer); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); if (mode == "edit") { TimeSheet sheet = TimeSheet.Load(cn, sheetName); timesheet.Data = sheet.Data; if (sheetName != timesheet.Name) { TimeSheet.Rename(cn, sheetName, timesheet.Name); } timesheet.Save(cn, true); } else { timesheet.Save(cn, false); } } }
public virtual JArray MemberFromUIDs(HttpContext context) { YZRequest request = new YZRequest(context); JArray jPost = request.GetPostData <JArray>(); BPMObjectNameCollection uids = jPost.ToObject <BPMObjectNameCollection>(); JArray rv = new JArray(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); foreach (string uid in uids) { User user = User.TryGetUser(cn, uid); //已删除和禁用的用户不显示 if (user == null || user.Disabled) { continue; } Member member = OrgSvr.TryGetMemberFromAccount(cn, user.Account); if (member == null) { member = new Member(); } rv.Add(this.Serialize(member, user)); } } return(rv); }
public virtual JObject RecedeBack(HttpContext context) { YZRequest request = new YZRequest(context); int stepid = request.GetInt32("StepID"); JObject jPost = request.GetPostData <JObject>(); string comments = (string)jPost["comments"]; string formdata = (string)jPost["formdata"]; List <int> toStepIDs = jPost["toStepIDs"].ToObject <List <int> >(); BPMProcStep srcStep; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); if (!String.IsNullOrEmpty(formdata)) { BPMProcess.Post(cn, formdata); } srcStep = BPMProcStep.Load(cn, stepid); BPMStepCollection newSteps = BPMProcStep.RecedeBack(cn, stepid, toStepIDs.ToArray(), comments); List <string> to = new List <string>(); foreach (BPMProcStep step in newSteps) { to.Add(String.Format("{0}[{1}]", step.NodeName, YZStringHelper.GetUserShortName(step.RecipientAccount, step.RecipientFullName))); } JObject rv = new JObject(); rv["tosteps"] = String.Join(";", to.ToArray()); return(rv); } }
public virtual JObject Remind(HttpContext context) { YZRequest request = new YZRequest(context); JObject jPost = request.GetPostData <JObject>(); string comments = (string)jPost["comments"]; JArray jTargets = (JArray)jPost["targets"]; UserCollection users = new UserCollection(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); foreach (JObject jTarget in jTargets) { int stepid = (int)jTarget["stepid"]; BPMObjectNameCollection uids = jTarget["uids"].ToObject <BPMObjectNameCollection>(); users.Append(BPMProcStep.Remind(cn, stepid, uids, comments)); } } JObject rv = new JObject(); rv[YZJsonProperty.success] = true; rv["UserNameList"] = YZStringHelper.GetUserNameListString(users); return(rv); }
public virtual object Transfer(HttpContext context) { YZRequest request = new YZRequest(context); int stepid = request.GetInt32("StepID"); string account = request.GetString("Account"); JObject jPost = request.GetPostData <JObject>(); string comments = (string)jPost["comments"]; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); MemberCollection members = OrgSvr.GetUserPositions(cn, account); if (members.Count == 0) { throw new Exception(String.Format(Resources.YZMobile.Aspx_User_NoPosition, account)); } User user = BPMProcStep.Transfer(cn, stepid, members[0].FullName, comments); return(new { ShortName = user.ShortName }); } }
public virtual void ShareFiles(HttpContext context) { YZRequest request = new YZRequest(context); int folderid = request.GetInt32("folderid"); JObject post = request.GetPostData <JObject>(); List <string> fileids = post["fileids"].ToObject <List <string> >(); using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { YZSoft.FileSystem.FileCollection files = FileSystem.DirectoryManager.GetFiles(provider, cn, folderid, null, null, -1); foreach (string fileid in fileids) { if (files.TryGetFileByID(fileid) == null) { YZSoft.FileSystem.File file = new YZSoft.FileSystem.File(); file.FolderID = folderid; file.FileID = fileid; file.AddBy = YZAuthHelper.LoginUserAccount; file.AddAt = DateTime.Now; file.Comments = "share"; file.OrderIndex = YZSoft.FileSystem.DirectoryManager.GetFileNextOrderIndex(provider, cn, folderid); FileSystem.DirectoryManager.Insert(provider, cn, file); } } } } }
public virtual JObject SaveMember(HttpContext context) { YZRequest request = new YZRequest(context); string mode = request.GetString("mode"); string parentou = request.GetString("parentou", ""); JObject data = request.GetPostData <JObject>(); Member member = data["Member"].ToObject <Member>(); User user = data["User"].ToObject <User>(request.Serializer); BPMObjectNameCollection fgOUs = data["Member"]["FGOUs"].ToObject <BPMObjectNameCollection>(); BPMObjectNameCollection fgYWs = data["Member"]["FGYWs"].ToObject <BPMObjectNameCollection>(); SupervisorCollection spvs = data["Supervisors"].ToObject <SupervisorCollection>(); string headshot = (string)data["User"]["headshot"]; string sign = (string)data["User"]["sign"]; Member newMember = null; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); if (mode == "edit") { string fullname = request.GetString("fullname"); OUProviderInfo providerInfo = OrgSvr.GetProviderInfo(cn, fullname); if (providerInfo.Editable) { newMember = Member.UpdateMember(cn, parentou, fullname, member, user, fgOUs, fgYWs, spvs); } else { newMember = Member.FromFullName(cn, fullname); } } else { newMember = OU.AddMember(cn, request.GetString("parentou"), null, member, user, fgOUs, fgYWs, spvs); } //设置外出 UserCommonInfo userCommonInfo = data["UserCommonInfo"].ToObject <UserCommonInfo>(); User.SetOutOfOffice(cn, user.Account, userCommonInfo.OutOfOfficeState, userCommonInfo.OutOfOfficeFrom, userCommonInfo.OutOfOfficeTo); //设置主管 TaskRuleCollection taskRules = data["TaskRules"].ToObject <TaskRuleCollection>(); User.SaveTaskRules(cn, user.Account, taskRules); //头像与签名 this.SaveHeadshot(context, headshot, sign, user.Account); return(this.SerializeOUObject(cn, newMember)); } }
public virtual void SaveAccountSelfServiceSetting(HttpContext context) { YZRequest request = new YZRequest(context); JObject post = request.GetPostData <JObject>(); AccountSelfServicesSetting setting = post.ToObject <AccountSelfServicesSetting>(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); setting.Save(cn); } }
public virtual Library.Library CreateLibrary(HttpContext context) { YZRequest request = new YZRequest(context); string libType = request.GetString("libType"); string FolderID = request.GetString("FolderID", null); string DocumentFolderID = request.GetString("DocumentFolderID", null); JObject jPost = request.GetPostData <JObject>(); Library.Library libPost = jPost["data"].ToObject <Library.Library>(); ACL acl = jPost["acl"].ToObject <ACL>(); using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { Library.Library lib = new Library.Library(); lib.LibType = libType; lib.Name = libPost.Name; lib.Desc = libPost.Desc; if (!String.IsNullOrEmpty(FolderID)) { Folder folder = this.CreateLibFolder(provider, cn, libPost.Name, FolderID); lib.FolderID = folder.FolderID; } if (!String.IsNullOrEmpty(DocumentFolderID)) { Folder folder = this.CreateLibFolder(provider, cn, libPost.Name, DocumentFolderID); lib.DocumentFolderID = folder.FolderID; } lib.Owner = YZAuthHelper.LoginUserAccount; lib.CreateAt = DateTime.Now; lib.ImageFileID = libPost.ImageFileID; lib.OrderIndex = LibraryManager.GetLibraryNextOrderIndex(provider, cn, libType); lib.Deleted = false; LibraryManager.Insert(provider, cn, lib); using (BPMConnection bpmcn = new BPMConnection()) { bpmcn.WebOpen(); SecurityManager.SaveACL(bpmcn, SecurityResType.Library, lib.LibID.ToString(), null, acl); } return(lib); } } }
public virtual void SaveFolder(HttpContext context) { YZRequest request = new YZRequest(context); SecurityResType securityResType = request.GetEnum <SecurityResType>("securityResType"); string path = request.GetString("path", ""); JObject post = request.GetPostData <JObject>(); ACL acl = post["acl"].ToObject <ACL>(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); SecurityManager.SaveACL(cn, securityResType, path, null, acl); } }
public virtual void DeleteObjects(HttpContext context) { YZRequest request = new YZRequest(context); StoreZoneType zone = request.GetEnum <StoreZoneType>("zone"); string folder = request.GetString("folder", ""); JArray jPost = request.GetPostData <JArray>(); StoreObjectIdentityCollection objects = jPost.ToObject <StoreObjectIdentityCollection>(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); cn.DeleteObjects(zone, folder, objects); } }
public virtual void UnSubscribe(HttpContext context) { YZRequest request = new YZRequest(context); string clientid = request.GetString("clientid"); JArray jPost = request.GetPostData <JArray>(); BPMObjectNameCollection channels = jPost.ToObject <BPMObjectNameCollection>(); Client client = ClientManager.Instance.TryGetByID(clientid); if (client != null) { client.UnSubscribeTo(channels); } }
public virtual void MoveDownMembers(HttpContext context) { YZRequest request = new YZRequest(context); string parentou = request.GetString("parentou"); JArray post = request.GetPostData <JArray>(); BPMObjectNameCollection members = post.ToObject <BPMObjectNameCollection>(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); OU.MoveDownMembers(cn, parentou, members); } }
public virtual void SaveProcess(HttpContext context) { YZRequest request = new YZRequest(context); string fileid = request.GetString("fileid"); JObject jPost = request.GetPostData <JObject>(); JObject jProcess = (JObject)jPost["process"]; JObject jChart = (JObject)jPost["chart"]; string savePath = AttachmentInfo.FileIDToPath(fileid, AttachmentManager.AttachmentRootPath); if (jProcess["Property"] == null) { jProcess["Property"] = new JObject(); } if (jProcess["Property"]["CreateAt"] != null) { jProcess["Property"]["CreateAt"] = DateTime.Parse((string)jProcess["Property"]["CreateAt"]); } jProcess["Property"]["LastChange"] = DateTime.Now; jProcess["Property"]["ChangeBy"] = YZAuthHelper.LoginUserAccount; System.IO.Directory.CreateDirectory(savePath.Substring(0, savePath.LastIndexOf(@"\"))); using (System.IO.StreamWriter ws = new System.IO.StreamWriter(savePath, false, System.Text.Encoding.UTF8)) { ws.Write(jProcess.ToString()); } AttachmentInfo attachment; File bpafile = jProcess.ToObject <File>(); bpafile.FileID = fileid; using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { attachment = AttachmentManager.GetAttachmentInfo(provider, cn, fileid); attachment.LastUpdate = DateTime.Now; //AttachmentManager.(provider, cn, attachment); bpafile.FileName = attachment.Name; bpafile.UpdateSpritesIdentityAndLink(provider, cn); } } this.SaveChart(savePath, jChart); }
public virtual JObject GetTableSchemas(HttpContext context) { YZRequest request = new YZRequest(context); string serverName = request.GetString("ServerName", null); TableIdentityCollection tables = request.GetPostData <JArray>().ToObject <TableIdentityCollection>(); FlowDataSet dataSet; using (BPMConnection cn = new BPMConnection()) { this.OpenConnection(cn, serverName); dataSet = DataSourceManager.LoadDataSetSchema(cn, tables); return(YZJsonHelper.SerializeSchema(dataSet)); } }
public virtual void ResetPassword(HttpContext context) { YZRequest request = new YZRequest(context); string parentou = request.GetString("parentou"); string uid = request.GetString("uid"); JObject post = request.GetPostData <JObject>(); string pwd = (string)post["Password"]; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); User.ResetPassword(cn, parentou, uid, pwd); } }
public virtual object Reply(HttpContext context) { YZRequest request = new YZRequest(context); string clientid = request.GetString("clientid", null); int messageid = request.GetInt32("messageid"); JObject jPost = request.GetPostData <JObject>(); string msg = (string)jPost["message"]; YZMessage parentMessage; YZMessage message = new YZMessage(); YZMessageCollection replies; using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { parentMessage = SocialManager.GetMessageByID(provider, cn, messageid); message.resType = parentMessage.resType; message.resId = parentMessage.resId; message.uid = YZAuthHelper.LoginUserAccount; message.date = DateTime.Now; message.message = msg; message.replyto = parentMessage.id; SocialManager.Insert(provider, cn, message); replies = SocialManager.GetMessageReplies(provider, cn, parentMessage.id); parentMessage["Replies"] = replies; parentMessage["Praised"] = SocialManager.GetVotePraisedCount(provider, cn, parentMessage.id); } } using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); this.PostProcessMessage(cn, parentMessage); foreach (YZMessage replyMessage in replies) { this.PostProcessMessage(cn, replyMessage); } } YZSoft.Web.Push.MessageBus.Instance.onPostComments(clientid, message); return(parentMessage); }
public virtual void SaveMobileFormSetting(HttpContext context) { YZRequest request = new YZRequest(context); string processName = request.GetString("processName"); Version version = request.GetVersion("version"); JObject post = request.GetPostData <JObject>(); MobileFormSetting mobileFormSetting = post.ToObject <MobileFormSetting>(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); BPMProcess.SaveMobileFormSetting(cn, processName, version, mobileFormSetting); } }