Пример #1
0
        public static void WriteToLog(string e)
        {
            DateTime      timeEnd   = DateTime.Now;
            DateTime      timeBegin = DateTime.Now;
            StringBuilder logStr    = new System.Text.StringBuilder();

            logStr.Append("\r\n--->St:").Append(timeEnd.ToString("yyyy-MM-dd HH:mm:ss.fff")).Append(" Response error, ").Append(timeEnd.Subtract(timeBegin).Milliseconds).Append(" ms:");
            logStr.Append("\r\n").Append(e);
            logStr.Append("\r\n--->Ed:").Append(e);
            DailyLogFileWriter DataLogFileWriter = null;
            string             logPath           = ConfigurationManager.AppSettings["WeChatLogPath"];

            DataLogFileWriter = new DailyLogFileWriter(logPath, "LOG");
            DataLogFileWriter.Write(timeBegin.ToString("yyyy-MM-dd"), logStr.ToString());
            DataLogFileWriter.Close();
        }
Пример #2
0
        public static void InitiateData()
        {
            if (!isInitiated)
            {
                DbCommand cmd = null;
                try
                {
                    string str = ConfigurationManager.AppSettings["ShowErrorDetail"];
                    Config.ShowErrorDetail = ((str != null) && (str.ToLower().Equals("true")));
                    str = ConfigurationManager.AppSettings["LoadBalance"];
                    Config.LoadBalance = ((str != null) && (str.ToLower().Equals("true")));
                    str = ConfigurationManager.AppSettings["CrmDbCharSetIsNotChinese"];
                    Config.DbCharSetIsNotChinese = ((str != null) && (str.ToLower().Equals("true")));
                    str = ConfigurationManager.AppSettings["WXUrl"];
                    if (str != null)
                    {
                        Config.WXUrl = str;
                    }
                    string logPath = ConfigurationManager.AppSettings["bfcrm.log.path"];
                    DataLogFileWriter  = new DailyLogFileWriter(logPath, "bfcrm");
                    ErrorLogFileWriter = new LogFileWriter(logPath);//, );
                    if (!ErrorLogFileWriter.SetFileName("bfcrmerror.log"))
                    {
                        for (int i = 1; i < 100; i++)
                        {
                            if (ErrorLogFileWriter.SetFileName(string.Format("bfcrmerror_{0}.log", i.ToString().PadLeft(2, '0'))))
                            {
                                break;
                            }
                        }
                    }

                    DbConnection conn = DbConnManager.GetDbConnection("CRMDB");
                    cmd = conn.CreateCommand();
                    StringBuilder sql = new StringBuilder();
                    sql.Append("select JLBH,CUR_VAL from BFCONFIG where JLBH in (0,520000102,520000103,520000112,520000113,520000115,520000120,520000121,520000123,520000128,520000129)");
                    try
                    {
                        try
                        {
                            conn.Open();
                        }
                        catch (Exception e)
                        {
                            throw new MyDbException(e.Message, true);
                        }
                        cmd.CommandText = sql.ToString();
                        DbDataReader reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            int jlbh   = DbUtils.GetInt(reader, 0);
                            int curVal = DbUtils.GetInt(reader, 1);
                            switch (jlbh)
                            {
                            case 0:
                                CurrentDbId = curVal;
                                break;

                            case 520000102:
                                Config.NoNegativeValidCent = (curVal != 0);
                                break;

                            case 520000103:
                                Config.IsSingleCompany = (curVal != 0);
                                break;

                            case 520000112:
                                Config.LengthVerifyOfCashCard = curVal;
                                //Config.LengthVerifyOfVipCard = curVal;
                                break;

                            case 520000113:
                                Config.LengthVerifyOfVipCard = curVal;
                                //Config.LengthVerifyOfCashCard = curVal;
                                break;

                            case 520000115:
                                Config.NoNegativeYearCent = (curVal != 0);
                                break;

                            case 520000120:
                                Config.NoCentWhenPayCoupon = (curVal != 0);
                                break;

                            case 520000121:
                                Config.NoOfferCouponWhenPayCoupon = (curVal != 0);
                                break;

                            case 520000123:
                                Config.PayCashCardWithArticle = (curVal != 0);
                                break;

                            case 520000128:         //卡磁道内容是否二次加密
                                Config.DesEncryptVipCardTrackSecondly  = (curVal != 0);
                                Config.DesEncryptCashCardTrackSecondly = (curVal != 0);
                                break;

                            case 520000129:
                                Config.IsUpgradedProject2013 = (curVal != 0);
                                break;
                            }
                        }
                        reader.Close();
                        cmd.CommandText = "select USER_DM,USER_PSW,HTTPOK,WSOK,WCFOK from CRMUSER";
                        reader          = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            CrmAccessUser user = new CrmAccessUser();
                            AccessUserList.Add(user);
                            user.UserId            = DbUtils.GetString(reader, 0);
                            user.Password          = DbUtils.GetString(reader, 1);
                            user.HttpHandlerAccess = DbUtils.GetBool(reader, 2);
                            user.WebServiceAccess  = DbUtils.GetBool(reader, 3);
                            user.WcfAccess         = DbUtils.GetBool(reader, 4);
                        }
                        reader.Close();
                        cmd.CommandText = "select IPADDR from CRMCLIENT where WSOK = 1 ";
                        reader          = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            WebServiceClientIpList.Add(DbUtils.GetString(reader, 0));
                        }
                        reader.Close();
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
                catch (Exception e)
                {
                    if (cmd == null)
                    {
                        CrmServerPlatform.WriteErrorLog("\r\n" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "  System Init Error: " + e.Message.ToString());
                    }
                    else
                    {
                        CrmServerPlatform.WriteErrorLog("\r\n" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "  System Init, sql: " + cmd.CommandText + "\r\n Error: " + e.Message.ToString());
                    }
                }

                ChangYi.Crm.Server.BackgroundProc backgroundProc = new ChangYi.Crm.Server.BackgroundProc();
                autoRollBackTransThread = new Thread(new ThreadStart(backgroundProc.AutoRollBackTrans));
                autoRollBackTransThread.IsBackground = true;
                autoRollBackTransThread.Start();

                isInitiated = true;
            }
        }