private static StreamReader GetNamesFile(string path)
 {
     var fileExistsLoader = new MockLoader<bool>(File.Exists(path));
     var loaderFile = new LoaderFile(path);
     Func<Stream> create = () => File.Create(path);
     return TestableGetnamesFile(fileExistsLoader, loaderFile, create);
 }
Пример #2
0
        public void DeleteApp(ref string request, ref Socket remoteSocket)
        {
            string hash = Worker.FindParamFromRequest(ref request, "hash", TypeCode.String);

            if (hash == null)
            {
                Worker.JsonAnswer(false, "Can not find hash in this request params.", ref remoteSocket);
                return;
            }
            App app = Database.app.SelectByHash(hash);

            if (app == null)
            {
                Worker.JsonAnswer(false, "Can not find application by this hash.", ref remoteSocket);
                return;
            }
            FileD file = Database.file.SelectById(app.app_id);

            if (file != null)
            {
                LoaderFile.DeleteFile(file);
            }
            Worker.uploader.DeleteDirectory(app.app_hash);
            Worker.JsonAnswer(true, "Build completely deleted.", ref remoteSocket);
        }
Пример #3
0
 public static void Initialization()
 {
     mail       = new MailF();
     auth       = new Authorization();
     loaderFile = new LoaderFile();
     uploader   = new UploadApp();
     upload     = new UploadF();
 }
Пример #4
0
    private void _Load()
    {
        byte[] bytes = LoaderFile.LoadBytes(PathManager.SceneData, Application.platform == RuntimePlatform.Android);
        string jsStr = Encoding.UTF8.GetString(bytes);
        SlzDictionary <string, SceneData> slzDictionary = JsonUtility.FromJson <SlzDictionary <string, SceneData> >(jsStr);//JsonMapper.ToObject<SlzDictionary<string, SceneData>>(jsStr);//

        _SceneData = slzDictionary.ToDictionary();
    }
Пример #5
0
        /// <summary>
        /// Event handler for when the OK button is clicked. Makes a final check on the temp directory and gives a warning if theres no space or cancels the ok if no value has been entered for it.
        /// </summary>
        private void OkButton_Click(object sender, RoutedEventArgs e)
        {
            //Make sure the directory that's been entered is not an empty string and that it actually exists. If not, show an error message and stay on the options dialog.
            if (TempDirectory.Length == 0)
            {
                MessageBox.Show(this, Properties.Resources.MustSelectValidFolderText, Properties.Resources.InvalidTempFolderStr, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (!Directory.Exists(TempDirectory))
            {
                try
                {
                    Directory.CreateDirectory(TempDirectory);
                }
                catch
                {
                    MessageBox.Show(this, Properties.Resources.ErrorUnableToCreateTempDirStr + TempDirectory, Properties.Resources.ErrorUnableToCreateDirShortStr, MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }
            //Make sure the drive the temp folder is on has enough space for at least a single layer DVD
            if (!Utils.CheckTempForSpace(TempDirectory))
            {
                // If there isnt enough space, show a warning and give the user the option to go ahead anyway.
                MessageBoxResult result = MessageBox.Show(this, Properties.Resources.WarningNotEnoughSpaceTempStr, Properties.Resources.ErrorNotEnoughSpaceShortStr, MessageBoxButton.OKCancel, MessageBoxImage.Warning);
                if (result != MessageBoxResult.OK)     //If the user hits cancel, they've decided not to go ahead with the selected directory which doesnt have enough space.
                {
                    return;
                }
            }
            if (EnableChannelCreation && (SrcWadFile.Trim().Length == 0 || LoaderFile.Trim().Length == 0 || KeyFile.Trim().Length == 0 || OriginalTitleId.Trim().Length == 0))
            {
                MessageBox.Show(this, Properties.Resources.ErrorInvalidChanCreationValsStr, Properties.Resources.ErrorInvalidValsShortStr, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (PartitionsToUseComboBox.SelectedIndex < 0)
            {
                MessageBox.Show(this, Properties.Resources.ErrorInvalidPartitionSettingStr, Properties.Resources.ErrorInvalidValsShortStr, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (PartitionsToUseComboBox.SelectedIndex == 0)
            {
                PartitionToUse = libwbfsNET.WbfsIntermWrapper.PartitionSelector.ONLY_GAME_PARTITION;
            }
            else if (PartitionsToUseComboBox.SelectedIndex == 1)
            {
                PartitionToUse = libwbfsNET.WbfsIntermWrapper.PartitionSelector.REMOVE_UPDATE_PARTITION;
            }
            else
            {
                PartitionToUse = libwbfsNET.WbfsIntermWrapper.PartitionSelector.ALL_PARTITIONS;
            }

            _allowClosing = true;       //Allow closing now that everything checks out.
            DialogResult  = true;       //Set the result of this dialog to true, meaning the OK button was clicked and was successful. This automatically closes the dialog since it's shown modally.
        }
Пример #6
0
 public Worker(ref Database callDB, ref LogProgram logprogram)
 {
     this.database    = callDB;
     this.logger      = logprogram;
     this.mail        = new MailF(database, logger);
     this.tasker      = new TaskManager(logger);
     this.loaderFile  = new LoaderFile(ref database, ref logger);
     this.excelModule = new ExcelModule(ref database, ref logger, ref loaderFile);
     tasker.EmailMonitoring(this);
 }
 public bool GetFileRequest(ref FileD file)
 {
     if (LoaderFile.LoadingFile(ref data, ref buffer, ref bytes, ref file))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public bool GetFilesRequest(ref FileD[] files, int count)
 {
     files = LoaderFile.LoadingFiles(ref data, ref buffer, ref bytes, ref count);
     if (files != null)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #9
0
        private void CreateSceneNode(LoaderFile file, TreeNode node, List <LoaderFile> scenes)
        {
            node.Text = file.guid_str;
            node.Name = file.guid_str;
            node.Tag  = file;
            var childScenes = wrapper.managers.sceneManager.GetChildResourcesOfSceneResource(file.guid);

            foreach (UInt32 cs in childScenes)
            {
                foreach (var sf in scenes)
                {
                    if (cs == sf.guid)
                    {
                        var child = new TreeNode();
                        CreateSceneNode(sf, child, scenes);
                        node.Nodes.Add(child);
                        break;
                    }
                }
            }
        }
Пример #10
0
 /// <summary>
 /// Saves the file by ref file_name, file_path and data. Set this paramaters if you want to change full_path, file_name and data of file.
 /// </summary>
 /// <param name="file">File.</param>
 public void SaveFile(ref FileD file)
 {
     LoaderFile.CreateFileBinary(ref file.file_name, ref file.file_path, ref file.data);
     Database.file.AddFile(file);
 }
Пример #11
0
        public void UploadBuild(ref string request, ref byte[] buffer, ref int bytes, ref Socket remoteSocket)
        {
            List <FileD> files = LoaderFile.LoadingFiles(ref request, ref buffer, ref bytes, ref count);

            if (files != null)
            {
                if (files.Count == 1)
                {
                    FileD  file     = files[0];
                    string app_hash = Worker.uploader.GenerateHash(8);
                    if (file.file_type == "application")
                    {
                        Directory.CreateDirectory(Worker.uploader.Full_Path_Upload + app_hash);
                        App app = null;
                        switch (file.file_extension)
                        {
                        case "vnd.android.package-archive":
                            app = Worker.uploader.UploadAPK(file, app_hash);
                            break;

                        case "octet-stream":
                            app = Worker.uploader.UploadIpa(file, app_hash);
                            break;

                        default:
                            LoaderFile.DeleteFile(file);
                            Worker.uploader.DeleteDirectory(app_hash);
                            Worker.JsonAnswer(false, "Archive type that uploaded is wrong.", ref remoteSocket);
                            break;
                        }
                        if (app == null)
                        {
                            LoaderFile.DeleteFile(file);
                            Worker.uploader.DeleteDirectory(app_hash);
                            Worker.JsonAnswer(false, "Error of handle upload archive.", ref remoteSocket);
                            return;
                        }
                        int?uid = Worker.FindParamFromRequest(ref request, "uid", TypeCode.Int32);
                        if (uid != null)
                        {
                            if (Database.user.SelectId(uid) != null)
                            {
                                app.user_id = (int)uid;
                            }
                        }
                        else
                        {
                            app.user_id = -1;
                        }
                        Worker.JsonData(app, ref remoteSocket);
                        if (file.file_extension == "vnd.android.package-archive")
                        {
                            app = Worker.uploader.GetAPKSet(Worker.uploader.Full_Path_Upload + app_hash, app);
                        }
                        Database.app.Add(app);
                    }
                }
                else
                {
                    foreach (FileD file in files)
                    {
                        LoaderFile.DeleteFile(file);
                    }
                    Worker.JsonAnswer(false, "Get from request not required count files.", ref remoteSocket);
                }
            }
            else
            {
                Worker.JsonAnswer(false, "Can't get file from request.", ref remoteSocket);
            }
        }
Пример #12
0
 public ExcelModule(ref Database Database, ref LogProgram logProgram, ref LoaderFile loaderFile)
 {
     this.database   = Database;
     this.logger     = logProgram;
     this.loaderFile = loaderFile;
 }