Ejemplo n.º 1
0
        private void GetDetail(HttpContext context, string btn)
        {
            if (btn != "show")
            {
                context.Response.Write("{\"status\":\"0.2\",\"msg\":\"对不起,您没有操作权限!\"}");
                return;
            }
            try
            {
                int ID = RequestHelper.GetInt("ID", 0);

                SCZM.BLL.Repair.Repair_Assignment bll = new SCZM.BLL.Repair.Repair_Assignment();
                DataSet   ds = bll.GetDetail(ID);
                DataTable dt = ds.Tables[0];
                if (dt.Rows.Count == 0)
                {
                    context.Response.Write("{\"status\":\"0\",\"msg\":\"对不起,该条数据已被其他人删除!\"}");
                    return;
                }
                string        rowsStr = Utils.ToJson(dt);
                DataTable     Assignment_ProcessDT    = ds.Tables["Assignment_Process"];
                string        Assignment_ProcessStr   = Utils.ToJson(Assignment_ProcessDT);
                DataTable     Assignment_ActualListDT = ds.Tables["Assignment_ActualList"];
                string        Assignment_ActualList   = Utils.ToJson(Assignment_ActualListDT);
                StringBuilder jsonStr = new StringBuilder();
                jsonStr.Append("{\"status\":\"1\",\"msg\":\"数据获取成功!\",\"info\":" + rowsStr);
                jsonStr.Append(",\"Assignment_ProcessInfo\":" + Assignment_ProcessStr);
                jsonStr.Append(",\"Assignment_ActualList\":" + Assignment_ActualList);
                jsonStr.Append("}");
                context.Response.Write(jsonStr);
            }
            catch (Exception e)
            {
                context.Response.Write("{\"status\":\"0\",\"msg\":\"对不起,系统出错:" + Utils.HtmlEncode(e.Message) + "\"}");
            }
        }
Ejemplo n.º 2
0
        private void SaveData(HttpContext context, string btn)
        {
            if (btn != "btnSave")
            {
                context.Response.Write("{\"status\":\"0.2\",\"msg\":\"对不起,您没有操作权限!\"}");
                return;
            }
            string ID                 = RequestHelper.GetString("ID");
            string IntentionId        = RequestHelper.GetString("IntentionId");
            string AssignmentCode     = RequestHelper.GetString("AssignmentCode");
            string AssignmentDate     = RequestHelper.GetString("AssignmentDate");
            string ExpectStartDate    = RequestHelper.GetString("ExpectStartDate");
            string ExpectCompleteDate = RequestHelper.GetString("ExpectCompleteDate");
            string MainRepair         = RequestHelper.GetString("MainRepair").Trim();
            string AssistRepair       = RequestHelper.GetString("AssistRepair").Trim();
            string detailStr          = RequestHelper.GetString("detailStr");
            string procedureList_prev = RequestHelper.GetString("procedureList_prev");
            string WorkContent        = RequestHelper.GetString("WorkContent").Trim();

            Model.System.sys_LoginUser          loginUserModel = BaseWeb.GetLoginInfo();
            SCZM.Model.Repair.Repair_Assignment model          = new SCZM.Model.Repair.Repair_Assignment();
            SCZM.BLL.Repair.Repair_Assignment   bll            = new SCZM.BLL.Repair.Repair_Assignment();
            model.ID          = Utils.StrToInt(ID, 0);
            model.IntentionId = Utils.StrToInt(IntentionId, 0);
            if (AssignmentCode == "")
            {
                AssignmentCode = "PG" + DateTime.Now.ToString("yyyyMMdd") + bll.GetMaxId();
            }
            model.AssignmentCode = AssignmentCode;
            if (AssignmentDate != "")
            {
                model.AssignmentDate = Utils.StrToDateTime(AssignmentDate);
            }
            if (ExpectStartDate != "")
            {
                model.ExpectStartDate = Utils.StrToDateTime(ExpectStartDate);
            }
            if (ExpectCompleteDate != "")
            {
                model.ExpectCompleteDate = Utils.StrToDateTime(ExpectCompleteDate);
            }
            model.MainRepair   = Utils.StrToInt(MainRepair, 0);
            model.AssistRepair = AssistRepair;
            model.WorkContent  = WorkContent;
            List <Model.Repair.Repair_Assignment_Procedure> modelList = new List <Model.Repair.Repair_Assignment_Procedure>();

            if (detailStr != "")
            {
                string[] detailArray = detailStr.Split('≮');
                for (int i = 0; i < detailArray.Length; i++)
                {
                    string[] detailMXArray = detailArray[i].Split('⊥');
                    Model.Repair.Repair_Assignment_Procedure model_Procedure = new Model.Repair.Repair_Assignment_Procedure();
                    model_Procedure.ProcedureId = Utils.StrToInt(detailMXArray[0], 0);
                    model_Procedure.Num         = Utils.StrToDecimal(detailMXArray[1], 0);
                    model_Procedure.WorkContent = Utils.Filter(detailMXArray[2]);
                    model_Procedure.AllNat      = Utils.StrToDecimal(detailMXArray[3], 0);
                    modelList.Add(model_Procedure);
                }
            }
            model.Repair_Assignment_Procedure = modelList;
            model.OperaDepId = loginUserModel.DepId;
            model.OperaId    = loginUserModel.ID;
            model.OperaName  = loginUserModel.PerName;
            model.OperaTime  = DateTime.Now;

            string operaMessage = "";
            string status       = "0";
            string operaAction  = "";
            string operaMemo    = "";

            try
            {
                if (ID == "")
                {
                    model.ID = bll.Add(model, out operaMessage);
                    if (model.ID > 0)
                    {
                        status      = "1";
                        operaAction = Enums.ActionEnum.Add.ToString();
                        operaMemo   = "新增维修派工:" + model.ID;
                    }
                }
                else
                {
                    if (bll.Update(model, procedureList_prev, out operaMessage))
                    {
                        status      = "1";
                        operaAction = Enums.ActionEnum.Edit.ToString();
                        operaMemo   = "修改维修派工:" + model.ID;
                    }
                }
                if (status == "1")
                {
                    //写入操作日志
                    BaseWeb.AddOpera(loginUserModel, int.Parse(RequestHelper.GetQueryString("MenuId")), operaAction, operaMemo);
                }
                if (status == "1")
                {
                    string userIdList = "";
                    if (MainRepair != "")
                    {
                        userIdList += MainRepair;
                        if (model.AssistRepair != "")
                        {
                            userIdList += "," + AssistRepair;
                        }
                    }
                    if (userIdList != "")
                    {
                        try
                        {
                            BLL.WX.WX_GetLoginInfo bll_Wx = new BLL.WX.WX_GetLoginInfo();
                            DataSet wx_AccountDs          = bll_Wx.getWxAccount_Id(userIdList);
                            if (wx_AccountDs != null && wx_AccountDs.Tables[0].Rows.Count > 0)
                            {
                                string touser = "", touser_ds = "";
                                for (int i = 0; i < wx_AccountDs.Tables[0].Rows.Count; i++)
                                {
                                    touser_ds = wx_AccountDs.Tables[0].Rows[i][0].ToString();
                                    if (touser_ds != "")
                                    {
                                        touser += touser_ds + "|";
                                    }
                                }
                                if (touser.Length > 0)
                                {
                                    touser = touser.Remove(touser.Length - 1);
                                    DataRow dr = bll.GetDetail(model.ID).Tables[0].Rows[0];
                                    //string message = "有新的派工,请及时查看";context.Request.Url.Authority + "/SCZM/Pages/WeiXin/WX_Schedule_List_procedure.html?AssignmentId="+model.ID
                                    WX.WX_GetLoginInfo.GetMessageCard(touser, "", "有新的派工,请及时查看。", " 派工单:" + dr["AssignmentCode"] + "\n 客户:" + dr["CustName"] + "\n 机型:" + dr["MachineModel"] + "\n 机号:" + dr["MachineCode"] + "\n 维修担当:" + dr["MainRepairName"] + "\n 计划维修日期:\n " + DateTime.Parse(dr["ExpectStartDate"].ToString()).ToLongDateString() + "-" + DateTime.Parse(dr["ExpectCompleteDate"].ToString()).ToLongDateString(), "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + new BLL.System.sys_Config().loadConfig().WxCorpid + "&redirect_uri=" + context.Request.Url.Authority + ConfigurationManager.AppSettings["appName"] + "Pages/WeiXin/WX_Schedule_List_new.html&response_type=code&scope=snsapi_userinfo&agentid=" + WX.WX_GetLoginInfo.GetAgentid("Schedule") + "#wechat_redirect", "查看", "Schedule");
                                    //WX.WX_GetLoginInfo.GetMessage(touser,"", message);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            operaMessage += "微信推送失败(" + e.Message + "),请及时联系系统管理员";
                        }
                    }
                }
                context.Response.Write("{\"status\":\"" + status + "\",\"msg\":\"" + operaMessage + "\"}");
                return;
            }
            catch (Exception e)
            {
                context.Response.Write("{\"status\":\"0\",\"msg\":\"对不起,系统出错:" + Utils.HtmlEncode(e.Message) + "\"}");
                return;
            }
        }