private bool NTLogin() { string account = this.Request.ServerVariables["LOGON_USER"]; bool b = YZAuthHelper.IsAuthenticated; string a = YZAuthHelper.LoginUserAccount; if (!String.IsNullOrEmpty(account)) { using (BPMConnection cn = new BPMConnection()) { cn.WebOpenAnonymous(); string regularAccount = null; if (BPM.Client.User.IsAccountExist(cn, account, ref regularAccount) && String.Compare(YZAuthHelper.BPMLogoutLastAccount, regularAccount, true) != 0) { YZAuthHelper.SetAuthCookie(regularAccount); YZAuthHelper.ClearLogoutFlag(); return(true); } else { YZAuthHelper.ClearLogoutFlag(); } } } return(false); }
public virtual JObject LoginTrial(HttpContext context) { YZRequest request = new YZRequest(context); bool isapp = request.GetBool("isapp"); string lang = request.GetString("lang", "zh-chs"); string cordova = request.GetString("cordova"); string model = request.GetString("model"); string name = request.GetString("name", model); string platform = request.GetString("platform"); string uuid = request.GetString("uuid"); string version = request.GetString("version"); string manufacturer = request.GetString("manufacturer"); bool isVirtual = request.GetBool("isVirtual", false); string serial = request.GetString("serial"); string uid = "99199"; string pwd = "1"; string realAccount = null; string token = null; if (!BPMConnection.Authenticate(YZAuthHelper.BPMServerName, YZAuthHelper.BPMServerPort, uid, pwd, out realAccount, out token)) { throw new Exception(Resources.YZStrings.Aspx_Login_Fail); } YZAuthHelper.SetAuthCookie(realAccount, token); YZAuthHelper.SetLangSession(YZCultureInfoParse.Parse(lang, YZCultureInfoParse.DefauleCultureInfo).LCID); YZAuthHelper.ClearLogoutFlag(); JObject rv = this.GenLoginResult(realAccount, true); return(rv); }
private bool SetAuth(string UserAccount) { if (YZAuthHelper.IsAuthenticated) { return(true); } if (!String.IsNullOrEmpty(UserAccount)) { using (BPMConnection cn = new BPMConnection()) { cn.WebOpenAnonymous(); string regularAccount = null; if (BPM.Client.User.IsAccountExist(cn, UserAccount, ref regularAccount)) { YZAuthHelper.SetAuthCookie(regularAccount); YZAuthHelper.ClearLogoutFlag(); return(true); } else { YZAuthHelper.ClearLogoutFlag(); } } } return(false); }
protected void Page_Load(object sender, EventArgs e) { userid = Request["uid"]; password = Request["PWD"]; JsonItem rv = new JsonItem(); string realAccount = null; try { if (BPMConnection.Authenticate(YZAuthHelper.BPMServerName, YZAuthHelper.BPMServerPort, userid, password, out realAccount)) { YZAuthHelper.SetAuthCookie(realAccount); YZAuthHelper.ClearLogoutFlag(); rv.Attributes["success"] = true; rv.Attributes["text"] = "登陆成功"; } } catch (Exception ex) { rv.Attributes["success"] = true; rv.Attributes["text"] = ex.Message; } }
public virtual void SetLanguage(HttpContext context) { YZRequest request = new YZRequest(context); int lcid = request.GetInt32("lcid"); YZAuthHelper.SetLangPersistent(lcid); }
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)); } }
protected override void AuthCheck(HttpContext context) { YZRequest request = new YZRequest(context); string method = request.GetString("Method", null); if (method != "GetSimulateInfo") { YZAuthHelper.AshxAuthCheck(); } }
public virtual JObject WeChatLogin(HttpContext context) { YZRequest request = new YZRequest(context); string lang = request.GetString("lang", "zh-chs"); string uid = YZAuthHelper.LoginUserAccount; JObject rv; YZAuthHelper.SetLangSession(YZCultureInfoParse.Parse(lang, YZCultureInfoParse.DefauleCultureInfo).LCID); rv = this.GenLoginResult(uid, false); return(rv); }
public virtual object Process(HttpContext context) { YZRequest request = new YZRequest(context); int stepid = request.GetInt32("StepID"); string uid = request.GetString("uid", YZAuthHelper.LoginUserAccount); //共享任务uid为空,会导致重定向到登录页面,产生异常 using (BPMConnection cn = new BPMConnection()) { string orguid = YZAuthHelper.LoginUserAccount; YZAuthHelper.SetAuthCookie(uid); try { cn.WebOpen(); } finally { YZAuthHelper.SetAuthCookie(orguid); } ProcessInfo processInfo = BPMProcess.GetProcessInfo(cn, stepid); if (processInfo.Links.Count == 0) { throw new BPMException(BPMExceptionType.MissOutLink, processInfo.NodeName); } string postXml = @"{0} <XForm> <Header> <Method>Process</Method> <PID>{1}</PID> <Action>{2}</Action> <Comment></Comment> </Header> <FormData> </FormData> </XForm>"; postXml = String.Format(postXml, "<?xml version=\"1.0\"?>", stepid, YZUtility.EncodeXMLInnerText(processInfo.Links[0].DisplayString)); using (MemoryStream postStream = new MemoryStream(Encoding.UTF8.GetBytes(postXml))) { PostResult postResult = BPMProcess.Post(cn, postStream); return(new { success = true, result = (postResult.PostResultType == PostResultType.TaskFinishedApproved || postResult.PostResultType == PostResultType.TaskFinishedRejected) ? "finished" : "running" }); } } }
protected override void AuthCheck(HttpContext context) { YZRequest request = new YZRequest(context); string method = request.GetString("method"); if (NameCompare.EquName(method, "GetString")) { return; } YZAuthHelper.AshxAuthCheck(); }
protected virtual JObject Serialize(BPMConnection cn, BPMProcStep step) { JObject jstep = TaskHandler.Serialize(cn, step); string loginUserAccount = YZAuthHelper.LoginUserAccount; if (step.IsHumanStep) { string account = String.IsNullOrEmpty(step.OwnerAccount) ? loginUserAccount:step.OwnerAccount; jstep["stk"] = YZAuthHelper.Acctout2FormAuthCookie(account); } return(jstep); }
public virtual void SetLanguage() { YZRequest request = new YZRequest(this.Context); int lcid = request.GetInt32("lcid"); YZAuthHelper.SetLangPersistent(lcid); this.Response.Clear(); JObject rv = new JObject(); rv["success"] = true; this.Response.Write(rv.ToString(Formatting.Indented, YZJsonHelper.Converters)); this.Response.End(); }
protected override void AuthCheck(HttpContext context) { YZRequest request = new YZRequest(context); string method = request.GetString("method"); if (NameCompare.EquName(method, "Login") || NameCompare.EquName(method, "LoginTrial") || NameCompare.EquName(method, "SendLoginValidationCode") || NameCompare.EquName(method, "GetPublicKey") || NameCompare.EquName(method, "DingTalkLogin")) { return; } YZAuthHelper.AshxAuthCheck(); }
public void logout() { try { YZAuthHelper.SignOut(); } catch (Exception) { //捕获 FormsAuthentication.SignOut()中的重定向 } finally { YZAuthHelper.SetLogoutFlag("logout", String.Empty); YZUrlBuilder url = YZUrlBuilder.FromPath(FormsAuthentication.LoginUrl); url.QueryString["ReturnUrl"] = this.ReturnUrl; this.Response.Redirect("~/admin/login/2018/Default.aspx", true); } }
protected void Page_Load(object sender, EventArgs e) { Session["Token"] = null; this.ClearCookies(); YZAuthHelper.SignOut(); YZAuthHelper.SetLogoutFlag("logout", String.Empty); string ssoUrl = System.Configuration.ConfigurationManager.AppSettings["ssoUrl"]; string LogOutRedirect = System.Configuration.ConfigurationManager.AppSettings["LogOutRedirect"]; if (String.IsNullOrEmpty(ssoUrl)) { //ssoUrl = "~/YZSoft/Login/"; ssoUrl = LogOutRedirect; } this.Response.Redirect(ssoUrl, true); }
private void SSOAuthLogin(OAuthToken TokenInfo) { #region string //string UID = System.Web.HttpContext.Current.Request.Params["UID"]; //string Pwd = System.Web.HttpContext.Current.Request.Params["Pwd"]; //string DesUrl = System.Web.HttpContext.Current.Request.Params["ReturnURL"]; //string Redirect = "http://www.e.com/HandlerSSO.aspx?UID={0}&Pwd={1}&ReturnURL={2}"; #endregion string UID = TokenInfo.AccountID; string Pwd = TokenInfo.PassWords; string DesUrl = TokenInfo.ReturnURL; string Redirect = String.IsNullOrEmpty(TokenInfo.RedirectURL) ? ConfigHelper.GetConfig("TokenCorrectRedirectURL") : TokenInfo.RedirectURL; if (!string.IsNullOrEmpty(UID)) { string realAccount = null; if (BPMConnection.Authenticate(YZAuthHelper.BPMServerName, YZAuthHelper.BPMServerPort, UID, Pwd, out realAccount)) { YZAuthHelper.SetAuthCookie(realAccount); YZAuthHelper.ClearLogoutFlag(); if (!String.IsNullOrEmpty(DesUrl)) { Response.Redirect(DesUrl); } else { Response.Redirect(Redirect.WithFormat(UID, Pwd, DesUrl)); } } else { Response.Write("BPM验证失败"); } } else { Response.Write("单点登录系统里UID为空"); } }
public Result UpdateUser(AuthInfo authInfo, UserInfo userInfo, string updateFieldName) { try { YZService.AuthSystem(authInfo); YZAuthHelper.SetAuthCookie(authInfo.RealLoginAccount); //传入值检查 if (String.Compare(updateFieldName, "Password") == 0) { throw new Exception(String.Format("属性不支持以更新方式修改:{0}", updateFieldName)); } using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); //获得用户原始信息 User user = new User(); user.Open(cn, userInfo.Account); //粘合新属性 PropertyInfo tagProp = typeof(User).GetProperty(updateFieldName); FieldInfo srcProp = typeof(UserInfo).GetField(updateFieldName); if (tagProp == null || srcProp == null) { throw new Exception(String.Format("无效的属性:{0}", updateFieldName)); } tagProp.SetValue(user, srcProp.GetValue(userInfo), null); //执行更新 BPM.Client.User.Update(cn, user.Account, user); } return(Result.SuccessResult); } catch (Exception e) { return(Result.FromException(e)); } }
public Result AddUser(AuthInfo authInfo, UserInfo userInfo) { try { YZService.AuthSystem(authInfo); YZAuthHelper.SetAuthCookie(authInfo.RealLoginAccount); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); OU.AddMember(cn, YZService.LDAPOU2BPMOUPath(userInfo.LDAPOU), null, userInfo.Member, userInfo.User, null, null, null); } return(Result.SuccessResult); } catch (Exception e) { return(Result.FromException(e)); } }
private void SSO() { //try //{ string UID = System.Web.HttpContext.Current.Request.Params["UID"]; string Pwd = System.Web.HttpContext.Current.Request.Params["Pwd"]; string DesUrl = System.Web.HttpContext.Current.Request.Params["ReturnURL"]; if (!string.IsNullOrEmpty(UID)) { string realAccount = null; if (BPMConnection.Authenticate(YZAuthHelper.BPMServerName, YZAuthHelper.BPMServerPort, UID, Pwd, out realAccount)) { YZAuthHelper.SetAuthCookie(realAccount); YZAuthHelper.ClearLogoutFlag(); if (!String.IsNullOrEmpty(DesUrl)) { Response.Redirect(DesUrl); } else { Response.Redirect("http://localhost/bpm"); } } else { Response.Write("BPM验证失败"); } } else { Response.Write("单点登录系统里uid为空"); } //} //catch (Exception) //{ //} }
public virtual JObject DingTalkLogin(HttpContext context) { YZRequest request = new YZRequest(context); string code = request.GetString("code"); string corpId = request.GetString("corpId"); string appSecret = request.GetString("appSecret"); string lang = request.GetString("lang", "zh-chs"); string accesstoken = DingTalkManager.Instance.GetAccessToken(corpId, appSecret); string uid = DingTalkManager.Instance.TryGetUserIdFromCode(accesstoken, code); string regularAccount = null; string linsql = ""; using (IYZAppAdminProvider applogin = IYZAppAdminProviderManager.DefaultProvider) { YZAppAdmin.LoginModule lm = applogin.LoadLogin(); linsql = lm.DdLinkSql; } if (!string.IsNullOrEmpty(linsql)) { string sql = string.Format(linsql, uid); uid = Convert.ToString(DBUtil_APP.GetSingle(sql)); } using (BPMConnection cn = new BPMConnection()) { cn.WebOpenAnonymous(); if (!User.IsAccountExist(cn, uid, ref regularAccount)) { throw new Exception(String.Format("当前钉钉登录用户{0},不是有效的BPM账号!", uid)); } YZAuthHelper.SetAuthCookie(regularAccount); } YZAuthHelper.SetLangSession(YZCultureInfoParse.Parse(lang, YZCultureInfoParse.DefauleCultureInfo).LCID); JObject rv = this.GenLoginResult(regularAccount, false); return(rv); }
protected void Page_Load(object sender, EventArgs e) { OAuthURL = Net.Common.ConfigHelper.GetConfig("OAuthURL"); GetToken = Net.Common.ConfigHelper.GetConfig("GetToken"); TokenService = Net.Common.ConfigHelper.GetConfig("TokenService"); YZAuthHelper.SignOut(); YZAuthHelper.SetLogoutFlag("logout", String.Empty); this.ClearCookies(); this.ClearSSOToken(); string AccountLogin = System.Configuration.ConfigurationManager.AppSettings["AccountLogin"]; string ssoUrl = System.Configuration.ConfigurationManager.AppSettings["ssoUrl"]; if (String.IsNullOrEmpty(ssoUrl)) { //ssoUrl = "~/YZSoft/Login/"; ssoUrl = AccountLogin; } this.Response.Redirect(ssoUrl, true); }
public void ProcessRequest(HttpContext context) { YZAuthHelper.OAuth(); //YZAuthHelper.AshxAuthCheck(); GridPageInfo gridPageInfo = new GridPageInfo(context); IDBProvider dbProvider = YZDBProviderManager.CurrentProvider; int year; if (context.Request.Params["byYear"] == "0") { year = -1; } else { string strYear = context.Request.Params["Year"]; year = String.IsNullOrEmpty(strYear) ? DateTime.Today.Year : Convert.ToInt32(strYear); } //获得数据 BPMTaskCollection tasks = new BPMTaskCollection(); int rowcount; JsonItem rootItem = new JsonItem(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); tasks = cn.GetHistoryTasks(year, HistoryTaskType.AllAccessable, dbProvider.FilterStringHistoryTaskTaskTableFilter, dbProvider.FilterStringHistoryTaskStepTableFilter, null, gridPageInfo.Start, gridPageInfo.Limit, out rowcount); //将数据转化为Json集合 rootItem.Attributes.Add(JsonItem.TotalRows, rowcount); JsonItemCollection children = new JsonItemCollection(); rootItem.Attributes.Add("children", children); rootItem.Attributes.Add("total", rowcount); foreach (BPMTask task in tasks) { JsonItem item = new JsonItem(); children.Add(item); item.Attributes.Add("tid", task.TaskID); item.Attributes.Add("pid", task.ParentStepID); item.Attributes.Add("sn", task.SerialNum); item.Attributes.Add("pn", task.ProcessName); item.Attributes.Add("user", YZStringHelper.GetUserShortName(task.OwnerAccount, task.OwnerDisplayName)); item.Attributes.Add("state", task.TaskState.ToString()); item.Attributes.Add("stateText", YZStringHelper.GetTaskStateDisplayName(task.TaskState)); item.Attributes.Add("stateProcessing", YZStringHelper.GetTaskProcessingStatus(cn, task.TaskState, task.TaskID)); item.Attributes.Add("date", YZStringHelper.DateToStringL(task.CreateAt)); task.Description = task.ShowDescByProcessName(true); item.Attributes.Add("desc", String.IsNullOrEmpty(task.Description) ? "无内容摘要" : task.Description); } } //System.Threading.Thread.Sleep(500); 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(rootItem.ToString()); }
protected virtual void AuthCheck(HttpContext context) { YZAuthHelper.AshxAuthCheck(); }
public virtual void ProcessRequest(HttpContext context) { YZAuthHelper.AshxAuthCheck(); YZRequest request = new YZRequest(context); context.Response.AppendHeader("Access-Control-Allow-Origin", "*"); try { string method = request.GetString("Method"); if (!YZNameChecker.IsValidMethodName(method)) { throw new Exception("Invalid method name"); } Type type = this.GetType(); System.Reflection.MethodInfo methodcall = type.GetMethod(method, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public, null, new Type[] { typeof(HttpContext) }, null); if (methodcall == null) { throw new Exception(String.Format(Resources.YZStrings.Aspx_UnknowCommand, method)); } object rv; try { rv = methodcall.Invoke(this, new object[] { context }); } catch (Exception exp) { throw exp.InnerException; } if (rv is JsonItem || rv is JsonItemCollection) { throw new Exception("JsonItem/JsonItemCollection is Obsoleted, please replace with JObject/JArray"); } JToken jToken; if (rv == null) { jToken = new JObject(); } else if (rv is JToken) { jToken = rv as JToken; } else { if (rv is string) { jToken = JValue.FromObject(rv); } else if (rv is IEnumerable) { jToken = JArray.FromObject(rv); } else { jToken = JValue.FromObject(rv); } } jToken["code"] = 0; if (context.Request.Params["DateFormat"] == "text") { context.Response.Write(jToken.ToString(Formatting.Indented)); } else { context.Response.Write(jToken.ToString(Formatting.Indented, request.Converters)); } } catch (Exception e) { JObject rv = new JObject(); rv["code"] = -1; rv["msg"] = HttpUtility.HtmlEncode(e.Message); context.Response.Write(rv.ToString(Formatting.Indented, request.Converters)); } }
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()); } }
public void ProcessRequest(HttpContext context) { JsonItem rv = new JsonItem(); string userid = context.Request.Params["uid"]; string password = context.Request.Params["pwd"]; string isWeixIn = context.Request.Params["isWeixIn"]; LoginUser loginUers = new LoginUser(); String NetWork = String.IsNullOrEmpty(context.Request.Params["NetWork"]) ? "" : context.Request.Params["NetWork"], Phone = String.IsNullOrEmpty(context.Request.Params["DevicePlatform"]) ? "" : context.Request.Params["DevicePlatform"], DeviceName = String.IsNullOrEmpty(context.Request.Params["DeviceName"]) ? "" : context.Request.Params["DeviceName"], UUID = String.IsNullOrEmpty(context.Request.Params["UUID"]) ? "" : context.Request.Params["UUID"], Versions = String.IsNullOrEmpty(context.Request.Params["Version"]) ? "Web客户端" : context.Request.Params["Version"], strErrorMsg = String.Empty; try { if (String.IsNullOrEmpty(userid) /*|| String.IsNullOrEmpty(password)*/) { if (String.IsNullOrWhiteSpace(isWeixIn)) { throw new Exception(JosonStrings.Aspx_Login_EnterAccountTip); } else { throw new Exception("请关注微信服务号【创维数字移动办公】后,绑定你的域账号!"); } } string realAccount = null; if (!String.IsNullOrEmpty(isWeixIn)) { var isDegug = Convert.ToString(context.Request.Params["isDebug"]).ToLower().Equals("true"); if (context.Request.UserAgent.ToLower().Contains("micromessenger")) { realAccount = userid; Versions = "微信客户端"; } else { if (!isDegug) { rv.Attributes["success"] = false; rv.Attributes["errorMessage"] = "试图非法登录!本次已经记录该操作!客户端仅提供微信绑定域用户使用" + DeviceName + Phone + NetWork; context.Response.Write(rv.ToString()); } else { realAccount = userid; Versions = "微信客户端"; } } } else { if (!BPMConnection.Authenticate(YZAuthHelper.BPMServerName, YZAuthHelper.BPMServerPort, userid, password, out realAccount)) { throw new Exception(JosonStrings.Aspx_Login_Fail); } } if (realAccount != null) { YZAuthHelper.SetAuthCookie(realAccount); YZAuthHelper.ClearLogoutFlag(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); User user = User.FromAccount(cn, realAccount); loginUers = cn.getLoginUser(userid, password, "LogIn", "logInOK", NetWork, Phone, UUID, DeviceName, Versions); JsonItem juser = new JsonItem(); rv.Attributes["user"] = juser; juser.Attributes["Account"] = user.Account; string andriodPushService = WebConfigurationManager.AppSettings["AndroidPushService"]; juser.Attributes["AndroidPushService"] = String.IsNullOrEmpty(andriodPushService) ? "JPush" : andriodPushService; juser.Attributes["HRID"] = user.HRID; juser.Attributes["DisplayName"] = user.DisplayName; juser.Attributes["ShortName"] = YZStringHelper.GetUserShortName(user.Account, user.DisplayName); juser.Attributes["LongName"] = YZStringHelper.GetUserFriendlyName(user.Account, user.DisplayName); DateTime today = DateTime.Today; juser.Attributes["LoginDate"] = String.Format("{0}年{1}月{2}日", today.Year, today.Month, today.Day); juser.Attributes["NetWork"] = NetWork; juser.Attributes["Phone"] = Phone; juser.Attributes["UUID"] = UUID; juser.Attributes["DeviceName"] = DeviceName; } new SqlServerProvider(context).InsertLogInInfo(loginUers); //System.Threading.Thread.Sleep(500); rv.Attributes["success"] = true; context.Response.Write(rv.ToString()); } } catch (Exception exp) { YZEventLog log = new YZEventLog(); log.WriteEntry(exp); loginUers.ErrorMsg = exp.Message; rv.Attributes["success"] = false; rv.Attributes["errorMessage"] = exp.Message; context.Response.Write(rv.ToString()); } }
public void ProcessRequest(HttpContext context) { try { 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.ContentType = "text/json"; string account = context.Request.Params["UserAccount"]; string token = context.Request.Params["Token"]; string thumbnail = context.Request.Params["thumbnail"]; YZAuthHelper.OAuth(); //YZAuthHelper.AshxAuthCheck(); //if (!YZAuthHelper.IsAuthenticated) //{ // JsonItem rv = new JsonItem(); // rv.Attributes["success"] = false; // rv.Attributes["errorMessage"] = JosonStrings.Aspx_Upload_NoAuth; // context.Response.Write(rv.ToString()); // return; //} HttpFileCollection files = context.Request.Files; if (files.Count > 0 && files[0].ContentLength > 0) { HttpPostedFile file = files[0]; string fileName = System.IO.Path.GetFileName(file.FileName); long fileSize = file.ContentLength; string fileExt = System.IO.Path.GetExtension(fileName).ToLower(); string fileId; string savePath; do { fileId = YZAttachmentHelper.GetNewFileID(); savePath = Attachment.FileIDToPath(fileId, YZAttachmentHelper.AttachmentRootPath); } while (File.Exists(savePath)); Directory.CreateDirectory(savePath.Substring(0, savePath.LastIndexOf(@"\"))); file.SaveAs(savePath); if (!String.IsNullOrEmpty(thumbnail) && !YZStringHelper.EquName(thumbnail, "n")) { this.MakeThumbnail(savePath, "S"); this.MakeThumbnail(savePath, "M"); } Attachment attachment = new Attachment(); attachment.FileID = fileId; attachment.Name = fileName; attachment.Ext = fileExt; attachment.Size = fileSize; attachment.LastUpdate = DateTime.Now; attachment.OwnerAccount = YZAuthHelper.LoginUserAccount; using (IDbConnection cn = YZDBProviderManager.CurrentProvider.OpenConnection()) { YZDBProviderManager.CurrentProvider.InsertAttachmentInfo(cn, attachment); } JsonItem rv = new JsonItem(); rv.Attributes["success"] = true; rv.Attributes["fileid"] = fileId; rv.Attributes["Name"] = fileName; rv.Attributes["Ext"] = fileExt; rv.Attributes["Size"] = fileSize; rv.Attributes["OwnerAccount"] = attachment.OwnerAccount; rv.Attributes["LastUpdate"] = YZStringHelper.DateToStringL(attachment.LastUpdate); context.Response.Write(rv.ToString()); } else { JsonItem rv = new JsonItem(); rv.Attributes["success"] = false; rv.Attributes["errorMessage"] = JosonStrings.Aspx_Invalid_File; context.Response.Write(rv.ToString()); } } catch (Exception exp) { JsonItem rv = new JsonItem(); rv.Attributes["success"] = false; rv.Attributes["errorMessage"] = exp.Message /* + exp.StackTrace*/; context.Response.Write(rv.ToString()); } }
public void ProcessRequest(HttpContext context) { YZAuthHelper.OAuth(); //YZAuthHelper.AshxAuthCheck(); try { UIStrings rs = new UIStrings(); int taskid = Int32.Parse(context.Request.Params["tid"]); JsonItem rv = new JsonItem(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); BPMStepCollection steps = BPMTask.GetAllSteps(cn, taskid); BPMTask task = BPMTask.Load(cn, taskid); rv.Attributes.Add("sn", task.SerialNum); rv.Attributes.Add("pn", task.ProcessName); //将数据转化为Json集合 JsonItemCollection children = new JsonItemCollection(); rv.Attributes.Add("children", children); foreach (BPMProcStep step in steps) { //不是有效的步骤 if (!step.IsHumanStep) { continue; } //跳过 - 无处理人的非共享任务 if (String.IsNullOrEmpty(step.OwnerAccount) && !step.Share) { continue; } JsonItem item = new JsonItem(); children.Add(item); item.Attributes.Add("StepDisplayName", step.StepDisplayName); string recpAccount; string recpDisplayName; if (step.Finished) { recpAccount = step.HandlerAccount; recpDisplayName = YZStringHelper.GetUserShortName(step.HandlerAccount, step.HandlerFullName); } else { recpAccount = step.RecipientAccount; recpDisplayName = YZStringHelper.GetUserShortName(step.RecipientAccount, step.RecipientFullName); } if (!step.IsConsignStep && recpAccount != step.OwnerAccount) { recpDisplayName = String.Format(rs["XFormDesigner.XSignTrace.OwnerFmt"], recpDisplayName, YZStringHelper.GetUserShortName(step.OwnerAccount, step.OwnerDisplayName)); } item.Attributes.Add("Recipient", recpDisplayName); item.Attributes.Add("OwnerAccount", step.OwnerAccount); item.Attributes.Add("OwnerFullName", step.OwnerFullName); item.Attributes.Add("OwnerDisplayName", step.OwnerDisplayName); item.Attributes.Add("Finished", step.Finished); item.Attributes.Add("FinishAt", YZStringHelper.DateToStringM(step.FinishAt, "")); item.Attributes.Add("ReceiveAt", YZStringHelper.DateToStringM(step.ReceiveAt, "")); item.Attributes.Add("SelActionDisplayString", step.SelActionDisplayString); item.Attributes.Add("Comments", HttpUtility.HtmlEncode(step.Comments)); } } //System.Threading.Thread.Sleep(500); //输出数据 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"; }
public void ProcessRequest(HttpContext context) { try { YZAuthHelper.OAuth(); //YZAuthHelper.AshxAuthCheck(); string loginUid = YZAuthHelper.LoginUserAccount; IDBProvider dbProvider = YZDBProviderManager.CurrentProvider; string method = context.Request.Params["method"]; JsonItem rv = new JsonItem(); // System.Threading.Thread.Sleep(2000); if (method == "Send") { //http://oauth.skyworthdigital.com/WebService/Iservice/Communication.ashx?UserAccount=SDT12872&restype=1&message=添加一条哦啊讨论啊&resId=216928&method=Send YZResourceType resType = (YZResourceType)Enum.Parse(typeof(YZResourceType), context.Request.Params["resType"], true); string resId = context.Request.Params["resId"]; string msg = context.Request.Params["message"]; if (!string.IsNullOrEmpty(msg.Trim())) { using (IDbConnection cn = dbProvider.OpenConnection()) { YZMessage message = new YZMessage(loginUid, DateTime.Now, resType, resId, msg); message.Insert(cn); YZCommunicationManager.UpdateReaded(cn, loginUid, resType, resId, message.id); JsonItem result = new JsonItem(); rv.Attributes.Add("message", result); message.Serialize(result); } } } else if (method == "GetTaskCommunicationList") { GridPageInfo gridPageInfo = new GridPageInfo(context); SecurityToken token = null; using (BPMConnection bpmcn = new BPMConnection()) { bpmcn.WebOpen(); token = bpmcn.Token; } using (IDbConnection cn = dbProvider.OpenConnection()) { //http://oauth.skyworthdigital.com/WebService/Iservice/Communication.ashx?UserAccount=SDT12872&method=GetTaskCommunicationList&SearchType=QuickSearch&Keyword=216928 //http://oauth.skyworthdigital.com/WebService/Iservice/Communication.ashx?UserAccount=SDT12872&method=GetTaskCommunicationList&SearchType=QuickSearch&Keyword=REQ2014090001 using (BPMConnection bpmcn = new BPMConnection()) { bpmcn.WebOpen(); IDbCommand cmd = dbProvider.GetTaskCommunicationListCommand(cn, loginUid, token.SIDs, dbProvider.FilterStringCommunicationListTaskTableFilter, dbProvider.FilterStringCommunicationMessageTableFilter, gridPageInfo.Start, gridPageInfo.Limit); cmd.Connection = cn; JsonItemCollection children = new JsonItemCollection(); rv.Attributes.Add("children", children); using (YZReader reader = new YZReader(cmd.ExecuteReader())) { while (reader.Read()) { JsonItem item = new JsonItem(); children.Add(item); string ownerAccount = reader.ReadString("OwnerAccount"); User owner = User.TryGetUser(bpmcn, ownerAccount); string ownerDisplayName = owner != null ? owner.DisplayName : ownerAccount; string lastMsgUid = reader.ReadString("uid"); User lastMsgUser = User.TryGetUser(bpmcn, lastMsgUid); string lastMessageUserShortName = lastMsgUser != null ? lastMsgUser.ShortName : lastMsgUid; TaskState state = (TaskState)reader.ReadEnum("State", typeof(TaskState), TaskState.Unknow); int taskid = reader.ReadInt32("TaskID"); item.Attributes["tid"] = taskid; item.Attributes["sn"] = reader.ReadString("SerialNum"); item.Attributes["pn"] = reader.ReadString("ProcessName"); item.Attributes["user"] = YZStringHelper.GetUserShortName(ownerAccount, ownerDisplayName); item.Attributes["state"] = state.ToString(); item.Attributes["stateText"] = YZStringHelper.GetTaskStateDisplayString(bpmcn, state, taskid); item.Attributes["date"] = YZStringHelper.DateToStringL(reader.ReadDateTime("CreateAt")); string desc = Convert.ToString(reader.ReadString("Description")); item.Attributes["desc"] = String.IsNullOrEmpty(desc) ? "无内容摘要" : desc.CutStrHTML(isHTML: true); item.Attributes["count"] = reader.ReadInt32("count"); item.Attributes["total"] = reader.ReadInt32("total"); item.Attributes["Id"] = reader.ReadInt32("Id"); item.Attributes["lastMessageId"] = reader.ReadInt32("lastMsgId"); item.Attributes["lastMessageUid"] = lastMsgUid; item.Attributes["lastMessageUserShortName"] = lastMessageUserShortName; item.Attributes["lastMessageDate"] = YZStringHelper.DateToStringL(reader.ReadDateTime("date")); item.Attributes["lastMessage"] = reader.ReadString("message"); } } } rv.Attributes["newMessageCount"] = dbProvider.GetTaskCommunicationNewMessageCount(cn, loginUid, token.SIDs); } } else if (method == "GetBadge") { YZResourceType resType = (YZResourceType)Enum.Parse(typeof(YZResourceType), context.Request.Params["resType"], true); string resId = context.Request.Params["resId"]; using (IDbConnection cn = dbProvider.OpenConnection()) { rv.Attributes["total"] = YZCommunicationManager.GetMessageCount(cn, resType, resId); rv.Attributes["newMessageCount"] = YZCommunicationManager.GetNewMessageCount(cn, loginUid, resType, resId); } } else if (method == "UpdateReaded") { YZResourceType resType = (YZResourceType)Enum.Parse(typeof(YZResourceType), context.Request.Params["resType"], true); string resId = context.Request.Params["resId"]; string strLastId = context.Request.Params["lastid"]; if (String.IsNullOrEmpty(strLastId)) { strLastId = "-1"; } int lastId = Convert.ToInt32(strLastId); using (IDbConnection cn = dbProvider.OpenConnection()) { YZCommunicationManager.UpdateReaded(cn, loginUid, resType, resId, lastId); } } else { //http://bpm.sdt.com/YZSoft/Forms/XForm/%E5%B7%A5%E4%BD%9C%E6%8A%A5%E5%91%8A/%E5%B7%A5%E4%BD%9C%E6%8A%A5%E5%91%8A.aspx?tid=216928 //http://oauth.skyworthdigital.com/WebService/Iservice/Communication.ashx?UserAccount=SDT12872&restype=1&lastid=306&resId=216928 YZResourceType resType = (YZResourceType)Enum.Parse(typeof(YZResourceType), context.Request.Params["resType"], true); string resId = context.Request.Params["resId"]; string strLastId = context.Request.Params["lastid"]; if (String.IsNullOrEmpty(strLastId)) { strLastId = "-1"; } int lastId = Convert.ToInt32(strLastId); //获得数据 JsonItemCollection children = new JsonItemCollection(); rv.Attributes.Add("children", children); using (BPMConnection bpmcn = new BPMConnection()) { bpmcn.WebOpen(); using (IDbConnection cn = dbProvider.OpenConnection()) { YZMessageCollection messages = YZCommunicationManager.GetNewMessages(cn, resType, resId, lastId); messages.Serialize(bpmcn, children); } } } //输出数据 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"; //输出数据 rv.Attributes.Add("success", true); context.Response.Write(rv.ToString()); } catch (Exception e) { JsonItem rv = new JsonItem(); 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"; rv.Attributes.Add("success", false); rv.Attributes.Add("errorMessage", e.Message); context.Response.Write(rv.ToString()); } }
public virtual object Start(HttpContext context) { YZRequest request = new YZRequest(context); Guid draftid = request.GetGuid("draftid", false); string memberfullname = request.GetString("memberfullname"); string uid = request.GetString("uid"); using (BPMConnection cn = new BPMConnection()) { string orguid = YZAuthHelper.LoginUserAccount; YZAuthHelper.SetAuthCookie(uid); try { cn.WebOpen(); } finally { YZAuthHelper.SetAuthCookie(orguid); } BPMDraft draft = new BPMDraft(); draft.Open(cn, draftid); JObject jDraftHeader = null; if (!String.IsNullOrEmpty(draft.Header)) { jDraftHeader = JObject.Parse(draft.Header); } PostInfo postInfo = BPMProcess.GetPostInfo(cn, draft.ProcessName, null, memberfullname, -1); if (postInfo.Links.Count == 0) { throw new BPMException(BPMExceptionType.MissOutLink, postInfo.NodeName); } string postXml = @"{0} <XForm> <Header> <Method>Post</Method> <ProcessName>{1}</ProcessName> <OwnerMemberFullName>{2}</OwnerMemberFullName> <Action>{3}</Action> <Comment>{4}</Comment> {5} </Header> {6} </XForm>"; StringBuilder sb = new StringBuilder(); if (jDraftHeader != null) { foreach (KeyValuePair <string, JToken> jProp in jDraftHeader) { string line = String.Format("<{0}>{1}</{0}>", jProp.Key, YZUtility.EncodeXMLInnerText(jProp.Value.ToString())); sb.AppendLine(line); } } postXml = String.Format(postXml, "<?xml version=\"1.0\"?>", YZUtility.EncodeXMLInnerText(draft.ProcessName), YZUtility.EncodeXMLInnerText(memberfullname), YZUtility.EncodeXMLInnerText(postInfo.Links[0].DisplayString), YZUtility.EncodeXMLInnerText(draft.Comments), sb.ToString(), draft.xml); using (MemoryStream postStream = new MemoryStream(Encoding.UTF8.GetBytes(postXml))) { PostResult postResult = BPMProcess.Post(cn, postStream); return(new { success = true, TaskID = postResult.TaskID, SN = postResult.SN }); } } }