Beispiel #1
0
        /// <summary>
        /// 保存意见,判断单据状态
        /// </summary>
        /// <returns></returns>
        public static bool SaveComments(TravelApprovalMul traApprClass, GetUserXq userXqClass, string nodeNumber, HttpContext context, string ddUrl, string logType, out string result)
        {
            string    connectionString = ToolsClass.GetConfig("DataOnLine");
            SqlHelper SqlHelper        = new SqlHelper("SqlServer", connectionString);

            result = string.Empty;
            string       IsLocalHost  = traApprClass.IsLocalHost == null ? "0" : traApprClass.IsLocalHost;
            string       ymadk        = System.Configuration.ConfigurationManager.AppSettings["ymadk"].ToString() + "/";
            GetMulParams getMulParams = new GetMulParams();
            //将意见及日期保存到ApprovalComments表,并改变状态
            string Sql = $"update ApprovalComments set ApprovalComments='{traApprClass.AuditingIdea}',Urls='{JsonConvert.SerializeObject(traApprClass.Urls)}',ApprovalStatus='{traApprClass.IsSp}',ApprovalDate='{DateTime.Now}' where BillNo ='{traApprClass.BillNo}' and ApprovalID='{userXqClass.jobnumber}' and NodeNumber ='{int.Parse(nodeNumber) + 1}' and BillClassId='{traApprClass.BillClassId}'";

            SqlHelper.ExecSql(Sql);
            ToolsClass.TxtLog(logType, "\r\n操作ApprovalComments表:" + Sql + "\r\n");
            bool processIsEnd = false;

            //判断当前节点是领导还是非领导
            Sql = "";
            // 1 2 3 null
            Sql = $"select  distinct  IsLeader IsLeader, IsAndOr IsAndOr from ApprovalComments where BillNo ='{traApprClass.BillNo}'  and NodeNumber ='{int.Parse(nodeNumber) + 1}'  and BillClassId='{traApprClass.BillClassId}'";
            DataTable IsLeader = SqlHelper.GetDataTable(Sql);

            if (IsLeader.Rows[0]["IsLeader"].ToString() == "1")
            {
                //领导为一次审批或者会签
                if (IsLeader.Rows[0]["IsAndOr"].ToString() == "1" || IsLeader.Rows[0]["IsAndOr"].ToString() == "2")
                {
                    Sql = "";
                    // 1 2 3 null
                    Sql = $"select  count(*) from ApprovalComments where BillNo ='{traApprClass.BillNo}'  and NodeNumber ='{int.Parse(nodeNumber) + 1}' and ApprovalStatus='0'  and BillClassId='{traApprClass.BillClassId}'";
                    //当前节点未完成
                    if (SqlHelper.GetValue(Sql).ToString() != "0")
                    {
                        if (IsLocalHost == "0")
                        {
                            processIsEnd = false;
                            result       = JsonConvert.SerializeObject(getMulParams.resultGetMulParams(ymadk, traApprClass.DDAuditingId, ddUrl, SqlHelper));
                            ToolsClass.TxtLog(logType, "\r\n返回前端信息:" + result + "\r\n");
                            // context.Response.Write(result);
                        }
                        else
                        {
                            processIsEnd = false;
                            result       = JsonConvert.SerializeObject(new ResultGetMulParams {
                                errcode = "0", errmsg = "", NextUrl = ""
                            });
                            ToolsClass.TxtLog(logType, "\r\n返回前端信息:" + result + "\r\n");
                            // context.Response.Write(result);
                        }
                        return(processIsEnd);
                    }
                    else
                    {
                        processIsEnd = true;
                    }
                }
                //领导为或签
                else if (IsLeader.Rows[0]["IsAndOr"].ToString() == "3")
                {
                    processIsEnd = true;
                    Sql          = "";
                    // 1 2 3 null
                    Sql = $"select  count(*) from ApprovalComments where BillNo ='{traApprClass.BillNo}'  and NodeNumber ='{int.Parse(nodeNumber) + 1}' and ApprovalStatus='0'  and BillClassId='{traApprClass.BillClassId}'";
                    //当前节点未完成
                    if (SqlHelper.GetValue(Sql).ToString() != "0")
                    {
                        if (IsLocalHost == "0")
                        {
                            processIsEnd = false;
                            result       = JsonConvert.SerializeObject(getMulParams.resultGetMulParams(ymadk, traApprClass.DDAuditingId, ddUrl, SqlHelper));
                            ToolsClass.TxtLog(logType, "\r\n返回前端信息:" + result + "\r\n");
                            //context.Response.Write(result);
                        }
                        else
                        {
                            processIsEnd = false;
                            result       = JsonConvert.SerializeObject(new ResultGetMulParams {
                                errcode = "0", errmsg = "", NextUrl = ""
                            });
                            ToolsClass.TxtLog(logType, "\r\n返回前端信息:" + result + "\r\n");
                            // context.Response.Write(result);
                        }
                        return(processIsEnd);
                    }
                    else
                    {
                        Sql = "";
                        Sql = $"update ApprovalComments set ApprovalStatus='1',ApprovalComments='工号为{userXqClass.jobnumber}的审批人已签',ApprovalDate='{DateTime.Now}' where BillNo ='{traApprClass.BillNo}'  and NodeNumber ='{int.Parse(nodeNumber) + 1}' and BillClassId='{traApprClass.BillClassId}' and ApprovalStatus='0'";
                        SqlHelper.ExecSql(Sql);
                    }
                    ToolsClass.TxtLog(logType, "\r\n操作ApprovalComments表:" + Sql + "\r\n");
                }
            }

            //如果不是领导
            if (IsLeader.Rows[0]["IsLeader"].ToString() != "1")
            {
                if (IsLeader.Rows[0]["IsAndOr"].ToString() == "1" || IsLeader.Rows[0]["IsAndOr"].ToString() == "2")
                {
                    Sql = "";
                    // 1 2 3 null
                    Sql = $"select  count(*) from ApprovalComments where BillNo ='{traApprClass.BillNo}'  and NodeNumber ='{int.Parse(nodeNumber) + 1}' and ApprovalStatus='0'  and BillClassId='{traApprClass.BillClassId}'";
                    //当前节点未完成
                    if (SqlHelper.GetValue(Sql).ToString() != "0")
                    {
                        if (IsLocalHost == "0")
                        {
                            processIsEnd = false;
                            result       = JsonConvert.SerializeObject(getMulParams.resultGetMulParams(ymadk, traApprClass.DDAuditingId, ddUrl, SqlHelper));
                            ToolsClass.TxtLog(logType, "\r\n返回前端信息:" + result + "\r\n");
                            //context.Response.Write(result);
                        }
                        else
                        {
                            processIsEnd = false;
                            result       = JsonConvert.SerializeObject(new ResultGetMulParams {
                                errcode = "0", errmsg = "", NextUrl = ""
                            });
                            ToolsClass.TxtLog(logType, "\r\n返回前端信息:" + result + "\r\n");
                            //context.Response.Write(result);
                        }
                        return(processIsEnd);
                    }
                    else
                    {
                        processIsEnd = true;
                    }
                }
                else if (IsLeader.Rows[0]["IsAndOr"].ToString() == "3")
                {
                    processIsEnd = true;
                    Sql          = "";
                    // 1 2 3 null
                    Sql = $"select  count(*) from ApprovalComments where BillNo ='{traApprClass.BillNo}'  and NodeNumber ='{int.Parse(nodeNumber) + 1}' and ApprovalStatus='0'  and BillClassId='{traApprClass.BillClassId}'";
                    //当前节点未完成
                    if (SqlHelper.GetValue(Sql).ToString() != "0")
                    {
                        if (IsLocalHost == "0")
                        {
                            processIsEnd = false;
                            result       = JsonConvert.SerializeObject(getMulParams.resultGetMulParams(ymadk, traApprClass.DDAuditingId, ddUrl, SqlHelper));
                            ToolsClass.TxtLog(logType, "\r\n返回前端信息:" + result + "\r\n");
                            // context.Response.Write(result);
                        }
                        else
                        {
                            processIsEnd = false;
                            result       = JsonConvert.SerializeObject(new ResultGetMulParams {
                                errcode = "0", errmsg = "", NextUrl = ""
                            });
                            ToolsClass.TxtLog(logType, "\r\n返回前端信息:" + result + "\r\n");
                            //  context.Response.Write(result);
                        }
                        return(processIsEnd);
                    }
                    else
                    {
                        Sql = "";
                        Sql = $"update ApprovalComments set ApprovalStatus='1',ApprovalComments='工号为{userXqClass.jobnumber}的审批人已签',ApprovalDate='{DateTime.Now}' where BillNo ='{traApprClass.BillNo}'  and NodeNumber ='{int.Parse(nodeNumber) + 1}' and BillClassId='{traApprClass.BillClassId}' and ApprovalStatus='0'";
                        SqlHelper.ExecSql(Sql);
                    }
                    ToolsClass.TxtLog(logType, "\r\n操作ApprovalComments表:" + Sql + "\r\n");
                }
                else
                {
                    processIsEnd = true;
                }
            }

            return(processIsEnd);
        }
Beispiel #2
0
        public ResultGetMulParams resultGetMulParams(string ymadk, string spid, string ddUrl, SqlHelper sqlHelper)
        {
            try
            {
                HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(ymadk + "/SelApproval");
                webrequest.Method = "post";
                GetMulParams mulParams = new GetMulParams
                {
                    SpTypeId     = "2",
                    Value        = "",
                    WTypeId      = "1",
                    DDOperatorId = spid,
                    Sign         = "70F1A62A657B745EB80137B1ED90D56D"
                };
                byte[] postdatabyte = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(mulParams));
                webrequest.ContentLength = postdatabyte.Length;
                Stream stream;
                stream = webrequest.GetRequestStream();
                stream.Write(postdatabyte, 0, postdatabyte.Length);
                stream.Close();
                string mulresult = string.Empty;
                using (var httpWebResponse = webrequest.GetResponse())
                    using (StreamReader responseStream = new StreamReader(httpWebResponse.GetResponseStream()))
                    {
                        mulresult = responseStream.ReadToEnd();
                    }

                string       NextUrl      = "";
                GetMulResult getMulResult = (GetMulResult)JsonConvert.DeserializeObject(mulresult, typeof(GetMulResult));
                ToolsClass.TxtLog("查询下条待审批日志", "\r\n接口返回信息:" + mulresult + "\r\n");
                string billno    = "";
                string ApplyDDId = "";
                string ApplyName = "";
                //http://oatest.romens.cn:8085/clfui/shenpi/index.html?BillNo=CL10602201910240021_B&BillClassId=71DFE51C-D684-41DD-B1E5-3DF1740978DD&showmenu=false
                // http://oatest.romens.cn:8085/txfui/shenpi/index.html?BillNo=TXF10653201909120003&BillClassId=B56B70A7-ECDC-4FCF-82C1-B5A37D0B88D4&showmenu=false
                if (getMulResult.Detail != null)
                {
                    billno    = getMulResult.Detail[getMulResult.Detail.Count - 1].BillNo;
                    ApplyDDId = getMulResult.Detail[getMulResult.Detail.Count - 1].InsteadOperatorGuid;
                    ApplyName = sqlHelper.GetValue($"select top 1 employeename from flowemployee where ddid = '{ApplyDDId}'").SqlDataBankToString();
                    string BillClassId = getMulResult.Detail[getMulResult.Detail.Count - 1].BillClassId;
                    if (billno.Contains("CL"))
                    {
                        NextUrl = ddUrl + "/clfui/shenpi/index.html?BillNo=" + billno + "&BillClassId=" + BillClassId + "&showmenu=false";
                    }
                    else if (billno.Contains("JTF"))
                    {
                        NextUrl = ddUrl + "/jtfui/shenpi/index.html?BillNo=" + billno + "&BillClassId=" + BillClassId + "&showmenu=false";
                    }
                    else if (billno.Contains("TXF"))
                    {
                        NextUrl = ddUrl + "/txfui/shenpi/index.html?BillNo=" + billno + "&BillClassId=" + BillClassId + "&showmenu=false";
                    }
                    else if (billno.Contains("ZDF"))
                    {
                        NextUrl = ddUrl + "/zdfui/shenpi/index.html?BillNo=" + billno + "&BillClassId=" + BillClassId + "&showmenu=false";
                    }
                    else if (billno.Contains("QTFY"))
                    {
                        NextUrl = ddUrl + "/qtfyui/shenpi/index.html?BillNo=" + billno + "&BillClassId=" + BillClassId + "&showmenu=false";
                    }
                }
                return(new ResultGetMulParams {
                    errcode = "0", errmsg = "", NextUrl = NextUrl, BillNo = billno, ApplyDDId = ApplyDDId, ApplyName = ApplyName
                });
            }
            catch (System.Exception ex)
            {
                return(new ResultGetMulParams {
                    errcode = "1", errmsg = JsonConvert.SerializeObject(ex), NextUrl = "", BillNo = "", ApplyDDId = "", ApplyName = ""
                });
            }
        }