public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string listID = context.Request.Form["listID"];
            string jobID  = new DataAccess.SaleList().GetModel(listID).JobID;

            DataAccess.RunProcedure run = new DataAccess.RunProcedure();
            DataSet view = run.JobView(jobID, "SaleList");

            if (view.Tables[3].Rows[0]["StatusName"].Equals("未提交."))
            {
                if (run.SLListDelete(listID))
                {
                    Entity.JobInfo job   = new DataAccess.JobInfo().GetModel(jobID);
                    DataTable      feeDt = run.JobFeeDetal(job.JobID, "SaleList").Tables[0];
                    job.Fee = decimal.Parse(feeDt.Rows[0]["Fee"].ToString());
                    if (job.Fee == 0)
                    {
                        job.FeeFlat = "无须缴费";
                    }
                    else
                    {
                        job.FeeFlat = "待缴费";
                    }
                    //提交数据到后台存储过程事务
                    DataAccess.TranHelper.BeginTran();
                    new DataAccess.JobInfo().Update(job);
                    try
                    {
                        DataAccess.TranHelper.CommitTran();
                        context.Response.Write("");
                    }
                    catch (Exception ex)
                    {
                        context.Response.Write("\n更新缴费信息出错!" + ex.Message);
                    }
                }
                else
                {
                    context.Response.Write("删除工单项失败!");
                }
            }
            else
            {
                context.Response.Write("该工单状态为已提交,无法继续修改工单信息!");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    Dictionary <string, string> dic = new Dictionary <string, string>();
                    foreach (string key in Request.Params)
                    {
                        dic.Add(key, Request.QueryString[key]);
                    }
                    if (!DataAccess.PayHelper.Verify(dic))
                    {
                        lblMessage.Text = "验签失败.";
                    }
                    else
                    {
                        string   jobID  = dic["OrderId"];
                        string   status = dic["Status"];
                        DateTime date   = new DateTime();
                        try
                        {
                            jobID  = dic["OrderId"];
                            status = dic["Status"];
                            date   = DateTime.ParseExact(dic["LastUpdated"], "yyyyMMddHHmmss", null).AddHours(8);
                        }
                        catch (Exception ex)
                        {
                            lblMessage.Text = "参数错误." + ex.ToString();
                            return;
                        }
                        switch (status)
                        {
                        case "Success":
                            Entity.JobInfo    job    = new DataAccess.JobInfo().GetModel(jobID);
                            Entity.HandleList handle = new DataAccess.HandleList().GetFeeData(jobID);
                            if (job == null || handle == null)
                            {
                                lblMessage.Text = "订单数据不存在.";
                            }
                            else
                            {
                                if (job.FeeFlat.Equals("已缴费"))
                                {
                                    Response.Redirect("JobList.aspx", false);
                                }
                                else
                                {
                                    job.FeeFlat          = "已缴费";
                                    handle.IsChecked     = true;
                                    handle.Status        = "已处理";
                                    handle.OpeartionUser = job.CustomsCode;
                                    handle.OpeartionTime = date;
                                    handle.Remark        = "网上支付";

                                    //提交事务至后台
                                    DataAccess.TranHelper.BeginTran();
                                    new DataAccess.JobInfo().Update(job);
                                    new DataAccess.HandleList().Update(handle);
                                    try
                                    {
                                        DataAccess.TranHelper.CommitTran();
                                        switch (job.JobType)
                                        {
                                        case "NA":
                                            new DataAccess.NADataAccess().ChangeFlow(job);
                                            break;

                                        case "MD":
                                            new DataAccess.MDDataAccess().ChangeFlow(job);
                                            break;

                                        case "RI":
                                            new DataAccess.RIDataAccess().ChangeFlow(job);
                                            break;

                                        case "RM":
                                            new DataAccess.RMDataAccess().ChangeFlow(job);
                                            break;

                                        case "SL":
                                            new DataAccess.SLDataAccess().ChangeFlow(job);
                                            break;

                                        case "UU":
                                            new DataAccess.UUDataAccess().ChangeFlow(job);
                                            break;
                                        }
                                        Response.Redirect("JobList.aspx", false);
                                    }
                                    catch (Exception ex)
                                    {
                                        lblMessage.Text = "更新支付数据失败." + ex.ToString();
                                        return;
                                    }
                                }
                            }
                            break;

                        default:

                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    lblMessage.Text = "系统错误." + ex.ToString();
                    return;
                }
            }
        }
Esempio n. 3
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                context.Response.ContentType = "text/plain";
                Dictionary <string, string> dic = new Dictionary <string, string>();
                foreach (string key in context.Request.Params)
                {
                    dic.Add(key, context.Request.QueryString[key]);
                }
                if (!DataAccess.PayHelper.Verify(dic))
                {
                    context.Response.Write(JsonConvert.SerializeObject(new Data("FAIL", "SignatureInvalid")));
                }
                else
                {
                    string   jobID  = dic["OrderId"];
                    string   status = dic["Status"];
                    DateTime date   = new DateTime();
                    try
                    {
                        jobID  = dic["OrderId"];
                        status = dic["Status"];
                        date   = DateTime.ParseExact(dic["LastUpdated"], "yyyyMMddHHmmss", null).AddHours(8);
                    }
                    catch (Exception ex)
                    {
                        context.Response.Write(JsonConvert.SerializeObject(new Data("FAIL", "ArgumentsInvalid." + ex.ToString())));
                        return;
                    }
                    switch (status)
                    {
                    case "Success":
                        Entity.JobInfo    job    = new DataAccess.JobInfo().GetModel(jobID);
                        Entity.HandleList handle = new DataAccess.HandleList().GetFeeData(jobID);
                        if (job == null || handle == null)
                        {
                            context.Response.Write(JsonConvert.SerializeObject(new Data("FAIL", "OrderNotFound")));
                        }
                        else
                        {
                            if (job.FeeFlat.Equals("已缴费"))
                            {
                                context.Response.Write(JsonConvert.SerializeObject(new Data("SUCCESS", "OK")));
                            }
                            else
                            {
                                job.FeeFlat          = "已缴费";
                                handle.IsChecked     = true;
                                handle.Status        = "已处理";
                                handle.OpeartionUser = job.CustomsCode;
                                handle.OpeartionTime = date;
                                handle.Remark        = "网上支付";

                                //提交事务至后台
                                DataAccess.TranHelper.BeginTran();
                                new DataAccess.JobInfo().Update(job);
                                new DataAccess.HandleList().Update(handle);
                                try
                                {
                                    DataAccess.TranHelper.CommitTran();
                                    switch (job.JobType)
                                    {
                                    case "NA":
                                        new CardCenter.DataAccess.NADataAccess().ChangeFlow(job);
                                        break;

                                    case "MD":
                                        new CardCenter.DataAccess.MDDataAccess().ChangeFlow(job);
                                        break;

                                    case "RI":
                                        new CardCenter.DataAccess.RIDataAccess().ChangeFlow(job);
                                        break;

                                    case "RM":
                                        new CardCenter.DataAccess.RMDataAccess().ChangeFlow(job);
                                        break;

                                    case "SL":
                                        new CardCenter.DataAccess.SLDataAccess().ChangeFlow(job);
                                        break;

                                    case "UU":
                                        new CardCenter.DataAccess.UUDataAccess().ChangeFlow(job);
                                        break;
                                    }
                                    context.Response.Write(JsonConvert.SerializeObject(new Data("SUCCESS", "OK")));
                                }
                                catch (Exception ex)
                                {
                                    context.Response.Write(JsonConvert.SerializeObject(new Data("FAIL", "WriteDataError." + ex.ToString())));
                                    return;
                                }
                            }
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                context.Response.Write(JsonConvert.SerializeObject(new Data("FAIL", "SystemError." + ex.ToString())));
                return;
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                context.Response.ContentType = "text/plain";
                string jobID  = context.Request.Form["hjobID"];
                string saleID = string.Empty;

                Entity.JobInfo job  = new Entity.JobInfo();
                Entity.JobInfo sJob = new Entity.JobInfo();
                DateTime       time = DateTime.Now;
                DataAccess.TranHelper.BeginTran();
                if (string.IsNullOrEmpty(jobID))
                {
                    DataAccess.RunProcedure procedure = new DataAccess.RunProcedure();

                    //JobInfo数据
                    job.JobID          = context.Request.Form["jobSelect"] + "-" + DataAccess.CardCenterHelper.GetCardNo();
                    job.JobType        = context.Request.Form["jobSelect"];
                    job.EnterpriseName = context.Request.Form["companyName"];
                    job.AgentPhone     = context.Request.Form["txtPhone"];
                    job.CreateTime     = time;
                    job.CreateUser     = context.Request.Form["customCode"];
                    job.IsDelete       = false;
                    job.Remark         = context.Request.Form["txtRemark"];
                    job.CustomsCode    = context.Request.Form["customCode"].Length == 10 ? context.Request.Form["customCode"] : null;
                    job.IsOnline       = false;
                    job.ExpressFlat    = false;
                    if (job.JobType == "SL")
                    {
                        job.Fee     = new DataAccess.Stock_Commodity().GetEntity(context.Request.Form["saleSelect"]).SellingPrice *int.Parse(context.Request.Form["txtNum"]);
                        job.FeeFlat = "待缴费";
                    }
                    else
                    {
                        job.Fee     = 0;
                        job.FeeFlat = "无须缴费";
                    }
                    new DataAccess.JobInfo().Add(job);

                    if (job.JobType == "NA" || job.JobType == "RI" || job.JobType == "RM")
                    {
                        sJob.JobID          = "SL-" + DataAccess.CardCenterHelper.GetCardNo();
                        sJob.JobType        = "SL";
                        sJob.EnterpriseName = job.EnterpriseName;
                        sJob.AgentPhone     = job.AgentPhone;
                        sJob.CreateTime     = job.CreateTime;
                        sJob.CreateUser     = job.CreateUser;
                        sJob.IsDelete       = false;
                        sJob.Remark         = job.Remark;
                        sJob.CustomsCode    = job.CustomsCode;
                        sJob.IsOnline       = false;
                        sJob.Fee            = new DataAccess.Stock_Commodity().GetEntity(context.Request.Form["saleSelect"]).SellingPrice *int.Parse(context.Request.Form["txtNum"]);
                        sJob.FeeFlat        = "待缴费";
                        sJob.ExpressFlat    = false;
                        new DataAccess.JobInfo().Add(sJob);

                        Entity.SaleBinding saleBind = new Entity.SaleBinding();
                        saleBind.Guid   = Guid.NewGuid().ToString();
                        saleBind.JobID  = job.JobID;
                        saleBind.SaleID = sJob.JobID;
                        new DataAccess.SaleBinding().Add(saleBind);
                        saleID = saleBind.SaleID;
                    }

                    //FlowInfo数据
                    Entity.FlowInfo flow = new Entity.FlowInfo();
                    flow.Guid       = Guid.NewGuid().ToString();
                    flow.JobID      = job.JobID;
                    flow.FlowID     = int.Parse(new DataAccess.Flow().GetList(string.Format("FlowOrder=2 and JobType='{0}'", job.JobType)).Tables[0].Rows[0]["FlowStatus"].ToString());
                    flow.SubmitDate = time;
                    flow.SubmitUser = PageBase.CommonObject.ManagerUserInfo.guid;
                    flow.Content    = "现场交单.";
                    flow.IsDelete   = false;
                    flow.Remark     = string.Empty;
                    new DataAccess.FlowInfo().Add(flow);

                    if (job.JobType == "NA" || job.JobType == "RI" || job.JobType == "RM")
                    {
                        Entity.FlowInfo sFlow = new Entity.FlowInfo();
                        sFlow.Guid       = Guid.NewGuid().ToString();
                        sFlow.JobID      = sJob.JobID;
                        sFlow.FlowID     = int.Parse(new DataAccess.Flow().GetList("FlowOrder=2 and JobType='SL'").Tables[0].Rows[0]["FlowStatus"].ToString());
                        sFlow.SubmitDate = flow.SubmitDate;
                        sFlow.SubmitUser = flow.SubmitUser;
                        sFlow.Content    = flow.Content;
                        sFlow.IsDelete   = false;
                        sFlow.Remark     = string.Empty;
                        new DataAccess.FlowInfo().Add(sFlow);
                    }

                    //绑定文件袋
                    if (!string.IsNullOrEmpty(context.Request.Form["hBar"]))
                    {
                        new DataAccess.JobBar().BindFile(context.Request.Form["hBar"], job.JobID);
                        if (job.JobType == "NA" || job.JobType == "RI" || job.JobType == "RM")
                        {
                            new DataAccess.JobBar().BindFile(context.Request.Form["hBar"], sJob.JobID);
                        }
                    }
                }
                else
                {
                    job = new DataAccess.JobInfo().GetModel(jobID);
                    if (job.JobType == "SL")
                    {
                        job.Fee += new DataAccess.Stock_Commodity().GetEntity(context.Request.Form["saleSelect"]).SellingPrice *int.Parse(context.Request.Form["txtNum"]);
                        new DataAccess.JobInfo().Update(job);
                    }
                    else if (job.JobType == "NA" || job.JobType == "RI" || job.JobType == "RM")
                    {
                        saleID    = new DataAccess.SaleBinding().GetList(string.Format("JobID='{0}'", jobID)).Tables[0].Rows[0]["SaleID"].ToString();
                        sJob      = new DataAccess.JobInfo().GetModel(saleID);
                        sJob.Fee += new DataAccess.Stock_Commodity().GetEntity(context.Request.Form["saleSelect"]).SellingPrice *int.Parse(context.Request.Form["txtNum"]);
                        new DataAccess.JobInfo().Update(sJob);
                    }
                }


                //工单项信息
                int random = new Random().Next(1, 9999);
                switch (job.JobType)
                {
                case "MD":
                    for (int i = 0; i < int.Parse(context.Request.Form["txtNum"]); i++)
                    {
                        Entity.ModifyList md = new Entity.ModifyList();
                        md.JobType      = context.Request.Form["businessSelect"];
                        md.ListID       = md.JobType + "-" + time.ToString("yyyyMMddhhmmssfff") + (random + i).ToString().PadLeft(4, '0');
                        md.JobID        = job.JobID;
                        md.CardType     = new DataAccess.Para_JobType().GetModel(md.JobType).CardType;
                        md.IsChangeName = false;
                        md.IsDelete     = false;
                        md.Remark       = "现场交单.";
                        new DataAccess.ModifyList().Add(md);
                    }
                    break;

                case "NA":
                    for (int i = 0; i < int.Parse(context.Request.Form["txtNum"]); i++)
                    {
                        Entity.NewlyAddedList na = new Entity.NewlyAddedList();
                        na.JobType  = context.Request.Form["businessSelect"];
                        na.ListID   = na.JobType + "-" + time.ToString("yyyyMMddhhmmssfff") + (random + i).ToString().PadLeft(4, '0');
                        na.JobID    = job.JobID;
                        na.CardType = new DataAccess.Para_JobType().GetModel(na.JobType).CardType;
                        na.CardholderIdentificationType = 1;
                        na.IsDelete = false;
                        na.Remark   = "现场交单.";
                        new DataAccess.NewlyAddedList().Add(na);
                    }
                    Entity.SaleList naSl = new Entity.SaleList();
                    if (new DataAccess.SaleList().GetList(string.Format("JobID='{0}' and ProductType='{1}' and IsDelete=0", saleID, context.Request.Form["saleSelect"])).Tables[0].Rows.Count == 0)
                    {
                        naSl.JobType     = "SL001";
                        naSl.ListID      = naSl.JobType + "-" + time.ToString("yyyyMMddhhmmssfff") + random.ToString().PadLeft(4, '0');
                        naSl.JobID       = saleID;
                        naSl.ProductType = context.Request.Form["saleSelect"];
                        naSl.Num         = int.Parse(context.Request.Form["txtNum"]);
                        naSl.IsDelete    = false;
                        naSl.Remark      = "现场交单.";
                        new DataAccess.SaleList().Add(naSl);
                    }
                    else
                    {
                        naSl      = new DataAccess.SaleList().GetModel(new DataAccess.SaleList().GetList(string.Format("JobID='{0}' and ProductType='{1}' and IsDelete=0", saleID, context.Request.Form["saleSelect"])).Tables[0].Rows[0]["ListID"].ToString());
                        naSl.Num += int.Parse(context.Request.Form["txtNum"]);
                        new DataAccess.SaleList().Update(naSl);
                    }
                    break;

                case "RI":
                    for (int i = 0; i < int.Parse(context.Request.Form["txtNum"]); i++)
                    {
                        Entity.ReIssueList ri = new Entity.ReIssueList();
                        ri.JobType  = context.Request.Form["businessSelect"];
                        ri.ListID   = ri.JobType + "-" + time.ToString("yyyyMMddhhmmssfff") + (random + i).ToString().PadLeft(4, '0');
                        ri.JobID    = job.JobID;
                        ri.CardType = new DataAccess.Para_JobType().GetModel(ri.JobType).CardType;
                        ri.IsDelete = false;
                        ri.Remark   = "现场交单.";
                        new DataAccess.ReIssueList().Add(ri);
                    }
                    Entity.SaleList riSl = new Entity.SaleList();
                    if (new DataAccess.SaleList().GetList(string.Format("JobID='{0}' and ProductType='{1}' and IsDelete=0", saleID, context.Request.Form["saleSelect"])).Tables[0].Rows.Count == 0)
                    {
                        riSl.JobType     = "SL001";
                        riSl.ListID      = riSl.JobType + "-" + time.ToString("yyyyMMddhhmmssfff") + random.ToString().PadLeft(4, '0');
                        riSl.JobID       = saleID;
                        riSl.ProductType = context.Request.Form["saleSelect"];
                        riSl.Num         = int.Parse(context.Request.Form["txtNum"]);
                        riSl.IsDelete    = false;
                        riSl.Remark      = "现场交单.";
                        new DataAccess.SaleList().Add(riSl);
                    }
                    else
                    {
                        riSl      = new DataAccess.SaleList().GetModel(new DataAccess.SaleList().GetList(string.Format("JobID='{0}' and ProductType='{1}' and IsDelete=0", saleID, context.Request.Form["saleSelect"])).Tables[0].Rows[0]["ListID"].ToString());
                        riSl.Num += int.Parse(context.Request.Form["txtNum"]);
                        new DataAccess.SaleList().Update(riSl);
                    }
                    break;

                case "RM":
                    for (int i = 0; i < int.Parse(context.Request.Form["txtNum"]); i++)
                    {
                        Entity.ReMakeList rm = new Entity.ReMakeList();
                        rm.JobType  = context.Request.Form["businessSelect"];
                        rm.ListID   = rm.JobType + "-" + time.ToString("yyyyMMddhhmmssfff") + (random + i).ToString().PadLeft(4, '0');
                        rm.JobID    = job.JobID;
                        rm.CardType = new DataAccess.Para_JobType().GetModel(rm.JobType).CardType;
                        rm.IsDelete = false;
                        rm.Remark   = "现场交单.";
                        new DataAccess.ReMakeList().Add(rm);
                    }
                    Entity.SaleList rmSl = new Entity.SaleList();
                    if (new DataAccess.SaleList().GetList(string.Format("JobID='{0}' and ProductType='{1}' and IsDelete=0", saleID, context.Request.Form["saleSelect"])).Tables[0].Rows.Count == 0)
                    {
                        rmSl.JobType     = "SL001";
                        rmSl.ListID      = rmSl.JobType + "-" + time.ToString("yyyyMMddhhmmssfff") + random.ToString().PadLeft(4, '0');
                        rmSl.JobID       = saleID;
                        rmSl.ProductType = context.Request.Form["saleSelect"];
                        rmSl.Num         = int.Parse(context.Request.Form["txtNum"]);
                        rmSl.IsDelete    = false;
                        rmSl.Remark      = "现场交单.";
                        new DataAccess.SaleList().Add(rmSl);
                    }
                    else
                    {
                        rmSl      = new DataAccess.SaleList().GetModel(new DataAccess.SaleList().GetList(string.Format("JobID='{0}' and ProductType='{1}' and IsDelete=0", saleID, context.Request.Form["saleSelect"])).Tables[0].Rows[0]["ListID"].ToString());
                        rmSl.Num += int.Parse(context.Request.Form["txtNum"]);
                        new DataAccess.SaleList().Update(rmSl);
                    }
                    break;

                case "SL":
                    Entity.SaleList sl = new Entity.SaleList();
                    if (new DataAccess.SaleList().GetList(string.Format("JobID='{0}' and ProductType='{1}' and IsDelete=0", saleID, context.Request.Form["saleSelect"])).Tables[0].Rows.Count == 0)
                    {
                        sl.JobType     = "SL001";
                        sl.ListID      = sl.JobType + "-" + time.ToString("yyyyMMddhhmmssfff") + random.ToString().PadLeft(4, '0');
                        sl.JobID       = job.JobID;
                        sl.ProductType = context.Request.Form["saleSelect"];
                        sl.Num         = int.Parse(context.Request.Form["txtNum"]);
                        sl.IsDelete    = false;
                        sl.Remark      = "现场交单.";
                        sl.ManagerFlag = 0;
                        sl.ManagerUser = PageBase.CommonObject.ManagerUserInfo.guid;
                        sl.ManagerTime = DateTime.Now;
                        new DataAccess.SaleList().Add(sl);
                    }
                    else
                    {
                        sl      = new DataAccess.SaleList().GetModel(new DataAccess.SaleList().GetList(string.Format("JobID='{0}' and ProductType='{1}' and IsDelete=0", saleID, context.Request.Form["saleSelect"])).Tables[0].Rows[0]["ListID"].ToString());
                        sl.Num += int.Parse(context.Request.Form["txtNum"]);
                        new DataAccess.SaleList().Update(sl);
                    }
                    break;

                case "UU":
                    for (int i = 0; i < int.Parse(context.Request.Form["txtNum"]); i++)
                    {
                        Entity.UpdateUnlockList uu = new Entity.UpdateUnlockList();
                        uu.JobType  = context.Request.Form["businessSelect"];
                        uu.ListID   = uu.JobType + "-" + time.ToString("yyyyMMddhhmmssfff") + (random + i).ToString().PadLeft(4, '0');
                        uu.JobID    = job.JobID;
                        uu.CardType = new DataAccess.Para_JobType().GetModel(uu.JobType).CardType;
                        uu.IsDelete = false;
                        uu.Remark   = "现场交单.";
                        new DataAccess.UpdateUnlockList().Add(uu);
                    }
                    break;
                }
                try
                {
                    if (job.JobType != "UU" && job.JobType != "MD")
                    {
                        //减少显示库存
                        Entity.Stock_Commodity mCommodity = new DataAccess.Stock_Commodity().GetEntity(context.Request.Form["saleSelect"]);
                        mCommodity.StockDesplay -= int.Parse(context.Request.Form["txtNum"]);
                        if (mCommodity.StockDesplay < 0)
                        {
                            throw new Exception(string.Format("{0}{1}({2})库存不足,请更换库存充足的安全产品厂商或稍后再试!", mCommodity.AdditionalAttributes, mCommodity.CommodityName, mCommodity.CommodityType));
                        }
                        else
                        {
                            new DataAccess.Stock_Commodity().Update(mCommodity);
                        }
                    }
                    DataAccess.TranHelper.CommitTran();
                    DataAccess.TranHelper.BeginTran();
                    //处理列表信息
                    switch (job.JobType)
                    {
                    case "MD":
                        new DataAccess.MDDataAccess().InsertHandleList(job);
                        break;

                    case "NA":
                        new DataAccess.NADataAccess().InsertHandleList(job);
                        new DataAccess.SLDataAccess().InsertHandleList(sJob);
                        break;

                    case "RI":
                        new DataAccess.RIDataAccess().InsertHandleList(job);
                        new DataAccess.SLDataAccess().InsertHandleList(sJob);
                        break;

                    case "RM":
                        new DataAccess.RMDataAccess().InsertHandleList(job);
                        new DataAccess.SLDataAccess().InsertHandleList(sJob);
                        break;

                    case "SL":
                        new DataAccess.SLDataAccess().InsertHandleList(job);
                        break;

                    case "UU":
                        new DataAccess.UUDataAccess().InsertHandleList(job);
                        break;
                    }
                    DataAccess.TranHelper.CommitTran();
                    context.Response.Write(JsonConvert.SerializeObject(new Data("", job.JobID)));
                }
                catch (Exception ex)
                {
                    context.Response.Write(JsonConvert.SerializeObject(new Data(ex.Message, "")));
                }
            }
            catch (Exception ex)
            {
                context.Response.Write(JsonConvert.SerializeObject(new Data(ex.Message, "")));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 保存提交
        /// </summary>
        /// <param name="context"></param>
        private static void Save(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            var data   = context.Request;
            var sr     = new StreamReader(data.InputStream);
            var stream = sr.ReadToEnd();
            var javaScriptSerializer = new JavaScriptSerializer();

            RequestDataJSON[] PostedData = javaScriptSerializer.Deserialize <RequestDataJSON[]>(stream);
            bool flag = true;

            if (PostedData != null)
            {
                string   jobID = null;
                DateTime time  = DateTime.Now;
                DataAccess.TranHelper.BeginTran();
                foreach (RequestDataJSON post in PostedData)
                {
                    Entity.HandleList handle = new DataAccess.HandleList().GetModel(post.id);
                    handle.IsChecked     = bool.Parse(post.operation == "" ? "false" : post.operation);
                    handle.Status        = handle.IsChecked ? "已处理" : "待处理";
                    handle.Remark        = post.remark;
                    handle.OpeartionUser = PageBase.CommonObject.ManagerUserInfo.guid;
                    handle.OpeartionTime = time;
                    jobID = handle.JobID;

                    if (handle.FunctionID.Equals("A06") && handle.JobID.IndexOf("SL") >= 0)
                    {
                        DataSet sl = new DataAccess.SaleList().GetList(string.Format("JobID='{0}' and IsDelete=0", handle.JobID));
                        if (sl.Tables[0].Select("ManagerFlag<>2").Length > 0)
                        {
                            flag = false;
                        }
                        else
                        {
                            new DataAccess.HandleList().Update(handle);
                        }
                    }
                    else
                    {
                        new DataAccess.HandleList().Update(handle);
                    }
                    if (handle.OpeartionID == 8)
                    {
                        Entity.JobInfo job = new DataAccess.JobInfo().GetModel(handle.JobID);
                        job.FeeFlat = handle.IsChecked ? "已缴费" : "待缴费";
                        new DataAccess.JobInfo().Update(job);
                    }
                }
                try
                {
                    DataAccess.TranHelper.CommitTran();
                    if (jobID != null)
                    {
                        Entity.JobInfo job = new DataAccess.JobInfo().GetModel(jobID);
                        switch (job.JobType)
                        {
                        case "NA":
                            new DataAccess.NADataAccess().ChangeFlow(job);
                            break;

                        case "MD":
                            new DataAccess.MDDataAccess().ChangeFlow(job);
                            break;

                        case "RI":
                            new DataAccess.RIDataAccess().ChangeFlow(job);
                            break;

                        case "RM":
                            new DataAccess.RMDataAccess().ChangeFlow(job);
                            break;

                        case "SL":
                            new DataAccess.SLDataAccess().ChangeFlow(job);
                            break;

                        case "UU":
                            new DataAccess.UUDataAccess().ChangeFlow(job);
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    context.Response.Write("提交失败" + ex.Message);
                }
            }
            if (flag)
            {
                context.Response.Write("提交成功");
            }
            else
            {
                context.Response.Write("工单项发放状态标记为“已发放”后,才允许修改发放环节状态!");
            }
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            DataTable dt = new DataAccess.RunProcedure().CloseList();

            foreach (DataRow dr in dt.Rows)
            {
                try
                {
                    Dictionary <string, string> result = new Dictionary <string, string>();
                    try
                    {
                        result = DataAccess.PayHelper.IPaySearch(dr["JobID"].ToString());
                    }
                    catch (Exception ex)
                    {
                        new DataAccess.Sys_Log().AddLog(string.Format("Function:CloseJob.Main;Param:{0};ErrorMsg:查询接口失败.{1}", dr["JobID"].ToString(), ex.ToString()));
                    }
                    bool IsSuccess = false;
                    if (result["status"] != null)
                    {
                        if (result["status"].Equals("Success"))
                        {
                            IsSuccess = true;
                        }
                    }
                    if (!IsSuccess)
                    {
                        //关闭工单
                        Entity.FlowInfo flow = new Entity.FlowInfo();
                        flow.Guid       = Guid.NewGuid().ToString();
                        flow.JobID      = dr["JobID"].ToString();
                        flow.FlowID     = 18;
                        flow.SubmitDate = DateTime.Now;
                        flow.SubmitUser = "******";
                        flow.Content    = "超时未支付,系统自动关闭工单。";
                        flow.IsDelete   = false;
                        try
                        {
                            if (!new DataAccess.FlowInfo().AddEx(flow))
                            {
                                new DataAccess.Sys_Log().AddLog(string.Format("Function:CloseJob.Main;Param:{0};ErrorMsg:关闭工单失败.入库失败", flow.JobID));
                            }
                        }
                        catch (Exception ex)
                        {
                            new DataAccess.Sys_Log().AddLog(string.Format("Function:CloseJob.Main;Param:{0};ErrorMsg:关闭工单失败.{1}", flow.JobID, ex.ToString()));
                        }
                        //恢复库存
                        DataTable dtSale = new DataAccess.SaleList().GetList(string.Format("JobID='{0}' and IsDelete=0", flow.JobID)).Tables[0];
                        foreach (DataRow drSale in dtSale.Rows)
                        {
                            Entity.SaleList        mSale      = new DataAccess.SaleList().DataRowToModel(drSale);
                            Entity.Stock_Commodity mCommodity = new DataAccess.Stock_Commodity().GetEntity(mSale.ProductType);
                            mCommodity.StockDesplay += mSale.Num;
                            try
                            {
                                if (!new DataAccess.Stock_Commodity().UpdateEx(mCommodity))
                                {
                                    new DataAccess.Sys_Log().AddLog(string.Format("Function:CloseJob.Main;Param:{0};ErrorMsg:恢复库存失败.入库失败", flow.JobID));
                                }
                            }
                            catch (Exception ex)
                            {
                                new DataAccess.Sys_Log().AddLog(string.Format("Function:CloseJob.Main;Param:{0};ErrorMsg:恢复库存失败.{1}", flow.JobID, ex.ToString()));
                            }
                        }
                    }
                    else
                    {
                        Entity.JobInfo    job    = new DataAccess.JobInfo().GetModel(dr["JobID"].ToString());
                        Entity.HandleList handle = new DataAccess.HandleList().GetFeeData(dr["JobID"].ToString());
                        if (job != null && handle != null)
                        {
                            //更新工单缴费信息
                            job.FeeFlat          = "已缴费";
                            handle.IsChecked     = true;
                            handle.Status        = "已处理";
                            handle.OpeartionUser = job.CustomsCode;
                            handle.OpeartionTime = DateTime.ParseExact(result["lastUpdated"], "yyyyMMddHHmmss", null).AddHours(8);
                            handle.Remark        = "网上支付";
                            try
                            {
                                if (!new DataAccess.JobInfo().UpdateEx(job) && new DataAccess.HandleList().UpdateEx(handle))
                                {
                                    new DataAccess.Sys_Log().AddLog(string.Format("Function:CloseJob.Main;Param:{0};ErrorMsg:更新工单失败.入库失败", job.JobID));
                                }
                            }
                            catch (Exception ex)
                            {
                                new DataAccess.Sys_Log().AddLog(string.Format("Function:CloseJob.Main;Param:{0};ErrorMsg:更新工单失败.{1}", job.JobID, ex.ToString()));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    new DataAccess.Sys_Log().AddLog(string.Format("Function:CloseJob.Main;Param:{0};ErrorMsg:未知错误.{1}", dr["JobID"].ToString(), ex.ToString()));
                }
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                context.Response.ContentType = "text/plain";
                string jobID                = context.Request.Form["hJobID"];
                string listID               = context.Request.Form["hListID"];//工单
                string commodity            = context.Request.Form["hCommodityID"];
                int    num                  = int.Parse(context.Request.Form["txtNum"]);
                DataAccess.RunProcedure run = new DataAccess.RunProcedure();
                DataSet view                = run.JobView(jobID, "SaleList");
                if (view.Tables[3].Rows[0]["StatusName"].Equals("未提交."))
                {
                    Entity.SaleList     sl   = new Entity.SaleList();
                    DataAccess.SaleList da   = new DataAccess.SaleList();
                    DateTime            time = DateTime.Now;

                    //判断是否已经存在选中安全产品类型的工单
                    if (da.GetList(string.Format("JobID='{0}' and IsDelete=0 and ProductType='{1}'", jobID, commodity)).Tables[0].Rows.Count > 0)
                    {
                        context.Response.Write("\n工单中已存在所选安全产品类型的工单项,请在原工单项中进行修改!");
                        return;
                    }

                    //工单缴费信息part1 - 更新为最新价格
                    Entity.JobInfo job   = new DataAccess.JobInfo().GetModel(jobID);
                    DataTable      feeDt = run.JobFeeDetal(job.JobID, "SaleList").Tables[0];
                    job.Fee = decimal.Parse(feeDt.Rows[0]["Fee"].ToString());

                    //工单项
                    if (string.IsNullOrEmpty(listID))
                    {
                        sl.JobType = "SL001";
                        sl.ListID  = sl.JobType + "-" + time.ToString("yyyyMMddhhmmssfff") + (new Random().Next(1, 10000)).ToString().PadLeft(4, '0');
                        sl.JobID   = jobID;
                    }
                    else
                    {
                        sl = da.GetModel(listID);
                        //工单缴费信息part2 - 减去修改前的价格
                        job.Fee -= new DataAccess.Stock_Commodity().GetEntity(sl.ProductType).SellingPrice *sl.Num;
                    }
                    sl.ProductType = commodity;
                    sl.Num         = num;
                    sl.IsDelete    = false;
                    sl.Remark      = "";
                    sl.ManagerFlag = 0;
                    sl.ManagerUser = PageBase.CommonObject.LoginUserInfo.companyId;
                    sl.ManagerTime = DateTime.Now;

                    //工单缴费信息part3 - 加上新的价格
                    job.Fee += new DataAccess.Stock_Commodity().GetEntity(sl.ProductType).SellingPrice *sl.Num;
                    if (job.Fee == 0)
                    {
                        job.FeeFlat = "无须缴费";
                    }
                    else
                    {
                        job.FeeFlat = "待缴费";
                    }

                    //提交数据到后台存储过程事务
                    DataAccess.TranHelper.BeginTran();
                    new DataAccess.SLDataAccess().InsertListData(sl);
                    new DataAccess.JobInfo().Update(job);
                    try
                    {
                        DataAccess.TranHelper.CommitTran();
                        context.Response.Write("");
                    }
                    catch (Exception ex)
                    {
                        context.Response.Write("\n数据提交出错!" + ex.Message);
                    }
                }
                else
                {
                    context.Response.Write("该工单状态为已提交,无法继续修改工单信息!");
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("\n" + ex.Message);
            }
        }