예제 #1
0
        public void Work(DateTime dtnow, bool isupload)
        {
            DateTime dt = DateTime.Now;
            int      yy = dtnow.Year;  // 得到年
            int      mm = dtnow.Month; // 得到月
            int      dd = dtnow.Day;   // 日
            int      hh = dtnow.Hour;  // 小时

            string strmm = mm > 9 ? mm + "" : "0" + mm;
            string strdd = dd > 9 ? dd + "" : "0" + dd;
            string strhh = hh > 9 ? hh + "" : "0" + hh;

            strhh = "01";
            string        ftpdir = yy + strmm + strdd;// ftp上的每天一个文件夹
            string        dir    = Application.StartupPath + "\\" + FactoryNo;
            DirectoryInfo dim    = new DirectoryInfo(dir);

            if (!dim.Exists)
            {
                dim.Create();
            }
            dir += "\\" + yy + strmm + strdd;// 文件夹(厂家编号/yyyyMMdd)
            DirectoryInfo di = new DirectoryInfo(dir);

            if (!di.Exists)
            {
                di.Create();
            }
            //深圳
            string fileName      = ProductId + "_" + yy + strmm + strdd + strhh + "0001.txt.sending"; // 文件名
            string filePath      = dir + "\\" + fileName;
            string szftpfilename = ProductId + "_" + yy + strmm + strdd + strhh + "0001.txt";         // ftp保存文件名


            EprInfoDAL          eprinfoDAL  = new EprInfoDAL();
            List <EprInfoModel> eprLst      = eprinfoDAL.GetTaoCanEprInfoAll();
            List <string>       szbillList  = new List <string>(); // 深圳帐单
            List <string>       daystatlist = new List <string>(); //帐号报表

            if (eprLst != null && eprLst.Count > 0)
            {
                TaoCanInfoDAL taocanDAL = new TaoCanInfoDAL();
                Dictionary <int, TaoCanInfoModel> taocandic = taocanDAL.GetAll();
                foreach (EprInfoModel e in eprLst)
                {
                    if (taocandic.ContainsKey(e.taocanId))
                    {
                        //他网和电信比率 8:2
                        TaoCanInfoModel tc       = taocandic[e.taocanId];
                        int             ctnumber = (int)(tc.Billnumber * 0.8); //移动账单数量
                        int             cmnumber = tc.Billnumber - ctnumber;   //电信账单数量

                        string bnetId = e.bnetId, bnetAccount = e.bnetAccount;
                        try
                        {
                            //生成sql
                            object[] obj = { e.id, bnetId, bnetAccount, ctnumber, 0, cmnumber, yy, mm, dd };
                            string   sql = string.Format("Insert into t_billdaystat(EprId,BnetId,BnetAccount,CTcount,CUcount,CMcount,YY,MM,DD) values({0},'{1}','{2}',{3},{4},{5},{6},{7},{8})", obj);
                            daystatlist.Add(sql);
                        }
                        catch (Exception ex)
                        {
                            MyDelegateFunc.WriteFmLog("CreateTaoCanBillJob==>生成sqlList失败:" + ex.Message);
                        }


                        for (int i = 0; i < ctnumber; i++)
                        {
                            StringBuilder sbstr = new StringBuilder();
                            sbstr.Append(e.bnetId);
                            sbstr.Append("|");
                            sbstr.Append(e.bnetAccount);
                            sbstr.Append("|");
                            sbstr.Append("0|1|0|0|");
                            sbstr.Append(dtnow.ToString("yyyy/MM/dd H:mm:ss", DateTimeFormatInfo.InvariantInfo));
                            szbillList.Add(sbstr.ToString());
                        }
                        for (int j = 0; j < cmnumber; j++)
                        {
                            StringBuilder sbstr = new StringBuilder();
                            sbstr.Append(e.bnetId);
                            sbstr.Append("|");
                            sbstr.Append(e.bnetAccount);
                            sbstr.Append("|");
                            sbstr.Append("0|0|1|0|");
                            sbstr.Append(dt.ToString("yyyy/MM/dd H:mm:ss", DateTimeFormatInfo.InvariantInfo));
                        }
                    }
                }
            }


            try
            {
                if (daystatlist != null && daystatlist.Count > 0)
                {
                    int result = SQLbll.BatchExec(daystatlist);
                    MyDelegateFunc.WriteFmLog("CreateTaoCanBillJob==>保存sql fail:" + result);
                }
            }
            catch (Exception ex)
            {
                MyDelegateFunc.WriteFmLog("CreateTaoCanBillJob==>保存sql失败:" + daystatlist[0]);
                MyDelegateFunc.WriteFmLog("CreateTaoCanBillJob==>保存sql失败:" + ex.Message);
            }

            if (isupload)
            {
                FtpClient ftp = new FtpClient();
                //深圳账单
                if (szbillList != null)
                {
                    bool bsz = MyFileOptions.WriteFileTXT(szbillList, filePath);
                    MyDelegateFunc.WriteFmLog("CreateTaoCanBillJob==>生成sz套餐文件[" + szftpfilename + "]结果:" + bsz);
                    if (bsz)
                    {
                        bool boolf = ftp.Upload(ftpdir, szftpfilename, filePath);
                        MyDelegateFunc.WriteFmLog("CreateTaoCanBillJob==>上传sz套餐账单[" + szftpfilename + "]结果:" + boolf);
                        if (boolf)
                        {
                            try
                            {
                                File.Move(filePath, dir + "\\" + szftpfilename);
                            }
                            catch (Exception ex)
                            {
                                MyDelegateFunc.WriteFmLog("CreateTaoCanBillJob==>修改sz套餐文件名[" + filePath + "]to[" + szftpfilename + "]失败:" + ex.Message);
                                logger.Error("CreateTaoCanBillJob==>修改sz套餐文件名[" + filePath + "]to[" + szftpfilename + "]失败:" + ex.Message);
                            }
                        }
                        else
                        {
                            MyDelegateFunc.WriteFmLog("CreateTaoCanBillJob=FTP=>上传sz套餐文件[" + filePath + "]失败");
                            logger.Error("CreateTaoCanBillJob=FTP=>上传sz套餐文件[" + filePath + "]失败");
                        }
                    }
                    else
                    {
                        MyDelegateFunc.WriteFmLog("CreateTaoCanBillJob==>生成sz文件[" + filePath + "]失败");
                        logger.Error("CreateTaoCanBillJob==>生成sz文件[" + filePath + "]失败");
                    }
                }
            }
        }
예제 #2
0
        public void Execute(IJobExecutionContext context)
        {
            DateTime dt     = DateTime.Now;
            int      yy     = dt.Year;  // 得到年
            int      mm     = dt.Month; // 得到月,因为从0开始的,所以要加1
            int      dd     = dt.Day;   // 日
            int      hh     = dt.Hour;  // 小时
            string   strmm  = mm > 9 ? mm + "" : "0" + mm;
            string   strdd  = dd > 9 ? dd + "" : "0" + dd;
            string   strhh  = hh > 9 ? hh + "" : "0" + hh;
            string   ftpdir = yy + strmm + strdd;// ftp上的每天一个文件夹

            FtpClient ftp = new FtpClient();

            try
            {
                if (!ftp.DirectoryIsExist(ftpdir))
                {
                    bool bmd = ftp.MakeDir(ftpdir);
                    MyDelegateFunc.WriteFmLog("CreateEmptyBillJob==>创建目录[" + ftpdir + "]结果:" + bmd);
                }
            }catch (Exception ex)
            {
                MyDelegateFunc.WriteFmLog("CreateEmptyBillJob==>创建目录[" + ftpdir + "]异常:" + ex.ToString());
            }


            //20 点的生成套餐账单,19点潮洲,21,22,23
            if (hh > 18)
            {
                return;
            }
            string        dir = Application.StartupPath + "\\" + FactoryNo;
            DirectoryInfo dim = new DirectoryInfo(dir);

            if (!dim.Exists)
            {
                dim.Create();
            }
            dir += "\\" + yy + strmm + strdd;// 文件夹(厂家编号/yyyyMMdd)
            DirectoryInfo di = new DirectoryInfo(dir);

            if (!di.Exists)
            {
                di.Create();
            }
            //深圳
            string        fileName      = ProductId + "_" + yy + strmm + strdd + strhh + "00" + "01.txt.sending"; // 文件名
            string        filePath      = dir + "\\" + fileName;
            string        szftpfilename = ProductId + "_" + yy + strmm + strdd + strhh + "00" + "01.txt";         // ftp保存文件名
            List <string> szbillList    = new List <string>();                                                    // 深圳帐单
            bool          bsz           = MyFileOptions.WriteFileTXT(szbillList, filePath);

            MyDelegateFunc.WriteFmLog("CreateEmptyBillJob==>生成空文件[" + filePath + "]结果:" + bsz);
            if (bsz)
            {
                bool boolf = ftp.Upload(ftpdir, szftpfilename, filePath);
                MyDelegateFunc.WriteFmLog("CreateEmptyBillJob==>上传空文件[" + filePath + "]结果:" + boolf);
                if (boolf)
                {
                    File.Move(filePath, dir + "\\" + szftpfilename);
                }
                else
                {
                }
            }
        }
예제 #3
0
        public void Work(DateTime dtnow, bool isupload)
        {
            DateTime dt = DateTime.Now;
            int      yy = dtnow.Year;  // 得到年
            int      mm = dtnow.Month; // 得到月
            int      dd = dtnow.Day;   // 日
            int      hh = dtnow.Hour;  // 小时

            try
            {
                string        strmm  = mm > 9 ? mm + "" : "0" + mm;
                string        strdd  = dd > 9 ? dd + "" : "0" + dd;
                string        strhh  = hh > 9 ? hh + "" : "0" + hh;
                string        ftpdir = yy + strmm + strdd;// ftp上的每天一个文件夹
                string        dir    = Application.StartupPath + "\\" + FactoryNo;
                DirectoryInfo dim    = new DirectoryInfo(dir);
                if (!dim.Exists)
                {
                    dim.Create();
                }
                dir += "\\" + yy + strmm + strdd;// 文件夹(厂家编号/yyyyMMdd)
                DirectoryInfo di = new DirectoryInfo(dir);
                if (!di.Exists)
                {
                    di.Create();
                }
                //深圳23点
                string fileName      = ProductId + "_" + yy + strmm + strdd + strhh + "0001.txt.sending"; // 文件名
                string filePath      = dir + "\\" + fileName;
                string szftpfilename = ProductId + "_" + yy + strmm + strdd + strhh + "0001.txt";         // ftp保存文件名
                try
                {
                    if (File.Exists(szftpfilename))
                    {
                        File.Delete(szftpfilename);
                    }
                }
                catch { }

                //东莞22点
                string strdghh       = "22";                                                                // hh - 1 > 9 ? hh - 1 + "" : "0" + (hh - 1);//东莞
                string dgfileName    = ProductId + "_" + yy + strmm + strdd + strdghh + "0001.txt.sending"; // 文件名
                string dgfilePath    = dir + "\\" + dgfileName;
                string dgftpfilename = ProductId + "_" + yy + strmm + strdd + strdghh + "0001.txt";         // ftp保存的文件名

                try
                {
                    if (File.Exists(dgftpfilename))
                    {
                        File.Delete(dgftpfilename);
                    }
                }
                catch { }

                //中山21点
                string strzshh       = "21";                                                                // hh - 2 > 9 ? hh - 2 + "" : "0" + (hh - 2);//中山
                string zsfileName    = ProductId + "_" + yy + strmm + strdd + strzshh + "0001.txt.sending"; // 文件名
                string zsfilePath    = dir + "\\" + zsfileName;
                string zsftpfilename = ProductId + "_" + yy + strmm + strdd + strzshh + "0001.txt";         // ftp保存的文件名
                try
                {
                    if (File.Exists(zsftpfilename))
                    {
                        File.Delete(zsftpfilename);
                    }
                }
                catch { }

                //潮洲19点
                string strczhh       = "19";                                                                // hh - 4 > 9 ? hh - 4 + "" : "0" + (hh - 4);//潮洲
                string czfileName    = ProductId + "_" + yy + strmm + strdd + strczhh + "0001.txt.sending"; // 文件名
                string czfilePath    = dir + "\\" + zsfileName;
                string czftpfilename = ProductId + "_" + yy + strmm + strdd + strczhh + "0001.txt";         // ftp保存的文件名
                try
                {
                    if (File.Exists(czftpfilename))
                    {
                        File.Delete(czftpfilename);
                    }
                }
                catch { }

                EprInfoDAL   eprDAO    = new EprInfoDAL();
                SmsMobileDAL mobileDAO = new SmsMobileDAL();
                BnetInfoDAL  bnetDAO   = new BnetInfoDAL();

                //查出所有企业信息和bnet信息
                Dictionary <int, EprInfoModel>     dicEprInfo  = eprDAO.GetEprInfoAll();
                Dictionary <string, BnetInfoModel> dicBnetInfo = bnetDAO.GetAll();

                //帐单
                List <string> szbillList  = new List <string>();                                                                           // 深圳帐单
                List <string> dgbillList  = new List <string>();                                                                           //东莞帐单
                List <string> zsbillList  = new List <string>();                                                                           //中山帐单
                List <string> czbillList  = new List <string>();                                                                           //潮洲帐单
                List <string> daystatlist = new List <string>();                                                                           //帐号报表
                Dictionary <int, MobileTypeCountModel> eprSendCount = mobileDAO.GetSumSMScountByDay(dicEprInfo.Keys.ToList(), yy, mm, dd); //查出企业发送量
                Dictionary <int, MobileTypeCountModel> billCount    = new Dictionary <int, MobileTypeCountModel>();                        //打折后企业的发送量
                foreach (int key in eprSendCount.Keys)
                {
                    try
                    {
                        MobileTypeCountModel mtcm    = null;
                        EprInfoModel         eprinfo = null;
                        try
                        {
                            mtcm    = eprSendCount[key];
                            eprinfo = dicEprInfo[key];
                            if (eprinfo != null && eprinfo.taocanId > 0)
                            {
                                continue;//套餐的不处理
                            }
                        }
                        catch (Exception ex)
                        {
                            MyDelegateFunc.WriteFmLog("打折异常[eprinfo]:" + ex.ToString());
                        }

                        if (eprinfo != null && (mtcm.CTcount > 0 || mtcm.CMcount > 0))
                        {
                            if (string.IsNullOrEmpty(eprinfo.bnetId) || eprinfo.bnetId.Equals("888"))
                            {
                                continue;
                            }

                            double        dprice = 10.00;
                            int           billct = mtcm.CTcount;
                            int           billcm = mtcm.CMcount;
                            BnetInfoModel bnetf  = null;
                            try
                            {
                                bnetf = dicBnetInfo[eprinfo.bnetId];
                            }
                            catch (Exception ex)
                            {
                                MyDelegateFunc.WriteFmLog("打折异常[bnetf]:" + ex.ToString());
                            }

                            if (bnetf != null)
                            {
                                //中山
                                if (bnetf.BnetAccount.StartsWith("760"))//eprinfo.areaId == 17
                                {
                                    billCount.Add(key, mtcm);
                                    continue;
                                }

                                string tprice = bnetf.Price;
                                if (!string.IsNullOrEmpty(tprice))
                                {
                                    bool b = double.TryParse(tprice, out dprice);
                                    if (dprice <= 0.00 || !b)
                                    {
                                        dprice = 10.00;
                                    }
                                }
                                MobileTypeCountModel mtcm_bill = new MobileTypeCountModel();

                                //double bcount_ct = billct * (dprice / 10);
                                mtcm_bill.CTcount = (int)(billct * (dprice / 10));// (int)Math.Ceiling(billct * (dprice / 10));

                                //  double bcount_cm = billcm * (dprice / 10);
                                mtcm_bill.CMcount    = (int)(billcm * (dprice / 10));// (int)Math.Ceiling(billcm * (dprice / 10));
                                mtcm_bill.Pirce      = dprice + "";
                                mtcm_bill.InitialNum = billct + billcm;
                                string inf = string.Format("INFO CreateBillJob==>企业id:{0},清单数量:{1},帐单数量:{2},单价:{3}", key, billcm + billct, mtcm_bill.CMcount + mtcm_bill.CTcount, tprice);
                                logger.Info(inf);
                                MyDelegateFunc.WriteFmLog(inf);
                                billCount.Add(key, mtcm_bill);
                            }//BnetInfo
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error("CreateBillJob==>计算账单条数异常:" + ex.Message);
                    }
                }//foreach eprCount


                //移动联通,电信
                foreach (int key in billCount.Keys)
                {
                    EprInfoModel         eprinfo     = eprDAO.GetEprInfo(key);
                    string               bnetId      = eprinfo.bnetId;
                    string               bnetAccount = eprinfo.bnetAccount;
                    MobileTypeCountModel mtcm        = billCount[key];//帐单数量

                    try
                    {
                        //生成sql
                        object[] obj = { eprinfo.id, bnetId, bnetAccount, mtcm.CTcount, mtcm.CUcount, mtcm.CMcount, yy, mm, dd, eprinfo.areaId, mtcm.Pirce, mtcm.InitialNum, mtcm.TotalCount };
                        string   sql = string.Format("Insert into JY15.gdkltx.dbo.t_billdaystat(EprId,BnetId,BnetAccount,CTcount,CUcount,CMcount,YY,MM,DD,AreaId,Price,InitialNum,TaoCanType) values({0},'{1}','{2}',{3},{4},{5},{6},{7},{8},{9},'{10}',{11},'{12}')", obj);
                        logger.Info(sql);
                        daystatlist.Add(sql);
                    }
                    catch (Exception ex)
                    {
                        MyDelegateFunc.WriteFmLog("CreateBillJob==>保存sqlList失败:" + ex.ToString());
                    }
                    for (int i = 0; i < mtcm.CTcount; i++)
                    {
                        StringBuilder sbstr = new StringBuilder();
                        sbstr.Append(bnetId);
                        sbstr.Append("|");
                        sbstr.Append(bnetAccount);
                        sbstr.Append("|");
                        sbstr.Append("0|1|0|0|");
                        sbstr.Append(dtnow.ToString("yyyy/MM/dd H:mm:ss", DateTimeFormatInfo.InvariantInfo));
                        szbillList.Add(sbstr.ToString());

                        /*
                         * if (bnetAccount.StartsWith("755"))//深圳
                         * {
                         *  szbillList.Add(sbstr.ToString());
                         * }
                         * else if (bnetAccount.StartsWith("769"))//东莞
                         * {
                         *  dgbillList.Add(sbstr.ToString());
                         * }
                         * else if (bnetAccount.StartsWith("760"))//中山
                         * {
                         *  zsbillList.Add(sbstr.ToString());
                         * }
                         * else if (bnetAccount.StartsWith("0768"))//潮洲
                         * {
                         *  czbillList.Add(sbstr.ToString());
                         * }
                         * */
                    }

                    //电信
                    for (int j = 0; j < mtcm.CMcount; j++)
                    {
                        StringBuilder sbstr = new StringBuilder();
                        sbstr.Append(bnetId);
                        sbstr.Append("|");
                        sbstr.Append(bnetAccount);
                        sbstr.Append("|");
                        sbstr.Append("0|0|1|0|");
                        sbstr.Append(dtnow.ToString("yyyy/MM/dd H:mm:ss", DateTimeFormatInfo.InvariantInfo));
                        szbillList.Add(sbstr.ToString());

                        /*
                         * if (bnetAccount.StartsWith("755"))//深圳
                         * {
                         *  szbillList.Add(sbstr.ToString());
                         * }
                         * else if (bnetAccount.StartsWith("769"))//东莞
                         * {
                         *  dgbillList.Add(sbstr.ToString());
                         * }
                         * else if (bnetAccount.StartsWith("760"))//中山
                         * {
                         *  zsbillList.Add(sbstr.ToString());
                         * }
                         * else if (bnetAccount.StartsWith("0768") || bnetAccount.StartsWith("768"))//潮洲
                         * {
                         *  czbillList.Add(sbstr.ToString());
                         * }
                         * */
                    }
                }//foreach billCount

                try
                {
                    if (daystatlist != null && daystatlist.Count > 0)
                    {
                        int result = SQLbll.BatchExec(daystatlist);
                        MyDelegateFunc.WriteFmLog("CreateBillJob==>保存sql fail:" + result);
                    }
                }
                catch (Exception ex)
                {
                    MyDelegateFunc.WriteFmLog("CreateBillJob==>保存sql失败:" + daystatlist[0]);
                    MyDelegateFunc.WriteFmLog("CreateBillJob==>保存sql失败:" + ex.Message);
                }


                //生成文件,上传

                FtpClient   ftp  = new FtpClient();
                LocalParams lp   = new LocalParams();
                HttpHelper  http = new HttpHelper();
                //深圳账单
                if (szbillList != null)
                {
                    bool bsz = MyFileOptions.WriteFileTXT(szbillList, filePath);
                    MyDelegateFunc.WriteFmLog("CreateBillJob==>生成sz文件[" + szftpfilename + "]结果:" + bsz);
                    if (bsz && isupload)
                    {
                        bool boolf = false;
                        int  i     = 0;
                        do
                        {
                            boolf = ftp.Upload(ftpdir, szftpfilename, filePath);
                            i++;
                        } while (!boolf && i < 3);
                        MyDelegateFunc.WriteFmLog("CreateBillJob==>上传sz账单[" + szftpfilename + "]结果:" + boolf);
                        if (boolf)
                        {
                            try
                            {
                                File.Move(filePath, dir + "\\" + szftpfilename);
                            }
                            catch (Exception ex)
                            {
                                MyDelegateFunc.WriteFmLog("CreateBillJob==>修改sz文件名[" + filePath + "]to[" + szftpfilename + "]失败:" + ex.Message);
                                logger.Error("CreateBillJob==>修改sz文件名[" + filePath + "]to[" + szftpfilename + "]失败:" + ex.Message);
                            }
                        }
                        else
                        {
                            string sendresult = http.Send(lp.UID, lp.PWD, "18002579031", 111, "上传sz文件[" + filePath + "]失败【嘉盈资讯】");
                            MyDelegateFunc.WriteFmLog("CreateBillJob==>上传sz文件[" + filePath + "]失败,发送短信结果:" + sendresult);
                            logger.Error("CreateBillJob==>上传sz文件[" + filePath + "]失败");
                        }
                    }
                    else
                    {
                        string sendresult = http.Send(lp.UID, lp.PWD, "18002579031", 111, "生成sz文件[" + filePath + "]失败【嘉盈资讯】");
                        MyDelegateFunc.WriteFmLog("CreateBillJob==>生成sz文件[" + filePath + "]失败,发送短信结果:" + sendresult);
                        logger.Error("CreateBillJob==>生成sz文件[" + filePath + "]失败");
                    }
                }
                else
                {
                    string sendresult = http.Send(lp.UID, lp.PWD, "18002579031", 111, "szbillList null【嘉盈资讯】");
                    MyDelegateFunc.WriteFmLog("CreateBillJob=FTP=>文件szbillList null,发送短信结果:" + sendresult);
                }

                //东莞账单
                if (dgbillList != null)
                {
                    bool bdg = MyFileOptions.WriteFileTXT(dgbillList, dgfilePath);
                    if (bdg && isupload)
                    {
                        bool booldg = ftp.Upload(ftpdir, dgftpfilename, dgfilePath);
                        MyDelegateFunc.WriteFmLog("CreateBillJob==>上传东莞账单[" + dgfilePath + "]结果:" + booldg);
                        if (booldg)
                        {
                            try
                            {
                                File.Move(dgfilePath, dir + "\\" + dgftpfilename);
                            }
                            catch (Exception ex)
                            {
                                logger.Error("CreateBillJob==>修改东莞文件名[" + dgfilePath + "]to[" + dgftpfilename + "]失败:" + ex.Message);
                            }
                        }
                    }
                    else
                    {
                        logger.Error("CreateBillJob==>生成dg文件[" + dgfilePath + "]失败");
                    }
                }



                //中山账单
                if (zsbillList != null)
                {
                    bool zsb = MyFileOptions.WriteFileTXT(zsbillList, zsfilePath);
                    if (zsb && isupload)
                    {
                        bool booldg = ftp.Upload(ftpdir, zsftpfilename, zsfilePath);
                        MyDelegateFunc.WriteFmLog("CreateBillJob==>上传中山账单[" + zsfilePath + "]结果:" + booldg);
                        if (booldg)
                        {
                            try
                            {
                                File.Move(zsfilePath, dir + "\\" + zsftpfilename);
                            }
                            catch (Exception ex)
                            {
                                logger.Error("CreateBillJob==>修改中山文件名[" + zsfilePath + "]to[" + zsftpfilename + "]失败:" + ex.Message);
                            }
                        }
                    }
                    else
                    {
                        logger.Error("CreateBillJob==>生成中山文件[" + zsfilePath + "]失败");
                    }
                }


                //潮洲账单
                if (czbillList != null)
                {
                    bool czb = MyFileOptions.WriteFileTXT(czbillList, czfilePath);
                    if (czb && isupload)
                    {
                        bool booldg = ftp.Upload(ftpdir, czftpfilename, czfilePath);
                        MyDelegateFunc.WriteFmLog("CreateBillJob==>上传潮洲账单[" + czfilePath + "]结果:" + booldg);
                        if (booldg)
                        {
                            try
                            {
                                File.Move(zsfilePath, dir + "\\" + czftpfilename);
                            }
                            catch (Exception ex)
                            {
                                logger.Error("CreateBillJob==>修改潮洲文件名[" + czfilePath + "]to[" + czftpfilename + "]失败:" + ex.Message);
                            }
                        }
                    }
                    else
                    {
                        logger.Error("CreateBillJob==>生成潮洲文件[" + czfilePath + "]失败");
                    }
                }
            }
            catch (Exception ex)
            {
                MyDelegateFunc.WriteFmLog("CreateBillJob==>Exception:" + ex.Message);
                logger.Error("CreateBillJob==>Exception:" + ex.Message);
            }
        }
예제 #4
0
        /// <summary>
        /// 计算套餐及超出部分
        /// </summary>
        /// <param name="dtnow">日期</param>
        /// <param name="isupload">是否上传</param>
        public void Work(DateTime dtnow, bool isupload)
        {
            string begintime = DateTools.FirstDayOfMonth(dtnow).ToShortDateString();
            string endtime   = DateTools.LastDayOfMonth(dtnow).ToShortDateString() + " 23:59:59";
            int    yy        = dtnow.Year;  // 得到年
            int    mm        = dtnow.Month; // 得到月
            int    dd        = dtnow.Day;   // 日
            int    hh        = dtnow.Hour;  // 小时

            string strmm = mm > 9 ? mm + "" : "0" + mm;
            string strdd = dd > 9 ? dd + "" : "0" + dd;
            string strhh = hh > 9 ? hh + "" : "0" + hh;

            strhh = "20";
            string        ftpdir = yy + strmm + strdd;// ftp上的每天一个文件夹
            string        dir    = Application.StartupPath + "\\" + FactoryNo;
            DirectoryInfo dim    = new DirectoryInfo(dir);

            if (!dim.Exists)
            {
                dim.Create();
            }
            dir += "\\" + yy + strmm + strdd;// 文件夹(厂家编号/yyyyMMdd)
            DirectoryInfo di = new DirectoryInfo(dir);

            if (!di.Exists)
            {
                di.Create();
            }
            //深圳
            string fileName      = ProductId + "_" + yy + strmm + strdd + strhh + "0001.txt.sending"; // 文件名
            string filePath      = dir + "\\" + fileName;
            string szftpfilename = ProductId + "_" + yy + strmm + strdd + strhh + "0001.txt";         // ftp保存文件名


            EprInfoDAL eprinfoDAL = new EprInfoDAL();
            Dictionary <int, EprInfoModel> eprDic = eprinfoDAL.GetTaoCanEprInfoAll2();


            SmsMobileDAL smsdal = new SmsMobileDAL();
            Dictionary <int, MobileTypeCountModel> eprCount  = smsdal.GetSumSMScountByMomth(eprDic.Keys.ToList(), begintime, endtime); //企业发送统计
            Dictionary <int, MobileTypeCountModel> billCount = new Dictionary <int, MobileTypeCountModel>();                           //套餐企业的发送量

            TaoCanInfoDAL taocanDAL = new TaoCanInfoDAL();
            Dictionary <int, TaoCanInfoModel> taocanDic = taocanDAL.GetAll(); //套餐企业信息
            List <string> daystatlist = new List <string>();                  //帐号报表
            List <string> szbillList  = new List <string>();                  // 深圳帐单

            //计算账单数量
            foreach (int key in eprCount.Keys)
            {
                MobileTypeCountModel mtcm    = eprCount[key]; //发送量
                EprInfoModel         eprinfo = eprDic[key];   //企业信息
                if (!taocanDic.ContainsKey(eprinfo.taocanId))
                {
                    continue;
                }
                TaoCanInfoModel taocaninfo = taocanDic[eprinfo.taocanId];                       //套餐信息
                int             billct     = mtcm.CMcount + mtcm.CTcount - taocaninfo.TCNumber; //超出套餐数量

                //套餐账单
                int taocanneiTotalCount = taocaninfo.Billnumber;


                if (billct > 0)//超出套餐量
                {
                    /*
                     * int taocanneiCTbillcount = (int)(taocaninfo.Billnumber / 2);//套餐内移动数量
                     * int taocanneiCMbillcount = taocaninfo.Billnumber - taocanneiCTbillcount;//套餐内电信动数量
                     *
                     *
                     * int taocanneiCTcount = (int)taocaninfo.TCNumber / 2;
                     * int taocanneiCMcount = taocaninfo.TCNumber = taocanneiCTcount;
                     * int ct = mtcm.CTcount - taocanneiCTcount > 0 ? mtcm.CTcount - taocanneiCTcount : 0;//套餐外移动多出数量
                     * int cm = mtcm.CMcount - taocanneiCMcount > 0 ? mtcm.CMcount - taocanneiCMcount : 0;//套餐外电信多出数量
                     * int ctwaibill = (int)Math.Ceiling(ct * (dprice / 10));//移动套餐外折算后数量
                     * int cmwaibill = (int)Math.Ceiling(cm * (dprice / 10));//电信动套餐外折算后数量
                     * */

                    double dprice = 10.00;
                    if (!string.IsNullOrEmpty(taocaninfo.TCOutsidePrice))
                    {
                        bool b = double.TryParse(taocaninfo.TCOutsidePrice, out dprice);
                        if (dprice <= 0.00 || !b)
                        {
                            dprice = 10.00;
                        }
                    }
                    int ctwaibill = (int)Math.Ceiling(billct * (dprice / 10));//移动套餐外折算后数量
                    int cmwaibill = 0;
                    //账单
                    MobileTypeCountModel mtcm_bill = new MobileTypeCountModel();
                    mtcm_bill.TotalCount = ctwaibill + cmwaibill + taocanneiTotalCount; //总量
                    mtcm_bill.CTcount    = mtcm_bill.TotalCount;                        //移动
                    mtcm_bill.CMcount    = 0;                                           //电信
                    MyDelegateFunc.WriteFmLog(string.Format("CreateTaoCanCloseBillJob==>【超出套餐】企业id:{0},清单数量:{1},帐单数量:{2},套餐外单价:{3},套餐量:{4}", key, (mtcm.CMcount + mtcm.CTcount), mtcm_bill.TotalCount, taocaninfo.TCOutsidePrice, taocaninfo.TCNumber));
                    billCount.Add(key, mtcm_bill);
                }
                else
                {
                    if (mtcm.TotalCount == 0)//未发送
                    {
                        MobileTypeCountModel mbill = new MobileTypeCountModel();
                        mbill.TotalCount = taocanneiTotalCount;
                        mbill.CTcount    = taocanneiTotalCount;
                        mbill.CMcount    = 0;
                        MyDelegateFunc.WriteFmLog(string.Format("CreateTaoCanCloseBillJob==>【未发】送企业id:{0},清单数量:{1}", key, mbill.TotalCount));
                        billCount.Add(key, mbill);
                    }
                    else//套餐内
                    {
                        double dprice = 10.00;
                        string tprice = taocaninfo.TCPrice;
                        if (!string.IsNullOrEmpty(tprice))
                        {
                            bool b = double.TryParse(tprice, out dprice);
                            if (dprice <= 0.00 || !b)
                            {
                                dprice = 10.00;
                            }
                        }

                        MobileTypeCountModel mbill = new MobileTypeCountModel();
                        mbill.TotalCount = taocanneiTotalCount;

                        //mbill.CTcount = (int)Math.Ceiling(mtcm.CTcount * (dprice / 10)); ;
                        // mbill.CMcount = taocanneiTotalCount - mbill.CTcount;
                        mbill.CTcount = taocanneiTotalCount;
                        mbill.CMcount = 0;
                        MyDelegateFunc.WriteFmLog(string.Format("CreateTaoCanCloseBillJob==>【套餐内】未发送企业id:{0},清单数量:{1},电信数量:{2},移动数量:{3}", key, mbill.TotalCount, mbill.CMcount, mbill.CMcount));
                        billCount.Add(key, mbill);
                    }
                }
            }


            //生成账单
            foreach (int key in billCount.Keys)
            {
                EprInfoModel         eprinfo = eprDic[key]; //企业信息
                MobileTypeCountModel mtcm = billCount[key]; //发送量
                string bnetId = eprinfo.bnetId, bnetAccount = eprinfo.bnetAccount;
                try
                {
                    //生成sql
                    object[] obj = { eprinfo.id, bnetId, bnetAccount, mtcm.CTcount, mtcm.CUcount, mtcm.CMcount, yy, mm, dd };
                    string   sql = string.Format("Insert into jy15.gdkltx.dbo.t_billdaystat(EprId,BnetId,BnetAccount,CTcount,CUcount,CMcount,YY,MM,DD) values({0},'{1}','{2}',{3},{4},{5},{6},{7},{8})", obj);
                    daystatlist.Add(sql);
                }
                catch (Exception ex)
                {
                    MyDelegateFunc.WriteFmLog("CreateTaoCanCloseBillJob==>生成sqlList失败:" + ex.Message);
                }
                for (int i = 0; i < mtcm.CTcount; i++)
                {
                    StringBuilder sbstr = new StringBuilder();
                    sbstr.Append(bnetId);
                    sbstr.Append("|");
                    sbstr.Append(bnetAccount);
                    sbstr.Append("|");
                    sbstr.Append("0|1|0|0|");
                    sbstr.Append(dtnow.ToString("yyyy/MM/dd H:mm:ss", DateTimeFormatInfo.InvariantInfo));
                    szbillList.Add(sbstr.ToString());
                }
            }

            try
            {
                if (daystatlist != null && daystatlist.Count > 0)
                {
                    int result = SQLbll.BatchExec(daystatlist);
                    MyDelegateFunc.WriteFmLog("CreateTaoCanCloseBillJob==>保存sql result:" + result);
                }
            }
            catch (Exception ex)
            {
                MyDelegateFunc.WriteFmLog("CreateTaoCanCloseBillJob==>保存sql失败:" + daystatlist[0]);
                MyDelegateFunc.WriteFmLog("CreateTaoCanCloseBillJob==>保存sql失败:" + ex.Message);
            }

            FtpClient ftp = new FtpClient();

            //深圳账单
            if (szbillList != null)
            {
                bool bsz = MyFileOptions.WriteFileTXT(szbillList, filePath);
                MyDelegateFunc.WriteFmLog("CreateTaoCanCloseBillJob==>生成sz套餐文件[" + filePath + "]结果:" + bsz);
                if (bsz)
                {
                    if (!isupload)
                    {
                        return;
                    }
                    bool boolf = ftp.Upload(ftpdir, szftpfilename, filePath);
                    MyDelegateFunc.WriteFmLog("CreateTaoCanCloseBillJob==>上传sz套餐账单[" + szftpfilename + "]结果:" + boolf);
                    if (boolf)
                    {
                        try
                        {
                            File.Move(filePath, dir + "\\" + szftpfilename);
                        }
                        catch (Exception ex)
                        {
                            MyDelegateFunc.WriteFmLog("CreateTaoCanCloseBillJob==>修改sz套餐文件名[" + filePath + "]to[" + szftpfilename + "]失败:" + ex.Message);
                            logger.Error("CreateTaoCanCloseBillJob==>修改sz套餐文件名[" + filePath + "]to[" + szftpfilename + "]失败:" + ex.Message);
                        }
                    }
                    else
                    {
                        MyDelegateFunc.WriteFmLog("CreateTaoCanCloseBillJob=FTP=>上传sz套餐文件[" + filePath + "]失败");
                        logger.Error("CreateTaoCanCloseBillJob=FTP=>上传sz套餐文件[" + filePath + "]失败");
                    }
                }
                else
                {
                    MyDelegateFunc.WriteFmLog("CreateTaoCanCloseBillJob==>生成sz文件[" + filePath + "]失败");
                    logger.Error("CreateTaoCanCloseBillJob==>生成sz文件[" + filePath + "]失败");
                }
            }
        }
예제 #5
0
        /// <summary>
        /// 手动生成,保存在补推文件夹中
        /// </summary>
        /// <param name="dtnow">账单时间</param>
        /// <param name="begintime">开始时间</param>
        /// <param name="endtime">结束时间</param>
        /// <param name="eprIdLst">企业ID</param>
        /// <param name="isupload">是否上传</param>
        public void Work(DateTime dtnow, string begintime, string endtime, List <int> eprIdLst, bool isupload)
        {
            DateTime dt = DateTime.Now;
            int      yy = dtnow.Year;  // 得到年
            int      mm = dtnow.Month; // 得到月
            int      dd = dtnow.Day;   // 日
            int      hh = dtnow.Hour;  // 小时

            try
            {
                string        strmm  = mm > 9 ? mm + "" : "0" + mm;
                string        strdd  = dd > 9 ? dd + "" : "0" + dd;
                string        strhh  = hh > 9 ? hh + "" : "0" + hh;
                string        ftpdir = yy + strmm + strdd;// ftp上的每天一个文件夹
                string        dir    = Application.StartupPath + "\\" + FactoryNo + "\\add";
                DirectoryInfo dim    = new DirectoryInfo(dir);
                if (!dim.Exists)
                {
                    dim.Create();
                }
                dir += "\\" + yy + strmm + strdd;// 文件夹(厂家编号/yyyyMMdd)
                DirectoryInfo di = new DirectoryInfo(dir);
                if (!di.Exists)
                {
                    di.Create();
                }
                //深圳23点
                string fileName      = ProductId + "_" + yy + strmm + strdd + strhh + "0001.txt.sending"; // 文件名
                string filePath      = dir + "\\" + fileName;
                string szftpfilename = ProductId + "_" + yy + strmm + strdd + strhh + "0001.txt";         // ftp保存文件名
                try
                {
                    if (File.Exists(szftpfilename))
                    {
                        File.Delete(szftpfilename);
                    }
                }
                catch { }

                //东莞22点
                string strdghh       = hh - 1 > 9 ? hh - 1 + "" : "0" + (hh - 1);                           //东莞
                string dgfileName    = ProductId + "_" + yy + strmm + strdd + strdghh + "0001.txt.sending"; // 文件名
                string dgfilePath    = dir + "\\" + dgfileName;
                string dgftpfilename = ProductId + "_" + yy + strmm + strdd + strdghh + "0001.txt";         // ftp保存的文件名

                try
                {
                    if (File.Exists(dgftpfilename))
                    {
                        File.Delete(dgftpfilename);
                    }
                }
                catch { }

                //中山21点
                string strzshh       = hh - 2 > 9 ? hh - 2 + "" : "0" + (hh - 2);                           //中山
                string zsfileName    = ProductId + "_" + yy + strmm + strdd + strzshh + "0001.txt.sending"; // 文件名
                string zsfilePath    = dir + "\\" + zsfileName;
                string zsftpfilename = ProductId + "_" + yy + strmm + strdd + strzshh + "0001.txt";         // ftp保存的文件名
                try
                {
                    if (File.Exists(zsftpfilename))
                    {
                        File.Delete(zsftpfilename);
                    }
                }
                catch { }

                //潮洲19点
                string strczhh       = hh - 4 > 9 ? hh - 4 + "" : "0" + (hh - 4);                           //潮洲
                string czfileName    = ProductId + "_" + yy + strmm + strdd + strczhh + "0001.txt.sending"; // 文件名
                string czfilePath    = dir + "\\" + zsfileName;
                string czftpfilename = ProductId + "_" + yy + strmm + strdd + strczhh + "0001.txt";         // ftp保存的文件名
                try
                {
                    if (File.Exists(czftpfilename))
                    {
                        File.Delete(czftpfilename);
                    }
                }
                catch { }


                EprInfoDAL   eprDAO    = new EprInfoDAL();
                SmsMobileDAL mobileDAO = new SmsMobileDAL();
                BnetInfoDAL  bnetDAO   = new BnetInfoDAL();

                //查出所有企业信息和bnet信息

                Dictionary <int, EprInfoModel>     dicEprInfo  = eprDAO.GetEprInfoAll();
                Dictionary <string, BnetInfoModel> dicBnetInfo = bnetDAO.GetAll();

                //帐单
                List <string> szbillList  = new List <string>(); // 深圳帐单
                List <string> dgbillList  = new List <string>(); //东莞帐单
                List <string> zsbillList  = new List <string>(); //中山帐单
                List <string> czbillList  = new List <string>(); //潮洲帐单
                List <string> daystatlist = new List <string>(); //帐号报表
                //if (eprIdLst == null || eprIdLst.Count==0)
                //{
                //    eprIdLst = dicEprInfo.Keys.ToList();
                //}
                Dictionary <int, MobileTypeCountModel> eprCount  = mobileDAO.GetSumSMScountByDay(eprIdLst, begintime, endtime); //查出企业发送量
                Dictionary <int, MobileTypeCountModel> billCount = new Dictionary <int, MobileTypeCountModel>();                //打折后企业的发送量
                foreach (int key in eprCount.Keys)
                {
                    try
                    {
                        MobileTypeCountModel mtcm    = null;
                        EprInfoModel         eprinfo = null;
                        try
                        {
                            mtcm    = eprCount[key];
                            eprinfo = dicEprInfo[key];
                            if (eprinfo != null && eprinfo.taocanId > 0)
                            {
                                continue;//套餐的不处理
                            }
                        }
                        catch (Exception ex)
                        {
                            MyDelegateFunc.WriteFmLog("打折异常[eprinfo]:" + ex.ToString());
                        }

                        if (eprinfo != null && (mtcm.CTcount > 0 || mtcm.CMcount > 0))
                        {
                            if (string.IsNullOrEmpty(eprinfo.bnetId) || eprinfo.bnetId.Equals("888"))
                            {
                                continue;
                            }

                            double        dprice = 10.00;
                            int           billct = mtcm.CTcount;
                            int           billcm = mtcm.CMcount;
                            BnetInfoModel bnetf  = null;
                            try
                            {
                                bnetf = dicBnetInfo[eprinfo.bnetId];
                            }
                            catch (Exception ex)
                            {
                                MyDelegateFunc.WriteFmLog("打折异常[bnetf]:" + ex.ToString());
                            }

                            if (bnetf != null)
                            {
                                //中山
                                if (bnetf.BnetAccount.StartsWith("760"))//eprinfo.areaId == 17
                                {
                                    billCount.Add(key, mtcm);
                                    continue;
                                }

                                string tprice = bnetf.Price;
                                if (!string.IsNullOrEmpty(tprice))
                                {
                                    bool b = double.TryParse(tprice, out dprice);
                                    if (dprice <= 0.00 || !b)
                                    {
                                        dprice = 10.00;
                                    }
                                }

                                MobileTypeCountModel mtcm_bill = new MobileTypeCountModel();
                                //double bcount_ct = billct * (dprice / 10);
                                mtcm_bill.CTcount = (int)(billct * (dprice / 10));// (int)Math.Ceiling(billct * (dprice / 10));

                                //  double bcount_cm = billcm * (dprice / 10);
                                mtcm_bill.CMcount    = (int)(billcm * (dprice / 10)); //(int)Math.Ceiling(billcm * (dprice / 10));
                                mtcm_bill.Pirce      = dprice + "";
                                mtcm_bill.InitialNum = billcm + billct;
                                string inf = string.Format("CreateBillJob==>企业id:{0},清单数量:{1},帐单数量:{2},单价:{3}", key, billcm + billct, mtcm_bill.CMcount + mtcm_bill.CTcount, tprice);
                                logger.Info(inf);
                                MyDelegateFunc.WriteFmLog(inf);
                                billCount.Add(key, mtcm_bill);
                            }//BnetInfo
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error("CreateBillJob==>计算账单条数异常:" + ex.Message);
                    }
                }//foreach eprCount


                //移动,联通
                foreach (int key in billCount.Keys)
                {
                    EprInfoModel         eprinfo     = eprDAO.GetEprInfo(key);
                    string               bnetId      = eprinfo.bnetId;
                    string               bnetAccount = eprinfo.bnetAccount;
                    MobileTypeCountModel mtcm        = billCount[key];//帐单数量

                    try
                    {
                        //生成sql

                        object[] obj = { eprinfo.id, bnetId, bnetAccount, mtcm.CTcount, mtcm.CUcount, mtcm.CMcount, yy, mm, dd, eprinfo.areaId, mtcm.Pirce, mtcm.InitialNum, mtcm.TotalCount };
                        string   sql = string.Format("Insert into JY15.gdkltx.dbo.t_billdaystat(EprId,BnetId,BnetAccount,CTcount,CUcount,CMcount,YY,MM,DD,AreaId,Price,InitialNum,TaoCanType) values({0},'{1}','{2}',{3},{4},{5},{6},{7},{8},{9},'{10}',{11},'{12}')", obj);
                        //object[] obj = { eprinfo.id, bnetId, bnetAccount, mtcm.CTcount, mtcm.CUcount, mtcm.CMcount, yy, mm, dd, mtcm.Pirce, mtcm.InitialNum, mtcm.TaoCanType };
                        //string sql = string.Format("Insert into  JY15.gdkltx.dbo.t_billdaystat(EprId,BnetId,BnetAccount,CTcount,CUcount,CMcount,YY,MM,DD,Price,InitialNum,TaoCanType) values({0},'{1}','{2}',{3},{4},{5},{6},{7},{8},'{9}','{10}','{11}')", obj);
                        MyDelegateFunc.WriteFmLog("CreateBillJob==>sql:" + sql);
                        logger.Info(sql);
                        daystatlist.Add(sql);
                    }
                    catch (Exception ex)
                    {
                        MyDelegateFunc.WriteFmLog("CreateBillJob==>保存sqlList失败:" + ex.ToString());
                    }
                    for (int i = 0; i < mtcm.CTcount; i++)
                    {
                        StringBuilder sbstr = new StringBuilder();
                        sbstr.Append(bnetId);
                        sbstr.Append("|");
                        sbstr.Append(bnetAccount);
                        sbstr.Append("|");
                        sbstr.Append("0|1|0|0|");
                        sbstr.Append(dtnow.ToString("yyyy/MM/dd H:mm:ss", DateTimeFormatInfo.InvariantInfo));
                        szbillList.Add(sbstr.ToString());

                        /*
                         * if (bnetAccount.StartsWith("755"))//深圳
                         * {
                         *  szbillList.Add(sbstr.ToString());
                         * }
                         * else if (bnetAccount.StartsWith("769"))//东莞
                         * {
                         *  dgbillList.Add(sbstr.ToString());
                         * }
                         * else if (bnetAccount.StartsWith("760"))//中山
                         * {
                         *  zsbillList.Add(sbstr.ToString());
                         * }
                         * else if (bnetAccount.StartsWith("0768"))//潮洲
                         * {
                         *  czbillList.Add(sbstr.ToString());
                         * }
                         * */
                    }

                    //电信
                    for (int j = 0; j < mtcm.CMcount; j++)
                    {
                        StringBuilder sbstr = new StringBuilder();
                        sbstr.Append(bnetId);
                        sbstr.Append("|");
                        sbstr.Append(bnetAccount);
                        sbstr.Append("|");
                        sbstr.Append("0|0|1|0|");
                        sbstr.Append(dtnow.ToString("yyyy/MM/dd H:mm:ss", DateTimeFormatInfo.InvariantInfo));
                        szbillList.Add(sbstr.ToString());

                        /*
                         * if (bnetAccount.StartsWith("755"))//深圳
                         * {
                         *  szbillList.Add(sbstr.ToString());
                         * }
                         * else if (bnetAccount.StartsWith("769"))//东莞
                         * {
                         *  dgbillList.Add(sbstr.ToString());
                         * }
                         * else if (bnetAccount.StartsWith("760"))//中山
                         * {
                         *  zsbillList.Add(sbstr.ToString());
                         * }
                         * else if (bnetAccount.StartsWith("0768"))//潮洲
                         * {
                         *  czbillList.Add(sbstr.ToString());
                         * }
                         * */
                    }


                    /*
                     * int billc = billCount[key];//帐单数量
                     * int totalcount = 0;//已累的数量
                     * List<SmsMobileModel> smslist = mobileDAO.GetListByYYMMDD(key, yy, mm, dd);
                     * foreach (SmsMobileModel sms in smslist)
                     * {
                     *    if (totalcount > billc)
                     *    {
                     *        break;
                     *    }
                     *    int t = Tools.GetMobileType(sms.mobile);
                     *    for (int i = 0; i < sms.smsCount; i++)
                     *    {
                     *        try
                     *        {
                     *            if (totalcount > billc)
                     *            {
                     *                break;
                     *            }
                     *            totalcount++;
                     *            // 账单格式:条数只能是1 多条,需要生成多条记录
                     *            // bnetid|bnetaccount|小灵通条数|移动条数|联通条数|电信条数|时间
                     *            StringBuilder sbstr = new StringBuilder();
                     *            sbstr.Append(bnetId);
                     *            sbstr.Append("|");
                     *            sbstr.Append(bnetAccount);
                     *            sbstr.Append("|");
                     *            switch (t)
                     *            {
                     *                case 1:
                     *                case 2:
                     *                    sbstr.Append("0|1|0|0|");
                     *                    break;
                     *                case 3:
                     *                    sbstr.Append("0|0|1|0|");
                     *                    break;
                     *                default:
                     *                    sbstr.Append("0|1|0|0|");
                     *                    break;
                     *                //	case 3:
                     *                //	sbstr.append("0|0|0|1|");
                     *                //	break;
                     *
                     *            }
                     *
                     *            sbstr.Append(sms.sendTime.ToString("yyyy/MM/dd H:mm:ss", DateTimeFormatInfo.InvariantInfo));
                     *
                     *            if (bnetAccount.StartsWith("755"))//深圳
                     *            {
                     *                szbillList.Add(sbstr.ToString());
                     *            }
                     *            else if (bnetAccount.StartsWith("769"))//东莞
                     *            {
                     *                dgbillList.Add(sbstr.ToString());
                     *            }
                     *            else if (bnetAccount.StartsWith("760"))//中山
                     *            {
                     *                zsbillList.Add(sbstr.ToString());
                     *            }
                     *        }
                     *        catch (Exception ex)
                     *        {
                     *            logger.Error("CreateBillJob==>生成账单字符串异常:" + ex.Message);
                     *        }
                     *
                     *    }//for smscount
                     *
                     * }//foreach smsList
                     */
                }//foreach billCount

                try
                {
                    if (daystatlist != null && daystatlist.Count > 0)
                    {
                        int result = SQLbll.BatchExec(daystatlist);
                        MyDelegateFunc.WriteFmLog("CreateBillJob==>保存sql fail:" + result);
                    }
                }
                catch (Exception ex)
                {
                    MyDelegateFunc.WriteFmLog("CreateBillJob==>保存sql失败:" + daystatlist[0]);
                    MyDelegateFunc.WriteFmLog("CreateBillJob==>保存sql失败:" + ex.Message);
                }


                FtpClient ftp = new FtpClient();

                //深圳账单
                if (szbillList != null)
                {
                    bool bsz = MyFileOptions.WriteFileTXT(szbillList, filePath);
                    MyDelegateFunc.WriteFmLog("CreateBillJob==>生成sz文件[" + filePath + "]结果:" + bsz);
                    if (bsz && isupload)
                    {
                        bool boolf = ftp.Upload(ftpdir, szftpfilename, filePath);
                        MyDelegateFunc.WriteFmLog("CreateBillJob==>上传sz账单[" + szftpfilename + "]结果:" + boolf);
                        if (boolf)
                        {
                            try
                            {
                                File.Move(filePath, dir + "\\" + szftpfilename);
                            }
                            catch (Exception ex)
                            {
                                MyDelegateFunc.WriteFmLog("CreateBillJob==>修改sz文件名[" + filePath + "]to[" + szftpfilename + "]失败:" + ex.Message);
                                logger.Error("CreateBillJob==>修改sz文件名[" + filePath + "]to[" + szftpfilename + "]失败:" + ex.Message);
                            }
                        }
                        else
                        {
                            MyDelegateFunc.WriteFmLog("CreateBillJob=FTP=>上传sz文件[" + filePath + "]失败");
                            logger.Error("CreateBillJob=FTP=>上传sz文件[" + filePath + "]失败");
                        }
                    }
                }

                //东莞账单
                if (dgbillList != null)
                {
                    bool bdg = MyFileOptions.WriteFileTXT(dgbillList, dgfilePath);
                    MyDelegateFunc.WriteFmLog("CreateBillJob==>生成dg文件[" + dgfilePath + "]结果:" + bdg);
                    if (bdg && isupload)
                    {
                        bool booldg = ftp.Upload(ftpdir, dgftpfilename, dgfilePath);
                        MyDelegateFunc.WriteFmLog("CreateBillJob==>上传dg账单[" + dgfilePath + "]结果:" + booldg);
                        if (booldg)
                        {
                            try
                            {
                                File.Move(dgfilePath, dir + "\\" + dgftpfilename);
                            }
                            catch (Exception ex)
                            {
                                logger.Error("CreateBillJob==>修改dg文件名[" + dgfilePath + "]to[" + dgftpfilename + "]失败:" + ex.Message);
                            }
                        }
                    }
                }



                //中山账单
                if (zsbillList != null)
                {
                    bool zsb = MyFileOptions.WriteFileTXT(zsbillList, zsfilePath);
                    MyDelegateFunc.WriteFmLog("CreateBillJob==>生成zs文件[" + zsfilePath + "]结果:" + zsb);
                    if (zsb && isupload)
                    {
                        bool booldg = ftp.Upload(ftpdir, zsftpfilename, zsfilePath);
                        MyDelegateFunc.WriteFmLog("CreateBillJob==>上传中山账单[" + zsfilePath + "]结果:" + booldg);
                        if (booldg)
                        {
                            try
                            {
                                File.Move(zsfilePath, dir + "\\" + zsftpfilename);
                            }
                            catch (Exception ex)
                            {
                                logger.Error("CreateBillJob==>修改中山文件名[" + zsfilePath + "]to[" + zsftpfilename + "]失败:" + ex.Message);
                            }
                        }
                    }
                }

                //潮洲账单
                if (czbillList != null)
                {
                    bool czb = MyFileOptions.WriteFileTXT(czbillList, czfilePath);
                    if (czb && isupload)
                    {
                        bool booldg = ftp.Upload(ftpdir, czftpfilename, czfilePath);
                        MyDelegateFunc.WriteFmLog("CreateBillJob==>上传潮洲账单[" + czfilePath + "]结果:" + booldg);
                        if (booldg)
                        {
                            try
                            {
                                File.Move(zsfilePath, dir + "\\" + czftpfilename);
                            }
                            catch (Exception ex)
                            {
                                logger.Error("CreateBillJob==>修改潮洲文件名[" + czfilePath + "]to[" + czftpfilename + "]失败:" + ex.Message);
                            }
                        }
                    }
                    else
                    {
                        logger.Error("CreateBillJob==>生成潮洲文件[" + czfilePath + "]失败");
                    }
                }
            }
            catch (Exception ex)
            {
                MyDelegateFunc.WriteFmLog("CreateBillJob==>Exception:" + ex.Message);
                logger.Error("CreateBillJob==>Exception:" + ex.Message);
            }
        }