Exemple #1
0
        /// <summary>
        /// Procesa el mensaje a registrar en log
        /// </summary>
        /// <param name="message">Mensaje para el registro de log</param>
        /// <param name="logToFile">indica si se escribe en archivo</param>
        /// <param name="type">tipo de mensaje(1:INFO, 2:ALERT, 3:ERROR)</param>
        public void LogMessage(string message, bool logToFile, EnumMessageType type)
        {
            message.Trim();

            if (string.IsNullOrEmpty(message))
            {
                return;
            }

            if (!logToFile)
            {
                throw new Exception("Invalid Code");
            }

            if (type != EnumMessageType.ALERT && type != EnumMessageType.ERROR && type != EnumMessageType.INFO)
            {
                throw new Exception("Must Especify a MessageType");
            }

            Log log = new Log
            {
                Message = message,
                TYpe    = (int)type,
                Date    = DateTime.Now
            };

            if (logToFile)
            {
                this.LoggerToFile.LogToFile(log);
            }
        }
Exemple #2
0
        public void Save(string message, EnumMessageType enumMessageType = EnumMessageType.Information)
        {
            // Set Locked
            _readWriteLock.EnterWriteLock();
            try
            {
                if (!_dataUltimaCriacao.HasValue || DateTime.Now.Day != _dataUltimaCriacao.Value.Day)
                {
                    //Verifica se o arquivo existe
                    if (File.Exists(GetFilePath()))
                    {
                        //Renomeia o arquivo antigo
                        RenameOldFile();
                    }

                    _dataUltimaCriacao = DateTime.Now;
                }


                // Grava o arquivo
                using (StreamWriter sw = File.AppendText(GetFilePath()))
                {
                    message = $"{DateTime.Now} - {enumMessageType.GetDescription()} -> {message}";

                    sw.WriteLine(message);
                    sw.Close();
                }
            }
            finally
            {
                // Release lock
                _readWriteLock.ExitWriteLock();
            }
        }
Exemple #3
0
        private static void SaveToContigency(string message, EnumMessageType enumMessageType = EnumMessageType.Information)
        {
            string whereToSave = ConfigHelper.GetKeyAppSettings("Log_TrySave_Set_Sequence_EnumLogType_Contingency");

            string[] vetEnumLogType = whereToSave.Split(',');

            int contingencyNumberUsed          = 0;
            int contingencyNumberUsedWithError = 0;

            foreach (var enumLogType in vetEnumLogType)
            {
                ILog log = FactoryLog.GetLogType(enumLogType);

                contingencyNumberUsed++;

                try
                {
                    log.Save(message, enumMessageType);

                    break;
                }
                catch
                {
                    contingencyNumberUsedWithError++;
                }
            }

            if (contingencyNumberUsed == contingencyNumberUsedWithError)
            {
                throw new Exception("LOG_CONTIGENCY -> Não foi possível salvar o log.");
            }
        }
        public Message Create(string s, EnumMessageType type)
        {
            Message message = (Message)null;

            switch (type)
            {
                case EnumMessageType.INFO:
                    {
                        message = new InfoMessage(s);
                        break;
                    }
                case EnumMessageType.WARNING:
                    {
                        message = new WarningMessage(s);
                        break;
                    }
                case EnumMessageType.ERROR:
                    {
                        message = new ErrorMessage(s);
                        break;
                    }
            }

            return message;
        }
Exemple #5
0
        public static void Save(string message, EnumMessageType enumMessageType = EnumMessageType.Information)
        {
            if (string.IsNullOrWhiteSpace(message))
            {
                return;
            }

            //Verifica se tem permissão para gravar o tipo de mensagem
            if (HasPermissionSaveMessageType(enumMessageType) == false)
            {
                return;
            }

            try
            {
                //Salva em todos os lugares configurados
                SaveToAll(message, enumMessageType);
            }
            catch (Exception ex)
            {
                //Verifica se tem permissão para gravar o tipo de mensagem
                if (HasPermissionSaveMessageType(enumMessageType) == false)
                {
                    return;
                }

                //Salva no primeiro local configurado, caso de algum erro, salva no próximo lugar
                SaveToContigency("LOG_SAVEALL -> " + GetMessageOfException(ex), EnumMessageType.Error);
                SaveToContigency("LOG_CONTIGENCY -> " + message);
            }
        }
Exemple #6
0
        public Message Create(string s, EnumMessageType type)
        {
            Message message = (Message)null;

            switch (type)
            {
            case EnumMessageType.INFO:
            {
                message = new InfoMessage(s);
                break;
            }

            case EnumMessageType.WARNING:
            {
                message = new WarningMessage(s);
                break;
            }

            case EnumMessageType.ERROR:
            {
                message = new ErrorMessage(s);
                break;
            }
            }

            return(message);
        }
Exemple #7
0
        private static ReturnMessageModel ReturnMessage(String message, EnumMessageType messageType)
        {
            ReturnMessageModel returnMessageModel = new ReturnMessageModel();

            returnMessageModel.MessageType = messageType;
            returnMessageModel.Message     = message;

            return(returnMessageModel);
        }
Exemple #8
0
        public void NotifyMessage(string message, EnumMessageType type)
        {
            Notification notification = null;

            if (TryGetNotificationStrategy(type, ref notification))
            {
                notification.SendNotificaction(message);
            }
            // notification.SendNotificaction(message);
        }
Exemple #9
0
        private static void SaveToAll(string message, EnumMessageType enumMessageType)
        {
            string whereToSave = ConfigHelper.GetKeyAppSettings("Log_SaveAll_Set_Sequence_EnumLogType");

            whereToSave.Trim().Split(',').ToList().ForEach(enumLogType =>
            {
                ILog log = FactoryLog.GetLogType(enumLogType);

                log.Save(message, enumMessageType);
            });
        }
Exemple #10
0
        protected static string FormatMessage(string message, EnumMessageType messageType)
        {
            string cssClass = "Message ";

            switch (messageType)
            {
            case EnumMessageType.Error:
                cssClass += "Error";
                break;

            case EnumMessageType.Success:
                cssClass += "Success";
                break;
            }
            return(String.Format("<div class='{0}'>{1}</div>", cssClass, message));
        }
Exemple #11
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="message"></param>
        /// <param name="title"></param>
        /// <param name="type"></param>
        public clsErrorHandler(string message, string title = "", EnumMessageType type = EnumMessageType.Error)
        {
            this.Message = message;
            this.Type = type;

            if (title != "")
            {
                this.Title = title;
            }
            else
            {
                convertTypeToString(type);
            }

            writeToLog();
            raiseError();
        }
Exemple #12
0
        private static bool HasPermissionSaveMessageType(EnumMessageType enumMessageType)
        {
            string enumsMessageType = ConfigHelper.GetKeyAppSettings("Log_MessageType_View");

            string[] vetEnumsMessageType = enumsMessageType.Trim().Split(',');

            //Verifica se o tipo de messagem tem permissao para gravar
            bool permissao = false;

            vetEnumsMessageType.ToList().ForEach(x => {
                if (int.Parse(x) == (int)enumMessageType)
                {
                    permissao = true;
                }
            });

            return(permissao);
        }
        public void Save(string message, EnumMessageType enumMessageType = EnumMessageType.Information)
        {
            EventLog eventLog = new EventLog();

            eventLog.Source = _source;

            if (enumMessageType == EnumMessageType.Information)
            {
                eventLog.WriteEntry(message, EventLogEntryType.Information);
            }
            else if (enumMessageType == EnumMessageType.Warning)
            {
                eventLog.WriteEntry(message, EventLogEntryType.Warning);
            }
            else if (enumMessageType == EnumMessageType.Error)
            {
                eventLog.WriteEntry(message, EventLogEntryType.Error);
            }
        }
Exemple #14
0
        public void NotifyMessage(string message, EnumMessageType type)
        {
            switch (type)
            {
            case EnumMessageType.Email:
                new Notification().EmailNotify(message);
                break;

            case EnumMessageType.Whatsapp:
                new Notification().WhatsappNotify(message);
                break;

            case EnumMessageType.Sms:
                new Notification().SmsNotify(message);
                break;

            default:
                break;
            }
        }
Exemple #15
0
        private void Notify(WwwWorkItem wwwWorkItem, EnumMessageType message)
        {
            try
            {
                if (links.ContainsKey(wwwWorkItem))
                {
                    WorkTarget target = links[wwwWorkItem];
                    switch (message)
                    {
                    case EnumMessageType.DownSuccess:
                        if (target != null)
                        {
                            if (target.successCallBack != null)
                            {
                                target.successCallBack(target.url, wwwWorkItem.dataPath, target.successCallParam);
                            }
                        }
                        break;

                    case EnumMessageType.HasError:
                        if (target != null)
                        {
                            System.Action <string, string, System.Object> callback = target.successCallBack;

                            if (callback != null)
                            {
                                callback(target.url, null, target.successCallParam);
                            }
                        }
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogError("www download call back error->" + message + "^" + e.ToString());
            }

            WwwWorkpool.instance.CheckTheQueueAndWork();
        }
Exemple #16
0
        private bool TryGetNotificationStrategy(EnumMessageType type, ref Notification notification)
        {
            switch (type)
            {
            case EnumMessageType.Email:
                notification = new Notification(new Email());
                break;

            case EnumMessageType.Whatsapp:
                notification = new Notification(new Whatsapp());
                break;

            case EnumMessageType.Sms:
                notification = new Notification(new Sms());
                break;

            default:
                notification = new Notification(new Whatsapp());
                break;
            }

            return(notification != null);
        }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            EnumMessageType msg    = (EnumMessageType)value;
            BitmapImage     bitmap = null;

            switch (msg)
            {
            case EnumMessageType.Info:
                bitmap = new BitmapImage(new Uri(@"..\Image\Info24_24.png", UriKind.Relative));
                break;

            case EnumMessageType.Warning:
                bitmap = new BitmapImage(new Uri(@"..\Image\Warning24_24.png", UriKind.Relative));
                break;

            case EnumMessageType.Error:
                bitmap = new BitmapImage(new Uri(@"..\Image\Error24_24.png", UriKind.Relative));
                break;

            default:
                break;
            }
            return(bitmap);
        }
Exemple #18
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            EnumMessageType msg   = (EnumMessageType)value;
            Brush           brush = null;

            switch (msg)
            {
            case EnumMessageType.Info:
                brush = new SolidColorBrush(Color.FromRgb(0, 0, 0));
                break;

            case EnumMessageType.Warning:
                brush = new SolidColorBrush(Color.FromRgb(200, 200, 0));
                break;

            case EnumMessageType.Error:
                brush = new SolidColorBrush(Color.FromRgb(255, 0, 0));
                break;

            default:
                break;
            }
            return(brush);
        }
Exemple #19
0
 private TreatmentMessageModel(string id, EnumMessageType messageType, string expectedChunkId, string expectedNextChunkId)
 {
     _id          = id;
     _messageType = messageType;
 }
Exemple #20
0
 public Message(EnumMessageType enumMessageType, object payLoad, object origin)
 {
     _enumMessageType = enumMessageType;
     _payLoad         = payLoad;
     _origin          = origin;
 }
Exemple #21
0
 protected void ShowMessage(string msgText, EnumMessageType msgType)
 {
     TempData["MessageText"] = msgText;
     TempData["MessageType"] = msgType;
 }
 public GameMessageMeta(short messageId, EnumMessageType messageType, EnumServerType serverType)
 {
     this.messageId   = messageId;
     this.messageType = messageType;
     this.serverType  = serverType;
 }
 public ChangedEventMessage(string message, EnumMessageType messageType)
 {
     Message     = message;
     MessageType = messageType;
 }
 public static void SetMessageType(DependencyObject obj, EnumMessageType value)
 {
     obj.SetValue(MessageTypeProperty, value);
 }
Exemple #25
0
        /// <summary>
        /// 通过消息类型枚举值获取消息类型代码
        /// </summary>
        /// <param name="em"></param>
        /// <returns></returns>
        public static int EnumMessageType_GetTypeCodeByEnum(EnumMessageType em)
        {
            var typeCode = 0;

            switch (em)
            {
            case EnumMessageType.BookingSuccess:
                typeCode = 1001;
                break;

            case EnumMessageType.CancelBooking:
                typeCode = 1002;
                break;

            case EnumMessageType.StopExaming:
                typeCode = 1003;
                break;

            case EnumMessageType.CancelStopExaming:
                typeCode = 1004;
                break;

            case EnumMessageType.BerthApply:
                typeCode = 1005;
                break;

            case EnumMessageType.InformAdmission:
                typeCode = 1006;
                break;

            case EnumMessageType.CancelBerth:
                typeCode = 1007;
                break;

            case EnumMessageType.SurgeryApply:
                typeCode = 1008;
                break;

            case EnumMessageType.SurgeryVerify:
                typeCode = 1009;
                break;

            case EnumMessageType.SurgeryRefuse:
                typeCode = 1010;
                break;

            case EnumMessageType.SurgeryCancel:
                typeCode = 1011;
                break;

            case EnumMessageType.MedicalBookingSuccess:
                typeCode = 1012;
                break;

            case EnumMessageType.MedicalCancelBookingSuccess:
                typeCode = 1013;
                break;

            case EnumMessageType.AlterMedicalBookingSuccess:
                typeCode = 1014;
                break;

            case EnumMessageType.BookingSuccessReNotify:
                typeCode = 1015;
                break;

            case EnumMessageType.CheckingInSuccess:
                typeCode = 1016;
                break;
            }
            return(typeCode);
        }
Exemple #26
0
 private MessageBoxImage getMessageIconByType(EnumMessageType type)
 {
     switch (type)
     {
         case EnumMessageType.Error:
             return MessageBoxImage.Error;
         case EnumMessageType.Info:
             return MessageBoxImage.Information;
         case EnumMessageType.Warning:
             return MessageBoxImage.Warning;
         default:
             return MessageBoxImage.Error;
     }
 }
Exemple #27
0
 private TreatmentMessageModel(MessageModel messageModel, EnumMessageType messageType)
 {
     _messageModel = messageModel;
     _messageType  = messageType;
 }
Exemple #28
0
 public Message(EnumMessageType enumMessageType, object payLoad, object origin)
 {
     _enumMessageType = enumMessageType;
     _payLoad = payLoad;
     _origin = origin;
 }
Exemple #29
0
        /// <summary>
        /// 通过消息类型名称获取消息类型枚举值
        /// </summary>
        /// <param name="typeName"></param>
        /// <returns></returns>
        public static EnumMessageType EnumMessageType_GetTypeEnumByName(string typeName)
        {
            var messageTypeEnum = new EnumMessageType();

            switch (typeName)
            {
            case "预约成功":
                messageTypeEnum = EnumMessageType.BookingSuccess;
                break;

            case "取消预约成功":
                messageTypeEnum = EnumMessageType.CancelBooking;
                break;

            case "医生停诊成功":
                messageTypeEnum = EnumMessageType.StopExaming;
                break;

            case "医生取消停诊成功":
                messageTypeEnum = EnumMessageType.CancelStopExaming;
                break;

            case "床位申请成功":
                messageTypeEnum = EnumMessageType.BerthApply;
                break;

            case "通知入院":
                messageTypeEnum = EnumMessageType.InformAdmission;
                break;

            case "床位取消成功":
                messageTypeEnum = EnumMessageType.CancelBerth;
                break;

            case "手术申请成功":
                messageTypeEnum = EnumMessageType.SurgeryApply;
                break;

            case "手术审核成功":
                messageTypeEnum = EnumMessageType.SurgeryVerify;
                break;

            case "手术拒绝成功":
                messageTypeEnum = EnumMessageType.SurgeryRefuse;
                break;

            case "手术取消成功":
                messageTypeEnum = EnumMessageType.SurgeryCancel;
                break;

            case "医技预约成功":
                messageTypeEnum = EnumMessageType.MedicalBookingSuccess;
                break;

            case "医技取消预约成功":
                messageTypeEnum = EnumMessageType.MedicalCancelBookingSuccess;
                break;

            case "医技修改预约成功":
                messageTypeEnum = EnumMessageType.AlterMedicalBookingSuccess;
                break;

            case "医技预约再次提醒":
                messageTypeEnum = EnumMessageType.BookingSuccessReNotify;
                break;

            case "患者签到成功":
                messageTypeEnum = EnumMessageType.CheckingInSuccess;
                break;
            }
            return(messageTypeEnum);
        }
Exemple #30
0
 public async Task SaveAsync(string message, EnumMessageType enumMessageType = EnumMessageType.Information)
 {
     await Task.Run(() => Save(message, enumMessageType));
 }
Exemple #31
0
        /// <summary>
        /// 通过消息类型枚举值获取消息类型名称
        /// </summary>
        /// <param name="em"></param>
        /// <returns></returns>
        public static string EnumMessageType_GetTypeNameByEnum(EnumMessageType em)
        {
            var typeName = "";

            switch (em)
            {
            case EnumMessageType.BookingSuccess:
                typeName = "预约成功";
                break;

            case EnumMessageType.CancelBooking:
                typeName = "取消预约成功";
                break;

            case EnumMessageType.StopExaming:
                typeName = "医生停诊成功";
                break;

            case EnumMessageType.CancelStopExaming:
                typeName = "医生取消停诊成功";
                break;

            case EnumMessageType.BerthApply:
                typeName = "床位申请成功";
                break;

            case EnumMessageType.InformAdmission:
                typeName = "通知入院";
                break;

            case EnumMessageType.CancelBerth:
                typeName = "床位取消成功";
                break;

            case EnumMessageType.SurgeryApply:
                typeName = "手术申请成功";
                break;

            case EnumMessageType.SurgeryVerify:
                typeName = "手术审核成功";
                break;

            case EnumMessageType.SurgeryRefuse:
                typeName = "手术拒绝成功";
                break;

            case EnumMessageType.SurgeryCancel:
                typeName = "手术取消成功";
                break;

            case EnumMessageType.MedicalBookingSuccess:
                typeName = "医技预约成功";
                break;

            case EnumMessageType.MedicalCancelBookingSuccess:
                typeName = "医技取消预约成功";
                break;

            case EnumMessageType.AlterMedicalBookingSuccess:
                typeName = "医技修改预约成功";
                break;

            case EnumMessageType.BookingSuccessReNotify:
                typeName = "医技预约再次提醒";
                break;

            case EnumMessageType.CheckingInSuccess:
                typeName = "患者签到成功";
                break;
            }
            return(typeName);
        }
Exemple #32
0
 private TreatmentMessageModel(string id, EnumMessageType messageType)
 {
     _id          = id;
     _messageType = messageType;
 }
Exemple #33
0
 private string convertTypeToString(EnumMessageType type)
 {
     switch (type)
     {
         case EnumMessageType.Error:
             return "Fehler";
         case EnumMessageType.Info:
             return "Info";
         case EnumMessageType.Warning:
             return "Warning";
         default:
             return "Error";
     }
 }
Exemple #34
0
 public TreatmentMessageModel(string id, string errorMessage, EnumMessageType messageType)
 {
     _id           = id;
     _errorMessage = errorMessage;
     _messageType  = messageType;
 }
Exemple #35
0
        public void Save(string message, EnumMessageType enumMessageType = EnumMessageType.Information)
        {
            List <DbParameter> parametros = new List <DbParameter>();

            if (_enumDatabaseType == EnumDatabaseType.SqlServer)
            {
                parametros.Add(new SqlParameter()
                {
                    DbType        = DbType.String,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@ApplicationName",
                    Value         = _applicationName
                });

                parametros.Add(new SqlParameter()
                {
                    DbType        = DbType.String,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@Message",
                    Value         = message
                });


                parametros.Add(new SqlParameter()
                {
                    DbType        = DbType.String,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@MessageType",
                    Value         = enumMessageType.GetDescription()
                });
            }
            else if (_enumDatabaseType == EnumDatabaseType.MySql)
            {
                parametros.Add(new MySqlParameter()
                {
                    DbType        = DbType.String,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@ApplicationName",
                    Value         = _applicationName
                });

                parametros.Add(new MySqlParameter()
                {
                    DbType        = DbType.String,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@Message",
                    Value         = message
                });

                parametros.Add(new MySqlParameter()
                {
                    DbType        = DbType.String,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@MessageType",
                    Value         = enumMessageType.GetDescription()
                });
            }
            else if (_enumDatabaseType == EnumDatabaseType.Firebird)
            {
                parametros.Add(new FbParameter()
                {
                    DbType        = DbType.String,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@ApplicationName",
                    Value         = _applicationName
                });

                parametros.Add(new FbParameter()
                {
                    DbType        = DbType.String,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@Message",
                    Value         = message
                });

                parametros.Add(new FbParameter()
                {
                    DbType        = DbType.String,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@MessageType",
                    Value         = enumMessageType.GetDescription()
                });
            }


            string sql = $"INSERT INTO log (Application, MessageType, Message, CurrentDate) VALUES (@ApplicationName, @MessageType, @Message, '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}');";

            CommandSql comandoSql = new CommandSql(_connectionString, sql, parametros, _enumDatabaseType);

            this.ExecuteNonQuery(comandoSql);
        }