/// <summary> /// 获取用户信息 /// </summary> /// <param name="UserID"></param> /// <returns></returns> public JsonResult GetUserInfo(string UserID) { return(this.ExecuteFunctionRun(() => { Organization.User user = (Organization.User)Engine.Organization.GetUnit(UserID); if (user != null) { user.ImageUrl = GetUserImageUrl(user); } var result = new { Success = user != null, User = user, PortalRoot = this.PortalRoot, ManagerName = GetUserManagerName(user), OUDepartName = GetUserParentName(user), chkEmail = user == null ? false : user.CheckNotifyType(OThinker.Organization.NotifyType.Email), chkMobileMessage = user == null ? false : user.CheckNotifyType(OThinker.Organization.NotifyType.MobileMessage), chkWeChat = user == null ? false : user.CheckNotifyType(OThinker.Organization.NotifyType.WeChat), chkApp = user == null ? false : user.CheckNotifyType(OThinker.Organization.NotifyType.App), chkDingTalk = user == null ? false : user.CheckNotifyType(OThinker.Organization.NotifyType.DingTalk), }; return Json(result, JsonRequestBehavior.AllowGet); })); }
/// <summary> /// 获取移动办公单点登录编码 /// </summary> /// <param name="user"></param> /// <param name="mobileType"></param> /// <param name="uuid"></param> /// <param name="jpushId"></param> /// <returns></returns> private string GetMobileToken(OThinker.Organization.User user, string mobileType, string uuid, string jpushId) { user.SID = uuid; if (!string.IsNullOrEmpty(jpushId)) { //保证用户JPushID的唯一性 List <string> usersId = Engine.PortalQuery.GetUsersIdByjpushId(jpushId); List <Organization.Unit> units = Engine.Organization.GetUnits(usersId.ToArray()); foreach (var unit in units) { if (unit.ObjectID != user.ObjectID) { Organization.User Updateuser = unit as Organization.User; Updateuser.JPushID = null; this.Engine.LogWriter.Write("删除" + Updateuser.Name + "[" + Updateuser.Code + "] jpushId"); this.Engine.Organization.UpdateUnit(user.ObjectID, Updateuser); } } // JPushId 只会在第一次登录的时候取值 user.JPushID = jpushId; } // 生成一个Token值 string mobileToken = Guid.NewGuid().ToString().Replace("-", string.Empty); user.MobileToken = mobileToken;// OThinker.Security.MD5Encryptor.GetMD5(mobileToken); user.MobileType = mobileType.ToLower().IndexOf("android") > -1 ? OThinker.Organization.MobileSystem.Android : OThinker.Organization.MobileSystem.iOS; // 更新用户的信息 if (user.DirtyProperties.Length > 0) { this.Engine.LogWriter.Write("更新" + user.Name + "[" + user.Code + "] jpushId:" + jpushId); this.Engine.Organization.UpdateUnit(user.ObjectID, user); } return(mobileToken); }
/// <summary> /// 通过用户别名获得身份 /// </summary> /// <param name="Engine"></param> /// <param name="TempImagesPath"></param> /// <param name="UserLoginName"></param> /// <returns></returns> private static UserValidator GetUserValidator(IEngine Engine, string TempImagesPath, string UserLoginName, Dictionary <string, object> PortalSettings) { if (string.IsNullOrEmpty(UserLoginName)) { return(null); } Organization.User unit = Engine.Organization.GetUserByCode(UserLoginName); if (unit == null) { return(null); } return(new UserValidator(Engine, unit.ObjectID, TempImagesPath, PortalSettings)); }
/// <summary> /// 通过用户别名获得身份 /// </summary> /// <param name="Engine"></param> /// <param name="UserLoginName"></param> /// <param name="Settings"></param> /// <returns></returns> public static UserValidator GetUserValidator(IEngine Engine, string UserLoginName, Dictionary <string, object> Settings) { if (string.IsNullOrEmpty(UserLoginName)) { return(null); } string tempImagesPath = Path.Combine(HttpContext.Current.Server.MapPath("."), "TempImages"); Organization.User unit = Engine.Organization.GetUserByCode(UserLoginName); if (unit == null) { return(null); } return(new UserValidator(Engine, unit.ObjectID, tempImagesPath, Settings)); }
/// <summary> /// 获取用户信息 /// </summary> /// <returns></returns> public void GetUserInfo() { string userId = Request["UserID"]; Organization.User user = AppUtility.Engine.Organization.GetUnit(userId) as Organization.User; Employee u = null; if (user != null) { u = new Employee() { ObjectID = user.ObjectID, Name = user.Name, Email = user.Email, Description = user.Description, // Country = user.Country, EmployeeNumber = user.EmployeeNumber, EmployeeRank = user.EmployeeRank, // Street = user.Street, Birthday = user.Birthday, OfficePhone = user.OfficePhone, Mobile = user.Mobile, PostalCode = user.PostalCode, PostOfficeBox = user.PostOfficeBox, // City = user.City, ParentID = user.ParentID //, // SourceParentID = user.SourceID // Province = user.Province }; u.DepartName = AppUtility.Engine.Organization.GetName(u.ParentID); u.DepartmentName = u.DepartName; string company = AppUtility.Engine.Organization.GetParent(u.ParentID); if (company != null) { // u.CompanyID = company; // u.CompanyName = AppUtility.Engine.Organization.GetName(u.CompanyID); } } Response.Clear(); Response.Write(JSSerializer.Serialize(u)); Response.Buffer = true; }
/// <summary> ///更新用户信息 /// </summary> /// <param name="unit"></param> /// <returns></returns> public JsonResult UpdateUserInfo(string UserID, string Mobile, string OfficePhone, string Email, string FacsimileTelephoneNumber, bool chkEmail, bool chkApp, bool chkWeChat, bool chkMobileMessage, bool chkDingTalk) { return(this.ExecuteFunctionRun(() => { ActionResult result = new ActionResult(true); #region add by chenghuashan 2018-02-24 if (!string.IsNullOrEmpty(Mobile)) { string sql = "SELECT Code,Name FROM OT_User WHERE Mobile='" + Mobile + "' and ObjectID <>'" + UserID + "'"; System.Data.DataTable dt = this.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteDataTable(sql); if (dt.Rows.Count > 0) { string msg = ""; foreach (System.Data.DataRow row in dt.Rows) { msg += "\n" + row["Name"] + "(" + row["Code"] + ")"; } result.Success = false; result.Message = "手机号码不允许重复,以下用户使用此手机号" + msg; return Json(result, "text/html"); } } #endregion //UserID修改人的ID Organization.User EditUnit = (OThinker.Organization.User)Engine.Organization.GetUnit(UserID); string dirPath = AppDomain.CurrentDomain.BaseDirectory + "TempImages//face//" + Engine.EngineConfig.Code + "//" + this.UserValidator.User.ParentID + "//"; string ID = this.UserValidator.UserID; System.Web.HttpFileCollectionBase files = HttpContext.Request.Files; if (files.Count > 0) { byte[] content = GetBytesFromStream(files[0].InputStream); if (content.Length > 0) { string Type = files[0].ContentType; string fileExt = ".jpg"; string savepath = dirPath + ID + fileExt; try { if (!Directory.Exists(Path.GetDirectoryName(savepath))) { Directory.CreateDirectory(Path.GetDirectoryName(savepath)); } using (FileStream fs = new FileStream(savepath, FileMode.OpenOrCreate, FileAccess.ReadWrite)) { using (BinaryWriter bw = new BinaryWriter(fs)) { bw.Write(content); bw.Close(); } } } catch (Exception ex) { // 这里如果直接输出异常,那么用户不能登录 Engine.LogWriter.Write("加载用户图片出现异常,UserValidator:" + ex.ToString()); } if (UserID == this.UserValidator.UserID) { this.UserValidator.ImagePath = ID + fileExt; } FileInfo file = GetFile(dirPath, ID + fileExt); if (file != null) { AttachmentHeader header = this.Engine.BizObjectManager.GetAttachmentHeader(OThinker.Organization.User.TableName, this.UserValidator.UserID, this.UserValidator.UserID); if (header != null) { Engine.BizObjectManager.UpdateAttachment(header.BizObjectSchemaCode, header.BizObjectId, header.AttachmentID, this.UserValidator.UserID, file.Name, Type, content, header.FileFlag); } else { // 用户头像采用附件上传方式 Attachment attach = new Attachment() { ObjectID = this.UserValidator.UserID, BizObjectId = this.UserValidator.UserID, BizObjectSchemaCode = OThinker.Organization.User.TableName, FileName = file.Name, Content = content, ContentType = Type, ContentLength = (int)file.Length }; Engine.BizObjectManager.AddAttachment(attach); } // 用户头像 EditUnit.ImageID = UserID; EditUnit.ImageUrl = "TempImages//face//" + Engine.EngineConfig.Code + "//" + this.UserValidator.User.ParentID + "//" + file.Name; result.Extend = new { ImageUrl = EditUnit.ImageUrl }; } } } EditUnit.Mobile = Mobile; EditUnit.OfficePhone = OfficePhone; EditUnit.Email = Email; EditUnit.FacsimileTelephoneNumber = FacsimileTelephoneNumber; EditUnit.ModifiedTime = DateTime.Now; //接收消息 EditUnit.SetNotifyType(Organization.NotifyType.App, chkApp); EditUnit.SetNotifyType(Organization.NotifyType.Email, chkEmail); EditUnit.SetNotifyType(Organization.NotifyType.MobileMessage, chkMobileMessage); EditUnit.SetNotifyType(Organization.NotifyType.WeChat, chkWeChat); EditUnit.SetNotifyType(Organization.NotifyType.DingTalk, chkDingTalk); // 写入服务器 Organization.HandleResult HandleResult = Engine.Organization.UpdateUnit(this.UserValidator.UserID, EditUnit); if (HandleResult == Organization.HandleResult.SUCCESS && EditUnit.ObjectID == this.UserValidator.UserID) { this.UserValidator.User = EditUnit as OThinker.Organization.User; } else { result.Success = false; result.Extend = null; } return Json(result, "text/html", JsonRequestBehavior.AllowGet); }, string.Empty)); }
public bool ReturnItem(string userId, string workItemId, string activityCode, string SchemaCode, double xbzjye, string state, DateTime bzjyedysj, string userName, string PassState, double yzzfbzj) { Organization.User user = this.Engine.Organization.GetUnit(userId) as Organization.User; if (user == null) { return(false); } // 获取工作项 OThinker.H3.DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetPublishedSchema(SchemaCode); OThinker.H3.WorkItem.WorkItem item = this.Engine.WorkItemManager.GetWorkItem(workItemId); OThinker.H3.Instance.InstanceContext context = this.Engine.InstanceManager.GetInstanceContext(item.InstanceId); OThinker.H3.DataModel.BizObject bo = new OThinker.H3.DataModel.BizObject(Engine, schema, userId); bo.ObjectID = context.BizObjectId; bo.Load(); //装载流程数据; if (bo.Schema.ContainsField("BZJYE")) //保证金余额 { bo["BZJYE"] = xbzjye; } if (bo.Schema.ContainsField("LCZT")) { bo["LCZT"] = state; } if (bo.Schema.ContainsField("BZJYEDYSJ")) { bo["BZJYEDYSJ"] = bzjyedysj; } if (bo.Schema.ContainsField("CWCLR")) { bo["CWCLR"] = userName; } if (bo.Schema.ContainsField("CWSPRID")) { bo["CWSPRID"] = userId; } //this.AppendComment(item.InstanceId, item, OThinker.Data.BoolMatchValue.Unspecified, "现保证金余额x钱,应再支付X保证金"); // 结束工作项 if (PassState == "TG") {//财务通过 this.Engine.WorkItemManager.FinishWorkItem( item.ObjectID, user.ObjectID, H3.WorkItem.AccessPoint.ExternalSystem, null, OThinker.Data.BoolMatchValue.True, string.Empty, null, H3.WorkItem.ActionEventType.Backward, (int)OThinker.H3.Controllers.SheetButtonType.Return); if (bo.Schema.ContainsField("CWSPYJDX")) { bo["CWSPYJDX"] = "通过"; } this.AppendComment(context, item, OThinker.Data.BoolMatchValue.True, "通过");//财务部通过后,显示通过 } else {//财务驳回 this.Engine.WorkItemManager.FinishWorkItem( item.ObjectID, user.ObjectID, H3.WorkItem.AccessPoint.ExternalSystem, null, OThinker.Data.BoolMatchValue.False, string.Empty, null, H3.WorkItem.ActionEventType.Backward, (int)OThinker.H3.Controllers.SheetButtonType.Return); var info = "现保证金余额" + string.Format("{0:N2}", xbzjye) + "元,应再支付" + string.Format("{0:N2}", yzzfbzj) + "保证金"; this.AppendComment(context, item, OThinker.Data.BoolMatchValue.False, info); if (bo.Schema.ContainsField("CWSPYJDX")) { bo["CWSPYJDX"] = "驳回"; } try { MessageClass ms = new MessageClass(); string sql = @"select distinct a.PARTICIPANT,b.code, d.objectid , d.code jxsuserCode, e.JXS,e.JXSCODE from Ot_Workitemfinished a join Ot_User b on a.PARTICIPANT = b.objectid join Ot_Instancecontext c on c.objectid = a.instanceid join OT_User d on d.objectid = c.ORIGINATOR join I_DealerLoan e on e.objectid = c.bizobjectid where ACTIVITYCODE='Activity3' and c.workFlowCode = 'DealerLoan' and instanceid='" + item.InstanceId + "'"; DataTable dt = OThinker.H3.Controllers.AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteDataTable(sql); string msstr1 = dt.Rows[0]["JXS"].ToString() + "(" + dt.Rows[0]["JXSCODE"].ToString() + ") 还需要支付<font color=\"red\">" + string.Format("{0:N2}", yzzfbzj) + "</font> 元 保证金金额才可以进行本次贷款申请,现保证金账户余额 " + string.Format("{0:N2}", xbzjye) + " 元"; string msstr2 = "您的账户还需要支付<font color=\"red\">" + string.Format("{0:N2}", yzzfbzj) + "</font> 元 保证金金额才可以进行本次贷款申请,现保证金账户余额 " + string.Format("{0:N2}", xbzjye) + "元"; if (dt != null && dt.Rows != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { ms.InsertMSG(dt.Rows[i]["PARTICIPANT"].ToString(), dt.Rows[i]["code"].ToString(), msstr1, true, 0, ""); } } ms.InsertMSG(dt.Rows[0]["objectid"].ToString(), dt.Rows[0]["jxsCode"].ToString(), msstr2, false, 0, ""); } catch (Exception e) { } } bo.Update(); // 准备触发后面Activity的消息 OThinker.H3.Messages.ActivateActivityMessage activateMessage = new OThinker.H3.Messages.ActivateActivityMessage( OThinker.H3.Messages.MessageEmergencyType.Normal, item.InstanceId, activityCode, OThinker.H3.Instance.Token.UnspecifiedID, null, new int[] { item.TokenId }, false, H3.WorkItem.ActionEventType.Backward); // 通知该Activity已经完成 OThinker.H3.Messages.AsyncEndMessage endMessage = new OThinker.H3.Messages.AsyncEndMessage( OThinker.H3.Messages.MessageEmergencyType.Normal, item.InstanceId, item.ActivityCode, item.TokenId, OThinker.Data.BoolMatchValue.False, true, OThinker.Data.BoolMatchValue.False, false, activateMessage); this.Engine.InstanceManager.SendMessage(endMessage); return(true); }