コード例 #1
0
ファイル: IndicatorFO.cs プロジェクト: tianzhifeng/EPC
        /// <summary>
        ///
        /// </summary>
        /// <param name="belongYear"></param>
        /// <param name="list"></param>
        public void SaveIndicator(int belongYear, List <Dictionary <string, object> > list, IndicatorType indicatorType, IndicatorOrgType orgType)
        {
            string tableName = "S_KPITEMP_INDICATORCOMPANY";

            if (orgType == IndicatorOrgType.Org)
            {
                tableName = "S_KPITEMP_INDICATORORG";
            }
            else if (orgType == IndicatorOrgType.Person)
            {
                tableName = "S_KPITEMP_INDICATORPERSON";
            }
            var db      = SQLHelper.CreateSqlHelper(ConnEnum.Market);
            var version = this.GetTmpMaxVersion(belongYear, IndicatorType.YearIndicator.ToString(), orgType);

            foreach (var item in list)
            {
                item.SetValue("BelongYear", belongYear);
                item.SetValue("IndicatorType", indicatorType.ToString());
                if (String.IsNullOrEmpty(item.GetValue("BelongQuarter")) && !String.IsNullOrEmpty(item.GetValue("BelongMonth")))
                {
                    var belongMonth = Convert.ToInt32(item.GetValue("BelongMonth"));
                    var quarter     = MarketHelper.GetQuarter(belongMonth);
                    item.SetValue("BelongQuarter", quarter);
                }
                if (String.IsNullOrEmpty(item.GetValue("Version")))
                {
                    item.SetValue("Version", version);
                    item.SetValue("CurrentVersion", YesNo.No.ToString());
                }
                if (String.IsNullOrEmpty(item.GetValue("ID")))
                {
                    item.InsertDB(db, tableName);
                }
                else
                {
                    item.UpdateDB(db, tableName, item.GetValue("ID"));
                }
            }
        }
コード例 #2
0
ファイル: IndicatorFO.cs プロジェクト: tianzhifeng/EPC
        public void CreateMonthTmpData(int belongYear, IndicatorOrgType orgType)
        {
            var    indicatorDefines = this.GetIndicatorDefine(orgType);
            var    db            = SQLHelper.CreateSqlHelper(ConnEnum.Market);
            string tempTableName = "S_KPITEMP_INDICATORCOMPANY";
            string tableName     = "S_KPI_INDICATORCOMPANY";

            if (orgType == IndicatorOrgType.Org)
            {
                tableName     = "S_KPI_INDICATORORG";
                tempTableName = "S_KPITEMP_INDICATORORG";
            }
            else if (orgType == IndicatorOrgType.Person)
            {
                tableName     = "S_KPI_INDICATORPERSON";
                tempTableName = "S_KPITEMP_INDICATORPERSON";
            }
            string sql = "SELECT * FROM {0} WHERE BELONGYEAR='{1}' AND INDICATORTYPE='{2}'  {3}";
            var    dt  = db.ExecuteDataTable(String.Format(sql, tempTableName, belongYear, IndicatorType.MonthIndicator.ToString(), "AND CURRENTVERSION='" + YesNo.Yes.ToString() + "'"));

            if (dt.Rows.Count > 0)
            {
                return;
            }
            dt = this.GetTmpMaxVersionTable(belongYear, IndicatorType.MonthIndicator.ToString(), orgType);
            var dataTable = db.ExecuteDataTable(String.Format(sql, tableName, belongYear, IndicatorType.YearIndicator.ToString(), ""));

            foreach (DataRow row in dataTable.Rows)
            {
                if (orgType == IndicatorOrgType.Org)
                {
                    if (Convert.ToInt32(dt.Compute("Count(ID)", " OrgID='" + row["OrgID"] + "'")) > 0)
                    {
                        continue;
                    }
                }
                else if (orgType == IndicatorOrgType.Person)
                {
                    if (Convert.ToInt32(dt.Compute("Count(ID)", " UserID='" + row["UserID"] + "'")) > 0)
                    {
                        continue;
                    }
                }
                for (int i = 1; i <= 12; i++)
                {
                    var dic = new Dictionary <string, object>();
                    dic.SetValue("BelongYear", belongYear);
                    dic.SetValue("BelongMonth", i);
                    dic.SetValue("BelongQuarter", MarketHelper.GetQuarter(i));
                    dic.SetValue("IndicatorType", IndicatorType.MonthIndicator.ToString());
                    dic.SetValue("CurrentVersion", YesNo.No.ToString());
                    dic.SetValue("Version", 1);
                    dic.SetValue("CreateDate", DateTime.Now);
                    dic.SetValue("BusiniessCategory", row["BusiniessCategory"]);
                    if (orgType == IndicatorOrgType.Org)
                    {
                        dic.SetValue("OrgID", row["OrgID"]);
                        dic.SetValue("OrgName", row["OrgName"]);
                        dic.SetValue("SortIndex", row["SortIndex"]);
                    }
                    else if (orgType == IndicatorOrgType.Person)
                    {
                        dic.SetValue("UserID", row["UserID"]);
                        dic.SetValue("UserName", row["UserName"]);
                    }
                    dic.InsertDB(db, tempTableName, FormulaHelper.CreateGuid());
                }
            }
        }
コード例 #3
0
ファイル: IndicatorFO.cs プロジェクト: tianzhifeng/EPC
        public void UpgradeIndicator(int belongYear, IndicatorType indicatorType, IndicatorOrgType orgType)
        {
            var    categories = this.GetIndicatorCategory(orgType);
            string tableName  = "S_KPITEMP_INDICATORCOMPANY";

            if (orgType == IndicatorOrgType.Org)
            {
                tableName = "S_KPITEMP_INDICATORORG";
            }
            else if (orgType == IndicatorOrgType.Person)
            {
                tableName = "S_KPITEMP_INDICATORPERSON";
            }
            var db         = SQLHelper.CreateSqlHelper(ConnEnum.Market);
            var data       = this.GetTmpMaxVersionData(belongYear, indicatorType.ToString(), orgType);
            var maxVersion = this.GetTmpMaxVersion(belongYear, indicatorType.ToString(), orgType) + 1;

            foreach (var item in data)
            {
                item.SetValue("Version", maxVersion);
                item.SetValue("CurrentVersion", YesNo.No.ToString());
                item.InsertDB(db, tableName, FormulaHelper.CreateGuid());
            }

            if ((orgType == IndicatorOrgType.Person || orgType == IndicatorOrgType.Org) &&
                (indicatorType == IndicatorType.QuarterIndicator || indicatorType == IndicatorType.MonthIndicator))
            {
                var maxDt    = this.GetTmpMaxVersionTable(belongYear, indicatorType.ToString(), orgType);
                var yearData = this.GetIndicateData(belongYear, IndicatorType.YearIndicator.ToString(), orgType);
                var key      = orgType == IndicatorOrgType.Org ? "OrgID" : "UserID";
                var keyName  = orgType == IndicatorOrgType.Org ? "OrgName" : "UserName";
                var count    = indicatorType == IndicatorType.QuarterIndicator ? 4 : 12;
                foreach (var item in yearData)
                {
                    var rows = maxDt.Select(key + "='" + item.GetValue(key) + "'");
                    if (rows.Length > 0)
                    {
                        continue;
                    }
                    for (int i = 1; i <= count; i++)
                    {
                        if (categories.Count > 0)
                        {
                            foreach (var category in categories)
                            {
                                var dic = new Dictionary <string, object>();
                                dic.SetValue("BelongYear", belongYear);
                                if (indicatorType == IndicatorType.MonthIndicator)
                                {
                                    dic.SetValue("BelongQuarter", MarketHelper.GetQuarter(i));
                                    dic.SetValue("BelongMonth", i);
                                }
                                else if (indicatorType == IndicatorType.QuarterIndicator)
                                {
                                    dic.SetValue("BelongQuarter", i);
                                }
                                dic.SetValue(key, item.GetValue(key));
                                dic.SetValue(keyName, item.GetValue(keyName));
                                dic.SetValue("Version", maxVersion);
                                dic.SetValue("BusiniessCategory", category.Code);
                                dic.SetValue("IndicatorType", indicatorType);
                                dic.SetValue("CurrentVersion", YesNo.No.ToString());
                                dic.SetValue("SortIndex", item.GetValue("SortIndex"));
                                dic.InsertDB(db, tableName);
                            }
                        }
                        else
                        {
                            var dic = new Dictionary <string, object>();
                            dic.SetValue("BelongYear", belongYear);
                            if (indicatorType == IndicatorType.MonthIndicator)
                            {
                                dic.SetValue("BelongQuarter", MarketHelper.GetQuarter(i));
                                dic.SetValue("BelongMonth", i);
                            }
                            else if (indicatorType == IndicatorType.QuarterIndicator)
                            {
                                dic.SetValue("BelongQuarter", i);
                            }
                            dic.SetValue(key, item.GetValue(key));
                            dic.SetValue(keyName, item.GetValue(keyName));
                            dic.SetValue("Version", maxVersion);
                            dic.SetValue("IndicatorType", indicatorType);
                            dic.SetValue("CurrentVersion", YesNo.No.ToString());
                            dic.SetValue("SortIndex", item.GetValue("SortIndex"));
                            dic.InsertDB(db, tableName);
                        }
                    }
                }
            }
        }