Esempio n. 1
0
        public void Index()
        {
            var context = HttpContext;

            _dealerId   = context.Request["DealerId"];
            _dealerName = context.Request["DealerName"];
            ScoreManage sm = ScoreManage.LoadGradeObject("loadfullscorestruct", "C_Grade", new StructNames(false), LoadDealerInfo, System.Configuration.ConfigurationManager.AppSettings["BPMEngine"]);

            context.Response.Write(JsonConvert.SerializeObject(sm.GetGrade()));
        }
Esempio n. 2
0
        private string GetGrade()
        {
            ScoreManage   sm     = ScoreManage.LoadGradeObject("loadfullscorestruct", "C_Grade", new StructNames(false), LoadDealerInfo, System.Configuration.ConfigurationManager.AppSettings["BPMEngine"]);
            List <Dealer> result = sm.GetGrade(true);

            if (result == null || result.Count <= 0 || result[0].ResultList.Count <= 0)
            {
                return("");
            }
            else
            {
                return(result[0].ResultList[0].ResultGrade);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 读取数据和计算评分
        /// </summary>
        /// <returns>评分json</returns>
        static string LoadDataAndGetGrade()
        {
            Log.WriteLog(true, "开始读取数据结构", 0.0, null);
            ScoreManage sm = ScoreManage.LoadGradeObject("loadfullscorestruct", "C_Grade", new StructNames(), LoadDealerInfo, Config.Settings["Engine"]);

            //ScoreManage.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteDataTable("TRUNCATE TABLE C_JXSMC ");
            //Log.WriteLog(true, sm.GetGradeLog, 0);
            sm.ReCordLog = Program.recordLog;
            Log.WriteLog(true, "开始计算评分", 0.0, null);
            List <Dealer> dealers = sm.GetGrade(true);

            if (Program.recordLog)
            {
                Log.WriteLog(true, sm.GetGradeLog, 0.0, null);
            }
            JArray        jarray  = new JArray();
            JArray        ret     = new JArray();
            List <string> sqlList = new List <string>();

            foreach (Dealer item in dealers)
            {
                JObject token = new JObject();
                token.Add("menu_name", "customer_success");
                token.Add("third_system_no", item.DealerId);
                token.Add("account", item.DealerAccount);
                token.Add("dealerType", item.DealerType);
                token.Add("dealerKind", item.DealerKind);
                token.Add("dealerName", item.DealerName);
                token.Add("hasScore", item.ResultList.Count > 0 ? "1" : "0");
                token.Add("SystemScore", item.ResultList.Count > 0 ? item.ResultList[0].TotalScore.ToString() : "");
                token.Add("grade", item.ResultList.Count > 0 ? item.ResultList[0].ResultGrade : "");
                ret.Add(token);
                Score rw = item.ResultList.Count > 0 ? item.ResultList[0].Scores.FirstOrDefault(x => x.ScoreName == "入网评分") : null;
                Score yw = item.ResultList.Count > 0 ? item.ResultList[0].Scores.FirstOrDefault(x => x.ScoreName == "业务评分") : null;
                sqlList.Add(DealerGrade.Replace("[VALUES]",
                                                "'" + item.DealerId + "','" + item.DealerName + "','" + item.DealerType + "','" +
                                                (rw != null ? rw.RealScore.ToString() : "") + "','" +
                                                (yw != null ? yw.RealScore.ToString() : "") + "','" +
                                                (item.ResultList.Count > 0 ? item.ResultList[0].TotalScore.ToString() : "") + "','" +
                                                (item.ResultList.Count > 0 ? item.ResultList[0].ResultGrade : "") + "','" +
                                                item.DealerKind + "','" + DateTime.Now.Year + "','" + DateTime.Now.Month + "','" +
                                                DateTime.Now.Day + "','" + item.DealerId + "','" + (item.ResultList.Count > 0 ? "1" : "0") + "'"));
            }
            try
            {
                foreach (string sql in sqlList)
                {
                    int i = ScoreManage.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteNonQuery(sql);
                }
            }
            catch (Exception e)
            {
            }
            string sendData = ret.ToString();

            if (!Directory.Exists(".\\WaitPush"))
            {
                Directory.CreateDirectory(".\\WaitPush");
            }
            StreamWriter sw = new StreamWriter(".\\WaitPush\\" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_fff") + ".txt");

            sw.Write(sendData);
            sw.Close();

            return("源数据:\r\n" + JsonConvert.SerializeObject(dealers) + "\r\n处理后数据:\r\n" + sendData + "\r\n");
        }
Esempio n. 4
0
        public void Index()
        {
            var context = HttpContext;

            context.Response.ContentType = "text/plain";
            string score  = "";
            string action = context.Request["action"] ?? "";

            _dealerName = context.Request["dealer"] ?? "";
            _dealerId   = context.Request["crmDealerId"] ?? "";
            string type       = context.Request["type"] ?? "";
            string dealerType = context.Request["dealerType"] ?? "";

            if (string.IsNullOrEmpty(_dealerName) || string.IsNullOrEmpty(type))
            {
                try
                {
                    string    sql = "SELECT DISTRIBUTOR,TYPE,DISTRIBUTORTYPE FROM I_ALLOWIN WHERE CRMDEALERID='" + _dealerId + "'";
                    DataTable dt  = AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteDataTable(sql);
                    type        = dt.Rows[0]["TYPE"] + string.Empty;
                    dealerType  = dt.Rows[0]["DISTRIBUTORTYPE"] + string.Empty;
                    _dealerName = dt.Rows[0]["DISTRIBUTOR"] + string.Empty;
                }
                catch (Exception ex) { }
            }
            ScoreManage   sm        = ScoreManage.LoadGradeObject("loadfullscorestruct", "C_Grade", new StructNames(false), LoadDealerInfo, System.Configuration.ConfigurationManager.AppSettings["BPMEngine"]);
            List <Dealer> scoreList = sm.GetGrade();

            foreach (var dealer in scoreList)
            {
                foreach (var list in dealer.ResultList)
                {
                    if (type == list.DealerType && dealerType == list.DealerIntranet)
                    {
                        if (action == "Prewaring" || action == "Relegation" || action == "RiskPoint2")
                        {
                            score = list.TotalScore.ToString();
                        }
                        else
                        {
                            foreach (var item in list.Scores)
                            {
                                if (item.ScoreName == "入网评分" && (action == "AllowIn" || action == "RiskPoint1" || action == "UpdateEnterNet"))
                                {
                                    score = item.RealScore.ToString();
                                }
                            }
                        }
                    }
                }
            }
            if (action == "RiskPoint1" && !string.IsNullOrEmpty(_dealerName))
            {
                string sql =
                    "SELECT TOTAL,ICOUNT,CASE WHEN TOTAL IS NULL OR TOTAL = 0 THEN 0 ELSE ROUND(ICOUNT*100/TOTAL,2) END RATE FROM (" +
                    "SELECT DISTINCT IA.DISTRIBUTOR AS Dealer,IA.SystemScore,IA.TYPE,IA.DISTRIBUTORTYPE,IA.PROVINCE,IA.CITY,IA.CrmDealerId," +
                    "(SELECT COUNT(1) FROM in_cms.mv_dy_application_date_info@to_dy_cms cms WHERE cms.经销商名称 = IA.DISTRIBUTOR) TOTAL," +
                    "(SELECT COUNT(1) FROM in_cms.mv_dy_application_date_info@to_dy_cms cms WHERE cms.经销商名称 = IA.DISTRIBUTOR AND TO_DATE(cms.合同到期日,'yyyy-mm-dd')< SYSDATE) ICOUNT " +
                    "FROM I_ALLOWIN IA WHERE IA.DISTRIBUTOR = '" + _dealerName + "')";
                DataTable table = AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteDataTable(sql);
                score += "|" + table.Rows[0]["RATE"] + "%";
            }
            //string ms = JsonConvert.SerializeObject(sm.GetGrade());
            context.Response.Write(score);
        }