Пример #1
0
        /// <summary>
        /// 入口函数
        /// </summary>
        /// <param name="vouchtype"></param>
        /// <param name="dsHead"></param>
        /// <param name="dsBody"></param>
        public void Run(string vouchtype, DataSet dsHead, DataSet dsBody)
        {
            Model.Synergismlog log = new Synergismlog();
            log.OP       = (APIOp)ClassFactory.GetBaseOp(vouchtype, tasktype);
            log.TaskType = tasktype;

            DealResult dr = new DealResult();

            dr.ResultNum = Constant.ResultNum_NoError;

            BLL.TaskLog.ITaskLogDetail logdtbll = ClassFactory.GetITaskLogDetailBLL(log.TaskType);
            BLL.TaskLog.ITaskLogMain   logbll   = ClassFactory.GetITaskLogMainBLL(log.TaskType);

            Model.Synergismlogdt fdt = logdtbll.GetFrist(log, log.OP);

            //把记录设为处理中
            log.Cstatus = Constant.SynerginsLog_Cstatus_Dealing;
            log.Endtime = DateTime.Now;
            logbll.Update(log, log.OP);

            //预置为完成
            log.Cstatus = Constant.SynerginsLog_Cstatus_Complete;

            //获取下一节点(节点数可能大于1)
            List <Model.Synergismlogdt> listnext = logdtbll.GetNext(fdt, log.OP);

            //协同操作
            dr = MakeLogDT(vouchtype, dsHead, dsBody, log, dr, logdtbll, logbll, fdt, listnext);
        }
Пример #2
0
        /// <summary>
        /// 获取上游单据审核日期
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static string GetVerifyData(Model.Synergismlogdt dt)
        {
            string strDefault = DateTime.Now.ToString("yyyy-MM-dd").Replace('.', '-').Replace('/', '-');

            if (dt.Ilineno <= 1)
            {
                return(strDefault);
            }

            BLL.TaskLog.ITaskLogDetail bllDT = ClassFactory.GetITaskLogDetailBLL(dt.TaskType);
            DAL.TaskLog.ITaskLogDetail dalDT = ClassFactory.GetITaskLogDetailDAL(dt.TaskType);
            Model.Synergismlogdt       dtPrev;
            dtPrev = bllDT.GetPrevious(dt, dt.OP);
            Model.ConnectInfo ConnectStr = dalDT.getConnectStr(dtPrev);

            return(DAL.Common.GetVerifyDate(ConnectStr, dtPrev));
        }
Пример #3
0
        /// <summary>
        /// 判断日志中记录的单据在账套中是否真的存在    added by liuxzha 2015.03.23
        /// 日志查询界面使用
        /// </summary>
        /// <param name="autoid"></param>
        /// <returns> 0 本节点没有生成,子结点也没生成;
        ///           10 本节点生成,子结点没有生成,单据为未审核状态
        ///           11 本节点生成,子结点没有生成,单据为已审核状态
        ///           100 本节点没有生成,子结点已经生成
        ///           110 本节点生成,子结点也已经生成,单据为未审核状态
        ///           111 本节点生成,子结点也已经生成,单据为已审核状态</returns>
        public int ChkExistsInData(string autoid)
        {
            int res = 0;

            //bool bHasCreateChild = false; //在日志中是否已生成子节点

            DAL.TaskLog.ITaskLogDetail daldt    = ClassFactory.GetITaskLogDetailDAL(3);
            BLL.TaskLog.ITaskLogDetail logdtbll = ClassFactory.GetITaskLogDetailBLL(3);
            Model.Synergismlogdt       dt       = daldt.GetModel(autoid);

            List <Model.Synergismlogdt> nextlist = logdtbll.GetNext(dt, null);

            foreach (Model.Synergismlogdt next in nextlist)
            {
                if (!string.IsNullOrEmpty(next.Cvoucherno))
                {
                    //bHasCreateChild = true;
                    res += 100;
                }
            }

            BaseData bd = ClassFactory.GetBaseData(dt);

            bd.Dodelete            = true;
            bd.Synergismlogdt      = dt;
            bd.Fristsynergismlogdt = daldt.GetFirst(dt);
            BaseOp op = ClassFactory.GetBaseOp(dt);

            op.MakeData(dt, bd);
            Model.APIData apidata = bd as Model.APIData;
            string        vouchid = op.GetCodeorID(dt.Cvoucherno, bd, "id");

            if (!string.IsNullOrEmpty(vouchid))
            {
                res += 10;   //本节点已生成
                if (((APIOp)op).CheckAuditStatus(dt.Cvoucherno, apidata.ConnectInfo.Constring))
                {
                    res += 1;
                }
            }

            return(res);
        }
Пример #4
0
        public override Model.DealResult MakeVouch(BaseData bd)
        {
            Model.DealResult dr   = new Model.DealResult();
            DbHelperSQLP     help = new DbHelperSQLP(bd.ConnectInfo.Constring);
            string           sql  = "select cvalue from accinformation  with(nolock)  where  cname = 'bSAcreat' and ISNULL(cValue,'')<>''";
            string           flag = help.GetSingle(sql).NullToString();

            if (flag.ToLower() != "true")
            {
                return(base.MakeVouch(bd));
            }

            Model.Synergismlogdt       dt     = bd.Synergismlogdt;
            BLL.TaskLog.ITaskLogDetail bll    = ClassFactory.GetITaskLogDetailBLL(bd.TaskType);
            Model.Synergismlogdt       prnext = bll.GetPrevious(dt, null);
            if (prnext.Cvouchertype != "01" && prnext.Cvouchertype != "03")
            {
                return(base.MakeVouch(bd));                                                              //modified by liuxzha 支持退货单
            }
            string id   = string.Empty;
            int    time = 1;

            while (string.IsNullOrEmpty(id) && time < 5)
            {
                sql = "select id from rdrecord32   with(nolock) where cbuscode='" + prnext.Cvoucherno + "'";
                id  = help.GetSingle(sql).NullToString();
                System.Threading.Thread.Sleep(1000 * time);
                time++;
            }
            if (string.IsNullOrEmpty(id))
            {
                throw new Exception("未能取到U8系统自动生成的出库单!");
            }
            // DAL.Common.WriteWinLog(id);
            dr.VouchIdRet = id;
            return(dr);
        }
Пример #5
0
        /// <summary>
        /// XTLibrary 入口函数
        /// 通过任务主表获取需要执行的任务并执行任务
        /// </summary>
        /// <param name="log"></param>
        /// <returns></returns>
        public void Run(Model.Synergismlog log)
        {
            System.Diagnostics.Trace.WriteLine("begin Run(Model.Synergismlog log)   ");

            System.Diagnostics.Trace.WriteLine("before log.OPClass   ");
            log.OPClass = log.OPClass;
            log.OP      = ClassFactory.GetBaseOp(log);
            DealResult dr = new DealResult();

            dr.ResultNum = Constant.ResultNum_NoError;
            System.Diagnostics.Trace.WriteLine("after log.OPClass   ");


            System.Diagnostics.Trace.WriteLine("before ITaskLogDetail  ");
            BLL.TaskLog.ITaskLogDetail logdtbll = ClassFactory.GetITaskLogDetailBLL(log.TaskType);
            System.Diagnostics.Trace.WriteLine("after ITaskLogDetail  ");

            System.Diagnostics.Trace.WriteLine("before ITaskLogMain  ");
            BLL.TaskLog.ITaskLogMain logbll = ClassFactory.GetITaskLogMainBLL(log.TaskType);
            System.Diagnostics.Trace.WriteLine("after ITaskLogMain  ");


            System.Diagnostics.Trace.WriteLine("before logdtbll.GetFrist  ");
            Model.Synergismlogdt fdt = logdtbll.GetFrist(log, log.OP);
            System.Diagnostics.Trace.WriteLine("after logdtbll.GetFrist  ");

            //挂起主表(置于等待中)
            if (fdt.Cstatus == Constant.SynergisnLogDT_Cstatus_NoAudit)
            {
                log.Cstatus = Constant.SynerginsLog_Cstatus_Wait;
                log.Endtime = DateTime.Now;
                logbll.Update(log, log.OP);
                //return dr;
            }

            //把记录设为处理中
            log.Cstatus = Constant.SynerginsLog_Cstatus_Dealing;
            log.Endtime = DateTime.Now;
            logbll.Update(log, log.OP);

            //预置为完成
            log.Cstatus = Constant.SynerginsLog_Cstatus_Complete;

            //获取下一节点(节点数可能大于1)
            List <Model.Synergismlogdt> listnext = logdtbll.GetNext(fdt, log.OP);

            //协同操作

            System.Diagnostics.Trace.WriteLine("before MakeLogDT  ");
            dr = MakeLogDT(log, dr, logdtbll, logbll, fdt, listnext);
            System.Diagnostics.Trace.WriteLine("after MakeLogDT  ");

            //发送消息


            //更新最终状态
            log.Endtime = DateTime.Now;
            logbll.Update(log, log.OP);

            // return dr;
        }
Пример #6
0
        /// <summary>
        /// 删除
        /// added by liuxzha 2016.03.08
        /// </summary>
        /// <param name="taskType">任务类别 0 CQ 1 XT</param>
        /// <param name="autoid"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public DealResult DeleteVouch(int tasktype, Synergismlogdt dt)
        {
            DealResult dr = new DealResult();

            try
            {
                DAL.TaskLog.ITaskLogDetail daldt    = ClassFactory.GetITaskLogDetailDAL(tasktype);
                BLL.TaskLog.ITaskLogDetail logdtbll = ClassFactory.GetITaskLogDetailBLL(tasktype);


                #region 协同 校验
                if (tasktype.Equals("1"))
                {
                    List <Model.Synergismlogdt> nextlist = logdtbll.GetNext(dt, null);

                    foreach (Model.Synergismlogdt next in nextlist)
                    {
                        if (!string.IsNullOrEmpty(next.Cvoucherno))
                        {
                            dr.ResultNum = -1;
                            dr.ResultMsg = "下游单据未删除,请先删除下游单据";
                            return(dr);
                        }
                    }
                }
                #endregion

                BaseData bd = ClassFactory.GetBaseData(dt);
                bd.Dodelete            = true;
                bd.Synergismlogdt      = dt;
                bd.Fristsynergismlogdt = daldt.GetFirst(dt);
                BaseOp op = ClassFactory.GetBaseOp(dt);
                op.MakeData(dt, bd);

                string vouchid = op.GetCodeorID(dt.Cvoucherno, bd, "id");

                if (!string.IsNullOrEmpty(vouchid))
                {
                    dr = op.UndoMake(bd, dt);
                }

                if (dr.ResultNum < Constant.ResultNum_NoError)
                {
                    return(dr);
                }
                dt.Cstatus    = Constant.SynergisnLogDT_Cstatus_Delete;
                dt.Cvoucherno = string.Empty;
                daldt.Update(dt);
                DAL.TaskLog.ITaskLogMain logdal = ClassFactory.GetITaskLogMainDAL(tasktype);


                Model.Synergismlog log = logdal.GetModel(dt.Id, dt.OP);
                log.Cstatus = Constant.SynerginsLog_Cstatus_Wait;
                logdal.Update(log, dt.OP);
            }
            catch (Exception ex)
            {
                dr.ResultMsg = ex.ToString();
                dr.ResultNum = -1;
            }
            return(dr);
        }
Пример #7
0
        /// <summary>
        /// 生单\审核 主函数
        /// </summary>
        /// <param name="log">任务主表信息</param>
        /// <param name="dr"></param>
        /// <param name="logdtbll">任务子表信息</param>
        /// <param name="logbll">任务主表BLL</param>
        /// <param name="fdt">首节点信息</param>
        /// <param name="listnext">当前任务节点信息,档案同步时有可能存在多个子结点</param>
        /// <returns></returns>
        private DealResult MakeLogDT(Synergismlog log, DealResult dr, BLL.TaskLog.ITaskLogDetail logdtbll, BLL.TaskLog.ITaskLogMain logbll, Model.Synergismlogdt fdt, List <Model.Synergismlogdt> listnext)
        {
            for (int i = 0; i < listnext.Count; i++)
            {
                System.Diagnostics.Trace.WriteLine("listnext.Count:  " + listnext.Count);

                Synergismlogdt       preDt;
                Model.Synergismlogdt nextdt = listnext[i];

                ////处理数据开始
                try
                {
                    System.Diagnostics.Trace.WriteLine("  处理数据开始  ");

                    BaseData bd = ClassFactory.GetBaseData(nextdt);
                    bd.Fristsynergismlogdt = fdt;
                    bd.Synergismlogdt      = nextdt;

                    BaseOp op = ClassFactory.GetBaseOp(nextdt);
                    nextdt.OP = op;
                    preDt     = logdtbll.GetPrevious(nextdt, nextdt.OP);
                    if (op == null)
                    {
                        throw new Exception("插件安装错误");
                    }

                    if (nextdt.Cdealmothed == 3)  //删除
                    {
                        TaskOperator t = new TaskOperator();
                        return(t.DeleteVouch(0, nextdt));
                    }
                    else if (nextdt.Cdealmothed == 2)  //修改
                    {
                    }



                    System.Diagnostics.Trace.WriteLine("  before MakeData  ");
                    dr = op.MakeData(nextdt, bd);
                    System.Diagnostics.Trace.WriteLine("  after MakeData  ");


                    string ccode;
                    if (nextdt.Cstatus != DAL.Constant.SynergisnLogDT_Cstatus_NoAudit)
                    {
                        if (nextdt.Cdealmothed == 2)
                        {
                            dr = op.MakeUpdate(bd);
                            return(dr);
                        }

                        System.Diagnostics.Trace.WriteLine("  before MakeVouch  ");
                        dr = op.MakeVouch(bd);  //生单、档案协同
                        System.Diagnostics.Trace.WriteLine("  after MakeVouch  ");

                        if (dr.ResultNum == DAL.Constant.ResultNum_NormalError)
                        {
                            throw new Exception("API错误:" + dr.ResultMsg);
                        }

                        ccode = op.GetCodeorID(dr.VouchIdRet, bd, "code");

                        nextdt.Cstatus    = DAL.Constant.SynergisnLogDT_Cstatus_NoAudit;
                        nextdt.Dmaketime  = DateTime.Now;
                        nextdt.Cvoucherno = ccode;
                        logdtbll.Update(nextdt, nextdt.OP);
                    }
                    else
                    {
                        ccode = nextdt.Cvoucherno;
                    }

                    if (string.IsNullOrEmpty(ccode))
                    {
                        //throw new Exception("获取上游单据失败");

                        if (nextdt.Cstatus != DAL.Constant.SynergisnLogDT_Cstatus_NoAudit)
                        {
                            nextdt.Cstatus = DAL.Constant.SynerginsLog_Cstatus_NoDeal;
                        }
                        nextdt.Dmaketime  = DateTime.Now;
                        nextdt.Cvoucherno = ccode;
                        logdtbll.Update(nextdt, nextdt.OP);
                        break;
                    }

                    if (nextdt.Isaudit == DAL.Constant.SynergisnLogDT_Isaudit_True)
                    {
                        nextdt.Cstatus = DAL.Constant.SynergisnLogDT_Cstatus_Complete;
                        dr             = op.MakeAudit(bd, nextdt); //审核单据
                    }
                    else
                    {
                        nextdt.Cstatus = DAL.Constant.SynergisnLogDT_Cstatus_NoAudit;
                    }
                    //nextdt.Cstatus = Constant.SynergisnLogDT_Cstatus_Complete;
                    nextdt.Dmaketime  = DateTime.Now;
                    nextdt.Cvoucherno = ccode;
                    logdtbll.Update(nextdt, nextdt.OP);

                    //log.Cstatus = DAL.Common.SetLogStatus(log.Cstatus, Constant.SynerginsLog_Cstatus_Complete);
                    if (nextdt.Isaudit == DAL.Constant.SynergisnLogDT_Isaudit_True)
                    {
                        log.Cstatus = DAL.Common.SetLogStatus(log.Cstatus, DAL.Constant.SynerginsLog_Cstatus_Complete);
                    }
                    else
                    {
                        log.Cstatus = DAL.Common.SetLogStatus(log.Cstatus, DAL.Constant.SynerginsLog_Cstatus_Wait);
                        break;
                    }
                    List <Model.Synergismlogdt> listnl = logdtbll.GetNext(nextdt, nextdt.OP);
                    MakeLogDT(log, dr, logdtbll, logbll, fdt, listnl);
                }
                catch (Exception ex)
                {
                    dr.ResultNum = DAL.Constant.ResultNum_NormalError;
                    dr.ResultMsg = ex.Message;
                    Log.WriteWinLog(ex.ToString());
                    nextdt.Cstatus    = DAL.Constant.SynergisnLogDT_Cstatus_Error;
                    nextdt.Cerrordesc = ex.Message;
                    nextdt.Errortimes++;
                    nextdt.Dmaketime = DateTime.Now;
                    logdtbll.Update(nextdt, nextdt.OP);
                    preDt = logdtbll.GetPrevious(nextdt, nextdt.OP);

                    log.Cstatus = DAL.Common.SetLogStatus(log.Cstatus, DAL.Constant.SynerginsLog_Cstatus_Error);
                }
            }

            return(dr);
        }