コード例 #1
0
 protected override void SaveWorkerDoWork(object sender, DoWorkEventArgs e)
 {
     Utils.EnsureCulture();
     Dispatcher.Invoke(new Action(() => {
         if (string.IsNullOrWhiteSpace(_pathAndFileName))
         {
             return;
         }
         btnStart.IsEnabled  = btnClose.IsEnabled = false;
         aiLoader.Visibility = Visibility.Visible;
     }));
     Thread.Sleep(new Random().Next(2500, 7500));
     Dispatcher.Invoke(new Action(() => {
         aiLoader.Visibility = Visibility.Collapsed;
         btnStart.IsEnabled  = btnClose.IsEnabled = true;
         if (RestoreService.PerformRestore(_pathAndFileName))
         {
             MessageWindowHelpers.Show(this,
                                       string.Format(RestoreResources.RestorePerformingSuceeded, _pathAndFileName));
         }
         else
         {
             MessageWindowHelpers.Show(this, RestoreResources.RestorePerformingFailed, MessageBoxButton.OK,
                                       MessageBoxImage.Hand);
         }
     }));
 }
コード例 #2
0
ファイル: CommandLibrary.cs プロジェクト: m-sadegh-sh/Phoenix
 private static void OnShutdownPhoenixCommandExecuted(object sender, ExecutedRoutedEventArgs e)
 {
     if (
         MessageWindowHelpers.Show(null, SharedResources.CloseQuestion, MessageBoxButton.YesNo,
                                   MessageBoxImage.Question) == MessageBoxResult.Yes)
     {
         Utils.GetWindow <MainWindow>().AnimateableClose();
     }
 }
コード例 #3
0
 private void BtnStartClick(object sender, RoutedEventArgs e)
 {
     if (!File.Exists(tbPath.Text))
     {
         MessageWindowHelpers.Show(this, RestoreResources.FileNotFound, MessageBoxButton.OK, MessageBoxImage.Hand);
         tbPath.FocusAndSelect();
         return;
     }
     TryToSave();
 }
コード例 #4
0
ファイル: Global.cs プロジェクト: m-sadegh-sh/Phoenix
 internal static void CloseQuestioner(WindowBase windowBase, CancelEventArgs e)
 {
     if (windowBase.ChangesHappened)
     {
         e.Cancel =
             MessageWindowHelpers.Show(windowBase, SharedResources.UnsavedChangesCloseQuestion,
                                       MessageBoxButton.YesNo, MessageBoxImage.Exclamation) ==
             MessageBoxResult.No;
     }
 }
コード例 #5
0
        private static void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            MessageWindowHelpers.Show(null, SplashResources.UnhandledExceptionOcurred, MessageBoxButton.OK,
                                      MessageBoxImage.Hand);
            SingleInstance <App> .Cleanup();

            Logger.Write(e.Exception);
            e.Handled = true;
            Current.Shutdown();
        }
コード例 #6
0
        private void BtnStartClick(object sender, RoutedEventArgs e)
        {
            while (true)
            {
                var backupFileName = "";
                switch (Settings.Default.BackupFileNamingFormat)
                {
                case 0:
                    object returnValue;
                    if (InputWindowHelpers.Show(this, x => !string.IsNullOrWhiteSpace(x as string),
                                                BackupResources.BackupFileNameDescription,
                                                BackupResources.BackupFileName, out returnValue, backupFileName))
                    {
                        backupFileName = returnValue.ToString();
                    }
                    if (string.IsNullOrWhiteSpace(backupFileName))
                    {
                        return;
                    }
                    break;

                case 1:
                    backupFileName = DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss");
                    break;

                case 2:
                    backupFileName = Guid.NewGuid().ToString();
                    break;
                }
                _pathAndFileName = Settings.Default.BackupPath + "\\" + backupFileName + ".bak";
                if (backupFileName.IndexOfAny(Path.GetInvalidFileNameChars()) > -1 ||
                    Settings.Default.BackupPath.IndexOfAny(Path.GetInvalidPathChars()) > -1)
                {
                    MessageWindowHelpers.Show(this, BackupResources.InvalidPathAndFileName, MessageBoxButton.OK,
                                              MessageBoxImage.Hand);
                }
                else if (File.Exists(_pathAndFileName) && Settings.Default.BackupFileNamingFormat == 0)
                {
                    MessageWindowHelpers.Show(this, BackupResources.FileExists, MessageBoxButton.OK,
                                              MessageBoxImage.Hand);
                }
                else
                {
                    break;
                }
            }
            TryToSave();
        }
コード例 #7
0
ファイル: Utils.cs プロジェクト: m-sadegh-sh/Phoenix
        internal static void SetResolution(int width, int height)
        {
            if (!width.Equals(SystemParameters.VirtualScreenWidth) &&
                !height.Equals(SystemParameters.VirtualScreenHeight))
            {
                switch (Resolution.ChangeTo(width, height))
                {
                case ResolutionChangeResult.DisplayChangeSuccessful:
                    break;

                case ResolutionChangeResult.DisplayChangeFailed:
                    MessageWindowHelpers.Show(null, MessagesResources.ChangeResolutionFailed);
                    break;

                case ResolutionChangeResult.DisplayChangeRestart:
                    MessageWindowHelpers.Show(null, MessagesResources.ChangeResolutionRestartNeeded);
                    break;
                }
            }
        }
コード例 #8
0
 protected override void SaveWorkerDoWork(object sender, DoWorkEventArgs e)
 {
     Utils.EnsureCulture();
     Dispatcher.Invoke(new Action(() => {
         btnStart.IsEnabled  = btnClose.IsEnabled = false;
         aiLoader.Visibility = Visibility.Visible;
     }));
     Thread.Sleep(new Random().Next(2500, 7500));
     Dispatcher.Invoke(new Action(() => {
         aiLoader.Visibility = Visibility.Collapsed;
         btnStart.IsEnabled  = btnClose.IsEnabled = true;
         if (BackupService.MakeBackup(_pathAndFileName))
         {
             MessageWindowHelpers.Show(this,
                                       string.Format(BackupResources.BackupCreationSuceeded, _pathAndFileName));
         }
         else
         {
             MessageWindowHelpers.Show(this, BackupResources.BackupCreationFailed, MessageBoxButton.OK,
                                       MessageBoxImage.Hand);
         }
     }));
 }
コード例 #9
0
ファイル: Global.cs プロジェクト: m-sadegh-sh/Phoenix
 internal static void LoginLocked(WindowBase target)
 {
     MessageWindowHelpers.Show(target, LoginResources.LockedOut, MessageBoxButton.OK, MessageBoxImage.Hand);
 }
コード例 #10
0
ファイル: Global.cs プロジェクト: m-sadegh-sh/Phoenix
 internal static void LoginFailed(WindowBase target)
 {
     MessageWindowHelpers.Show(target, LoginResources.UserNameAndOrPasswordIsIncorrect, MessageBoxButton.OK,
                               MessageBoxImage.Hand);
 }
コード例 #11
0
ファイル: Global.cs プロジェクト: m-sadegh-sh/Phoenix
 internal static void DeletionFailed(WindowBase target)
 {
     MessageWindowHelpers.Show(target, SharedResources.DeletionFailed, MessageBoxButton.OK, MessageBoxImage.Error);
 }
コード例 #12
0
ファイル: Global.cs プロジェクト: m-sadegh-sh/Phoenix
 internal static MessageBoxResult ReferenceFound(WindowBase target, string validationMessage)
 {
     return(MessageWindowHelpers.Show(target, validationMessage, MessageBoxButton.YesNo,
                                      MessageBoxImage.Exclamation));
 }
コード例 #13
0
 private void BtnRestoreDefaultsClick(object sender, RoutedEventArgs e)
 {
     MessageWindowHelpers.Show(this, SettingsResources.RestartRequired);
     Settings.Default.ResetPennding = true;
     Settings.Default.Save();
 }
コード例 #14
0
        protected override void SaveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Result != null)
            {
                ReportViewerView   reportView;
                ReportViewerWindow reportViewer;
                switch (tvZones.ActualIndex())
                {
                case 0:
                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                    var props = new PropsReportViewViewModel();
                    reportView   = new ReportViewerView(props);
                    reportViewer = new ReportViewerWindow {
                        Content = reportView
                    };
                    var propsRes = (IList <Prop>)e.Result;
                    if (propsRes.Count > 0)
                    {
                        props.Items = propsRes;
                        reportViewer.ShowDialog(this);
                    }
                    else
                    {
                        MessageWindowHelpers.Show(this, ReportPreviewResources.NoResults);
                    }
                    break;

                case 6:
                case 7:
                case 8:
                case 9:
                case 10:
                    var materials = new MaterialsReportViewViewModel();
                    reportView   = new ReportViewerView(materials);
                    reportViewer = new ReportViewerWindow {
                        Content = reportView
                    };
                    var materialsRes = (IList <Material>)e.Result;
                    if (materialsRes.Count > 0)
                    {
                        materials.Items = materialsRes;
                        reportViewer.ShowDialog(this);
                    }
                    else
                    {
                        MessageWindowHelpers.Show(this, ReportPreviewResources.NoResults);
                    }
                    break;

                case 11:
                case 12:
                case 13:
                case 14:
                case 15:
                    var repositoryMaterials = new RepositoryMaterialsReportViewViewModel();
                    reportView   = new ReportViewerView(repositoryMaterials);
                    reportViewer = new ReportViewerWindow {
                        Content = reportView
                    };
                    var repositoryMaterialsRes = (IList <RepositoryMaterial>)e.Result;
                    if (repositoryMaterialsRes.Count > 0)
                    {
                        repositoryMaterials.Items = repositoryMaterialsRes;
                        reportViewer.ShowDialog(this);
                    }
                    else
                    {
                        MessageWindowHelpers.Show(this, ReportPreviewResources.NoResults);
                    }
                    break;

                case 16:
                case 17:
                case 18:
                case 19:
                case 20:
                    var items = new ItemsReportViewViewModel();
                    reportView   = new ReportViewerView(items);
                    reportViewer = new ReportViewerWindow {
                        Content = reportView
                    };
                    var itemsRes = (IList <Item>)e.Result;
                    if (itemsRes.Count > 0)
                    {
                        items.Items = itemsRes;
                        reportViewer.ShowDialog(this);
                    }
                    else
                    {
                        MessageWindowHelpers.Show(this, ReportPreviewResources.NoResults);
                    }
                    break;

                case 21:
                case 22:
                case 23:
                case 24:
                case 25:
                    var repositoryItems = new RepositoryItemsReportViewViewModel();
                    reportView   = new ReportViewerView(repositoryItems);
                    reportViewer = new ReportViewerWindow {
                        Content = reportView
                    };
                    var repositoryItemsRes = (IList <RepositoryItem>)e.Result;
                    if (repositoryItemsRes.Count > 0)
                    {
                        repositoryItems.Items = repositoryItemsRes;
                        reportViewer.ShowDialog(this);
                    }
                    else
                    {
                        MessageWindowHelpers.Show(this, ReportPreviewResources.NoResults);
                    }
                    break;

                case 26:
                case 27:
                case 28:
                case 29:
                    var labs = new LabsReportViewViewModel();
                    reportView   = new ReportViewerView(labs);
                    reportViewer = new ReportViewerWindow {
                        Content = reportView
                    };
                    var labsRes = (IList <Lab>)e.Result;
                    if (labsRes.Count > 0)
                    {
                        labs.Items = labsRes;
                        reportViewer.ShowDialog(this);
                    }
                    else
                    {
                        MessageWindowHelpers.Show(this, ReportPreviewResources.NoResults);
                    }
                    break;

                case 30:
                case 31:
                case 32:
                    var labProps = new LabPropsReportViewViewModel();
                    reportView   = new ReportViewerView(labProps);
                    reportViewer = new ReportViewerWindow {
                        Content = reportView
                    };
                    var labPropsRes = (IList <LabProp>)e.Result;
                    if (labPropsRes.Count > 0)
                    {
                        labProps.Items = labPropsRes;
                        reportViewer.ShowDialog(this);
                    }
                    else
                    {
                        MessageWindowHelpers.Show(this, ReportPreviewResources.NoResults);
                    }
                    break;

                case 33:
                case 34:
                case 35:
                    var logs = new LogsReportViewViewModel();
                    reportView   = new ReportViewerView(logs);
                    reportViewer = new ReportViewerWindow {
                        Content = reportView
                    };
                    var logsRes = (IList <Log>)e.Result;
                    if (logsRes.Count > 0)
                    {
                        logs.Items = logsRes;
                        reportViewer.ShowDialog(this);
                    }
                    else
                    {
                        MessageWindowHelpers.Show(this, ReportPreviewResources.NoResults);
                    }
                    break;
                }
            }
            aiLoader.Visibility = Visibility.Collapsed;
            OnSaving            = false;
        }
コード例 #15
0
ファイル: Global.cs プロジェクト: m-sadegh-sh/Phoenix
 internal static void ShowSuceeded(WindowBase target)
 {
     MessageWindowHelpers.Show(target, NotificationsResources.ShowSucceeded);
 }
コード例 #16
0
ファイル: Global.cs プロジェクト: m-sadegh-sh/Phoenix
 internal static bool ShowQuestion(WindowBase target)
 {
     return
         (MessageWindowHelpers.Show(target, NotificationsResources.ShowQuestion, MessageBoxButton.YesNo,
                                    MessageBoxImage.Question) == MessageBoxResult.Yes);
 }
コード例 #17
0
        protected override void OnStartup(StartupEventArgs e)
        {
            Current.DispatcherUnhandledException += OnDispatcherUnhandledException;

            base.OnStartup(e);
            if (!SingleInstance <App> .InitializeAsFirstInstance(PhoenixUniqueKey))
            {
                Current.Shutdown();
                return;
            }
            OriginResolution = new Rect {
                Width  = SystemParameters.VirtualScreenWidth,
                Height = SystemParameters.VirtualScreenHeight
            };
            if (Settings.Default.ResetPennding)
            {
                Settings.Default.Reset();
            }
            if (Settings.Default.ModeIndex == -1)
            {
                Utils.UpdateScreenResolution();
            }
            if (string.IsNullOrEmpty(Settings.Default.BackupPath))
            {
                var executionPath = AppDomain.CurrentDomain.BaseDirectory;
                var backupPath    = string.Format(@"{0}Backup", executionPath);

                Settings.Default.BackupPath = backupPath;
                Settings.Default.Save();
            }
            if (!Directory.Exists(Settings.Default.BackupPath))
            {
                Directory.CreateDirectory(Settings.Default.BackupPath,
                                          new DirectorySecurity(AppDomain.CurrentDomain.BaseDirectory,
                                                                AccessControlSections.Owner));
            }
            Utils.SetResolution();
            Utils.EnsureCulture();

            Utils.AddThemeBaseDictionaries();
            try {
                DbContext.Init();
            } catch (Exception ex) {
                Logger.Write(ex);
                MessageWindowHelpers.Show(null, SplashResources.DatabaseInitFailed, MessageBoxButton.OK,
                                          MessageBoxImage.Hand);
                Current.Shutdown();
                return;
            }
            try {
                PropsService.Get(Guid.NewGuid());
            } catch (Exception ex) {
                Logger.Write(ex);
                MessageWindowHelpers.Show(null, SplashResources.DatabaseTestFailed, MessageBoxButton.OK,
                                          MessageBoxImage.Hand);
                Current.Shutdown();
                return;
            }
            try {
                var administratorRole = RolesService.Instanse.GetAdministrator(false);
                if (administratorRole == null)
                {
                    RolesService.Instanse.CreateAdministrator();
                }

                var systemUser = UsersService.Instanse.GetSystemUser(false);
                if (systemUser == null)
                {
                    UsersService.Instanse.CreateSystemUser();
                }
            } catch (Exception exception) {
                Logger.Write(exception);
                MessageWindowHelpers.Show(null, SplashResources.TestCheckIndeedRecordsFailed, MessageBoxButton.OK,
                                          MessageBoxImage.Hand);
            }
        }
コード例 #18
0
ファイル: Global.cs プロジェクト: m-sadegh-sh/Phoenix
 internal static void DeletionSuceededWithSomeFailures(WindowBase target)
 {
     MessageWindowHelpers.Show(target, SharedResources.DeletionSucceededWithFailures, MessageBoxButton.OK,
                               MessageBoxImage.Exclamation);
 }
コード例 #19
0
        private bool ValidateFields()
        {
            if (_materials)
            {
                if (cmbMaterials.SelectedValue == null)
                {
                    cmbMaterials.Focus();
                    return(false);
                }
            }
            else if (cmbItems.SelectedValue == null)
            {
                cmbItems.Focus();
                return(false);
            }

            if (cmbActionType.SelectedIndex == -1)
            {
                cmbActionType.Focus();
                return(false);
            }

            int temp;

            if (!(int.TryParse(tbAmount.Text, out temp) && temp > 0))
            {
                Global.ValidationFailed(this, InputResources.Invalid);
                tbAmount.FocusAndSelect();
                return(false);
            }

            if (cmbLabs.SelectedValue == null)
            {
                cmbLabs.Focus();
                return(false);
            }

            if (string.IsNullOrWhiteSpace(tbTargetApplicant.Text))
            {
                Global.ValidationFailed(this,
                                        string.Format(RepositoryMaterialsAndItemsResources.TargetNull,
                                                      tbTargetApplicant.Tag));
                tbTargetApplicant.FocusAndSelect();
                return(false);
            }

            if (cmbActionType.SelectedIndex == 0)
            {
                int result;
                if (_materials)
                {
                    RepositoryMaterialsService.Instanse.ValidateAmount((Guid)cmbMaterials.SelectedValue,
                                                                       -int.Parse(tbAmount.Text), out result);
                    if (result == -1)
                    {
                        if (
                            MessageWindowHelpers.Show(this,
                                                      string.Format(
                                                          RepositoryMaterialsAndItemsResources.CriticalAmount,
                                                          new[] { tbAmount.Text, cmbActionType.Tag, cmbMaterials.Text }),
                                                      MessageBoxButton.YesNo, MessageBoxImage.Warning) ==
                            MessageBoxResult.Yes)
                        {
                            return(true);
                        }
                        tbAmount.FocusAndSelect();
                        return(false);
                    }
                    if (result >= 0)
                    {
                        Global.ValidationFailed(this,
                                                string.Format(RepositoryMaterialsAndItemsResources.InvalidAmount,
                                                              new[] {
                            result.ToString(),
                            cmbEntryMode.SelectedIndex == 0
                                                                            ? tbAmount.Tag
                                                                            : ComputingUnit.Count.ToUIString(true)
                        }));
                        tbAmount.FocusAndSelect();
                        return(false);
                    }
                }
                else
                {
                    RepositoryItemsService.Instanse.ValidateAmount((Guid)cmbItems.SelectedValue,
                                                                   -int.Parse(tbAmount.Text), out result);
                    if (result == -1)
                    {
                        if (
                            MessageWindowHelpers.Show(this,
                                                      string.Format(RepositoryMaterialsAndItemsResources.CriticalCount,
                                                                    new[]
                                                                    { tbAmount.Text, cmbActionType.Tag, cmbItems.Text }),
                                                      MessageBoxButton.YesNo, MessageBoxImage.Warning) ==
                            MessageBoxResult.Yes)
                        {
                            return(true);
                        }
                        tbAmount.FocusAndSelect();
                        return(false);
                    }
                    if (result >= 0)
                    {
                        Global.ValidationFailed(this,
                                                string.Format(RepositoryMaterialsAndItemsResources.InvalidCount,
                                                              new[] { result.ToString(), tbAmount.Tag }));
                        tbAmount.FocusAndSelect();
                        return(false);
                    }
                }
            }

            return(true);
        }
コード例 #20
0
ファイル: Global.cs プロジェクト: m-sadegh-sh/Phoenix
 internal static void SubmissionSuceeded(WindowBase target)
 {
     MessageWindowHelpers.Show(target, SharedResources.SubmissionSucceeded);
 }
コード例 #21
0
ファイル: Global.cs プロジェクト: m-sadegh-sh/Phoenix
 internal static bool SubmitQuestion(WindowBase target)
 {
     return
         (MessageWindowHelpers.Show(target, SharedResources.UnsavedChangesSubmitQuestion, MessageBoxButton.YesNo,
                                    MessageBoxImage.Question) == MessageBoxResult.Yes);
 }
コード例 #22
0
ファイル: Global.cs プロジェクト: m-sadegh-sh/Phoenix
 internal static void OpFailed(WindowBase target)
 {
     MessageWindowHelpers.Show(target, SharedResources.OpFailed, MessageBoxButton.OK, MessageBoxImage.Hand);
 }
コード例 #23
0
ファイル: Global.cs プロジェクト: m-sadegh-sh/Phoenix
 internal static void ValidationFailed(WindowBase target, string validationMessage)
 {
     MessageWindowHelpers.Show(target, validationMessage, MessageBoxButton.OK, MessageBoxImage.Error);
 }
コード例 #24
0
ファイル: Global.cs プロジェクト: m-sadegh-sh/Phoenix
 internal static bool DeleteQuestion(WindowBase target)
 {
     return
         (MessageWindowHelpers.Show(target, SharedResources.DeleteQuestion, MessageBoxButton.YesNo,
                                    MessageBoxImage.Question) == MessageBoxResult.Yes);
 }
コード例 #25
0
        protected override void SaveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (ValidateFields())
            {
                var result = MessageBoxResult.Yes;
                var type   = (ReportType)cmbStatus.SelectedIndex;
                if (type == ReportType.Used || type == ReportType.DeliveredToRepository)
                {
                    result = MessageWindowHelpers.Show(this, PropStatusResources.Attention, MessageBoxButton.YesNo,
                                                       MessageBoxImage.Question);
                }
                if (result == MessageBoxResult.Yes)
                {
                    if (_current.Type == (short)cmbStatus.SelectedIndex)
                    {
                        switch (_current.Type)
                        {
                        case 1:
                        case 2:
                            _current.ChangedOn   = dtpOutDate.Value;
                            _current.ResolveDate = dtpInDate.Value;
                            break;

                        case 3:
                        case 5:
                            _current.ChangedOn = dtpOutDate.Value;
                            break;
                        }
                        _current.Description = tbDescription.Text;
                        if (PropStatusChangesService.Instanse.Insert(_current))
                        {
                            Global.SubmissionSuceeded(this);
                            ResetFields();
                            if (
                                MessageWindowHelpers.Show(this, PropStatusResources.SelectAnotherProp,
                                                          MessageBoxButton.YesNo, MessageBoxImage.Question) ==
                                MessageBoxResult.Yes)
                            {
                                TryToLoad(true);
                            }
                            else
                            {
                                Close();
                            }
                        }
                        else
                        {
                            Global.SubmissionFailed(this);
                        }
                    }
                    else
                    {
                        _current.IsAlive = false;
                        if (PropStatusChangesService.Instanse.Insert(_current))
                        {
                            var newPropStatusChange = new PropStatusChange
                            {
                                PropID = _current.PropID, Type = (short)cmbStatus.SelectedIndex
                            };

                            switch (newPropStatusChange.Type)
                            {
                            case 1:
                            case 2:
                                newPropStatusChange.ChangedOn   = dtpOutDate.Value;
                                newPropStatusChange.ResolveDate = dtpInDate.Value;
                                break;

                            case 3:
                            case 5:
                                newPropStatusChange.ChangedOn = dtpOutDate.Value;
                                break;
                            }
                            newPropStatusChange.Description = tbDescription.Text;
                            if (PropStatusChangesService.Instanse.Insert(newPropStatusChange))
                            {
                                Global.SubmissionSuceeded(this);
                                ResetFields();
                                if (
                                    MessageWindowHelpers.Show(this, PropStatusResources.SelectAnotherProp,
                                                              MessageBoxButton.YesNo, MessageBoxImage.Question) ==
                                    MessageBoxResult.Yes)
                                {
                                    TryToLoad(true);
                                }
                                else
                                {
                                    Close();
                                }
                            }
                            else
                            {
                                Global.SubmissionFailed(this);
                            }
                        }
                        else
                        {
                            Global.SubmissionFailed(this);
                        }
                    }
                }
            }
            aiLoader.Visibility = Visibility.Collapsed;
            OnSaving            = false;
        }