public DeleteUserConsumer(IModel channel, DatepickerAvailabilityLogic datepickerAvailabilityLogic,
                           LogLogic logLogic)
 {
     _channel = channel;
     _datepickerAvailabilityLogic = datepickerAvailabilityLogic;
     _logLogic = logLogic;
 }
        public ActionResult audit(int cid, int status)
        {
            try
            {
                var user = GetUserData();
                if (CustomerLogic.UpdateStatus(cid, status, user.UserId))
                {
                    //添加客户操作日志
                    LogLogic.AddCustomerLog(new LogBaseModel()
                    {
                        objId         = cid,
                        UserId        = user.UserId,
                        ShopId        = user.ShopId,
                        AppSystem     = OS,
                        OperationType = status
                    });

                    return(Json(new ResultModel(ApiStatusCode.OK)));
                }
                else
                {
                    return(Json(new ResultModel(ApiStatusCode.SERVICEERROR)));
                }
            }
            catch (Exception ex)
            {
                LogHelper.Log(string.Format("audit:message:{0},StackTrace:{1}", ex.Message, ex.StackTrace), LogHelperTag.ERROR);
                return(Json(new ResultModel(ApiStatusCode.SERVICEERROR)));
            }
        }
Example #3
0
        public void ApplyTransaction(GateTransaction transaction)
        {
            if (transaction.RemoveComponent == false)
            {
                transaction.Gate.ID = LogLogic.AddComponent(Program.Backend, transaction.Gate.Type);

                Instances.Add(transaction.Gate);
            }
            else
            {
                if (transaction.Gate.ID == 0)
                {
                    throw new InvalidOperationException("Cannot delete a gate that doesn't have a valid id! (Maybe you forgot to apply the transaction before?)");
                }

                if (LogLogic.RemoveComponent(Program.Backend, transaction.Gate.ID) == false)
                {
                    Console.WriteLine($"RemoveComponent(Type: {transaction.Gate.ID}) -> false");
                    Console.WriteLine($"Warn: Rust said we couldn't remove this gate id: {transaction.Gate.ID}. ({transaction.Gate})");
                }
                else
                {
                    Console.WriteLine($"RemoveComponent(Type: {transaction.Gate.ID}) -> true");
                }

                if (Instances.Remove(transaction.Gate) == false)
                {
                    Console.WriteLine($"Warn: Removed non-existent gate! {transaction.Gate}");
                }
            }
        }
Example #4
0
        public ActionResult Init()
        {
            try
            {
                AppInitModel data = AppServiceLogic.Instance.Initialize(Version, OS);
                data.userData = GetUserData();
                if (data.userData != null)
                {
                    data.baseData.userStatus = data.userData.IsActive;
                    //添加登录日志
                    LogLogic.AddLoginLog(new LoginLogModel()
                    {
                        UserId       = data.userData.UserId,
                        UserIdentity = data.userData.UserIdentity,
                        BelongOne    = data.userData.BelongOne,
                        ShopId       = data.userData.ShopId,
                        AppSystem    = OS
                    });
                    UserLogic.UpdateLastLoginTime(data.userData.UserId);
                }
                else
                {
                    data.baseData.userStatus = -1;
                }

                return(Json(new ResultModel(ApiStatusCode.OK, data)));
            }
            catch (Exception ex)
            {
                LogHelper.Log(string.Format("Init error--->StackTrace:{0} message:{1}", ex.StackTrace, ex.Message), LogHelperTag.ERROR);
                return(Json(new ResultModel(ApiStatusCode.SERVICEERROR)));
            }
        }
Example #5
0
        /// <summary>
        /// 执行SQL语句,返回只读数据集
        /// </summary>
        /// <param name="connection">数据库连接</param>
        /// <param name="transaction">事务</param>
        /// <param name="commandType">命令类型(存储过程,命令文本, 其它.)</param>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="parms">查询参数</param>
        /// <returns>返回只读数据集</returns>
        private static MySqlDataReader ExecuteDataReader(MySqlConnection connection, MySqlTransaction transaction, CommandType commandType, string commandText, params MySqlParameter[] parms)
        {
            #region 开始时间
            Stopwatch stopwatch = Stopwatch.StartNew();
            #endregion 开始时间

            MySqlCommand command = new MySqlCommand();
            PrepareCommand(command, connection, transaction, commandType, commandText, parms);
            MySqlDataReader dr = null;

            try
            {
                dr = command.ExecuteReader(CommandBehavior.CloseConnection);
            }
            catch (Exception ex)
            {
                string strLog = "/*" + DateTime.Now.ToString("HH:mm:ss.fff") + "\t" + ex.Message.Replace("\r\n", String.Empty) + "*/ " + MySqlParameterCache.FormatSQLScript(String.Empty, commandType, commandText, parms).Replace("\r\n", String.Empty);
                LogLogic.Write(strLog, ERROR_WRITE_LOG_PATH, ERROR_WRITE_LOG_EXTENSION);
            }

            #region 结束时间
            stopwatch.Stop();
            #endregion 结束时间

            #region 输出SQLScript
            if (MYSQL_SCRIPT_WRITE_LOG)
            {
                string strTestSQL = MySqlParameterCache.FormatSQLScript(String.Empty, commandType, commandText, parms);
                SQLScriptWriteLog(stopwatch.ElapsedMilliseconds, strTestSQL.Replace("\r\n", String.Empty));
            }
            #endregion  输出SQLScript

            return(dr);
        }
Example #6
0
        public MockedLogLogic()
        {
            var autoMapperConfig = AutoMapperConfig.Config.CreateMapper();
            var logDal           = new MockedLogDal().Mock;

            LogLogic = new LogLogic(logDal, autoMapperConfig);
        }
Example #7
0
 public UpdateUserConsumer(IServiceProvider serviceProvider, IModel channel)
 {
     _channel        = channel;
     using var scope = serviceProvider.CreateScope();
     _userLogic      = scope.ServiceProvider.GetRequiredService <UserLogic>();
     _logLogic       = scope.ServiceProvider.GetRequiredService <LogLogic>();
 }
Example #8
0
        // FIXME: Revert here is just a mirrored copy if Apply.
        // We could make this less error prone by consolidating them into one thing?
        public void RevertTransaction(GateTransaction transaction)
        {
            if (transaction.RemoveComponent == false)
            {
                // Here we should revert a add transation, i.e. removing the component
                if (transaction.Gate.ID == 0)
                {
                    throw new InvalidOperationException("Cannot revert a transaction where the gates doesn't have a valid id! (Maybe you forgot to apply the transaction before?)");
                }

                if (LogLogic.RemoveComponent(Program.Backend, transaction.Gate.ID) == false)
                {
                    Console.WriteLine($"Warn: Rust said we couldn't remove this gate id: {transaction.Gate.ID}. ({transaction.Gate})");
                }

                if (Instances.Remove(transaction.Gate) == false)
                {
                    Console.WriteLine($"Warn: Removed non-existent gate! {transaction.Gate}");
                }
            }
            else
            {
                // Here we are reverting a delete, i.e. adding it back again
                transaction.Gate.ID = LogLogic.AddComponent(Program.Backend, transaction.Gate.Type);
                Instances.Add(transaction.Gate);
            }
        }
 public EventDateUserController(EventDateUserLogic eventDateUserLogic,
                                ControllerHelper controllerHelper, LogLogic logLogic)
 {
     _eventDateUserLogic = eventDateUserLogic;
     _controllerHelper   = controllerHelper;
     _logLogic           = logLogic;
 }
Example #10
0
 public EventController(IMapper mapper, EventLogic eventLogic, ControllerHelper controllerHelper,
                        LogLogic logLogic)
 {
     _mapper           = mapper;
     _eventLogic       = eventLogic;
     _controllerHelper = controllerHelper;
     _logLogic         = logLogic;
 }
 public DeleteUserConsumer(IModel channel, EventDateUserLogic eventDateUserLogic,
                           EventStepUserLogic eventStepUserLogic, LogLogic logLogic)
 {
     _channel            = channel;
     _eventDateUserLogic = eventDateUserLogic;
     _eventStepUserLogic = eventStepUserLogic;
     _logLogic           = logLogic;
 }
Example #12
0
 public DatepickerAvailabilityController(DatepickerAvailabilityLogic datepickerAvailabilityLogic,
                                         ControllerHelper controllerHelper, IMapper mapper, LogLogic logLogic)
 {
     _datepickerAvailabilityLogic = datepickerAvailabilityLogic;
     _controllerHelper            = controllerHelper;
     _mapper   = mapper;
     _logLogic = logLogic;
 }
Example #13
0
 public DatepickerController(DatepickerLogic datepickerLogic, IMapper mapper,
                             ControllerHelper controllerHelper, LogLogic logLogic)
 {
     _datepickerLogic  = datepickerLogic;
     _mapper           = mapper;
     _controllerHelper = controllerHelper;
     _logLogic         = logLogic;
 }
 public AuthenticationController(AuthenticationLogic authorizationLogic, LogLogic logLogic, JwtLogic jwtLogic,
                                 ControllerHelper controllerHelper)
 {
     _authorizationLogic = authorizationLogic;
     _logLogic           = logLogic;
     _jwtLogic           = jwtLogic;
     _controllerHelper   = controllerHelper;
 }
Example #15
0
 public UserController(UserLogic userLogic, IMapper mapper, ControllerHelper helper,
                       LogLogic logLogic)
 {
     _userLogic = userLogic;
     _mapper    = mapper;
     _helper    = helper;
     _logLogic  = logLogic;
 }
Example #16
0
        /// <summary>
        /// Post
        /// </summary>
        public ActionResult Post(LogInfo logInfo)
        {
            LogLogic logic = new LogLogic();

            if (!ModelState.IsValid)
            {
                //return badre(ModelState);
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "参数不合法"));
            }

            //检查安全密钥
            if (!logic.CheckKeyIsIsValid(logInfo))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "安全密钥不匹配,请检查安全密钥!"));
            }

            #region 设置颜色

            var color = "#FFFF33";
            switch (logInfo.Level)
            {
            case "Error":
                color = "#FF3030";
                break;

            case "Warn":
                color = "#FFC125";
                break;

            case "Debug":
                color = "#FAEBD7";
                break;

            case "Info":
                color = "#FCFCFC";
                break;

            case "Trace":
                color = "#3CB371";
                break;

            default:
                break;
            }

            #endregion

            var data = new LogAttachment()
            {
                Title    = HttpUtility.UrlDecode(logInfo.Title),
                Text     = HttpUtility.UrlDecode(logInfo.Message),
                Pretext  = logInfo.Level,
                Color    = color,
                Fallback = logInfo.Title
            };

            return(Json(Log(data)));
        }
 public AdminController(QuestionLogic questionLogic, CategoryLogic categoryLogic, ReactionLogic reactionLogic, UserLogic userLogic, ChatLogic chatLogic, LogLogic logLogic)
 {
     _questionLogic = questionLogic;
     _categoryLogic = categoryLogic;
     _reactionLogic = reactionLogic;
     _userLogic     = userLogic;
     _chatLogic     = chatLogic;
     _logLogic      = logLogic;
 }
Example #18
0
        public void AddNullLog()
        {
            var logRepositoryMock = new Mock <ILogRepository>(MockBehavior.Strict);

            logRepositoryMock.Setup(m => m.Add(It.IsAny <Log>()));
            logRepositoryMock.Setup(m => m.SaveChanges());

            logLogic = new LogLogic(logRepositoryMock.Object);
            logLogic.Add(null);

            logRepositoryMock.VerifyAll();
        }
Example #19
0
        public RpcServer(IModel channel, string queue, Func<string, Task<string>> callbackMethod, LogLogic logLogic)
        {
            _logLogic = logLogic;

            channel.QueueDeclare(queue, false, false, false, null);
            channel.BasicQos(0, 1, false);
            var consumer = new EventingBasicConsumer(channel);
            channel.BasicConsume(queue,
                false, consumer);

            Configure(channel, consumer, callbackMethod);
        }
Example #20
0
        public void RemoveNullLog()
        {
            var logRepositoryMock = new Mock <ILogRepository>(MockBehavior.Strict);

            logRepositoryMock.Setup(m => m.Remove(It.IsAny <Log>()));
            logRepositoryMock.Setup(m => m.Get(It.IsAny <Guid>())).Returns((Log)null);
            logRepositoryMock.Setup(m => m.SaveChanges());

            logLogic = new LogLogic(logRepositoryMock.Object);
            logLogic.Remove(anotherLog);

            logRepositoryMock.VerifyAll();
        }
Example #21
0
 /// <summary>
 /// 输出SQL脚本到Log
 /// </summary>
 /// <param name="dateTimeBegin">开始时间</param>
 /// <param name="dateTimeEnd">结束时间</param>
 /// <param name="strSQLScript">输出SQL脚本</param>
 public static void SQLScriptWriteLog(long longMilliseconds, string strSQLScript)
 {
     try
     {
         string strUrl             = ClientModel.GetUrl();
         string strUserHostAddress = ClientModel.GetIPAdderss();
         string strLog             = "/*" + longMilliseconds.ToString().PadLeft(8, ' ') + "ms " + DateTime.Now.ToString("HH:mm:ss.fff") + " " + strUserHostAddress.PadLeft(15, ' ') + "*/ " + strSQLScript + " /*" + strUrl + "*/";
         LogLogic.Write(strLog, MYSQL_SCRIPT_WRITE_LOG_PATH, MYSQL_SCRIPT_WRITE_LOG_EXTENSION);
     }
     catch
     {
     }
 }
Example #22
0
        protected override async Task <HttpResponseMessage> SendAsync(
            HttpRequestMessage request, CancellationToken cancellationToken)
        {
            LogLogic.logRequest(request);

            var result = await base.SendAsync(request, cancellationToken);

            var responseBody = await result.Content.ReadAsStringAsync();

            LogLogic.logResponse(responseBody);

            return(result);
        }
Example #23
0
        public void GetAllLogs()
        {
            List <Log> logs = new List <Log>();

            var logRepositoryMock = new Mock <ILogRepository>(MockBehavior.Strict);

            logRepositoryMock.Setup(m => m.GetAll()).Returns(logs);

            logLogic = new LogLogic(logRepositoryMock.Object);
            var result = logLogic.GetAll();

            logRepositoryMock.VerifyAll();

            Assert.AreEqual(logs.Count, result.Count);
        }
Example #24
0
        public void GetLogsByDate()
        {
            List <Log> logs = new List <Log>();

            logs.Add(anotherLog);
            DateTime from = DateTime.Now.AddDays(-2);
            var      logRepositoryMock = new Mock <ILogRepository>(MockBehavior.Strict);

            logRepositoryMock.Setup(m => m.GetLogsByDate(It.IsAny <DateTime>(), It.IsAny <DateTime>())).Returns(logs);

            logLogic = new LogLogic(logRepositoryMock.Object);
            var result = logLogic.GetLogsByDate(from, DateTime.Now);

            logRepositoryMock.VerifyAll();

            Assert.AreEqual(logs, result);
        }
 public IActionResult Import(Guid token)
 {
     try
     {
         LogLogic ll   = new LogLogic(null);
         User     user = sessionLogic.GetUserFromToken(token);
         Log      log  = new Log {
             Username = user.Username,
             Date     = DateTime.Now,
             Accion   = "Import"
         };
         ll.AddRegister(log);
         return(Ok());
     }
     catch (DataBaseLogicException) { return(BadRequest("Error en la conexión con la base de datos")); }
     catch (InvalidOperationLogicException) { return(BadRequest("Error en el sistema")); }
 }
        public void AddRegisterTest()
        {
            String user = "******";
            Log    log  = new Log {
                Username = user,
                Date     = DateTime.Now,
            };

            var mock = new Mock <IRepository <Log> >(MockBehavior.Strict);

            mock.Setup(m => m.Add(It.IsAny <Log>()));
            mock.Setup(m => m.Save());

            ILog LogLogic = new LogLogic(mock.Object);
            var  result   = LogLogic.AddRegister(log);

            mock.VerifyAll();
            Assert.AreEqual(log.Username, result.Username);
        }
Example #27
0
        private void addReply()
        {
            int    mailid   = GetFormValue("mailid", 0);
            int    SendType = GetFormValue("sendtype", 0);
            string content  = HttpUtility.UrlDecode(GetFormValue("content", ""));
            string auth     = GetFormValue("auth", "");
            string title    = HttpUtility.UrlDecode(GetFormValue("title", ""));
            int    userId   = 0;

            if (!string.IsNullOrEmpty(auth))
            {
                userId = UserLogic.GetUserIdByAuthToken(auth);
                if (userId == 0)
                {
                    json = JsonHelper.JsonSerializer(new ResultModel(ApiStatusCode.令牌失效));
                    return;
                }
                var user = UserLogic.GetModel(userId);


                MailModel model = new MailModel();
                model.AuthorId    = -1;
                model.AuthorName  = user.NickName;
                model.Title       = title;
                model.BodyContent = content;
                model.CoverUrl    = user.UserHeadImg;
                model.SendType    = SendType;
                model.ReplyPid    = mailid;
                model.ReplyUserId = userId;
                model.PhoneModel  = HttpUtility.UrlDecode(GetFormValue("pm", ""));
                if (ArticleLogic.AddMailInfo(model) > 0)
                {
                    //将该消息接收人的已阅读状态改为未读
                    LogLogic.UpdateMailNotReadStatus(userId, mailid);
                    json = JsonHelper.JsonSerializer(new ResultModel(ApiStatusCode.OK));
                }
            }
            else
            {
                json = JsonHelper.JsonSerializer(new ResultModel(ApiStatusCode.令牌失效));
            }
        }
Example #28
0
        public void OnResultExecuted(ResultExecutedContext filterContext)
        {
            // Save log entries
            var logLogic = new LogLogic();

            logLogic.FlushRequestLogs();

            // Stop if static resource
            var webHelper = new WebHelper(filterContext.HttpContext);

            if (webHelper.IsStaticResource())
            {
                return;
            }

            // Close DB connections
            var mgr = MyServiceLocator.GetInstance <IDbSessionCleanup>();

            mgr.CloseDbConnections();
        }
        public MainPage()
        {
            _jobLogic     = new JobLogic();
            _triggerLogic = new TriggerLogic();
            _logLogic     = new LogLogic();

            InitializeComponent();

            Jobs     = _jobLogic.appoggio;
            Triggers = _triggerLogic.appoggio;

            EnableView(ViewTypeEnum.TRIGGER);
            _triggerLogic.LoadGrid(dataGridView1, Jobs);

            try
            {
                CheckStatus();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
 public IActionResult Login([FromBody] SessionModel sessionModel)
 {
     try
     {
         Guid token = sessionLogic.Login(sessionModel.username, sessionModel.password);
         if (token == null)
         {
             return(BadRequest(sessionModel));
         }
         LogLogic ll  = new LogLogic(null);
         Log      log = new Log {
             Username = sessionModel.username,
             Date     = DateTime.Now,
             Accion   = "Login"
         };
         ll.AddRegister(log);
         return(Ok(token));
     }
     catch (ArgumentException exception)
     {
         return(BadRequest("Error " + sessionModel.username + " " + sessionModel.password + " -> " + exception.Message));
     }
 }