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 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) { 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 GetTaskLst(String UserAccount) { IDictionary<String, Dictionary<String, String>> DictLst = new Dictionary<String, Dictionary<String, String>>(); // SecurityToken token = null; // YZAuthHelper.AuthCheck(); // string LoginUserAccount = YZAuthHelper.LoginUserAccount; YZAuthHelper.OAuth(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); int taskCount = cn.GetMyTaskCount(); //int ShareTaskCount = cn.GetShareTaskCount(); int ProcessNameCounts = 0; var TaskList = cn.GetMyTaskList(); foreach (BPM.Client.BPMTaskListItem BPMTaskList in TaskList) { int TaskID = BPMTaskList.TaskID; String TaskState = BPMTaskList.TaskState.ToString(); String SerialNum = BPMTaskList.SerialNum; String ProcessName = BPMTaskList.ProcessName; String OwnerDisplayName = BPMTaskList.OwnerDisplayName; String StepName = BPMTaskList.StepID + "-" + BPMTaskList.StepName; if (!DictLst.ContainsKey(ProcessName)) { ProcessName = String.Format("ProcessName=N'{0}'", ProcessName); TaskList = cn.GetMyTaskList(ProcessName, "StepID DESC", 0, 100, out ProcessNameCounts); Dictionary<String, String> iDict = new Dictionary<String, String>(); foreach (BPM.Client.BPMTaskListItem thisTaskList in TaskList) { string stepDisplayName = BPMProcStep.GetStepDisplayName(thisTaskList.StepName); TaskID = thisTaskList.TaskID; TaskState = thisTaskList.TaskState.ToString(); SerialNum = thisTaskList.SerialNum; ProcessName = thisTaskList.ProcessName; OwnerDisplayName = thisTaskList.OwnerDisplayName; StepName = thisTaskList.StepID + "-" + stepDisplayName; String Keys = SerialNum + "|" + StepName + "|" + OwnerDisplayName; iDict.Add(Keys, ProcessName); } ProcessName = ProcessName + "|" + ProcessNameCounts; if (!DictLst.ContainsKey(ProcessName)) DictLst.Add(ProcessName, iDict); } } } // return DictLst; }
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 virtual void ProcessRequest(HttpContext context) { JObject result = null; try { string UserAccount = context.Request.Params["UserAccount"]; //if (YZAuthHelper.IsAuthenticated == false) //{ // YZAuthHelper.OAuth(); // //throw new Exception("登录BPM验证失败"); //} //else //{ // UserAccount = YZAuthHelper.LoginUserAccount; //} YZAuthHelper.OAuth(); //检查来源地址是否允许访问 CheckRomoteAddress(); result = new JObject(); requestString = new StreamReader(context.Request.InputStream, Encoding.UTF8).ReadToEnd(); string Method = context.Request.Params["Method"]; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); if (string.Compare(Method, "GetUserInfo", true) == 0) { result = GetUserInfo(cn, UserAccount); } else if (string.Compare(Method, "SaveAttachment", true) == 0) { result = SaveAttachment(context); } else if (string.Compare(Method, "GetFormInfo", true) == 0) { int TaskID = Convert.ToInt32(GetParamValue("TaskID", "-1")); int StepID = Convert.ToInt32(GetParamValue("StepID", "-1")); //int TaskID = 603680; //int StepID = -1; //TaskID = 701461; //StepID = 10532325; result = GetFormInfo(cn, UserAccount, TaskID, StepID); result["success"] = true; } else if (string.Compare(Method, "GetReturnSteps", true) == 0) { int StepID = Convert.ToInt32(GetParamValue("StepID", "-1")); result = GetReturnStepsForm(cn, UserAccount, StepID); result["success"] = true; } else if (string.Compare(Method, "TaskProcess", true) == 0) { int TaskID = Convert.ToInt32(GetParamValue("TaskID", "-1")); int StepID = Convert.ToInt32(GetParamValue("StepID", "-1")); string Action = Convert.ToString(GetParamValue("Action")); string Type = Convert.ToString(GetParamValue("Type")); string Comment = Convert.ToString(GetParamValue("Comment")); string Transfer_TransferTo = Convert.ToString(GetParamValue("Transfer_TransferTo", null)); string Consign_ConsignUsers = Convert.ToString(GetParamValue("Consign_ConsignUsers", null)); int RecedeBack_ToStepID = Convert.ToInt32(GetParamValue("RecedeBack_ToStepID", null)); result = TaskProcess(cn, UserAccount, TaskID, StepID, Action, Type, Comment, Transfer_TransferTo, Consign_ConsignUsers, RecedeBack_ToStepID); result["success"] = true; } else if (string.Compare(Method, "PostTask", true) == 0) { string ProcessName = GetParamValue("ProcessName"); string Action = GetParamValue("Action"); string Comment = GetParamValue("Comment", ""); bool Draft = Convert.ToBoolean(GetParamValue("Draft", "false")); int ExistTaskID = Convert.ToInt32(GetParamValue("ExistTaskID", "-1")); string FormData = GetParamValue("FormData"); XmlDocument doc = JsonConvert.DeserializeXmlNode(FormData, "FormData"); result = PostTask(cn, ProcessName, UserAccount, Action, Comment, Draft, ExistTaskID, doc.OuterXml); } else if (string.Compare(Method, "GetApprovalLog", true) == 0) { int TaskID = Convert.ToInt32(GetParamValue("TaskID", "-1")); result = GetApprovalLog(cn, TaskID); } else if (string.Compare(Method, "MyTask", true) == 0) { string Path = GetParamValue("Path", "/"); int Start = Convert.ToInt32(GetParamValue("Start")); int Limit = Convert.ToInt32(GetParamValue("Limit")); string ProcessName = GetParamValue("ProcessName", ""); string Keyword = GetParamValue("Keyword", ""); result = MyTask(cn, Path, Start, Limit, ProcessName, Keyword); } else { throw new Exception(String.Format("找不到{0}方法", Method)); } } } catch (Exception e) { result = new JObject(); result["success"] = false; result["errorMessage"] = e.Message; } if (YZAuthHelper.IsAuthenticated) { ClearAuth(); } 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(result.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()); } }
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 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()); }