public static void AshxAuthCheck(bool checkLogin) { if (String.Compare(System.Web.Configuration.WebConfigurationManager.AppSettings["ShowMaintenancePage"], "true", true) == 0) { HttpContext.Current.Response.StatusCode = 500; JsonItem rv = new JsonItem(); rv.Attributes.Add("success", false); rv.Attributes.Add("errorCode", 100); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(rv.ToString()); HttpContext.Current.Response.End(); } else if (checkLogin && !YZAuthHelper.IsAuthenticated) { HttpContext.Current.Response.StatusCode = 200; JsonItem rv = new JsonItem(); rv.Attributes.Add("success", false); rv.Attributes.Add("errorCode", 101); rv.Attributes.Add("errorMessage", Resources.YZStrings.Aspx_LoginTimeout); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(rv.ToString()); HttpContext.Current.Response.End(); } }
public static void AshxAuthCheck(bool checkLogin) { if (String.Compare(System.Web.Configuration.WebConfigurationManager.AppSettings["ShowMaintenancePage"], "true", true) == 0) { HttpContext.Current.Response.StatusCode = 500; JsonItem rv = new JsonItem(); rv.Attributes.Add("success", false); rv.Attributes.Add("errorCode", 100); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(rv.ToString()); HttpContext.Current.Response.End(); } else if (checkLogin && !YZAuthHelper.IsAuthenticated) { HttpContext.Current.Response.StatusCode = 200; JsonItem rv = new JsonItem(); rv.Attributes.Add("success", false); rv.Attributes.Add("errorCode", 101); rv.Attributes.Add("errorMessage", "登录超时"); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(rv.ToString()); HttpContext.Current.Response.End(); } }
private void JsonTest() { //Proje içerisinde dâhili json ayrıştırıcı içerir, property isimleri için tırnak kullanımı şart koşulmaz //Ek olarak tek satırlı ve çok satırlı yorumları destekler, doğrudan bir sınıfa atanabilir/sınıftan jsona çevirilebilir. //ExplicitOpetör sayesinde doğrudan string ataması yapılabilir. //veya JsonItem item = JsonDecoder.Decode("{item1: 'değer', 'item2': 'değer'}"); JsonItem item = "{item1: 'değer', 'item2': 'değer'}"; Dictionary <string, object> keys = new Dictionary <string, object>(); //Listeye sonradan bir veriyi JSON formatında ekledik. item.AddSubItem("{item3: 'değer', item4: 'değer'}"); //Verilen nesnenin tipine göre içerisine aktarma yapar. item.ExportTo(ref keys); //Ayrıca dinamik olarakta aşağıdaki şekilde kullanılabilir. dynamic jitem = new JsonItem(); jitem.Item1 = "değer1"; jitem.Item2 = "değer2"; jitem.Item3 = "değer3"; jitem.Item4 = new JsonItem() { }; jitem.Item4.Item1 = "değer2"; string result = jitem.ToString(); JsonItem sinifaAtanacak = "{name: 'macmillan', group: 'AR-GE', Value: 12345, Excluded: 'Bu değer atanmayacak'}"; JsonTestClass testclass = new JsonTestClass(); sinifaAtanacak.ExportTo(ref testclass); //Aynı sınıfı aşağıdaki şekilde JSON a çevirebilirsiniz. JsonItem jsitem = JsonDecoder.DecodeFrom(testclass); string jsonmetni = jsitem.ToString(); //Veya jsitem.ToJson(); }
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(); 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 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()); } }
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); }
public void ProcessRequest(HttpContext context) { try { string idstr = context.Request.Params["fileids"]; JsonItem rv = new JsonItem(); rv.Attributes.Add("success", true); JsonItemCollection files = new JsonItemCollection(); rv.Attributes["files"] = files; if (String.IsNullOrEmpty(idstr)) { context.Response.Write(rv.ToString()); return; } string[] ids = idstr.Split(',', ';'); AttachmentCollection attachments; using (IDbConnection cn = QueryManager.CurrentProvider.OpenConnection()) { attachments = YZAttachmentHelper.GetAttachmentsInfo(cn, ids); } foreach (Attachment attachment in attachments) { JsonItem file = new JsonItem(); files.Add(file); file.Attributes["attachment"] = attachment.FileID; file.Attributes["name"] = attachment.Name; file.Attributes["type"] = attachment.Ext; file.Attributes["size"] = attachment.Size; string requestUrl = HttpContext.Current.Request.Url.ToString(); string RedirectURLBase = requestUrl.Substring(0, requestUrl.IndexOf("Attachment", StringComparison.OrdinalIgnoreCase)) + "Attachment/download.ashx?FileID=" + attachment.FileID; file.Attributes["DownloadUrl"] = RedirectURLBase; } 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"; // if (attachments.Count > 0) context.Response.Write(rv.ToString()); } catch (Exception ex) { JsonItem rv = new JsonItem(); rv.Attributes.Add("success", false); rv.Attributes.Add("errorMessage", JosonMobile.Msg_ALL_FileNoExist + ex.Message); context.Response.Write(rv.ToString()); } }
public void ProcessRequest(HttpContext context) { YZAuthHelper.OAuth(); //YZAuthHelper.AshxAuthCheck(); //GridPageInfo gridPageInfo = new GridPageInfo(context); //IDBProvider dbProvider = YZDBProviderManager.CurrentProvider; int Mouth; if (context.Request.Params["byMouth"] == "1") { Mouth = 0; } else { string strMouth = context.Request.Params["Mouth"]; Mouth = String.IsNullOrEmpty(strMouth) ? DateTime.Today.Month : Convert.ToInt32(strMouth); } //获得数据 BPMTaskCollection tasks = new BPMTaskCollection(); int rowcount = 0; JsonItem rootItem = new JsonItem(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); String UserAccount = context.Request.Params["UserAccount"]; //User user = User.FromAccount(cn, UserID); //YZAuthHelper.SetAuthCookie(realAccount); //YZAuthHelper.GetCookie(); DataTable Dt = new SqlServerProvider(context).getWorkTimesLog(UserAccount, Mouth); //将数据转化为Json集合 rootItem.Attributes.Add(JsonItem.TotalRows, rowcount); JsonItemCollection children = new JsonItemCollection(); rootItem.Attributes.Add("children", children); rootItem.Attributes.Add("total", Dt.Rows.Count); int index = 0; foreach (DataRow Dr in Dt.Rows) { JsonItem item = new JsonItem(); children.Add(item); String StartTime = String.IsNullOrEmpty(Convert.ToString(Dr["StartTime"])) ? null : Convert.ToString(Dr["StartTime"]); String EndTime = String.IsNullOrEmpty(Convert.ToString(Dr["EndTime"])) ? null : Convert.ToString(Dr["EndTime"]); item.Attributes.Add("ID", index); item.Attributes.Add("EmpID", Dr["EmpID"].ToString()); item.Attributes.Add("WorkDay", Dr["WorkDay"].ToString()); item.Attributes.Add("WeekInt", Dr["WeekInt"].ToString()); item.Attributes.Add("ClassID", Dr["ClassID"].ToString()); item.Attributes.Add("StartTime", YZStringHelper.DateToStringL(Convert.ToDateTime(StartTime))); item.Attributes.Add("EndTime", YZStringHelper.DateToStringL(Convert.ToDateTime(EndTime))); item.Attributes.Add("NotCard", Convert.ToString(Dr["NotCard"])); item.Attributes.Add("GongGan", Convert.ToString(Dr["GongGan"])); item.Attributes.Add("V1", Convert.ToString(Dr["V1"])); item.Attributes.Add("V2", Convert.ToString(Dr["V2"])); item.Attributes.Add("V3", Convert.ToString(Dr["V3"])); item.Attributes.Add("V4", Convert.ToString(Dr["V4"])); item.Attributes.Add("V5", Convert.ToString(Dr["V5"])); item.Attributes.Add("V6", Convert.ToString(Dr["V6"])); item.Attributes.Add("HDay", Convert.ToString(Dr["HDay"]).Split(',')[0].Replace(" ", "")); item.Attributes.Add("Holiday", Convert.ToString(Dr["Holiday"])); item.Attributes.Add("OverTime_H", Convert.ToString(Dr["OverTime_H"])); item.Attributes.Add("OverTime_W", Convert.ToString(Dr["OverTime_W"])); item.Attributes.Add("OverTime", Convert.ToString(Dr["OverTime"])); //item.Attributes.Add("UserShortName", YZStringHelper.GetUserShortName(task.OwnerAccount, task.OwnerDisplayName)); index++; } } //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()); }
public void ProcessRequest(HttpContext context) { YZAuthHelper.OAuth(); //YZAuthHelper.AshxAuthCheck(); GridPageInfo gridPageInfo = new GridPageInfo(context); IDBProvider dbProvider = YZDBProviderManager.CurrentProvider; //获得数据 BPMTaskListCollection tasks = new BPMTaskListCollection(); int rowcount; JsonItem rootItem = new JsonItem(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); tasks = cn.GetMyTaskList(dbProvider.FilterStringMyTask, null, gridPageInfo.Start, gridPageInfo.Limit, out rowcount); //将数据转化为Json集合 rootItem.Attributes.Add(JsonItem.TotalRows, rowcount); rootItem.Attributes.Add("total", rowcount); JsonItemCollection children = new JsonItemCollection(); rootItem.Attributes.Add("children", children); foreach (BPMTaskListItem task in tasks) { JsonItem item = new JsonItem(); children.Add(item); //string OwnerDisplayName = (YZStringHelper.GetUserShortName(task.OwnerAccount, task.OwnerDisplayName) + task.ProcessName).Length>4 // ? YZStringHelper.GetUserShortName(task.OwnerAccount, task.OwnerDisplayName).CutStrHTML(2) // : YZStringHelper.GetUserShortName(task.OwnerAccount, task.OwnerDisplayName); item.Attributes.Add("tid", task.TaskID); item.Attributes.Add("pid", task.StepID); item.Attributes.Add("sn", task.SerialNum); item.Attributes.Add("pn", task.ProcessName); item.Attributes.Add("stepName", string.Empty); //item.Attributes.Add("stepName", BPMProcStep.GetStepDisplayName(task.StepName).CutStrHTML(4)); //item.Attributes.Add("user", OwnerDisplayName); item.Attributes.Add("user", YZStringHelper.GetUserShortName(task.OwnerAccount, task.OwnerDisplayName)); //item.Attributes.Add("date", String.Empty); item.Attributes.Add("date", YZStringHelper.DateToStringL(task.CreateAt)); task.Description = task.ShowDescByProcessName(true); item.Attributes.Add("desc", String.IsNullOrEmpty(task.Description) ? "无内容摘要" : task.Description); DateTime time = new DateTime(); time.ToUniversalTime(); } } //System.Threading.Thread.Sleep(2000); 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()); }
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"; }
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()); }
public void ProcessRequest(HttpContext context) { //if (context.Request.Headers["If-None-Match"] != null || context.Request.Headers["If-Modified-Since"] != null) //{ // context.Response.Status = "304 Not Modified"; // context.Response.Cache.AppendCacheExtension("max-age=" + 365 * 24 * 60 * 60); // context.Response.Cache.SetExpires(DateTime.Now.AddYears(1)); // context.Response.AppendHeader("ETag", "Never_Modify"); // context.Response.Cache.SetETag("Never_Modify"); // context.Response.Cache.SetLastModified(DateTime.Now.AddMinutes(-1)); // context.Response.End(); // return; //} string fileId = context.Request.Params["fileid"]; try { Attachment attachment; using (IDbConnection cn = QueryManager.CurrentProvider.OpenConnection()) { attachment = YZAttachmentHelper.GetAttachmentInfo(cn, fileId); } string fileName = attachment.Name; string fileExt = attachment.Ext; long fileSize = attachment.Size; string filePath = Attachment.FileIDToPath(fileId, YZAttachmentHelper.AttachmentRootPath); if (!File.Exists(filePath)) { throw new Exception(String.Format(Net.MobileHelper.YZSoft.Resources.JosonStrings.Aspx_Upload_FileIDNotFount, fileId)); } bool contentDisposition = true; string range = context.Request.Headers["HTTP_RANGE"]; string content_type = "application/octet-stream"; RegistryKey file_key = Registry.ClassesRoot.OpenSubKey(fileExt); if (file_key != null) { content_type = file_key.GetValue("Content Type", content_type).ToString(); } context.Response.AppendHeader("Content-Type", content_type); if (contentDisposition) { context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + context.Server.UrlPathEncode(fileName)); } context.Response.AppendHeader("Accept-Ranges", "bytes"); if (range == null) { //全新下载 context.Response.AppendHeader("Content-Length", fileSize.ToString()); context.Response.CacheControl = HttpCacheability.Public.ToString(); context.Response.Cache.AppendCacheExtension("max-age=" + 365 * 24 * 60 * 60); context.Response.Cache.SetExpires(DateTime.Now.AddYears(1)); context.Response.AppendHeader("ETag", "Never_Modify"); context.Response.Cache.SetETag("Never_Modify"); context.Response.Cache.SetLastModified(DateTime.Now.AddMinutes(-1)); context.Response.TransmitFile(filePath); } else { //断点续传以及多线程下载支持 string[] file_range = range.Substring(6).Split(new char[1] { '-' }); context.Response.Status = "206 Partial Content"; context.Response.AppendHeader("Content-Range", "bytes " + file_range[0] + "-" + file_range[1] + "/" + fileSize.ToString()); context.Response.AppendHeader("Content-Length", (Int32.Parse(file_range[1]) - Int32.Parse(file_range[0]) + 1).ToString()); context.Response.TransmitFile(filePath, long.Parse(file_range[0]), (long)(Int32.Parse(file_range[1]) - Int32.Parse(file_range[0]) + 1)); } } catch (Exception exp) { JsonItem rv = new JsonItem(); rv.Attributes.Add("success", false); rv.Attributes.Add("errorMessage", exp.Message); 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"; }
protected void Page_Load(object sender, EventArgs e) { if (String.Compare(System.Web.Configuration.WebConfigurationManager.AppSettings["ShowMaintenancePage"], "true", true) == 0) { Response.Redirect("~/YZSoft/core/Maintenance/Default.aspx"); } bool webLogin = String.Compare(WebConfigurationManager.AppSettings["WebLoginEnable"], "false", true) == 0 ? false : true; bool ntLogin = String.Compare(WebConfigurationManager.AppSettings["NTLoginEnable"], "false", true) == 0 ? false : true; string action = this.Request.Params["action"]; if (action == "login") { string type = this.Request.Params["type"]; JsonItem rv = new JsonItem(); if (type == "NT") //NT登录 { try { if (this.NTLogin()) { rv[YZJsonProperty.success] = true; rv["text"] = Resources.YZStrings.Aspx_Login_Success; } } catch (Exception exp) { rv[YZJsonProperty.success] = false; rv["text"] = exp.Message; } if (rv.Attributes.ContainsKey(YZJsonProperty.success)) { Response.Clear(); this.Response.Write(rv.ToString()); Response.End(); } else { this.Response.Clear(); this.Response.Status = "401 Unauthorized"; this.Response.AppendHeader("WWW-Authenticate", "NTLM");//Basic, Digest, NTLM, and Negotiate this.Response.End(); } } else //BPM 登录 { string userid = this.Request.Params["uid"]; string password = this.Request.Params["pwd"]; string positionid = this.Request.Params["posid"]; if (String.IsNullOrEmpty(userid) /*|| String.IsNullOrEmpty(password)*/) { rv[YZJsonProperty.success] = false; rv["text"] = Resources.YZStrings.Aspx_Login_EnterAccountTip; } else if (String.IsNullOrEmpty(positionid)) { rv[YZJsonProperty.success] = false; rv["text"] = Resources.YZStrings.Aspx_Login_SelPosTip; } else { try { string realAccount; string token; if (BPMConnection.Authenticate(YZAuthHelper.BPMServerName, YZAuthHelper.BPMServerPort, userid, password, out realAccount, out token)) { YZAuthHelper.SetAuthCookie(realAccount, token); YZAuthHelper.ClearLogoutFlag(); rv[YZJsonProperty.success] = true; rv["text"] = Resources.YZStrings.Aspx_Login_Success; } else { rv[YZJsonProperty.success] = false; rv["text"] = Resources.YZStrings.Aspx_Login_Fail; } } catch (Exception exp) { YZEventLog log = new YZEventLog(); log.WriteEntry(exp); rv[YZJsonProperty.success] = false; rv["text"] = exp.Message; } } Response.Clear(); Response.Write(rv.ToString()); Response.End(); } } else if (action == "logout") { YZAuthHelper.SignOut(); YZAuthHelper.SetLogoutFlag("logout", String.Empty); string ssoUrl = System.Configuration.ConfigurationManager.AppSettings["ssoUrl"]; if (String.IsNullOrEmpty(ssoUrl)) { ssoUrl = "~/"; //ssoUrl = "~/YZSoft/Login/"; } this.Response.Redirect(ssoUrl, true); } else if (action == "changeuser") { YZAuthHelper.SignOut(); YZAuthHelper.SetLogoutFlag("changeuser", YZAuthHelper.LoginUserAccount); string ssoUrl = System.Configuration.ConfigurationManager.AppSettings["ssoUrl"]; if (String.IsNullOrEmpty(ssoUrl)) { ssoUrl = "~/"; //ssoUrl = "~/YZSoft/Login/"; } this.Response.Redirect(ssoUrl, true); } else { string ssoUrl = WebConfigurationManager.AppSettings["ssoUrl"]; if (!String.IsNullOrEmpty(ssoUrl)) { Response.Redirect(ssoUrl, true); } if (ntLogin && !webLogin) //仅NT登录 { if (YZAuthHelper.BPMLogoutType != "logout" && YZAuthHelper.BPMLogoutType != "changeuser") //非登出情况下 { if (this.NTLogin()) //NT登录成功 { if (!String.IsNullOrEmpty(Request.QueryString["ReturnURL"])) { Response.Redirect(Request.QueryString["ReturnURL"]); } else { Response.Redirect("~/"); } return; } if (String.IsNullOrEmpty(this.Request.ServerVariables["LOGON_USER"])) { this.Response.Clear(); this.Response.Status = "401 Unauthorized"; this.Response.AppendHeader("WWW-Authenticate", "NTLM");//Basic, Digest, NTLM, and Negotiate this.Response.End(); return; } } } //页标题 this.Page.Title = System.Web.Configuration.WebConfigurationManager.AppSettings["CompanyInfoLoginPageTitle"]; if (String.IsNullOrEmpty(this.Page.Title)) { this.Page.Title = Resources.YZStrings.Aspx_Login_Title; } //根据启动程序应用Css string startApp = System.Web.Configuration.WebConfigurationManager.AppSettings["StartApp"]; if (String.IsNullOrEmpty(startApp)) { startApp = "YZApp"; } this._litLoginCss.Text = String.Format("<link href=\"../../../{0}/Styles/login.css\" rel=\"stylesheet\" type=\"text/css\" />", startApp); //显示文字 this._litBoxCaption.Text = Resources.YZStrings.Aspx_Login_BoxCaption; this._litAccount.Text = Resources.YZStrings.Aspx_Login_Account; this._lnkRegNewAccount.Text = Resources.YZStrings.Aspx_Login_RegNewAccount; this._litPwd.Text = Resources.YZStrings.Aspx_Login_Pwd; this._lnkForgotPwd.Text = Resources.YZStrings.Aspx_Login_ForgotPwd; this._btnLogin.Value = Resources.YZStrings.Aspx_Login_BtnLogin; this._btnNTLogin.Value = Resources.YZStrings.Aspx_Login_BtnNTLogin; string[] strLcids = Resources.YZStrings.All_Languages.Split(new char[] { ',', ';' }); Type resType = typeof(Resources.YZStrings); ResourceManager mgr = new ResourceManager(resType.FullName, resType.Assembly); List <String> langs = new List <string>(); foreach (string strLcid in strLcids) { string resName = "All_Languages_" + strLcid; string langName = mgr.GetString(resName); bool current = String.Compare(langName, Resources.YZStrings.All_Languages_Cur, 0) == 0; langs.Add(String.Format("<a href=\"#\" class=\"yz-login-lang-item {0}\" onclick=\"changeLanguage('{1}');\">{2}</a>", current ? "yz-login-lang-item-selected" : "", strLcid, langName)); } this._litChangeLang.Text = String.Join("<span class=\"yz-login-lang-sp\">|</span>", langs.ToArray()); //关闭用户注册,忘记密码链接 //this._lnkRegNewAccount.Enabled = false; //this._lnkForgotPwd.Enabled = false; this._lnkRegNewAccount.Visible = false; this._lnkForgotPwd.Visible = false; this._litStep2Caption.Text = Resources.YZStrings.Aspx_Login_Step2_BoxCaption; this._litStep2Msg.Text = String.Format(Resources.YZStrings.Aspx_Login_Step2_Msg, "<span class=\"point\">●</span>"); this._litStep1Caption.Text = Resources.YZStrings.Aspx_Login_Step1_BoxCaption; this._litStep1Msg.Text = Resources.YZStrings.Aspx_Login_Step1_Msg; this._litStep1InsCurStep0.Text = Resources.YZStrings.Aspx_Login_Step1_Install_CurStep; this._litStep1InsCurStep1.Text = Resources.YZStrings.Aspx_Login_Step1_Install_CurStep; this._litStep1InsCurStep2.Text = Resources.YZStrings.Aspx_Login_Step1_Install_CurStep; this._litStep1InsCurStep3.Text = Resources.YZStrings.Aspx_Login_Step1_Install_CurStep; this._litStep1InsCurStep4.Text = Resources.YZStrings.Aspx_Login_Step1_Install_CurStep; this._litStep1NotInstalled.Text = Resources.YZStrings.Aspx_Login_Step1_Install_NotInstalled; this._litStep1InstallNow.Text = Resources.YZStrings.Aspx_Login_Step1_Install_InstallNow; this._litStep1Installing.Text = Resources.YZStrings.Aspx_Login_Step1_Install_Installing; this._litStep1Installing1.Text = Resources.YZStrings.Aspx_Login_Step1_Install_Installing; this._litStep1PlsWaiting.Text = Resources.YZStrings.Aspx_Login_Step1_Install_PlsWaiting; this._litStep1InstallFinished.Text = Resources.YZStrings.Aspx_Login_Step1_Install_InstallFinished; this._litStep1CheckAgain.Text = Resources.YZStrings.Aspx_Login_Step1_Install_CheckAgain; this._litStep1InstallFailed.Text = Resources.YZStrings.Aspx_Login_Step1_Install_InstallFailed; this._litStep1Retry.Text = Resources.YZStrings.Aspx_Login_Step1_Install_Retry; this._litStep1InstallSucceed.Text = Resources.YZStrings.Aspx_Login_Step1_Install_InstallSucceed; this._litStep1LoginContinue.Text = Resources.YZStrings.Aspx_Login_Step1_Login_Continue; this._litStep1Ignore.Text = Resources.YZStrings.Aspx_Login_Step1_Ignore; this._litStep0Caption.Text = Resources.YZStrings.Aspx_Login_Step0_BoxCaption; this._litStep0Msg.Text = Resources.YZStrings.Aspx_Login_Step0_Msg; this._litStep0Skip.Text = Resources.YZStrings.Aspx_Login_Step0_Skip; this._litStep0Skip1.Text = Resources.YZStrings.Aspx_Login_Step0_Skip; this._litStep0DownloadBrowser.Text = Resources.YZStrings.Aspx_Login_Step0_DownloadBrowser; this._downloadXP.Text = Resources.YZStrings.Aspx_Login_Step0_Download; this._downloadVista.Text = Resources.YZStrings.Aspx_Login_Step0_Download; this._download2003.Text = Resources.YZStrings.Aspx_Login_Step0_Download; this._downloadMore.Text = Resources.YZStrings.Aspx_Login_Step0_Download_More; //JS文字 JsonItem jsonStrings = new JsonItem(); jsonStrings.Attributes.Add("Account", YZAuthHelper.LoginUserAccount); jsonStrings.Attributes.Add("SelPos", Resources.YZStrings.Aspx_Login_SelPos); jsonStrings.Attributes.Add("SelPosTip", Resources.YZStrings.Aspx_Login_SelPosTip); jsonStrings.Attributes.Add("EnterAccountTip", Resources.YZStrings.Aspx_Login_EnterAccountTip); jsonStrings.Attributes.Add("EnterPwdTip", Resources.YZStrings.Aspx_Login_EnterPwdTip); jsonStrings.Attributes.Add("BrowserNameOpera", Resources.YZStrings.Aspx_BrowserNameOpera); jsonStrings.Attributes.Add("BrowserNameSafari", Resources.YZStrings.Aspx_BrowserNameSafari); jsonStrings.Attributes.Add("BrowserNameGoogle", Resources.YZStrings.Aspx_BrowserNameGoogle); jsonStrings.Attributes.Add("BrowserNameFirefox", Resources.YZStrings.Aspx_BrowserNameFirefox); jsonStrings.Attributes.Add("BrowserNameOther", Resources.YZStrings.Aspx_BrowserNameOther); jsonStrings.Attributes.Add("BrowserWarning", Resources.YZStrings.Aspx_Login_BrowserWarning); jsonStrings.Attributes.Add("Unknow", Resources.YZStrings.Aspx_Login_Unknow); jsonStrings.Attributes.Add("HttpErr", Resources.YZStrings.Aspx_Login_HttpErr); HtmlGenericControl jsstrs = new HtmlGenericControl("script"); jsstrs.Attributes["type"] = "text/javascript"; jsstrs.InnerHtml = String.Format("var Strings = {0}", jsonStrings.ToString()); this.Page.Header.Controls.AddAt(1, jsstrs); //地图信息 JArray factorys; using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { factorys = provider.GetFactorys(cn); } } string returnUrl = String.Empty; if (!String.IsNullOrEmpty(Request.QueryString["ReturnURL"])) { returnUrl = this.ResolveClientUrl(Request.QueryString["ReturnURL"]); } else { returnUrl = this.ResolveClientUrl("~/"); } HtmlGenericControl js = new HtmlGenericControl("script"); js.Attributes["type"] = "text/javascript"; js.InnerHtml = "var _FactoryData=" + factorys.ToString() + ";\n" + "var returnUrl=\"" + YZUtility.EncodeJsString(returnUrl) + "\";"; this.Page.Header.Controls.AddAt(1, js); if (!webLogin) { this._txtUserId.Enabled = false; this._txtPassword.Enabled = false; this._txtUserId.CssClass = "input input-disabled"; this._txtPassword.CssClass = "input input-disabled"; this._lnkRegNewAccount.Enabled = false; this._lnkForgotPwd.Enabled = false; this._btnLogin.Disabled = true; } if (!ntLogin) { this._btnNTLogin.Disabled = true; } } }
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 void ProcessRequest(HttpContext context) { YZAuthHelper.OAuth(); //YZAuthHelper.AshxAuthCheck(); //GridPageInfo gridPageInfo = new GridPageInfo(context); //IDBProvider dbProvider = YZDBProviderManager.CurrentProvider; int rowcount = 0; //获得数据 BPMTaskCollection tasks = new BPMTaskCollection(); JsonItem rootItem = new JsonItem(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); String UserID = context.Request.Params["UserID"]; String Phone = context.Request.Params["Phone"]; //User user = User.FromAccount(cn, UserID); //YZAuthHelper.SetAuthCookie(realAccount); //YZAuthHelper.GetCookie(); //将数据转化为Json集合 rootItem.Attributes.Add(JsonItem.TotalRows, rowcount); JsonItemCollection children = new JsonItemCollection(); rootItem.Attributes.Add("children", children); int index = 0; if (Phone == null) { DataTable Dt = new SqlServerProvider(context).getUserLogInfo(UserID); rootItem.Attributes.Add("total", Dt.Rows.Count); foreach (DataRow Dr in Dt.Rows) { JsonItem item = new JsonItem(); children.Add(item); item.Attributes.Add("ID", index); item.Attributes.Add("UserAccount", Dr["UserAccount"].ToString()); item.Attributes.Add("DisplayName", Dr["DisplayName"].ToString()); item.Attributes.Add("Company", Dr["Company"].ToString()); item.Attributes.Add("Department", Dr["Department"].ToString()); item.Attributes.Add("Counts", Convert.ToString(Dr["Counts"])); item.Attributes.Add("Phone", Convert.ToString(Dr["Phone"])); index++; } } else { DataTable Dt = new SqlServerProvider(context).getUserLogInfoDtl(UserID, Phone); rootItem.Attributes.Add("total", Dt.Rows.Count); foreach (DataRow Dr in Dt.Rows) { JsonItem item = new JsonItem(); children.Add(item); item.Attributes.Add("ID", index); item.Attributes.Add("UserAccount", Dr["UserAccount"].ToString()); item.Attributes.Add("DisplayName", Dr["DisplayName"].ToString()); item.Attributes.Add("Company", Dr["Company"].ToString()); item.Attributes.Add("Department", Dr["Department"].ToString()); item.Attributes.Add("UserEMail", Convert.ToString(Dr["UserEMail"])); item.Attributes.Add("LogDate", Convert.ToString(Dr["LogDate"])); item.Attributes.Add("Phone", Convert.ToString(Dr["Phone"])); item.Attributes.Add("UUID", Convert.ToString(Dr["UUID"])); item.Attributes.Add("DeviceName", Convert.ToString(Dr["DeviceName"])); item.Attributes.Add("NetWork", Convert.ToString(Dr["NetWork"])); item.Attributes.Add("Version", Convert.ToString(Dr["Version"])); item.Attributes.Add("ClientIP", Convert.ToString(Dr["ClientIP"])); item.Attributes.Add("FullName", Convert.ToString(Dr["FullName"])); index++; } } } context.Response.Write(rootItem.ToString()); }