コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest rp = context.Request;
            string msg = string.Empty;
            try
            {
                if (string.IsNullOrEmpty(rp["txtID"]))
                {
                    entity.ID = Guid.NewGuid();
                }
                else
                {
                    entity.ID = new Guid(rp["txtID"]);
                    entity.RecordStatus = StatusType.update;
                }
                entity.SbID = new Guid(rp["txtSbID"]);
                entity.GuZhangXx = rp["txtGuZhangXx"];
                entity.ChuLiYiJian = rp["txtChuLiYiJian"];
                if (!string.IsNullOrEmpty(rp["txtPlanTime"]))
                {
                    entity.PlanTime = DateTime.Parse(rp["txtPlanTime"]);
                }
                entity.Status = "制单";
                if (string.IsNullOrEmpty(context.Session["UserName"] as string))
                {
                    entity.CreaterID = Guid.NewGuid();
                    entity.CreaterName = "管理员";
                }
                else
                {
                    entity.CreaterID = new Guid(context.Session["UserID"].ToString());
                    entity.CreaterName = context.Session["UserName"] as string;
                }
                if (!string.IsNullOrEmpty(rp["txtRealTime"]))
                {
                    entity.RealTime = DateTime.Parse(rp["txtRealTime"]);
                }
                entity.Note = rp["txtNote"];

                if (!string.IsNullOrEmpty(rp["txtCity"]))
                {
                    entity.City = new Guid(rp["txtCity"]);
                }

                if (!string.IsNullOrEmpty(rp["txtXian"]))
                {
                    entity.Xian = new Guid(rp["txtXian"]);
                }

                if (!string.IsNullOrEmpty(rp["txtZhen"]))
                {
                    entity.Zhen = new Guid(rp["txtZhen"]);
                }
                entity.Address = rp["txtAddress"];
                entity.Tel = rp["txtTel"];
                entity.CreateDate = DateTime.Now;
                entity.Guzhang = rp["txtGuzhang"];
                WorkInfoManager manager = new WorkInfoManager();
                manager.Save(entity);
                context.Response.Write("{\"success\":\"true\",\"ID\":\"" + entity.ID + "\"}");

            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
            if (!string.IsNullOrEmpty(msg))
            {
                byte[] bytes = Encoding.UTF8.GetBytes(msg.Replace("\r\n", "<br/>"));
                string encode = Convert.ToBase64String(bytes);
                context.Response.Write("{\"success\":\"false\",\"msg\":\"" + encode + "\"}");
            }
            context.Response.End();
        }
コード例 #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest rp = context.Request;
            string msg = string.Empty;
            try
            {
                WorkInfoManager manager = new WorkInfoManager();
                List<BaseEntity> entityList = new List<BaseEntity>();
                int maxsequenc = manager.GetMaxSequence(new Guid(rp["txtWorkID"]));
                string zt = rp["txtHandResult"];
                WorkInfo work = new WorkInfo();
                work.ID = new Guid(rp["txtWorkID"]);
                work = manager.GetItemById(work.ID);
                work.RecordStatus = StatusType.update;
                work.Status = zt;
                ShebeiInfo s = new ShebeiInfo();
                s = new ShebeiInfoManager().GetItemById(work.SbID);

                if (zt == "处理中")
                {
                    string[] zprid = rp["txtZprID"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    string[] zprName = rp["txtZprName"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    work.CurrentUser = rp["txtZprName"];
                    for (int i = 0; i < zprid.Length; i++)
                    {
                        WorkHandLog tem = SetValue(rp, context);
                        tem.DownEr = new Guid(zprid[i]);
                        tem.DownName = zprName[i];
                        tem.HandSequence = maxsequenc;

                        entityList.Add(tem);
                    }
                    s.State = zt;
                }
                else
                {
                    work.RealTime = DateTime.Now;
                    work.CurrentUser = manager.GetLastUserName(work.ID) ;
                    WorkHandLog tem = SetValue(rp, context);
                    tem.HandSequence = maxsequenc;
                    int handType = 0;
                    int.TryParse(rp["txtHandType"], out handType);
                    tem.HandType = handType;
                    entityList.Add(tem);
                    s.State = "正常";

                    if (rp["txtHandType"] == "0")
                    {
                        //维修

                        string sql = "update ShebeiInfo set GZTJ=isnull(GZTJ,0)+1 where id='" + s.ID + "'";
                        Sharp.Data.SessionFactory.Default.FromCustomSql(sql).ExecuteNonQuery();
                    }
                    else if (rp["txtHandType"] == "1")
                    {
                        //更换
                        string sql = "update ShebeiInfo set GHTJ=isnull(GHTJ,0)+1 where id='" + s.ID + "'";
                        Sharp.Data.SessionFactory.Default.FromCustomSql(sql).ExecuteNonQuery();
                    }

                }

                entityList.Add(work);
                entityList.Add(s);
                manager.Save(entityList);
                context.Response.Write("{\"success\":\"true\"}");

            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
            if (!string.IsNullOrEmpty(msg))
            {
                byte[] bytes = Encoding.UTF8.GetBytes(msg.Replace("\r\n", "<br/>"));
                string encode = Convert.ToBase64String(bytes);
                context.Response.Write("{\"success\":\"false\",\"msg\":\"" + encode + "\"}");
            }
            context.Response.End();
        }