예제 #1
0
        private async Task CheckJavaExistence()
        {
            if (LDirectory.Exists(_globalVariables.PathToPortableJre))
            {
                return;
            }

            MessBox.ShowDial(
                MainResources.JavaInvalidVersion,
                MainResources.Information_Title,
                MainResources.OK
                );

            _visualProgress.SetBarValue(0);

            using (CreateWorking())
            {
                _visualProgress.SetBarUsual();
                _visualProgress.ShowBar();

                await _utils.DownloadJava(_visualProgress);

                _visualProgress.HideBar();
            }
        }
예제 #2
0
        private string CreateElement([NotNull] Action <string> elementCreator)
        {
            if (elementCreator == null)
            {
                throw new ArgumentNullException(nameof(elementCreator));
            }

            if (!LDirectory.Exists(_tempFolder))
            {
                LDirectory.CreateDirectory(_tempFolder);
            }

            int entryIndex;

            lock (_entryLock)
            {
                if (_lastEntry == int.MaxValue)
                {
                    _lastEntry = 1;
                }
                else
                {
                    _lastEntry++;
                }

                entryIndex = _lastEntry;
            }

            string filePath = Path.Combine(_tempFolder, $"temp_entry_{entryIndex}");

            elementCreator(filePath);
            return(filePath);
        }
예제 #3
0
        private void CheckForFiles([NotNull] GlobalVariables globalVariables)
        {
            var resourcesFolder = Path.Combine(globalVariables.PathToExeFolder, "Resources");

            string[] notExistingFiles;
            if (!LDirectory.Exists(resourcesFolder))
            {
                notExistingFiles = new[] { resourcesFolder };
            }
            else
            {
                notExistingFiles =
                    NeededFiles.Select(it => Path.Combine(resourcesFolder, it))
                    .Where(it => !LFile.Exists(it)).ToArray();
            }

            if (notExistingFiles.Length == 0)
            {
                return;
            }

            MessBox.ShowDial(
                string.Format(
                    MainResources.NoNeededFilesError,
                    notExistingFiles.Select(Path.GetFileName).Select(file => $"\"{file}\"").JoinStr(", ")
                    ),
                MainResources.Error
                );

            Shutdown();
        }
예제 #4
0
        private async void StartBtn_Click(object sender, EventArgs e)
        {
            string apkFile  = ViewModel.CurrentApk.Value;
            string saveFile = ViewModel.CurrentSave.Value;

            #region Проверка на существование файлов

            if (string.IsNullOrEmpty(apkFile) || !LFile.Exists(apkFile) ||
                (ViewModel.SavePlusMess.Value || ViewModel.OnlySave.Value) &&
                (string.IsNullOrEmpty(saveFile) || !LFile.Exists(saveFile) && !LDirectory.Exists(saveFile))
                )
            {
                HaveError(MainResources.File_or_save_not_selected, MainResources.File_or_save_not_selected);
                return;
            }

            #endregion

            _currentLog = CreateLogFileForApp(apkFile);

            using (CreateWorking())
            {
                try
                {
                    var currentCulture = Thread.CurrentThread.CurrentUICulture;
                    await Task.Factory.StartNew(() =>
                    {
                        Thread.CurrentThread.CurrentCulture   = currentCulture;
                        Thread.CurrentThread.CurrentUICulture = currentCulture;

                        ProcessAll();
                    });
                }
                catch (PathTooLongException ex)
                {
                    HaveError(Environment.NewLine + ex, MainResources.PathTooLongExceptionMessage);
                }
                catch (Exception ex)
                {
#if DEBUG
                    Debug.WriteLine(ex.ToString());
                    throw;
#else
                    _globalVariables.ErrorClient.Notify(ex);
                    HaveError(Environment.NewLine + ex, MainResources.Some_Error_Found);
#endif
                }
                finally
                {
                    _currentLog?.Close();
                    _currentLog = null;
                }
            }
        }
예제 #5
0
        public TempUtils(
            [NotNull] GlobalVariables globalVariables
            )
        {
            _tempFolder = globalVariables.TempPath;

            if (LDirectory.Exists(_tempFolder) && LDirectory.EnumerateFileSystemEntries(_tempFolder).Any())
            {
                LDirectory.Delete(_tempFolder, true);
            }
        }