public virtual object GetPersonalInfo(HttpContext context) { string uid = YZAuthHelper.LoginUserAccount; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); UserCommonInfo userCommonInfo = UserCommonInfo.FromAccount(cn, uid); User user = User.FromAccount(cn, uid); MemberCollection members = OrgSvr.GetUserPositions(cn, uid); JArray jMembers = new JArray(); foreach (Member member in members) { JObject jMember = new JObject(); jMembers.Add(jMember); jMember["LeaderTitle"] = member.LeaderTitle; jMember["Level"] = member.Level; jMember["OUName"] = member.GetParentOU(cn).Name; } return(new { user = user, userCommonInfo = userCommonInfo, positions = jMembers }); } }
public virtual JArray GetPositionsFromFullName(HttpContext context) { YZRequest request = new YZRequest(context); string memberfullname = request.GetString("memberfullname"); JArray rv = new JArray(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); Member themember = Member.FromFullName(cn, memberfullname); MemberCollection positions = OrgSvr.GetUserPositions(cn, themember.UserAccount); foreach (Member member in positions) { JObject jPos = new JObject(); rv.Add(jPos); string shortName = member.GetParentOU(cn).Name + "/" + member.UserAccount; string name = member.GetFriendlyFullName(cn); if (member.IsLeader) { name += "(" + member.LeaderTitle + ")"; shortName += "(" + member.LeaderTitle + ")"; } jPos["shortName"] = shortName; jPos["name"] = name; jPos["value"] = member.FullName; } } 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 Result ResetPassword(AuthInfo authInfo, string account, string password) { try { YZService.AuthSystem(authInfo); YZAuthHelper.SetAuthCookie(authInfo.RealLoginAccount); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); string oupath; MemberCollection members = OrgSvr.GetUserPositions(cn, account); if (members.Count == 0) { oupath = cn.GetRootOUs()[0].FullName; } else { oupath = members[0].GetParentOU(cn).FullName; } BPM.Client.User.ResetPassword(cn, oupath, account, password); } return(Result.SuccessResult); } catch (Exception e) { return(Result.FromException(e)); } }
public virtual object GetTeamReports(HttpContext context) { YZRequest request = new YZRequest(context); string myaccount = request.GetString("account", YZAuthHelper.LoginUserAccount); DateTime date = request.GetDateTime("date"); BPMObjectNameCollection accounts = new BPMObjectNameCollection(); accounts.Add(myaccount); using (BPMConnection bpmcn = new BPMConnection()) { bpmcn.WebOpen(); MemberCollection positions = OrgSvr.GetUserPositions(bpmcn, myaccount); foreach (Member position in positions) { DirectXSCollection xss = position.GetDirectXSs(bpmcn); foreach (DirectXS xs in xss) { if (!accounts.Contains(xs.UserAccount)) { accounts.Add(xs.UserAccount); } } } DailyReportCollection rv = new DailyReportCollection(); foreach (string account in accounts) { DailyReport dailyReport; using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { dailyReport = DailyReportManager.TryGetReport(provider, cn, account, date); if (dailyReport == null) { dailyReport = new DailyReport(); dailyReport.Account = account; dailyReport.Date = date; } rv.Add(dailyReport); } } User user = User.TryGetUser(bpmcn, account); dailyReport["ShortName"] = user == null ? "" : user.ShortName; } return(rv); } }
private Member GetMember(BPMConnection cn, string UserAccount) { Member m = new Member(); MemberCollection members = OrgSvr.GetUserPositions(cn, UserAccount); if (members.Count > 0) { m = members[0]; } return(m); }
public virtual object GetCompanyContactInfo(HttpContext context) { YZRequest request = new YZRequest(context); string uid = request.GetString("uid"); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); User user = User.FromAccount(cn, uid); UserCommonInfo userCommonInfo = UserCommonInfo.FromAccount(cn, uid); MemberCollection members = OrgSvr.GetUserPositions(cn, user.Account); SupervisorCollection supervisors = new SupervisorCollection(); foreach (Member member in members) { supervisors.AddRange(member.GetSupervisors(cn)); } JArray jMembers = new JArray(); foreach (Member member in members) { JObject jMember = new JObject(); jMembers.Add(jMember); jMember["LeaderTitle"] = member.LeaderTitle; jMember["Level"] = member.Level; jMember["OUName"] = member.GetParentOU(cn).Name; } JArray jSupervisors = new JArray(); foreach (Supervisor supervisor in supervisors) { JObject jSupervisor = new JObject(); jSupervisors.Add(jSupervisor); jSupervisor["Account"] = supervisor.UserAccount; jSupervisor["ShortName"] = YZStringHelper.GetUserShortName(supervisor.UserAccount, supervisor.UserFullName); jSupervisor["FGYWs"] = supervisor.FGYWEnabled ? supervisor.FGYWs.ToStringList(','):""; } return(new { user = user, userCommonInfo = userCommonInfo, positions = jMembers, supervisors = jSupervisors }); } }
public virtual object GetEmployeeInfo(HttpContext context) { YZRequest request = new YZRequest(context); string account = request.GetString("account"); bool includeDisabledUser = request.GetBool("includeDisabledUser", false); User user; List <object> rvPositions = new List <object>(); List <object> supervisors = new List <object>(); List <object> directXSs = new List <object>(); List <object> roles = new List <object>(); object[] groups; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); user = User.FromAccount(cn, account); MemberCollection positions = OrgSvr.GetUserPositions(cn, account); foreach (Member member in positions) { rvPositions.Add( new { ou = member.GetParentOU(cn).GetFriendlyFullName(cn), LeaderTitle = member.LeaderTitle, Level = member.Level } ); supervisors.AddRange(OrgManager.GetSupervisors(cn, member.FullName, includeDisabledUser)); directXSs.AddRange(OrgManager.GetDirectXSs(cn, member.FullName, includeDisabledUser)); roles.AddRange(OrgManager.GetRoles(cn, member.FullName)); } groups = OrgManager.GetGroups(cn, account); } return(new { user = user, positions = rvPositions, supervisors = supervisors, directxss = directXSs, roles = roles, groups = groups }); }
public virtual object SearchUser(HttpContext context) { YZRequest request = new YZRequest(context); string keyword = request.GetString("keyword", null); bool includeDisabledUser = request.GetBool("includeDisabledUser", false); //将数据转化为Json集合 JObject rv = new JObject(); JArray children = new JArray(); rv[YZJsonProperty.children] = children; if (!String.IsNullOrEmpty(keyword)) { using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); UserCollection users = OrgSvr.SearchUser(cn, keyword, includeDisabledUser); foreach (User user in users) { MemberCollection positions = OrgSvr.GetUserPositions(cn, user.Account); MemberCollection members = new MemberCollection(); if (positions.Count != 0) { members.Add(positions[0]); } foreach (Member member in members) { JObject jItem = this.JObjectFromMember(member, user); string oufullName = member.GetParentOU(cn).GetFriendlyFullName(cn); jItem["parentouFriendlyName"] = oufullName; jItem["memberFriendlyName"] = oufullName + "/" + user.Account; jItem["search"] = true; children.Add(jItem); } } } } //输出数据 return(rv); }
public virtual object GetLoginUserOrgRelationship(HttpContext context) { string account = YZAuthHelper.LoginUserAccount; List <object> rvPositions = new List <object>(); List <object> supervisors = new List <object>(); List <object> directXSs = new List <object>(); List <object> roles = new List <object>(); object[] groups; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); MemberCollection positions = OrgSvr.GetUserPositions(cn, account); foreach (Member member in positions) { rvPositions.Add( new { ou = member.GetParentOU(cn).GetFriendlyFullName(cn), LeaderTitle = member.LeaderTitle, Level = member.Level } ); supervisors.AddRange(OrgManager.GetSupervisors(cn, member.FullName, false)); directXSs.AddRange(OrgManager.GetDirectXSs(cn, member.FullName, false)); roles.AddRange(OrgManager.GetRoles(cn, member.FullName)); } groups = OrgManager.GetGroups(cn, account); } return(new { success = true, positions = rvPositions, supervisors = supervisors, directxss = directXSs, roles = roles, groups = groups }); }
public virtual object GetTeamList(HttpContext context) { YZRequest request = new YZRequest(context); DateTime date = request.GetDateTime("date"); string uid = YZAuthHelper.LoginUserAccount; BPMObjectNameCollection accounts = new BPMObjectNameCollection(); accounts.Add(uid); using (BPMConnection bpmcn = new BPMConnection()) { bpmcn.WebOpen(); MemberCollection positions = OrgSvr.GetUserPositions(bpmcn, uid); foreach (Member position in positions) { DirectXSCollection xss = position.GetDirectXSs(bpmcn); foreach (DirectXS xs in xss) { if (!accounts.Contains(xs.UserAccount)) { accounts.Add(xs.UserAccount); } } } using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { FootmarkCollection footmarks = FootmarkManager.GetFootmarks(provider, cn, accounts, date); return(new { children = this.SerializeAsTeamList(bpmcn, footmarks), unsignedusers = footmarks.GetUnSignedUsers(bpmcn, accounts) }); } } } }
private JObject UserInfo(BPMConnection cn, string UserAccount) { JObject UserInfo = new JObject(); MemberCollection members = OrgSvr.GetUserPositions(cn, UserAccount); if (members.Count > 0) { Member m = members[0]; UserInfo["UserAccount"] = m.UserAccount; UserInfo["DisplayName"] = m.UserDisplayName; UserInfo["LeaderTitle"] = m.LeaderTitle; UserInfo["Department"] = m.Department; UserInfo["Level"] = m.Level; UserInfo["FullName"] = members[0].FullName; User u = m.GetUser(cn); UserInfo["HRID"] = u.HRID; UserInfo["Birthday"] = u.Birthday.ToString("yyyy-MM-dd"); UserInfo["Sex"] = u.Sex == Sex.Male ? "男" : u.Sex == Sex.Female ? "女" : "未设置"; UserInfo["DateHired"] = u.DateHired.ToString("yyyy-MM-dd"); UserInfo["Office"] = u.Office; UserInfo["CostCenter"] = u.CostCenter; UserInfo["OfficePhone"] = u.OfficePhone; UserInfo["HomePhone"] = u.HomePhone; UserInfo["Mobile"] = u.Mobile; UserInfo["EMail"] = u.EMail; UserInfo["WWWHomePage"] = u.WWWHomePage; UserInfo["Description"] = u.Description; } else { throw new Exception("获取账号【" + UserAccount + "】的信息失败"); } return(UserInfo); }
protected void Page_Load(object sender, EventArgs e) { Response.Charset = "UTF-8"; Response.AddHeader("P3P", "CP=CAO PSA OUR"); //无此行当在ie的iframe中打开应用(default.aspx.cs)时设置cookie后,ajax request时cookie没了 this.Response.Cache.SetCacheability(HttpCacheability.NoCache); if (!YZAuthHelper.IsAuthenticated) { FormsAuthentication.RedirectToLoginPage(); return; } //设置页标题 this.Page.Title = System.Web.Configuration.WebConfigurationManager.AppSettings["CompanyInfoDefaultPageTitle"]; if (String.IsNullOrEmpty(this.Page.Title)) { this.Page.Title = Resources.YZStrings.Aspx_DefaultPage_Title; } //设置HTML标准 if (String.Compare(this.Request.Browser.Browser, "IE", true) == 0 && this.Request.Browser.MajorVersion == 6) { } else { this._litTop.Text = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; } //没有site参数,或site参数不正确 int factoryId = 0; Int32.TryParse(this.Request.QueryString["site"], out factoryId); //获得帐号信息 User user = new User(); int taskCount; int userLevel = 10; bool permSys = false; bool leave = false; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); //获得当前用户 user.Open(cn, YZAuthHelper.LoginUserAccount); taskCount = cn.GetMyTaskCount(null); UserCommonInfo userCommonInfo = UserCommonInfo.FromAccount(cn, YZAuthHelper.LoginUserAccount); MemberCollection positions = OrgSvr.GetUserPositions(cn, YZAuthHelper.LoginUserAccount); foreach (Member member in positions) { if (member.Level > userLevel) { userLevel = (int)member.Level; } } //检查对系统管理模块的权限 permSys = UserResourceSecurityManager.CheckPermision(cn, YZWellKnowRSID.SYS, "Execute"); leave = userCommonInfo.OutOfOfficeState == OutOfOfficeState.InOffice ? false:true; } JsonItem rv = new JsonItem(); rv.Attributes["LCID"] = YZLangHelper.CurrentCulture.LCID; rv.Attributes["CompanyName"] = System.Web.Configuration.WebConfigurationManager.AppSettings["CompanyInfoCompanyName"]; rv.Attributes["Account"] = YZAuthHelper.LoginUserAccount; rv.Attributes["DisplayName"] = user.DisplayName; rv.Attributes["TaskCount"] = taskCount; rv.Attributes["UserLevel"] = userLevel; rv.Attributes["PermSys"] = permSys; rv.Attributes["Leave"] = leave; rv.Attributes["Link1"] = System.Web.Configuration.WebConfigurationManager.AppSettings["CompanyInfoLink1"]; rv.Attributes["DBType"] = QueryManager.DBProviderName != "SQL Server" ? QueryManager.DBProviderName : ""; rv.Attributes["UnreadMessageCount"] = 0; //获得rootUrl string url = this.Request.Url.GetLeftPart(UriPartial.Authority); string virtualPath = HttpRuntime.AppDomainAppVirtualPath; if (virtualPath == "/") { virtualPath = String.Empty; } url = url + virtualPath + "/"; //在页面中包含JS string jscode = String.Format("var rootUrl='{0}';\nvar userInfo = {1}", url, rv.ToString()); HtmlGenericControl js = new HtmlGenericControl("script"); js.Attributes["type"] = "text/javascript"; js.InnerHtml = jscode; this.Page.Header.Controls.AddAt(1, js); //设置Cookie HttpCookie cookie; cookie = new HttpCookie("UserDisplayName", HttpUtility.UrlEncode(Convert.ToString(rv.Attributes["DisplayName"]), System.Text.Encoding.UTF8)); this.Response.SetCookie(cookie); cookie = new HttpCookie("UserLevel", userLevel.ToString()); this.Response.SetCookie(cookie); string startApp = this.Request.QueryString["StartApp"]; if (String.IsNullOrEmpty(startApp)) { startApp = System.Web.Configuration.WebConfigurationManager.AppSettings["StartApp"]; } if (String.IsNullOrEmpty(startApp)) { startApp = "YZApp"; } this._litStartApp.Text = String.Format("<script src=\"{0}/MainWindow.js\" type=\"text/javascript\"></script>", startApp); this._litStartAppCss.Text = String.Format("<link href=\"{0}/Styles/main.css\" rel=\"stylesheet\" type=\"text/css\" />", startApp); }
private MemoryStream GeneratePostXML(Guid guid, BPMConnection cn , string AppSN , string AppHRID , string AppHRName , DateTime AppDate , string AppDept , string AppCompany , string EmpID , string EmpName , DateTime ServiceTime , string ServiceType , string ServiceContent , int isSkyWorth ) { //设置Header DataTable tableHeader = new DataTable("Header"); tableHeader.Columns.Add(new DataColumn("Method", typeof(string))); tableHeader.Columns.Add(new DataColumn("ProcessName", typeof(string))); tableHeader.Columns.Add(new DataColumn("Action", typeof(string))); tableHeader.Columns.Add(new DataColumn("OwnerMemberFullName", typeof(string))); tableHeader.Columns.Add(new DataColumn("UploadFileGuid", typeof(string))); DataRow rowHeader = tableHeader.NewRow(); //设置Header数据 rowHeader["Method"] = "Post"; rowHeader["ProcessName"] = isSkyWorth == 0 ? "服务预约流程" : "服务预约流程"; rowHeader["Action"] = "提交"; rowHeader["OwnerMemberFullName"] = OrgSvr.GetUserPositions(cn, YZAuthHelper.LoginUserAccount)[0].FullName; rowHeader["UploadFileGuid"] = guid.ToString(); tableHeader.Rows.Add(rowHeader); //设置表单数据 DataSet formDataSet = new DataSet("FormData"); DataTable SubmitDataTab = new DataTable("ServiceOrder"); SubmitDataTab.Columns.Add(new DataColumn("TaskID", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("AppSN", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("AppHRID", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("AppName", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("AppDept", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("AppCompany", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("AppDate", typeof(DateTime))); SubmitDataTab.Columns.Add(new DataColumn("ServiceTime", typeof(DateTime))); SubmitDataTab.Columns.Add(new DataColumn("ServiceType", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("ServiceContent", typeof(string))); DataRow rowData = SubmitDataTab.NewRow(); rowData["AppSN"] = AppSN; rowData["AppHRID"] = AppHRID; rowData["AppName"] = AppHRName; rowData["AppDept"] = AppDept; rowData["AppCompany"] = AppCompany; rowData["AppDate"] = AppDate; rowData["ServiceType"] = ServiceType; rowData["ServiceTime"] = ServiceTime; rowData["ServiceContent"] = ServiceContent; SubmitDataTab.Rows.Add(rowData); formDataSet.Tables.Add(SubmitDataTab); //生成XML StringBuilder strBuilder = new StringBuilder(); StringWriter strWirter = new StringWriter(strBuilder); strWirter.WriteLine("<?xml version=\"1.0\"?>"); strWirter.WriteLine("<XForm>"); tableHeader.WriteXml(strWirter, XmlWriteMode.IgnoreSchema, false); formDataSet.WriteXml(strWirter); strWirter.WriteLine("</XForm>"); strWirter.Close(); String xmlData = strBuilder.ToString(); xmlData = xmlData.Replace("<DocumentElement>", ""); xmlData = xmlData.Replace("</DocumentElement>", ""); MemoryStream xmlStream = new MemoryStream(UTF8Encoding.UTF8.GetBytes(xmlData)); return(xmlStream); }
public virtual JObject GetPostInfo(HttpContext context) { YZRequest request = new YZRequest(context); string processName = request.GetString("processName"); int restartTaskID = request.GetInt32("restartTaskID", -1); string permisions = request.GetString("Permisions", null); Version processVersion = null; PostInfo postInfo; JObject perm; MemberCollection positions; FlowDataSet formdataset; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); if (restartTaskID == -1) { processVersion = cn.GetGlobalObjectLastVersion(StoreZoneType.Process, processName); } postInfo = BPMProcess.GetPostInfo(cn, processName, processVersion, null, restartTaskID); perm = this.CheckPermision(postInfo, permisions); positions = OrgSvr.GetUserPositions(cn, cn.UID); formdataset = BPMProcess.GetFormData(cn, processName, processVersion, null, restartTaskID); //准备返回值 JObject result = new JObject(); JObject jForm = new JObject(); if (String.IsNullOrEmpty(postInfo.MobileForm)) { //jForm["xclass"] = "YZSoft.form.Form5"; //jForm["config"] = new JObject(); jForm["xclass"] = "YZSoft.form.aspx.Form"; if (String.IsNullOrEmpty(postInfo.FormFile)) { throw new Exception(Resources.YZStrings.Aspx_Post_MissForm); } jForm["config"] = JObject.FromObject(new { aspxform = postInfo.FormFile }); } else { string xclass; JObject config; this.ParseMobileForm(postInfo.MobileForm, out xclass, out config); jForm["xclass"] = xclass; jForm["config"] = config; } result["form"] = jForm; result["subModel"] = "Post"; result["processName"] = postInfo.ProcessName; result["processVersion"] = postInfo.ProcessVersion.ToString(2); result["restartTaskID"] = restartTaskID; result["perm"] = perm; result["PersistParams"] = postInfo.PersistParams; result["NodePermisions"] = this.Serialize(postInfo.NodePermision); result["formdataset"] = this.ToResult(formdataset, true); //处理按钮 JArray links = new JArray(); result["links"] = links; foreach (Link link in postInfo.Links) { links.Add(this.Serialize(link, "normal")); } JArray jPoss = new JArray(); result["positions"] = jPoss; foreach (Member position in positions) { JObject jPos = new JObject(); jPoss.Add(jPos); string name = position.GetParentOU(cn).Name + "\\" + position.UserAccount; if (position.IsLeader) { name += "(" + position.LeaderTitle + ")"; } jPos["name"] = name; jPos["value"] = position.FullName; } //自由流 result["ParticipantDeclares"] = JArray.FromObject(postInfo.ParticipantDeclares); return(result); } }
public virtual JObject GetPostInfo(HttpContext context) { YZRequest request = new YZRequest(context); string processName = request.GetString("pn", null); int restartTaskID = request.GetInt32("restartTaskID", -1); string owner = request.GetString("owner", null); string permisions = request.GetString("Permisions", null); string did = request.GetString("did", null); Version processVersion = null; PostInfo postInfo; JObject perm; BPMDraft draft = null; JObject jDraftHeader = null; bool delagation; string selectPosition; MemberCollection positions; JObject rv = new JObject(); PostSubModel subModel; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); if (!String.IsNullOrEmpty(did)) { draft = new BPMDraft(); draft.Open(cn, new Guid(did)); processName = draft.ProcessName; if (!String.IsNullOrEmpty(draft.Header)) { jDraftHeader = JObject.Parse(draft.Header); } } if (draft != null) { subModel = (PostSubModel)Enum.Parse(typeof(PostSubModel), draft.Type.ToString()); } else { subModel = PostSubModel.Post; } if (restartTaskID == -1) { processVersion = cn.GetGlobalObjectLastVersion(StoreZoneType.Process, processName); } postInfo = BPMProcess.GetPostInfo(cn, processName, processVersion, owner, restartTaskID); perm = this.CheckPermision(postInfo, permisions); //获得delagation/selectPosition if (draft != null) { selectPosition = PositionManager.MemberFullNameFromID(cn, draft.OwnerPositionID); delagation = !YZStringHelper.EquName(draft.OwnerAccount, cn.UID); } else { if (postInfo.IsPostByAgent) { delagation = true; selectPosition = owner; } else { delagation = false; selectPosition = owner; } } //获得positions if (!delagation) { positions = OrgSvr.GetUserPositions(cn, cn.UID); if (String.IsNullOrEmpty(selectPosition) && positions.Count != 0) { selectPosition = positions[0].FullName; } } else { Member mb = new Member(); mb.Open(cn, selectPosition); positions = OrgSvr.GetUserPositions(cn, mb.UserAccount); selectPosition = mb.FullName; } if (String.IsNullOrEmpty(postInfo.FormFile)) { throw new Exception(Resources.YZStrings.Aspx_Post_MissForm); } //返回 rv[YZJsonProperty.success] = true; rv["subModel"] = subModel.ToString(); //基本信息 rv["pn"] = postInfo.ProcessName; rv["version"] = postInfo.ProcessVersion.ToString(2); rv["restartTaskID"] = restartTaskID; rv["url"] = YZUtility.GetFormRedirectUrl(postInfo.FormFile).ToString(); rv["perm"] = perm; rv["PersistParams"] = postInfo.PersistParams; rv["NodePermisions"] = this.Serialize(postInfo.NodePermision); rv["Comments"] = draft != null ? draft.Comments : null; rv["DraftHeader"] = jDraftHeader; //处理按钮 JArray links = new JArray(); rv["links"] = links; foreach (Link link in postInfo.Links) { links.Add(this.Serialize(link, "normal")); } //提交职位 rv["delagation"] = delagation; rv["selectPosition"] = selectPosition; JArray jPoss = new JArray(); rv["positions"] = jPoss; foreach (Member position in positions) { JObject jPos = new JObject(); jPoss.Add(jPos); string name = position.GetParentOU(cn).Name + "\\" + position.UserAccount; if (position.IsLeader) { name += "(" + position.LeaderTitle + ")"; } jPos["name"] = name; jPos["value"] = position.FullName; } //自由流 rv["ParticipantDeclares"] = JArray.FromObject(postInfo.ParticipantDeclares); } return(rv); }
private MemoryStream GeneratePostXML(Guid guid, BPMConnection cn , string AppSN , string AppHRID , string AppHRName , DateTime AppDate , string AppDept , string AppCompany , string EmpID , string EmpName , string LeaveID , string LeaveName , string LeaveTypeID , DateTime FromDate , DateTime ToDate , Int32 DayInt , int HourInt , string Note , string strAttachment , int isSkyWorth ) { //设置Header DataTable tableHeader = new DataTable("Header"); tableHeader.Columns.Add(new DataColumn("Method", typeof(string))); tableHeader.Columns.Add(new DataColumn("ProcessName", typeof(string))); tableHeader.Columns.Add(new DataColumn("Action", typeof(string))); tableHeader.Columns.Add(new DataColumn("OwnerMemberFullName", typeof(string))); tableHeader.Columns.Add(new DataColumn("UploadFileGuid", typeof(string))); DataRow rowHeader = tableHeader.NewRow(); //设置Header数据 rowHeader["Method"] = "Post"; rowHeader["ProcessName"] = isSkyWorth == 0 ? "请假申请" : "请假申请(石岩工厂)"; rowHeader["Action"] = "提交"; rowHeader["OwnerMemberFullName"] = OrgSvr.GetUserPositions(cn, YZAuthHelper.LoginUserAccount)[0].FullName; rowHeader["UploadFileGuid"] = guid.ToString(); tableHeader.Rows.Add(rowHeader); //设置表单数据 DataSet formDataSet = new DataSet("FormData"); // There is not any row in table "HR_LEAVE_MAIN[DigitalHR]", please check data bind! #region 数据库 //SELECT [TaskID] // ,[AppSN] // ,[AppHRID] // ,[AppHRName] // ,[AppDate] // ,[AppDept] // ,[AppCompany] // FROM [HR_Digital].[dbo].[HR_LEAVE_MAIN] //GO //休假历史记录 // SELECT [ID] // ,[TaskID] // ,[EmpID] // ,[FromDate] // ,[ToDate] // ,[Note] // ,[LeaveName] // FROM [HR_Digital].[dbo].[HR_LEAVE_HISTORY] // GO //SELECT [ID] // ,[TaskID] // ,[EmpID] // ,[EmpName] // ,[LeaveID] // ,[LeaveName] // ,[FromDate] // ,[ToDate] // ,[DayInt] // ,[HourInt] // ,[Note] // ,[Type] // ,[isFinish] // ,[Attachment] // ,[SangjiaTpye] // FROM [HR_Digital].[dbo].[HR_LEAVE_DTL] //GO //个人年假信息 //SELECT TOP 1000 [ID] // ,[TaskID] // ,[EmpID] // ,[YearNO] // ,[YearSum] // ,[YearUsed] // ,[YearUsable] // ,[ExpDate] // FROM [HR_Digital].[dbo].[HR_LEAVE_YEAR] #endregion DataTable SubmitDataTab = new DataTable("HR_LEAVE_MAIN"); SubmitDataTab.Columns.Add(new DataColumn("TaskID", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("AppSN", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("AppHRID", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("AppHRName", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("AppDept", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("AppCompany", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("AppDate", typeof(DateTime))); DataRow rowData = SubmitDataTab.NewRow(); rowData["AppSN"] = AppSN; rowData["AppHRID"] = AppHRID; rowData["AppHRName"] = AppHRName; rowData["AppDept"] = AppDept; rowData["AppCompany"] = AppCompany; rowData["AppDate"] = AppDate; SubmitDataTab.Rows.Add(rowData); formDataSet.Tables.Add(SubmitDataTab); SubmitDataTab = new DataTable("HR_LEAVE_DTL"); SubmitDataTab.Columns.Add(new DataColumn("TaskID", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("EmpID", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("EmpName", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("LeaveID", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("LeaveName", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("SangjiaTpye", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("FromDate", typeof(DateTime))); SubmitDataTab.Columns.Add(new DataColumn("ToDate", typeof(DateTime))); SubmitDataTab.Columns.Add(new DataColumn("DayInt", typeof(int))); SubmitDataTab.Columns.Add(new DataColumn("HourInt", typeof(int))); SubmitDataTab.Columns.Add(new DataColumn("Note", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("Attachment", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("isFinish", typeof(string))); rowData = SubmitDataTab.NewRow(); rowData["EmpID"] = EmpID; rowData["EmpName"] = EmpName; rowData["LeaveID"] = LeaveTypeID; rowData["LeaveName"] = LeaveName; rowData["SangjiaTpye"] = LeaveID; rowData["FromDate"] = FromDate; rowData["ToDate"] = ToDate; rowData["DayInt"] = DayInt; rowData["HourInt"] = HourInt; rowData["Note"] = Note; rowData["Attachment"] = strAttachment; SubmitDataTab.Rows.Add(rowData); formDataSet.Tables.Add(SubmitDataTab); //生成XML StringBuilder strBuilder = new StringBuilder(); StringWriter strWirter = new StringWriter(strBuilder); strWirter.WriteLine("<?xml version=\"1.0\"?>"); strWirter.WriteLine("<XForm>"); tableHeader.WriteXml(strWirter, XmlWriteMode.IgnoreSchema, false); formDataSet.WriteXml(strWirter); strWirter.WriteLine("</XForm>"); strWirter.Close(); String xmlData = strBuilder.ToString(); xmlData = xmlData.Replace("<DocumentElement>", ""); xmlData = xmlData.Replace("</DocumentElement>", ""); MemoryStream xmlStream = new MemoryStream(UTF8Encoding.UTF8.GetBytes(xmlData)); return(xmlStream); }
public void ProcessRequest(HttpContext context) { try { YZAuthHelper.OAuth(); //YZAuthHelper.AshxAuthCheck(); string method = context.Request.Params["Method"]; JsonItem JosonRv = new JsonItem(); if (YZStringHelper.EquName(method, "GET")) { string uid = YZAuthHelper.LoginUserAccount; using (BPMConnection cn = new BPMConnection()) { JsonItem data = new JsonItem(); JosonRv.Attributes.Add("data", data); cn.WebOpen(); UserAccount currentUser = cn.getCurrentUser(uid); User user = User.FromAccount(cn, uid); #region 用户信息 data.Attributes["Account"] = user.Account; data.Attributes["HRID"] = user.HRID; data.Attributes["DisplayName"] = user.ShortName; data.Attributes["Mobile"] = user.Mobile; data.Attributes["OfficePhone"] = user.OfficePhone; data.Attributes["HomePhone"] = user.HomePhone; data.Attributes["EMail"] = user.EMail; data.Attributes["Office"] = user.Office; data.Attributes["Birthday"] = YZStringHelper.DateToString(user.Birthday); data.Attributes["DateHired"] = YZStringHelper.DateToString(user.DateHired); data.Attributes["Desc"] = user.Description; #endregion #region 获得OU //获得OU String OULevel = String.Empty; String OUName = String.Empty; String Dept = String.Empty; BPMObjectNameCollection depts = new BPMObjectNameCollection(); MemberCollection members = OrgSvr.GetUserPositions(cn, uid); foreach (Member member in members) { OU ou = member.GetParentOU(cn); OULevel = ou.OULevel; Dept = ou.Name; String FullName = member.GetParentOU(cn).FullName; String mFullName = member.FullName; String mDepartment = member.Department; if (!ou.IsRootOU) { OUName = mFullName.Split(new char[2] { '/', '/' })[2]; depts.Add(OUName); } else { OUName = ou.Name; } if (String.IsNullOrEmpty(member.LeaderTitle)) { depts.Add(ou.Name); } else { depts.Add(String.Format("{0}({1})", ou.Name, member.LeaderTitle)); } } data.Attributes["Dept"] = String.Join(" > ", depts.ToArray()); #endregion UserCommonInfo userCommonInfo = UserCommonInfo.FromAccount(cn, uid); data.Attributes["AppSN"] = Net.Common.JosonRandom.GetRandomByDateTime(1, 999).Replace("/", ""); data.Attributes["AppCompany"] = OUName.GetShortName(); data.Attributes["AppDept"] = Dept; data.Attributes["AppDate"] = DateTime.Now; data.Attributes["AppHRName"] = user.ShortName; data.Attributes["AppHRID"] = YZAuthHelper.LoginUserAccount; data.Attributes["isSkyWorth"] = currentUser.AppFristDept != "制造中心" ? 0 : 1; data.Attributes["AppComDept"] = currentUser.AppCompany.ToConnects("\\") + currentUser.AppDept; JosonRv.Attributes.Add("success", true); JosonRv.Attributes.Add("successMessage", "ok"); context.Response.Write(JosonRv.ToString()); } } else if (YZStringHelper.EquName(method, "Submit")) { //遍历File表单元素 //HttpFileCollection files = HttpContext.Current.Request.Files; //try //{ // for (int iFile = 0; iFile < files.Count; iFile++) // { // ///检查文件扩展名字 // HttpPostedFile postedFile = files[iFile]; // string fileName, fileExtension; // fileName = System.IO.Path.GetFileName(postedFile.FileName); // if (fileName != "") // { // ///注意:可能要修改你的文件夹的匿名写入权限。 // postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("YZSoft/attachment/") + fileName); // } // } // HttpContext.Current.Response.Write("{success:true,msg:'File was successfully uploaded.'}"); //} //catch (System.Exception Ex) //{ // HttpContext.Current.Response.Write("{success:true,msg:'File was successfully uploaded.'}"); //} #region 接收数据 string uid = YZAuthHelper.LoginUserAccount; string EmpID = Convert.ToString(context.Request.Params["AppHRID"]); string EmpName = Convert.ToString(context.Request.Params["AppHRName"]); string LeaveID = Convert.ToString(context.Request.Params["LeaveID"]); string LeaveName = Convert.ToString(context.Request.Params["LeaveName"]); string LeaveTypeID = Convert.ToString(context.Request.Params["LeaveTypeID"]); String AppSN = Convert.ToString(context.Request.Params["AppSN"]); String AppCompany = Convert.ToString(context.Request.Params["AppCompany"]); String AppDept = Convert.ToString(context.Request.Params["AppDept"]); DateTime AppDate = Convert.ToDateTime(context.Request.Params["AppDate"]); String AppHRName = Convert.ToString(context.Request.Params["AppHRName"]); String AppHRID = Convert.ToString(context.Request.Params["AppHRID"]); String Address = Convert.ToString(context.Request.Params["Address"]); DateTime FromDate = YZStringHelper.StringToDate(context.Request.Params["startTime"]); DateTime ToDate = YZStringHelper.StringToDate(context.Request.Params["endTime"]); String allHours = Convert.ToString(context.Request.Params["allHours"]); int DayInt = Convert.ToInt32(allHours.Split('天')[0]); int HourInt = Convert.ToInt32(allHours.Split('天')[1].Split('小')[0]); String reasonWhyNote = Convert.ToString(context.Request.Params["reasonWhy"]); String suggestionMsg = Convert.ToString(context.Request.Params["suggestionMsg"]); String strAttachment = Convert.ToString(context.Request.Params["strAttachment"]); int isSkyWorth = Convert.ToInt32(context.Request.Params["isSkyWorth"]); #region iPHone 早期版本 客户端Bug修改 String strFromClient = submitFrom.UserAgent(context); //if (suggestionMsg.IndexOf("iphone") > -1 || suggestionMsg.IndexOf("iPhone") > -1) //{ // if (LeaveTypeID == "20") // { // LeaveTypeID = "30"; // } // else // { // LeaveTypeID = LeaveTypeID == "30" ? "20" : LeaveTypeID; // } //} #endregion #endregion using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); // Net.Common.GetRequestForm.Post<T> // http://extjs.org.cn/node/712 #region 提交数据 MemoryStream xmlStream = GeneratePostXML(Guid.NewGuid(), cn , AppSN , AppHRID , AppHRName , AppDate , AppDept , AppCompany , EmpID , EmpName , LeaveID , LeaveName , LeaveTypeID , FromDate , ToDate , DayInt , HourInt , reasonWhyNote + suggestionMsg + "\n\r" + strFromClient , strAttachment , isSkyWorth ); #endregion PostResult result = BPMProcess.Post(cn, xmlStream); String DisplayName = result.Recipients[0].Owner.DisplayName; //JsonItem JosonRv = new JsonItem(); JosonRv.Attributes.Add("success", true); JosonRv.Attributes.Add("successMessage", "\n\r <BR> 流程【" + result.SN + "】\n\r <BR> 成功提交给 " + DisplayName); context.Response.Write(JosonRv.ToString()); } } else { String strMsg = String.Format(JosonStrings.Aspx_UnknowCommand, method); //JsonItem JosonRv = new JsonItem(); JosonRv.Attributes.Add("success", false); JosonRv.Attributes.Add("errorMessage", strMsg); context.Response.Write(JosonRv.ToString()); throw new Exception(strMsg); } //System.Threading.Thread.Sleep(500); } catch (Exception e) { JsonItem JosonRv = new JsonItem(); JosonRv.Attributes.Add("success", false); JosonRv.Attributes.Add("errorMessage", e.Message); context.Response.Write(JosonRv.ToString()); } }
private MemoryStream GeneratePostXML(Guid guid, BPMConnection cn , string AppSN , string AppHRID , string AppHRName , DateTime AppDate , string AppDept , string AppCompany , string EmpID , string EmpName , string Address , DateTime FromDate , DateTime ToDate , Int32 DayInt , int HourInt , string Note , string strAttachment , int isSkyWorth ) { //设置Header DataTable tableHeader = new DataTable("Header"); tableHeader.Columns.Add(new DataColumn("Method", typeof(string))); tableHeader.Columns.Add(new DataColumn("ProcessName", typeof(string))); tableHeader.Columns.Add(new DataColumn("Action", typeof(string))); tableHeader.Columns.Add(new DataColumn("OwnerMemberFullName", typeof(string))); tableHeader.Columns.Add(new DataColumn("UploadFileGuid", typeof(string))); DataRow rowHeader = tableHeader.NewRow(); //设置Header数据 rowHeader["Method"] = "Post"; rowHeader["ProcessName"] = isSkyWorth == 0 ? "公干申请" : "公干申请(工厂)"; rowHeader["Action"] = "提交"; rowHeader["OwnerMemberFullName"] = OrgSvr.GetUserPositions(cn, YZAuthHelper.LoginUserAccount)[0].FullName; rowHeader["UploadFileGuid"] = guid.ToString(); tableHeader.Rows.Add(rowHeader); //设置表单数据 DataSet formDataSet = new DataSet("FormData"); #region 数据库 // SELECT [TaskID] // ,[AppSN] // ,[AppHRID] // ,[AppHRName] // ,[AppDate] // ,[AppDept] // ,[Type] // ,[AppCompany] // FROM [HR_Digital].[dbo].[HR_GongGan_MAIN] //GO //SELECT [ID] // ,[TaskID] // ,[EmpID] // ,[EmpName] // ,[Address] // ,[FromDate] // ,[ToDate] // ,[DayInt] // ,[HourInt] // ,[Note] // ,[Note1] // ,[Note2] // ,[Note3] // ,[Type] // ,[isFinish] // ,[Cost] // ,[State] // ,[Vehicle] // ,[OtherVehicle] // FROM [HR_Digital].[dbo].[HR_GangGan_DTL] //GO #endregion DataTable SubmitDataTab = new DataTable("HR_GongGan_MAIN"); SubmitDataTab.Columns.Add(new DataColumn("TaskID", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("AppSN", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("AppHRID", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("AppHRName", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("AppDept", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("AppCompany", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("AppDate", typeof(DateTime))); DataRow rowData = SubmitDataTab.NewRow(); rowData["AppSN"] = AppSN; rowData["AppHRID"] = AppHRID; rowData["AppHRName"] = AppHRName; rowData["AppDept"] = AppDept; rowData["AppCompany"] = AppCompany; rowData["AppDate"] = AppDate; SubmitDataTab.Rows.Add(rowData); formDataSet.Tables.Add(SubmitDataTab); SubmitDataTab = new DataTable("HR_GangGan_DTL"); SubmitDataTab.Columns.Add(new DataColumn("TaskID", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("EmpID", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("EmpName", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("Address", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("Vehicle", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("OtherVehicle", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("FromDate", typeof(DateTime))); SubmitDataTab.Columns.Add(new DataColumn("ToDate", typeof(DateTime))); SubmitDataTab.Columns.Add(new DataColumn("DayInt", typeof(int))); SubmitDataTab.Columns.Add(new DataColumn("HourInt", typeof(int))); SubmitDataTab.Columns.Add(new DataColumn("Note", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("Attachment", typeof(string))); SubmitDataTab.Columns.Add(new DataColumn("isFinish", typeof(string))); rowData = SubmitDataTab.NewRow(); rowData["EmpID"] = EmpID; rowData["EmpName"] = EmpName; rowData["Address"] = Address; rowData["OtherVehicle"] = ""; // OtherVehicle; rowData["Vehicle"] = ""; // Vehicle; rowData["FromDate"] = FromDate; rowData["ToDate"] = ToDate; rowData["DayInt"] = DayInt; rowData["HourInt"] = HourInt; rowData["Note"] = Note; rowData["Attachment"] = strAttachment; SubmitDataTab.Rows.Add(rowData); formDataSet.Tables.Add(SubmitDataTab); //生成XML StringBuilder strBuilder = new StringBuilder(); StringWriter strWirter = new StringWriter(strBuilder); strWirter.WriteLine("<?xml version=\"1.0\"?>"); strWirter.WriteLine("<XForm>"); tableHeader.WriteXml(strWirter, XmlWriteMode.IgnoreSchema, false); formDataSet.WriteXml(strWirter); strWirter.WriteLine("</XForm>"); strWirter.Close(); String xmlData = strBuilder.ToString(); xmlData = xmlData.Replace("<DocumentElement>", ""); xmlData = xmlData.Replace("</DocumentElement>", ""); MemoryStream xmlStream = new MemoryStream(UTF8Encoding.UTF8.GetBytes(xmlData)); return(xmlStream); }
public virtual JObject GetUsers(HttpContext context) { YZRequest request = new YZRequest(context); string keyword = request.GetString("keyword", null); bool position = request.GetBool("position", false); //获得数据 UserCollection users = new UserCollection(); int rowcount; JObject rv = new JObject(); //将数据转化为Json集合 JArray children = new JArray(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); users = OrgSvr.SearchUser(cn, keyword, 100); users.Sort(new UserCompare()); rowcount = users.Count; foreach (User user in users) { JObject item = new JObject(); children.Add(item); item["Name"] = user.DisplayName; item["Account"] = user.Account; item["HRID"] = user.HRID; item["ShortName"] = user.ShortName; item["group"] = YZPinYinHelper.GetShortPinyin(user.ShortName.Substring(0, 1)).ToUpper(); //item["Mobile"] = user.Mobile; //item["HomePhone"] = user.HomePhone; //item["OfficePhone"] = user.OfficePhone; //item["Mail"] = user.EMail; if (position) { JArray jMembers = new JArray(); item["positions"] = jMembers; MemberCollection members = OrgSvr.GetUserPositions(cn, user.Account); foreach (Member member in members) { JObject jMember = new JObject(); jMembers.Add(jMember); jMember["LeaderTitle"] = member.LeaderTitle; jMember["Level"] = member.Level; jMember["OUName"] = member.GetParentOU(cn).Name; } } } } rv[YZJsonProperty.children] = children; rv[YZJsonProperty.total] = rowcount; return(rv); }
public void ProcessRequest(HttpContext context) { YZAuthHelper.OAuth(); //YZAuthHelper.AshxAuthCheck(); string method = context.Request.Params["method"]; if (method == "GetUsers") { string keyword = context.Request.Params["keyword"]; keyword = string.IsNullOrEmpty(keyword) ? "ASDT" : keyword; //获得数据 UserCollection users = new UserCollection(); int rowcount; JsonItem rootItem = new JsonItem(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); users = OrgSvr.SearchUser(cn, keyword); List <User> usersLst = users.Where(s => s.NameSpace == "LDAP").ToList <User>(); //usersLst = users.Where(s => s.ExtAttributes["Supplayer"]=="SDT").ToList<User>(); //usersLst = users.Select(u => u.ExtAttributes["Supplayer"] == "").ToList<User>(); usersLst.Sort(new UserCompare()); rowcount = usersLst.Count; //将数据转化为Json集合 rootItem.Attributes.Add(JsonItem.TotalRows, rowcount); JsonItemCollection children = new JsonItemCollection(); rootItem.Attributes.Add("children", children); rootItem.Attributes.Add("total", rowcount); int i = 0; foreach (User user in usersLst) { i++; //if (i > 8) // break; if (user.Account == "sa") { continue; } JsonItem item = new JsonItem(); children.Add(item); item.Attributes.Add("Name", user.DisplayName); item.Attributes.Add("Account", user.Account); item.Attributes.Add("HRID", user.HRID); item.Attributes.Add("user", user.ShortName); item.Attributes.Add("group", YZPinYinHelper.GetShortPinyin(user.ShortName.Substring(0, 1)).ToUpper()); item.Attributes.Add("Mobile", user.Mobile); item.Attributes.Add("HomePhone", user.HomePhone); item.Attributes.Add("OfficePhone", user.OfficePhone); item.Attributes.Add("Mail", user.EMail); } } //输出数据 context.Response.Write(rootItem.ToString()); } else if (method == "GetUser") { string uid = context.Request.Params["uid"]; JsonItem rv = new JsonItem(); if (!String.IsNullOrEmpty(uid)) { using (BPMConnection cn = new BPMConnection()) { JsonItem data = new JsonItem(); rv.Attributes.Add("data", data); cn.WebOpen(); User user = User.FromAccount(cn, uid); data.Attributes["Account"] = user.Account; data.Attributes["HRID"] = user.HRID; data.Attributes["DisplayName"] = user.ShortName; data.Attributes["Mobile"] = user.Mobile; data.Attributes["OfficePhone"] = user.OfficePhone; data.Attributes["HomePhone"] = user.HomePhone; data.Attributes["EMail"] = user.EMail; data.Attributes["Office"] = user.Office; data.Attributes["Birthday"] = YZStringHelper.DateToString(user.Birthday); data.Attributes["DateHired"] = YZStringHelper.DateToString(user.DateHired); data.Attributes["Desc"] = user.Description; //获得所有主管 BPMObjectNameCollection depts = new BPMObjectNameCollection(); UserCollection supervisors = new UserCollection(); MemberCollection members = OrgSvr.GetUserPositions(cn, uid); foreach (Member member in members) { OU ou = member.GetParentOU(cn); String OULevel = ou.OULevel; String OUName = ou.Name; String FullName = member.GetParentOU(cn).FullName; String mFullName = member.FullName; String mDepartment = member.Department; if (!ou.IsRootOU) { OUName = mFullName.Split(new char[2] { '/', '/' })[2].GetShortName().ToString(); depts.Add(OUName); } if (String.IsNullOrEmpty(member.LeaderTitle)) { depts.Add(ou.Name); } else { depts.Add(ou.Name); } //depts.Add(String.Format("{0}({1})", ou.Name, member.LeaderTitle)); SupervisorCollection spvs = Member.GetSupervisors(cn, member.FullName); foreach (Supervisor spv in spvs) { User spvUser = User.TryGetUser(cn, spv.UserAccount); if (spvUser == null) { spvUser = new User(); spvUser.Account = spv.UserAccount; } spv.UserFullName = YZStringHelper.GetUserShortName(spvUser.Account, spvUser.DisplayName); if (!supervisors.Contains(spvUser.Account)) { supervisors.Add(spvUser); } } } JsonItemCollection jsonSupervisors = new JsonItemCollection(); data.Attributes["Supervisors"] = jsonSupervisors; foreach (User spv in supervisors) { JsonItem jsonSupervisor = new JsonItem(); jsonSupervisors.Add(jsonSupervisor); jsonSupervisor.Attributes["uid"] = spv.Account; jsonSupervisor.Attributes["ShortName"] = spv.ShortName; } data.Attributes["Dept"] = String.Join(" > ", depts.ToArray()); } } rv.Attributes.Add("success", true); context.Response.AppendHeader("Access-Control-Allow-Origin", "*"); // 响应类型 context.Response.AppendHeader("Access-Control-Allow-Methods", "POST"); // 响应头设置 context.Response.AppendHeader("Access-Control-Allow-Headers", "x-requested-with,content-type"); context.Response.Charset = "gb2312"; //设置字符集类型 context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312"); context.Response.ContentType = "application/json;charset=gb2312"; context.Response.Write(rv.ToString()); } }
public void ProcessRequest(HttpContext context) { try { YZAuthHelper.OAuth(); //YZAuthHelper.AshxAuthCheck(); string method = context.Request.Params["Method"]; JsonItem rv = new JsonItem(); if (YZStringHelper.EquName(method, "GET")) { string uid = YZAuthHelper.LoginUserAccount; using (BPMConnection cn = new BPMConnection()) { JsonItem data = new JsonItem(); rv.Attributes.Add("data", data); cn.WebOpen(); User user = User.FromAccount(cn, uid); UserInfoSelfMantSetting setting = new UserInfoSelfMantSetting(); setting.Load(cn); data.Attributes["Account"] = user.Account; data.Attributes["HRID"] = user.HRID; data.Attributes["DisplayName"] = user.DisplayName; data.Attributes["Mobile"] = user.Mobile; data.Attributes["OfficePhone"] = user.OfficePhone; data.Attributes["HomePhone"] = user.HomePhone; data.Attributes["EMail"] = user.EMail; data.Attributes["Office"] = user.Office; data.Attributes["Birthday"] = YZStringHelper.DateToString(user.Birthday); data.Attributes["DateHired"] = YZStringHelper.DateToString(user.DateHired); data.Attributes["editableFields"] = "DisplayName,HRID,Mobile,OfficePhone,HomePhone,EMail,Office,Birthday,DateHired"; //data.Attributes["editableFields"] = "Mobile,OfficePhone,HomePhone,EMail,Office"; //获得所有主管 BPMObjectNameCollection depts = new BPMObjectNameCollection(); BPMObjectNameCollection supervisors = new BPMObjectNameCollection(); MemberCollection members = OrgSvr.GetUserPositions(cn, uid); foreach (Member member in members) { OU ou = member.GetParentOU(cn); depts.Add(ou.Name); SupervisorCollection spvs = Member.GetSupervisors(cn, member.FullName); foreach (Supervisor spv in spvs) { if (!supervisors.Contains(spv.UserFriendlyName)) { supervisors.Add(spv.UserFriendlyName); } } } data.Attributes["Supervisor"] = String.Join(",", supervisors.ToArray()); data.Attributes["Dept"] = String.Join(",", depts.ToArray()); } } else if (YZStringHelper.EquName(method, "UPDATE")) { string uid = YZAuthHelper.LoginUserAccount; string fieldName = context.Request.Params["fieldName"]; string strValue = context.Request.Params["value"]; DateTime date; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); User user = User.FromAccount(cn, uid); switch (fieldName) { case "DisplayName": user.DisplayName = strValue; break; case "HRID": user.HRID = strValue; break; case "Mobile": user.Mobile = strValue; break; case "OfficePhone": user.OfficePhone = strValue; break; case "HomePhone": user.HomePhone = strValue; break; case "EMail": user.EMail = strValue; break; case "Office": user.Office = strValue; break; case "Birthday": if (DateTime.TryParse(strValue, out date)) { user.Birthday = date; } else { user.Birthday = DateTime.MinValue; } break; case "DateHired": if (DateTime.TryParse(strValue, out date)) { user.DateHired = date; } else { user.DateHired = DateTime.MinValue; } break; } User.Update(cn, uid, user); } } else { throw new Exception(String.Format(JosonStrings.Aspx_UnknowCommand, method)); } //System.Threading.Thread.Sleep(500); rv.Attributes.Add("success", true); context.Response.Write(rv.ToString()); } catch (Exception e) { JsonItem rv = new JsonItem(); rv.Attributes.Add("success", false); rv.Attributes.Add("errorMessage", e.Message); context.Response.Write(rv.ToString()); } context.Response.AppendHeader("Access-Control-Allow-Origin", "*"); // 响应类型 context.Response.AppendHeader("Access-Control-Allow-Methods", "POST"); // 响应头设置 context.Response.AppendHeader("Access-Control-Allow-Headers", "x-requested-with,content-type"); context.Response.Charset = "gb2312"; //设置字符集类型 context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312"); context.Response.ContentType = "application/json;charset=gb2312"; }