Exemple #1
0
        public bool Start()
        {
            try
            {
                this.bus.Subscribe <IPaymentMessage>("", msg =>
                {
                    log.Info(msg.ToJson());
                    //var dbName = "PaymentLog" + DateTime.Now.ToString("yyyyMM");
                    //if (msg.CompanyType == 1)
                    //{
                    //    dbName = dbName + "_HuaAn";
                    //}
                    //else if (msg.CompanyType == 2)
                    //{
                    //    dbName = dbName + "_Sunlight";
                    //}
                    ////业务日志
                    //else if (msg.CompanyType == 99)
                    //{
                    //    dbName = "CarBusinessLog" + DateTime.Now.ToString("yyyyMM");
                    //}
                    //else
                    //{
                    //    dbName = dbName + "_" + msg.CompanyType;
                    //}

                    var dbName = GetDbName(msg.CompanyType);

                    var colName = msg.BusinessModule ?? "Default";
                    //mongo.InsertOne(dbName, colName, msg);
                    var Msg = msg as MongoEntity;
                    mongo.InsertOne(dbName, colName, Msg);
                });


                log.Info("服务已启动");
                return(true);
            }
            catch (Exception ex)
            {
                log.Error("服务启动失败", ex);
                return(false);
            }
        }
Exemple #2
0
        public bool Start()
        {
            try
            {
                this.bus.Subscribe <ApiLogMessage>("", msg =>
                {
                    FilterPassword(msg);
                    log.Info(msg.ToJson());
                    var dbName  = "ApiLog" + DateTime.Now.ToString("yyyyMM");
                    var colName = msg.Cmd ?? "Default";
                    mongo.InsertOne(dbName, colName, msg);
                });

                log.Info("服务已启动");
                return(true);
            }
            catch (Exception ex)
            {
                log.Error("服务启动失败", ex);
                return(false);
            }
        }