public JsonItemCollection GetFactorys(IDbConnection cn) { JsonItemCollection factorys = new JsonItemCollection(); using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = cn as SqlConnection; cmd.CommandText = "SELECT * FROM iSYSFactory"; using (YZReader reader = new YZReader(cmd.ExecuteReader())) { while (reader.Read()) { JsonItem factory = new JsonItem(); factorys.Add(factory); factory.Attributes["ID"] = reader.ReadInt32("ID"); factory.Attributes["Name"] = reader.ReadString("Name"); factory.Attributes["MapX"] = reader.ReadInt32("MapX"); factory.Attributes["MapY"] = reader.ReadInt32("MapY"); } } } return(factorys); }
public static JsonItem GetTaskStateJsonItem(BPMConnection cn, TaskState state, int taskid) { JsonItem rv = new JsonItem(); rv.Attributes.Add("State", state.ToString().ToLower()); if (state == TaskState.Running) { JsonItemCollection children = new JsonItemCollection(); rv.Attributes.Add("children", children); BPMStepCollection steps = BPMTask.GetInProcessSteps(cn, taskid); foreach (BPMProcStep step in steps) { JsonItem item = new JsonItem(); item.Attributes.Add("StepName", step.StepDisplayName); item.Attributes.Add("Share", step.Share); item.Attributes.Add("RecipientAccount", step.RecipientAccount); item.Attributes.Add("RecipientDisplayName", step.RecipientFullName); children.Add(item); } } return(rv); }
public JsonItemCollection GetFactorys(IDbConnection cn) { JsonItemCollection factorys = new JsonItemCollection(); using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = cn as SqlConnection; cmd.CommandText = "SELECT * FROM iSYSFactory"; using (YZReader reader = new YZReader(cmd.ExecuteReader())) { while (reader.Read()) { JsonItem factory = new JsonItem(); factorys.Add(factory); factory.Attributes["ID"] = reader.ReadInt32("ID"); factory.Attributes["Name"] = reader.ReadString("Name"); factory.Attributes["MapX"] = reader.ReadInt32("MapX"); factory.Attributes["MapY"] = reader.ReadInt32("MapY"); } } } return factorys; }
public void Serialize(BPMConnection cn, JsonItemCollection items) { foreach (YZMessage message in this) { JsonItem item = new JsonItem(); items.Add(item); message.Serialize(cn, item); } }
public static JsonItem GetTaskStateJsonItem(BPMConnection cn, TaskState state, int taskid) { JsonItem rv = new JsonItem(); rv.Attributes.Add("State", state.ToString().ToLower()); if (state == TaskState.Running) { JsonItemCollection children = new JsonItemCollection(); rv.Attributes.Add("children", children); BPMStepCollection steps = BPMTask.GetInProcessSteps(cn, taskid); foreach (BPMProcStep step in steps) { JsonItem item = new JsonItem(); item.Attributes.Add("StepName", step.StepDisplayName); item.Attributes.Add("Share", step.Share); item.Attributes.Add("RecipientAccount", step.RecipientAccount); item.Attributes.Add("RecipientDisplayName", step.RecipientFullName); children.Add(item); } } return rv; }
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(); 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) { 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) { 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 { 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) { 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()); }