示例#1
0
        private async void RequestData(DisplayRootRegistry displayRootRegistry, DataUpdaterViewModel dataUpdater)
        {
            var net          = new Net();
            var dataLauncher = new LauncherInfoSerializer();
            var proc         = new ProcessHelper();

            var settingHelp = new SettingHelper();
            LauncherSettingLastSerializer lastSettingLauncher = null;


            try
            {
                lastSettingLauncher  = settingHelp.Read <LauncherSettingLastSerializer>(CommonConstant.KeySettings, CommonConstant.FileSettingsLauncher);
                dataLauncher.version = lastSettingLauncher.Info.Version;
            }
            catch (Exception ex)
            {
                if (ex is DirectoryNotFoundException || ex is FileNotFoundException)
                {
                    MessageBox.Show(CommonConstant.NotFoundFileSettings);
                }
                else
                {
                    MessageBox.Show(CommonConstant.ErrorReadOrWriteSettings);
                }
                proc.CloseProcess(Constant.PidLauncher);
                Application.Current.Shutdown();
                return;
            }



            var programLauncher = await net.RequestAsync(Constant.UrlUpdaterLauncherCheckVersion, Net.Post, dataLauncher);

            if (programLauncher.detail != null)
            {
                MessageBox.Show(ErrorParser.Parse(programLauncher.detail));
                return;
            }

            if (!programLauncher.is_updated)
            {
                var message = MessageBox.Show(Constant.DescriptionMessBoxUpdate, "Обновление", MessageBoxButton.OKCancel);
                if (message == MessageBoxResult.Cancel)
                {
                    return;
                }


                _dataMainViewModel.TimerUpdater.Stop();

                displayRootRegistry.ShowPresentation(dataUpdater);

                programLauncher = await net.RequestAsync <LauncherInfoSerializer>(
                    Constant.UrlUpdaterLauncherInfo,
                    Net.Post,
                    null,
                    null,
                    null,
                    (s, e) =>
                {
                    dataUpdater.ProgressValue = (e.BytesReceived * 100 / e.TotalBytesToReceive);
                });

                if (programLauncher.detail != null)
                {
                    displayRootRegistry.HidePresentation(dataUpdater);
                    MessageBox.Show(ErrorParser.Parse(programLauncher.detail));
                    return;
                }

                var cryptBytesLauncher = Convert.FromBase64String(programLauncher.data);


                if (Hash.Sha256Bytes(cryptBytesLauncher) == programLauncher.hash)
                {
                    var crypt = new Crypt(Encoding.UTF8.GetBytes(CommonConstant.Key));
                    crypt.RemoveAndSetIv(ref cryptBytesLauncher);

                    var bytesLauncher = crypt.Decode(cryptBytesLauncher);


                    proc.CloseProcess(Constant.PidLauncher);


                    var zip = new ArchiveHelper();

                    var bytesLauncherSetting = zip.Extract(bytesLauncher, programLauncher.hash, Path.GetTempPath());



                    settingHelp.RemoveProgram(@".\", false);

                    settingHelp.RemoveDumps <SettingLastSerializer, IRemoveData>(lastSettingLauncher.Info);



                    settingHelp.CopyFilesProgram(Path.GetTempPath() + programLauncher.hash, ".\\");

                    var getLauncherSetting = settingHelp.Read <LauncherSettingSerializer>(bytesLauncherSetting, CommonConstant.KeySettings);



                    settingHelp.RewriteLastToNewSettingsLauncher(getLauncherSetting, lastSettingLauncher, CommonConstant.KeySettings, CommonConstant.FileSettingsLauncher);

                    displayRootRegistry.HidePresentation(dataUpdater);


                    try
                    {
                        proc.StartProcess(getLauncherSetting.Info.StartApp, new string[1] {
                            programLauncher.hash
                        });
                    }
                    catch (System.ComponentModel.Win32Exception)
                    {
                        MessageBox.Show(Constant.NotFoundStartAppLauncher);
                    }

                    Application.Current.Shutdown();
                    return;
                }
                else
                {
                    MessageBox.Show(Constant.NoHashEqual);
                }


                displayRootRegistry.HidePresentation(dataUpdater);

                _dataMainViewModel.TimerUpdater.Start();
            }
        }
 public void AcceptMethod(object param)
 {
     DisplayRootRegistry.ClosePresentation(this);
 }
        public void CancelMethod(object param)
        {
            NewTitle = "";

            DisplayRootRegistry.ClosePresentation(this);
        }
示例#4
0
        /// <summary>
        /// Constructor
        /// </summary>
        public LoggerPropertyWindowViewModel(LogRow selectedLogRow, IList <LogRow> listHist, DisplayRootRegistry displayRootRegistry)
        {
            DisplayRootRegistry = displayRootRegistry;
            SelectedLogRow      = selectedLogRow;
            ListHist            = listHist;

            PopulateCurrentRow();
            PopulateHistoryRows();
        }
示例#5
0
 public override void CloseExecute(object sender)
 {
     DisplayRootRegistry.ShowPresentation(new MainViewModel());
     base.CloseExecute(sender);
 }
示例#6
0
        private void RunProgramLogic()
        {
            mainVM = new MainViewModel();

            DisplayRootRegistry.ShowPresentation(mainVM);
        }
 /// <summary>
 /// Constructor
 /// </summary>
 public ListDictionariesViewModel(DisplayRootRegistry displayRootRegistry)
 {
     DisplayRootRegistry = displayRootRegistry;
     GetAllTablesList();
     GetDictionariesList();
 }
        public void DeleteSelectedItemExecute(object sender)
        {
            DeleteSelectedItemEvent?.Invoke();

            DisplayRootRegistry.HidePresentation(this);
        }