Exemplo n.º 1
0
        /// <summary>
        /// 流程结束时调用
        /// </summary>
        /// <param name="ec"></param>
        public void FlowEnd(WorkFlowExecutionContext ec)
        {
            long phid = Convert.ToInt64(ec.BillInfo.PK1);
            var  mst  = base.Find(phid);

            //更新状态为已审批
            if (mst.Data.FApproveStatus != Convert.ToInt32(EnumApproveStatus.Approved).ToString())
            {
                mst.Data.FApproveStatus = Convert.ToInt32(EnumApproveStatus.Approved).ToString();


                mst.Data.FApproveDate = DateTime.Today;
                mst.Data.FApprover    = base.UserID;
                CurrentRule.Update <Int64>(mst.Data);
            }
            //调整单据审批结束将原调整中改为调整完成
            if (mst.Data.FType == "tz")
            {
                Dictionary <string, object> dicWhere = new Dictionary <string, object>();
                new CreateCriteria(dicWhere)
                .Add(ORMRestrictions <string> .Eq("FDeclarationDept", mst.Data.FDeclarationDept))
                .Add(ORMRestrictions <string> .Eq("FProjAttr", mst.Data.FProjAttr))
                .Add(ORMRestrictions <string> .Eq("FApproveStatus", "6"));
                IList <GHSubjectModel> models = GHSubjectRule.Find(dicWhere);
                if (models.Count > 0)
                {
                    foreach (GHSubjectModel a in models)
                    {
                        a.FApproveStatus = "7";
                        //a.PersistentState = PersistentState.Modified;
                        CurrentRule.Update <Int64>(a);
                    }
                    //GHSubjectRule.Save(models, "");
                    //CurrentRule.Update<Int64>(models);
                }
            }
            //throw new NotImplementedException();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 纳入预算同步数据到老G6H数据库
        /// </summary>
        /// <returns></returns>
        public string AddDataSP()
        {
            string result = "";

            List <string> FProjNameList = new List <string>();

            FProjNameList.Add("各部门收入预算汇总数据");
            FProjNameList.Add("各部门基本支出汇总数据");

            Dictionary <string, object> dicWhere = new Dictionary <string, object>();

            new CreateCriteria(dicWhere)
            .Add(ORMRestrictions <List <string> > .In("FProjName", FProjNameList))
            .Add(ORMRestrictions <string> .Eq("FYear", ConfigHelper.GetString("DBG6H_Year")));

            IList <GHSubjectModel> SubjectList = GHSubjectRule.Find(dicWhere);
            List <string>          OrgList     = new List <string>();

            if (SubjectList.Count > 0)
            {
                for (var x = 0; x < SubjectList.Count; x++)
                {
                    if (!OrgList.Contains(SubjectList[x].FDeclarationUnit))
                    {
                        OrgList.Add(SubjectList[x].FDeclarationUnit);
                    }
                }
                for (var y = 0; y < OrgList.Count; y++)
                {
                    List <string>               valuesqlList = new List <string>();
                    List <DateTime?>            DJRQList     = new List <DateTime?>();
                    List <string>               mstSqlList   = new List <string>();
                    List <string>               MstCodeList  = new List <string>();
                    List <string>               dtlSqlList   = new List <string>();
                    Dictionary <string, object> conndic      = new Dictionary <string, object>();
                    new CreateCriteria(conndic)
                    .Add(ORMRestrictions <string> .Eq("Dylx", "config"))
                    .Add(ORMRestrictions <string> .Eq("DefStr1", OrgList[y]));
                    IList <CorrespondenceSettings2Model> CorrespondenceSettings2s = CorrespondenceSettings2Rule.RuleHelper.Find(conndic);
                    if (CorrespondenceSettings2s.Count > 0 && CorrespondenceSettings2s[0].DefStr2 != null)
                    {
                        string userConn = CorrespondenceSettings2s[0].DefStr2;
                        string zbly_dm  = CorrespondenceSettings2s[0].DefStr3;
                        try
                        {
                            int ID = BudgetMstRule.GetId(userConn);
                            for (var i = 0; i < SubjectList.Count; i++)
                            {
                                if (OrgList[y] == SubjectList[i].FDeclarationUnit)
                                {
                                    GHSubjectModel Subject = SubjectList[i];
                                    string         DWDM;

                                    IList <QtOrgDygxModel> OrgDygx = QtOrgDygxRule.findByXmorg(Subject.FDeclarationUnit);
                                    if (OrgDygx.Count > 0)
                                    {
                                        //Subject.FDeclarationUnit = OrgDygx[0].Oldorg;
                                        DWDM = OrgDygx[0].Oldorg;
                                    }
                                    else
                                    {
                                        DWDM = Subject.FDeclarationUnit;
                                    }

                                    DateTime?DJRQ = Subject.FDateofDeclaration;
                                    //string DWDM = Subject.FDeclarationUnit;
                                    //string ZY = Subject.FDeclarationDept;
                                    //string DEF_STR7 = Subject.FDeclarationDept;

                                    int year = int.Parse(Subject.FYear);
                                    IList <SubjectMstModel> MstList = SubjectMstRule.FindByForeignKey(SubjectList[i].PhId);
                                    if (MstList.Count > 0)
                                    {
                                        for (var j = 0; j < MstList.Count; j++)
                                        {
                                            SubjectMstModel Mst = MstList[j];
                                            if (Mst.FProjCode != "" && Mst.FProjCode != null)
                                            {
                                                string YSKM_DM = Mst.FSubjectCode;
                                                //decimal PAY_JE = Mst.FProjAmount;
                                                string ZY;
                                                string DEF_STR7;
                                                IList <QtOrgDygxModel> OrgZY = QtOrgDygxRule.findByXmorg(Subject.FDeclarationUnit);
                                                if (OrgZY.Count > 0)
                                                {
                                                    ZY       = OrgZY[0].Oldbudget;
                                                    DEF_STR7 = OrgZY[0].Oldbudget;
                                                }
                                                else
                                                {
                                                    ZY       = Mst.FFillDept;
                                                    DEF_STR7 = Mst.FFillDept;
                                                }


                                                Dictionary <string, object> dicWhere2 = new Dictionary <string, object>();
                                                new CreateCriteria(dicWhere2)
                                                .Add(ORMRestrictions <string> .Eq("FProjCode", Mst.FProjCode))
                                                .Add(ORMRestrictions <Int64> .Eq("Mstphid", SubjectList[i].PhId));

                                                IList <SubjectMstBudgetDtlModel> DtlList = SubjectMstBudgetDtlRule.Find(dicWhere2);
                                                if (DtlList.Count > 0)
                                                {
                                                    string mstSql = "('" + "zc" + Mst.FProjCode + "','" + Mst.FProjName + "','zc')";
                                                    if (!MstCodeList.Contains(Mst.FProjCode))
                                                    {
                                                        MstCodeList.Add(Mst.FProjCode);
                                                        mstSqlList.Add(mstSql);
                                                    }
                                                    for (var a = 0; a < DtlList.Count; a++)
                                                    {
                                                        SubjectMstBudgetDtlModel Dtl = DtlList[a];
                                                        ID += 1;
                                                        decimal PAY_JE   = Dtl.FAmount;
                                                        string  DJH      = ID.ToString();
                                                        string  DEF_STR1 = "zc" + Mst.FProjCode;
                                                        string  MXXM     = "zc" + Dtl.FProjCode + "-" + (a + 1).ToString();
                                                        string  DEF_STR8 = "";
                                                        if (Dtl.FExpensesChannel != null && Dtl.FExpensesChannel != "")
                                                        {
                                                            IList <QtOrgDygxModel> OrgZCQD = QtOrgDygxRule.findByXmorg(Dtl.FExpensesChannel);
                                                            if (OrgZCQD.Count > 0)
                                                            {
                                                                // Dtl.FExpensesChannel = OrgZCQD[0].Oldorg;
                                                                DEF_STR8 = OrgZCQD[0].Oldorg;
                                                            }
                                                            else
                                                            {
                                                                DEF_STR8 = Dtl.FExpensesChannel;
                                                            }
                                                        }
                                                        //string DEF_STR8 = Dtl.FExpensesChannel;

                                                        string valuesql = "(" + ID + ",'" + DJH + "','" + DWDM + "','" + YSKM_DM + "'," + PAY_JE + ",'" + ZY + "','" +
                                                                          MXXM + "','" + DEF_STR7 + "','" + DEF_STR8 + "'," + year + ",'" + DEF_STR1 + "'";
                                                        string dtlSql = "('jj','" + "zc" + Mst.FProjCode + "','" + MXXM + "','" + Dtl.FDtlName + "','zc')";
                                                        valuesqlList.Add(valuesql);
                                                        DJRQList.Add(DJRQ);
                                                        dtlSqlList.Add(dtlSql);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            GHSubjectRule.AddDataSP(userConn, zbly_dm, valuesqlList, mstSqlList, dtlSqlList, DJRQList);
                        }
                        catch (Exception e)
                        {
                            result = result + OrgList[y] + ",";
                        }
                    }
                    else
                    {
                        result = result + OrgList[y] + ",";
                    }
                }
            }
            if (result != "")
            {
                result = result.Substring(0, result.Length - 1);
                result = result + "同步失败";
            }
            return(result);
        }