public static DateTime StringToDate(string date, string time) { if (String.IsNullOrEmpty(time)) { time = "00:00"; } DateTime rv = YZStringHelper.StringToDate(date); rv = DateTime.Parse(YZStringHelper.DateToString(rv) + " " + time, YZStringHelper.datetimeCultureInfo); return(rv); }
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) { 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); //UserCommonInfo userCommonInfo = UserCommonInfo.FromAccount(cn, uid); data.Attributes["AppSN"] = currentUser.AppSN; data.Attributes["AppCompany"] = currentUser.AppCompany; data.Attributes["AppDept"] = currentUser.AppDept; data.Attributes["AppDate"] = currentUser.SubmitDateTime; data.Attributes["AppHRName"] = currentUser.ShortName; data.Attributes["AppHRID"] = currentUser.AppHRID; 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")) { #region 接收数据 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 EmpID = Convert.ToString(context.Request.Params["AppHRID"]); string EmpName = Convert.ToString(context.Request.Params["AppHRName"]); 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 strVehicle = Convert.ToString(context.Request.Params["Vehicle"]); String OtherVehicle = Convert.ToString(context.Request.Params["OtherVehicle"]); 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"]); #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 , Address , FromDate , ToDate , DayInt , HourInt , reasonWhyNote + suggestionMsg , 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()); } }