예제 #1
0
        public void PhoneVestUpdate()
        {
            string url       = "http://v.showji.com/Locating/showji.com20150416273007.aspx?m={0}&output=json";
            Regex  rprovince = new Regex("\"Province\":\"([\\s\\S]*?)\"");
            Regex  rcity     = new Regex("\"City\":\"([\\s\\S]*?)\"");

            try
            {
                List <CustomerInfo> list = GetCustomerListForPhoneVest();
                WebClient           wc   = new WebClient();
                foreach (CustomerInfo c in list)
                {
                    try
                    {
                        string request = Http.GetPage(string.Format(url, c.Phone));
                        if (rprovince.IsMatch(request) && rcity.IsMatch(request))
                        {
                            string province = rprovince.Match(request).Groups[1].Value;
                            string city     = rcity.Match(request).Groups[1].Value;
                            if (!string.IsNullOrEmpty(province) && !string.IsNullOrEmpty(city))
                            {
                                c.PhoneVest = province + " " + city;
                                UpdateCustomerPhoneVest(c);
                                RefreshCustomerCache(c);
                                Thread.Sleep(5000);
                            }
                            else
                            {
                                c.PhoneVest = "未知";
                                UpdateCustomerPhoneVest(c);
                                RefreshCustomerCache(c);
                                Thread.Sleep(5000);
                            }
                        }
                    }
                    catch { }
                }
            }
            catch (Exception ex)
            {
                EventLogs.JobError("作业发生错误-号码归属地采集", EventLogs.EVENTID_JOB_ERROR, 0, ex);
                ExpLog.Write(ex);
            }
            finally
            {
            }
        }
예제 #2
0
        /// <summary>
        /// 每天凌晨2点5分开始执行
        /// </summary>
        public void CustomerForcedout()
        {
            if (DateTime.Now.Hour == 2 && DateTime.Now.Minute == 5)
            {
                if (!hasruncustomerforcedout)
                {
                    hasruncustomerforcedout = true;
                    try
                    {
                        EventLogs.JobLog("开始作业-线索强制转出");
                        List <CorporationInfo> list = Corporations.Instance.GetList(true);
                        foreach (CorporationInfo corpinfo in list)
                        {
                            List <CustomerInfo> listForced = new List <CustomerInfo>();
                            List <CustomerInfo> clist      = GetCustomerListByCorporation(corpinfo.ID, true);
                            if (corpinfo.Forcedoffday > 0)
                            {
                                string[] offcustomerlevel = corpinfo.Offcustomerlevel.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                                listForced.AddRange(clist.FindAll(l => l.CustomerStatus == (int)CustomerStatus.清洗_邀约 && DateTime.Today.Subtract(DataConvert.SafeDate(l.PostTime)).TotalDays >= (corpinfo.Forcedoffday - 1) && !offcustomerlevel.Contains(l.LastCustomerLevelID.ToString())));
                            }
                            if (corpinfo.Forcedoutday > 0)
                            {
                                string[] forcedoutdaylevel = corpinfo.Forcedoutdaylevel.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                                listForced.AddRange(clist.FindAll(l => l.CustomerStatus == (int)CustomerStatus.追踪_促成 && DateTime.Today.Subtract(DataConvert.SafeDate(l.PostTime)).TotalDays >= (corpinfo.Forcedoutday - 1) && !forcedoutdaylevel.Contains(l.LastCustomerLevelID.ToString())));
                            }
                            foreach (CustomerInfo entity in listForced)
                            {
                                entity.CustomerStatusSource = entity.CustomerStatus;
                                entity.CustomerStatus       = (int)CustomerStatus.潜客_转出;
                                entity.LurkStatus           = 1;

                                CustomerMoveRecordInfo minfo = new CustomerMoveRecordInfo()
                                {
                                    CustomerID           = entity.ID,
                                    CustomerStatus       = entity.CustomerStatus,
                                    CustomerStatusSource = entity.CustomerStatus,
                                    OwnerID          = entity.OwnerID,
                                    Owner            = entity.Owner,
                                    LastUpdateUserID = entity.LastUpdateUserID,
                                    LastUpdateUser   = entity.LastUpdateUser,
                                    CreateTime       = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
                                    SystemMsg        = DateTime.Today.ToString("yyyy年MM月dd日") + "线索强制转出"
                                };

                                CustomerMoveRecords.Instance.Add(minfo);

                                entity.SystemRemark = minfo.SystemMsg;

                                CommonDataProvider.Instance().UpdateCustomer(entity);
                            }
                            if (listForced.Count > 0)
                            {
                                ReloadCustomerListByCorporationCache(corpinfo.ID);
                            }
                        }
                        EventLogs.JobLog("完成作业-线索强制转出");
                    }
                    catch (Exception ex)
                    {
                        EventLogs.JobError("作业发生错误-线索强制转出", EventLogs.EVENTID_JOB_ERROR, 0, ex);
                        ExpLog.Write(ex);
                    }
                }
            }
            else
            {
                hasruncustomerforcedout = false;
            }
        }
예제 #3
0
        /// <summary>
        /// 客户降级(每天凌晨1点5分开始执行)
        /// </summary>
        public void CustomerDegrade()
        {
            if (DateTime.Now.Hour == 1 && DateTime.Now.Minute == 5)
            {
                if (!hasruncustomerdegrade)
                {
                    hasruncustomerdegrade = true;
                    try
                    {
                        EventLogs.JobLog("开始作业-客户降级");
                        List <CorporationInfo> list = Corporations.Instance.GetList(true);
                        foreach (CorporationInfo corpinfo in list)
                        {
                            bool hasdeeldata = false;
                            List <CustomerInfo>      clist     = GetCustomerListByCorporation(corpinfo.ID, true);
                            List <CustomerLevelInfo> levellist = CustomerLevels.Instance.GetListByCorpid(corpinfo.ID, true);

                            foreach (CustomerInfo cinfo in clist)
                            {
                                if (cinfo.LastCustomerLevelID > 0)
                                {
                                    CustomerLevelInfo level    = CustomerLevels.Instance.GetModel(cinfo.LastCustomerLevelID, true);
                                    InfoTypeInfo      infotype = InfoTypes.Instance.GetModel(cinfo.InfoTypeID);

                                    //如果已经是最低一级则不处理
                                    if (levellist.FindIndex(l => l.ID == cinfo.LastCustomerLevelID) == levellist.Count - 1)
                                    {
                                        continue;
                                    }

                                    if (level != null && level.Drtday > 0)
                                    {
                                        DateTime lastconnecttime = DateTime.Now;
                                        if (DateTime.TryParse(cinfo.LastConnectTime, out lastconnecttime))
                                        {
                                            if (infotype != null && infotype.Locked == 1)
                                            {
                                                double days = DateTime.Now.Subtract(lastconnecttime).TotalDays;
                                                //锁定级别判断
                                                if (infotype.Locklevel.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Contains(level.ID.ToString()))
                                                {
                                                    if (days <= infotype.Lockday)
                                                    {
                                                        continue;
                                                    }
                                                }

                                                //做降级处理
                                                if (days > level.Drtday)
                                                {
                                                    SetCustomerLevel(cinfo.ID, levellist[levellist.FindIndex(l => l.ID == cinfo.LastCustomerLevelID) + 1].ID);

                                                    hasdeeldata = true;
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            if (hasdeeldata)
                            {
                                ReloadCustomerListByCorporationCache(corpinfo.ID);
                            }
                        }
                        EventLogs.JobLog("完成作业-客户降级");
                    }
                    catch (Exception ex)
                    {
                        EventLogs.JobError("作业发生错误-客户降级", EventLogs.EVENTID_JOB_ERROR, 0, ex);
                        ExpLog.Write(ex);
                    }
                }
            }
            else
            {
                hasruncustomerdegrade = false;
            }
        }
예제 #4
0
파일: Cars.cs 프로젝트: shaohaiou/comopp
        public void CollectData()
        {
            //每个月5号,凌晨3点5分,采集数据
            if (DateTime.Now.Day == 5 && DateTime.Now.Hour == 3 && DateTime.Now.Minute == 5)
            {
                if (!iscollected)
                {
                    iscollected = true;
                    try
                    {
                        EventLogs.JobLog("开始作业-车型数据采集");
                        bool   hasnewdata             = false;
                        string urlBrand               = "http://sales.new4s.com/ajax/brand/1/";
                        string urlSeries              = "http://sales.new4s.com/ajax/brand/3/{0}/";
                        string urlModel               = "http://sales.new4s.com/ajax/brand/5/{0}/";
                        List <CarBrandInfo> listBrand = GetCarBrandList(true);

                        string           strBrand      = Http.GetPage(urlBrand, 3);
                        List <JsonModel> listJsonBrand = Serializer.DeserializeJson <List <JsonModel> >(strBrand);
                        if (listBrand == null)
                        {
                            listBrand = new List <CarBrandInfo>();
                        }
                        foreach (JsonModel jsonbrand in listJsonBrand)
                        {
                            int    brandid   = 0;
                            string brandname = jsonbrand.name.Replace(jsonbrand.fletter + "-", string.Empty);
                            if (!listBrand.Exists(l => l.Name == brandname))
                            {
                                brandid = AddCarBrand(new CarBrandInfo()
                                {
                                    Name      = brandname,
                                    NameIndex = jsonbrand.fletter
                                });
                            }
                            else
                            {
                                brandid = listBrand.Find(l => l.Name == brandname).ID;
                            }

                            if (brandid > 0)
                            {
                                List <CarSeriesInfo> listSeries = GetCarSeriesListByBrandID(brandid, true);
                                if (listSeries == null)
                                {
                                    listSeries = new List <CarSeriesInfo>();
                                }
                                string           strSeries      = Http.GetPage(string.Format(urlSeries, jsonbrand.id), 3);
                                List <JsonModel> listJsonSeries = Serializer.DeserializeJson <List <JsonModel> >(strSeries);
                                foreach (JsonModel jsonseries in listJsonSeries)
                                {
                                    int    seriesid   = 0;
                                    string seriesname = jsonseries.name;
                                    if (!listSeries.Exists(l => l.Name == seriesname))
                                    {
                                        seriesid = AddCarSeries(new CarSeriesInfo()
                                        {
                                            Name    = seriesname,
                                            BrandID = brandid
                                        });
                                    }
                                    else
                                    {
                                        seriesid = listSeries.Find(l => l.Name == seriesname).ID;
                                    }

                                    if (seriesid > 0)
                                    {
                                        List <CarModelInfo> listModel = GetCarModelListBySeriesID(seriesid, true);
                                        if (listModel == null)
                                        {
                                            listModel = new List <CarModelInfo>();
                                        }
                                        string           strModel      = Http.GetPage(string.Format(urlModel, jsonseries.id), 3);
                                        List <JsonModel> listJsonModel = Serializer.DeserializeJson <List <JsonModel> >(strModel);
                                        foreach (JsonModel jsonmodel in listJsonModel)
                                        {
                                            int    modelid   = 0;
                                            string modelname = jsonmodel.name;
                                            if (!listModel.Exists(l => l.Name == modelname))
                                            {
                                                modelid = AddCarModel(new CarModelInfo()
                                                {
                                                    Name     = modelname,
                                                    SeriesID = seriesid
                                                });
                                                hasnewdata = true;
                                            }
                                            else
                                            {
                                                modelid = listModel.Find(l => l.Name == modelname).ID;
                                            }

                                            if (modelid == 0)
                                            {
                                                throw new Exception("新增车型 " + modelname + " 出错");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        throw new Exception("新增车系 " + seriesname + " 出错");
                                    }
                                }
                            }
                            else
                            {
                                throw new Exception("新增品牌 " + brandname + " 出错");
                            }
                        }

                        if (hasnewdata)
                        {
                            ReloadCarBrandListCache();
                            ReloadCarSeriesListCache();
                            ReloadCarModelListCache();
                        }
                        EventLogs.JobLog("完成作业-车型数据采集");
                    }
                    catch (Exception ex)
                    {
                        EventLogs.JobError("作业发生错误-车型数据采集", EventLogs.EVENTID_JOB_ERROR, 0, ex);
                        ExpLog.Write(ex);
                    }
                }
            }
            else
            {
                iscollected = false;
            }
        }