Пример #1
0
        public void ShowError(string message, Exception exception)
        {
            StringBuilder sb = new StringBuilder(message.ToStringExt());

            sb.AppendLine(Hlp.GetExceptionText(exception).Substring(0, 200) + "...");
            ShowMessageFormInternal(LogLevel.Error, sb.ToString(), "Помилка", null);
        }
Пример #2
0
        public bool OnAddComment(string newComment)
        {
            _logger.Debug("OnAddComment");

            try
            {
                string login = _commonService.Login;
                Request.Comments = string.Format("{0}[{1}   {2}]{3}{4}{5}{6}", Request.Comments, DateTime.Now.ToString("dd.MM.yyyy    HH:mm:ss"), login, Environment.NewLine, newComment, Environment.NewLine, Environment.NewLine);
                return(true);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                _messageBoxMgr.ShowMessageWithDetail(LogLevel.Error, "Помилка під час додавання нового коменту.", Hlp.GetExceptionText(ex), "Помилка", null);
                return(false);
            }
        }
Пример #3
0
        public void OnExecuteAttach()
        {
            _logger.Debug("OnExecuteAttaches");

            try
            {
                if (Request.Attaches.Current == null)
                {
                    return;
                }
                string path = System.IO.Path.GetTempPath() + Request.Attaches.Current.Name;
                if (File.Exists(path))
                {
                    path = Path.GetDirectoryName(path) + "\\" + Path.GetFileNameWithoutExtension(path) + DateTime.Now.ToString("_dd_MM_hh_mm_ss") + Path.GetExtension(path);
                }
                using (System.IO.Stream s = new FileStream(path, FileMode.Create, FileAccess.ReadWrite))
                {
                    s.Write(Request.Attaches.Current.Blob, 0, Request.Attaches.Current.Blob.Length);
                }

                if (File.Exists(path))
                {
                    System.Diagnostics.Process.Start(path);
                }
                else
                {
                    throw new ArgumentException("Can not find file: " + path);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                _messageBoxMgr.ShowMessageWithDetail(LogLevel.Error, "Помилка під час відкриття додатку зверенння.", Hlp.GetExceptionText(ex), "Помилка", null);
            }
        }
Пример #4
0
        public void OnRemoveAttaches()
        {
            _logger.Debug("OnSaveAttaches");

            try
            {
                if (Request.Attaches.Current == null)
                {
                    return;
                }
                Request.Attaches.Entities.Remove(Request.Attaches.Current);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                _messageBoxMgr.ShowMessageWithDetail(LogLevel.Error, "Помилка під час видалення додатків зверенння.", Hlp.GetExceptionText(ex), "Помилка", null);
            }
        }
Пример #5
0
        public void OnSaveAttaches(bool saveAllFiles)
        {
            _logger.Debug("OnSaveAttaches");

            try
            {
                if (Request.Attaches.Entities.Count == 0)
                {
                    return;
                }

                if (saveAllFiles)
                {
                    using (FolderBrowserDialog directoryDialog = new FolderBrowserDialog())
                    {
                        if (directoryDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                        {
                            return;
                        }

                        string dirPath = directoryDialog.SelectedPath;
                        foreach (AttachEntity attach in Request.Attaches.Entities)
                        {
                            if (File.Exists(Path.Combine(dirPath, attach.Name)))
                            {
                                SaveAttachWithDialog(dirPath, attach);
                            }
                            else
                            {
                                File.WriteAllBytes(dirPath, attach.Blob);
                            }
                        }
                    }
                }
                else
                {
                    if (Request.Attaches.Current != null)
                    {
                        SaveAttachWithDialog(Path.GetTempPath(), Request.Attaches.Current);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                _messageBoxMgr.ShowMessageWithDetail(LogLevel.Error, "Помилка під час збереження додатків зверенння.", Hlp.GetExceptionText(ex), "Помилка", null);
            }
        }
Пример #6
0
        public void OnAddAttaches(bool moveToArchive)
        {
            _logger.Debug("OnAddAttaches");

            try
            {
                using (OpenFileDialog openDialog = new OpenFileDialog())
                {
                    openDialog.Multiselect      = true;
                    openDialog.RestoreDirectory = true;
                    System.Windows.Forms.DialogResult result = openDialog.ShowDialog();
                    if (result != System.Windows.Forms.DialogResult.OK || openDialog.FileNames == null || openDialog.FileNames.Length == 0)
                    {
                        return;
                    }

                    List <AttachEntity> attaches     = new List <AttachEntity>();
                    List <string>       fileNameList = new List <string>();
                    foreach (string fileName in openDialog.FileNames)
                    {
                        byte[] bytes = FileHlp.ReadFile(fileName);

                        AttachEntity attach = new AttachEntity();
                        attach.DateCreate = DateTime.Now;
                        attach.Name       = Path.GetFileName(fileName);
                        attach.Blob       = bytes;
                        attaches.Add(attach);

                        fileNameList.Add(fileName);
                    }
                    foreach (AttachEntity attach in attaches)
                    {
                        Request.Attaches.Entities.Add(attach);
                    }

                    if (moveToArchive)
                    {
                        AttachEntity attach = new AttachEntity();
                        attach.DateCreate = DateTime.Now;
                        attach.Name       = "Archive_req_" + Request.Id + ".zip";
                        attach.Blob       = FileHlp.AddToArchive(fileNameList);
                        Request.Attaches.Entities.Add(attach);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                _messageBoxMgr.ShowMessageWithDetail(LogLevel.Error, "Помилка під час додавання додатків до зверенння.", Hlp.GetExceptionText(ex), "Помилка", null);
            }
        }
Пример #7
0
        public void OnRefreshRequest()
        {
            _logger.Debug("OnRefreshRequest");

            if (Request.IsNewEntity)
            {
                return;
            }

            try
            {
                if (!Request.FullEquals(RequestOrigin))
                {
                    if (_messageBoxMgr.ShowDialog("Внесені зміни будуть загублені. Бажаєте продовжити?") != true)
                    {
                        return;
                    }
                }

                RequestEntity request = _mainController.GetRequestById(Request.Id);
                if (request == null)
                {
                    SetStatusMessage(LogLevel.Error, Properties.Resources.RequestNotFound);
                }
                else
                {
                    Request = request;
                    SetStatusMessage(LogLevel.Info, Properties.Resources.RequestRefreshed);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                _messageBoxMgr.ShowMessageWithDetail(LogLevel.Error, "Помилка під час оновлення зверенння.", Hlp.GetExceptionText(ex), "Помилка", null);
            }
        }
Пример #8
0
        public void OnApplyRequest()
        {
            _logger.Debug("OnApplyRequest");

            try
            {
                if (Validate())
                {
                    if (!_mainController.ProcessRequestViewModel(this))
                    {
                        SetStatusMessage(LogLevel.Error, Properties.Resources.RequestApplyError);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                _messageBoxMgr.ShowMessageWithDetail(LogLevel.Error, "Помилка під час збереження зверенння.", Hlp.GetExceptionText(ex), "Помилка", null);
            }
        }
Пример #9
0
 public void ShowErrorWithDetail(Exception exception)
 {
     ShowMessageWithDetail(LogLevel.Error, "Невідома помилка", Hlp.GetExceptionText(exception), "Помилка", null);
 }
Пример #10
0
 public void ShowErrorWithDetail(string message, Exception exception)
 {
     ShowMessageWithDetail(LogLevel.Error, message, Hlp.GetExceptionText(exception), "Помилка", null);
 }
Пример #11
0
 void EditFilter(RequestListFilterEntity filter)
 {
     try
     {
         RequestListFilterEntity newFilter = null;
         newFilter = _mainController.OpenRequestListFilterEditDialog(filter);
         if (newFilter != null)
         {
             _mainController.OnSaveFilter(newFilter);
             InitFilterList();
             Filter = newFilter;
             OnRefreshRequestList();
         }
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
         _messageBoxMgr.ShowMessageWithDetail(LogLevel.Error, "Помилка під час редагування фільтру.", Hlp.GetExceptionText(ex), "Помилка", null);
     }
 }
Пример #12
0
        public void OnRefreshRequestList()
        {
            _logger.Debug("OnRefreshRequestList");

            try
            {
                BindingCollection<RequestEntity> requestList =  _mainController.GetRequstList(Filter);
                RequestList.Fill(requestList);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                _messageBoxMgr.ShowMessageWithDetail(LogLevel.Error, "Помилка під час запиту реєстра зверенннь.", Hlp.GetExceptionText(ex), "Помилка", null);
            }            
        }
Пример #13
0
        public void OnCloneRequest()
        {
            _logger.Debug("OnCloneRequest");

            if (RequestList.Current == null) return;
            try
            {
                RequestEntity request = RefreshCurrentRequestFromDb();
                if (request == null) return;

                request = request.Clone();
                request.MarkAsNew();                
                OpenRequestEditForm(request);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                _messageBoxMgr.ShowMessageWithDetail(LogLevel.Error, "Помилка під час клонування зверенння.", Hlp.GetExceptionText(ex), "Помилка", null);
            }
        }        
Пример #14
0
        public void OnRemoveRequest()
        {
            _logger.Debug("OnRemoveRequest");

            RequestEntity request = RequestList.Current;
            if (request == null) return;
            if (_messageBoxMgr.ShowDialog("Ви бажаєте видалити зверення?") == true)
            {
                try
                {                    
                    _mainController.RemoveRequest(request.Id, true);                    
                }
                catch (Exception ex)
                {
                    _logger.Error(ex);
                    _messageBoxMgr.ShowMessageWithDetail(LogLevel.Error, "Помилка під час видалення зверенння.", Hlp.GetExceptionText(ex), "Помилка", null);
                }
            }
        }
Пример #15
0
        public void OnAddRequest()
        {
            _logger.Debug("OnAddRequest");

            RequestEntity request = null;
            try
            {
                request = RequestEntity.Create();
                OpenRequestEditForm(request);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);                
                _messageBoxMgr.ShowMessageWithDetail(LogLevel.Error, "Помилка під час створення зверенння.", Hlp.GetExceptionText(ex), "Помилка", null);
            }
        }