public void ProcessRequest(HttpContext context)
 {
     try
     {
         int id = int.Parse(context.Request["id"]);//处理的申请主键ID
         using (JDJS_WMS_DB_USEREntities model = new JDJS_WMS_DB_USEREntities())
         {
             var inspect = model.JDJS_WMS_Quality_Apply_Measure_Table.Where(r => r.ID == id).FirstOrDefault();
             if (inspect == null)
             {
                 context.Response.Write("该送检申请不存在,请确认后再试!");
                 return;
             }
             if (inspect.State != Enum.GetName(typeof(InspectStateType), 1))
             {
                 context.Response.Write("该测量记录状态不符,请确认后再试!");
                 return;
             }
             if (inspect.MeasureResult == null)
             {
                 context.Response.Write("该工件暂未填写测量结果,请确认后再试!");
                 return;
             }
             using (System.Data.Entity.DbContextTransaction mytran = model.Database.BeginTransaction())
             {
                 try
                 {
                     inspect.State = Enum.GetName(typeof(InspectStateType), 2);
                     model.SaveChanges();
                     mytran.Commit();
                     PathInfo         pathInfo         = new PathInfo();
                     bool             z                = true;
                     SendTextToWechat sendTextToWechat = new CompanyWeChatRobotRemind();
                     sendTextToWechat.SendText(inspect.ApplyPersonName + "提交的工件:" + inspect.WorkPieceName + "的测量已完成。结果为" + inspect.MeasureResult + "。点击http://3x196w2589.qicp.vip/M/appointList.html", pathInfo.GetQualituInspectAuditRobot(), new List <string>(), out z);
                     context.Response.Write("ok");
                     return;
                 }
                 catch (Exception ex)
                 {
                     mytran.Rollback();
                     context.Response.Write(ex.Message);
                     return;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         context.Response.Write(ex.Message);
         return;
     }
 }
Exemple #2
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                DateTime inspectTime     = Convert.ToDateTime(context.Request["inspectTime"]);                                //送检时间
                string   workpieceName   = context.Request["workpieceName"];                                                  //工件名称
                string   measureContent  = context.Request["measureContent"];                                                 //测量内容
                string   measureGoal     = context.Request["measureGoal"];                                                    //测量目的
                string   departmentName  = context.Request["departmentName"];                                                 //送检部门
                string   applyPersonName = context.Request["applyPersonName"];                                                //送检人员名称
                int      workpieceNum    = int.Parse(context.Request["workpieceNum"]);                                        //送检数量

                string   applyPersonTel = context.Request["applyPersonTel"] == null ? "" : context.Request["applyPersonTel"]; //送检人员联系方式,可以不给
                var      loginID        = Convert.ToInt32(context.Session["id"] == null?"0": context.Session["id"]);
                DateTime applyTime      = DateTime.Now;                                                                       //申请时间
                string   path           = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString() + "-" + DateTime.Now.Hour.ToString() + "-" + DateTime.Now.Minute.ToString() + "-" + DateTime.Now.Second.ToString() + "-" + DateTime.Now.Millisecond.ToString();
                PathInfo pathInfo       = new PathInfo();
                path = System.IO.Path.Combine(pathInfo.upLoadPath(), @"送检模块", path);
                if (!System.IO.Directory.Exists(path))
                {
                    System.IO.Directory.CreateDirectory(path);
                }
                using (JDJS_WMS_DB_USEREntities model = new JDJS_WMS_DB_USEREntities())
                {
                    using (System.Data.Entity.DbContextTransaction mytran = model.Database.BeginTransaction())
                    {
                        try
                        {
                            JDJS_WMS_Quality_Apply_Measure_Table jd = new JDJS_WMS_Quality_Apply_Measure_Table()
                            {
                                ApplyPersonId    = loginID,
                                ApplyPersonName  = applyPersonName,
                                ApplyPersonTel   = applyPersonTel,
                                ApplyTime        = applyTime,
                                DepartmentName   = departmentName,
                                InspectTime      = inspectTime,
                                MeasureContent   = measureContent,
                                MeasureGoal      = measureGoal,
                                WorkPieceName    = workpieceName,
                                WorkPieceNum     = workpieceNum,
                                State            = Enum.GetName(typeof(InspectStateType), 0),
                                AcceptPersonName = "",
                                Remark           = "",
                                SavePath         = path
                            };
                            model.JDJS_WMS_Quality_Apply_Measure_Table.Add(jd);
                            model.SaveChanges();
                            mytran.Commit();
                            bool             z = true;
                            SendTextToWechat sendTextToWechat = new CompanyWeChatRobotRemind();
                            sendTextToWechat.SendText(departmentName + ":" + applyPersonName + "新建送检申请,工件名称:" + workpieceName + "。工件数量:" + workpieceNum.ToString() + "。预计送检时间:" + inspectTime.ToShortDateString() + "。请尽快处理!" + "点击http://3x196w2589.qicp.vip/M/admin/appointList.html", pathInfo.GetQualituInspectApplyRobot(), new List <string>(), out z);
                            context.Response.Write("ok");
                        }
                        catch (Exception ex)
                        {
                            mytran.Rollback();
                            context.Response.Write(ex.Message);
                            return;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                context.Response.Write(ex.Message);
                return;
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                var    loginID    = Convert.ToInt32(context.Session["id"]);
                int    id         = int.Parse(context.Request["id"]); //处理的申请主键ID
                string result     = context.Request["result"];        //‘接受’|’未接受‘
                string remark     = context.Request["remark"];        //备注
                string personName = "";
                string state      = Enum.GetName(typeof(InspectStateType), 1);
                if (result == "未接受")
                {
                    state = Enum.GetName(typeof(InspectStateType), 3);
                }

                using (JDJS_WMS_DB_USEREntities model = new JDJS_WMS_DB_USEREntities())
                {
                    var person = model.JDJS_WMS_Staff_Info.Where(r => r.id == loginID).FirstOrDefault();
                    if (person != null)
                    {
                        personName = person.staff;
                    }
                    var inspect = model.JDJS_WMS_Quality_Apply_Measure_Table.Where(r => r.ID == id).FirstOrDefault();
                    if (inspect == null)
                    {
                        context.Response.Write("该送检申请不存在,请确认后再试!");
                        return;
                    }
                    if (inspect.State != Enum.GetName(typeof(InspectStateType), 0))
                    {
                        context.Response.Write("该测量记录状态不符,请确认后再试!");
                        return;
                    }
                    using (System.Data.Entity.DbContextTransaction mytran = model.Database.BeginTransaction())
                    {
                        try
                        {
                            inspect.AcceptPersonId   = loginID;
                            inspect.AcceptPersonName = personName;
                            inspect.AcceptTime       = DateTime.Now;
                            string str = inspect.Remark == null ? "" : inspect.Remark;
                            inspect.Remark = str + "<br/>" + personName + ":" + DateTime.Now.ToString() + "<br/>" + remark;
                            inspect.State  = state;
                            model.SaveChanges();
                            mytran.Commit();
                            PathInfo         pathInfo         = new PathInfo();
                            bool             z                = true;
                            SendTextToWechat sendTextToWechat = new CompanyWeChatRobotRemind();
                            sendTextToWechat.SendText(personName + result + inspect.ApplyPersonName + "提交的工件:" + inspect.WorkPieceName + "的送检申请。备注为" + remark + "。点击http://3x196w2589.qicp.vip/M/appointList.html", pathInfo.GetQualituInspectAuditRobot(), new List <string>(), out z);
                            context.Response.Write("ok");
                            return;
                        }
                        catch (Exception ex)
                        {
                            mytran.Rollback();
                            context.Response.Write(ex.Message);
                            return;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                context.Response.Write(ex.Message);
                return;
            }
        }