public ActionResult SaveFile(HttpPostedFileBase file, string PostId, string ProjectSectionId)
 {
     try
     {
         if (file.ContentLength > 0)
         {
             string filename = Path.GetFileName(file.FileName);
             string filepath = Path.Combine(Server.MapPath("~/Files"), filename);
             file.SaveAs(filepath);
             var objToSave = new SavedFile();
             objToSave.FileLink         = filename;
             objToSave.PostId           = Int32.Parse(PostId);
             objToSave.ProjectSectionId = Int32.Parse(ProjectSectionId);
             objToSave.UserId           = HttpUtil.CurrentUser.UserId;
             var result = _savedFileService.Save(objToSave);
             if (result.HasError)
             {
                 return(Content("Something Went wrong"));
             }
         }
         return(RedirectToAction("WorkProgressOwner", new { id = PostId }));
     }
     catch (Exception e)
     {
         return(Content("Something went wrong"));
     }
 }
Esempio n. 2
0
    public void SaveGame(string slotNumb)
    {
        SavedFile f = null;


        if (slotType == SlotButtonType.SaveWorld)
        {
            f = new SaveStateWorldMap(Globals.campaign);
        }
        else if (slotType == SlotButtonType.SaveBattle)
        {
            f = Globals.GetBoardManager().SaveMission();
        }
        else
        {
            f = (SavedFile)SaveLoadManager.LoadFile(

                slotNumb

                );

            Globals.campaign             = f.campaign;
            FilePath.CurrentSaveFilePath = slotNumb;
            f.SwitchScene();
            return;
        }

        SaveLoadManager.SaveCampaignProgress(f, slotNumb);
        ;
    }
        public Result <SavedFile> Save(SavedFile Entity)
        {
            var result = new Result <SavedFile>();

            try
            {
                var objtosave = _context.savedFiles.FirstOrDefault(u => u.SavedFileId == Entity.SavedFileId);
                if (objtosave == null)
                {
                    objtosave = new SavedFile();
                    _context.savedFiles.Add(objtosave);
                }

                objtosave.FileLink         = Entity.FileLink;
                objtosave.PostId           = Entity.PostId;
                objtosave.ProjectSectionId = Entity.ProjectSectionId;
                objtosave.UserId           = Entity.UserId;

                if (!IsValid(objtosave, result))
                {
                    return(result);
                }
                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                result.HasError = true;
                result.Message  = ex.Message;
            }
            return(result);
        }
Esempio n. 4
0
        public SavedFile GetSavedFileInfo(SavedFileType fileType)
        {
            SavedFile savedFile = null;
            var       isExists  = pluginSettings.SavedFiles.TryGetValue(pluginSettings.LatestPath ?? "", out var savedFileGroup) &&
                                  savedFileGroup.SavedFiles.TryGetValue(fileType, out savedFile) &&
                                  File.Exists(savedFile.Path);

            return(isExists ? savedFile : null);
        }
        public bool IsValid(SavedFile obj, Result <SavedFile> result)
        {
            if (!ValidationHelper.IsStringValid(obj.UserId.ToString()))
            {
                result.HasError = true;
                result.Message  = "Invalid UserId";
                return(false);
            }



            return(true);
        }
Esempio n. 6
0
    public void StartSavedGame()
    {
        SavedFile f = (SavedFile)SaveLoadManager.LoadFile(FilePath.SavedFolder + selectedSave);



        FilePath.CurrentSaveFilePath = FilePath.SavedFolder + selectedSave;



        Globals.campaign = f.campaign;

        f.SwitchScene();
    }
        public async Task <DbResult> AddFileInformationAsync(FileInformationModel fileInformation)
        {
            var entity = new SavedFile()
            {
                FileFullPath         = fileInformation.FileInfo.FullName,
                Filename             = fileInformation.Filename,
                SiteRelativeImageUrl = fileInformation.FileImageUrl,
                TvdbSeriesId         = fileInformation.TvdbSeriesId
            };

            var result = await AddSavedFileAsync(entity);

            return(result);
        }
Esempio n. 8
0
    public void Collect()
    {
        SavedFile stat = (SavedFile)(SaveLoadManager.LoadFile(FilePath.CurrentSaveFilePath));

        if (currMission.end_cutscenekey != "")
        {
            Globals.cutsceneData = new CutsceneData(Globals.campaign.GetCutsceneCopy(currMission.end_cutscenekey), stat, true);
            CustomeSceneLoader.LoadCutsceneScene();
        }
        else
        {
            stat.SwitchScene();
        }
    }
        public async Task <DbResult> AddSavedFileAsync(SavedFile entity)
        {
            var result = new DbResult();

            try
            {
                await db.AddAsync(entity);

                await db.SaveChangesAsync();

                result.Success = true;
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }

            return(result);
        }
Esempio n. 10
0
        public async Task <SavedFile> Save(IFormFile uploadedFile)
        {
            var savedFile = new SavedFile()
            {
                FileName           = uploadedFile.FileName,
                UploadedAt         = DateTimeOffset.Now,
                ContentDisposition = uploadedFile.ContentDisposition,
                ContentType        = uploadedFile.ContentType,
                FileSize           = uploadedFile.Length
            };

            _appDb.SavedFiles.Add(savedFile);
            await _appDb.SaveChangesAsync();

            var filePath = Path.Combine(_appData, $"{savedFile.Id}{Path.GetExtension(savedFile.FileName)}");

            using var fs = new FileStream(filePath, FileMode.Create);
            await uploadedFile.CopyToAsync(fs);

            return(savedFile);
        }
Esempio n. 11
0
        public async Task <SavedFile> AddFileAsync(Stream fileStream, string documentId, string fileName, string name, HttpRequestMessage req)
        {
            if (string.IsNullOrEmpty(documentId))
            {
                documentId = Guid.NewGuid().ToString();
            }

            var SavedFile = new SavedFile()
            {
                name       = string.IsNullOrEmpty(name) ? fileName : name,
                fileName   = fileName,
                documentId = documentId,
            };

            SavedFile = await _SavedFileRepository.CreateItemAsync(SavedFile, req);

            var resourceResponse = await _SavedFileRepository.AddAttachment(SavedFile.id, fileStream, "application/octet-stream", SavedFile.fileName);

            SavedFile.attachmentId = resourceResponse.Resource.Id;
            SavedFile = await _SavedFileRepository.UpdateItemAsync(SavedFile.id, SavedFile, req);

            return(SavedFile);
        }
Esempio n. 12
0
    public bool populatechanges; //lets the player set flags, make decisions etc


    public CutsceneData(CutScene cs, SavedFile file, bool populatechanges)
    {
        this.currentFIle     = file;
        this.currentScene    = cs;
        this.populatechanges = populatechanges;
    }
 public string GetFileStorageUri(SavedFile file)
 {
     return GetFileStorageUri(file.StorageFileName, file.Category);
 }
 //todo, make async, will need to filestream to a memstream
 public byte[] RetrieveFileContents(SavedFile file)
 {
     string fileLocation = GetFileStoragePath(file.StorageFileName, file.Category);
     if (File.Exists(fileLocation))
     {
         return File.ReadAllBytes(fileLocation);
     }
     else
     {
         return null;
     }
 }
 public void DeleteFile(SavedFile file)
 {
     string fileLocation = GetFileStoragePath(file.StorageFileName, file.Category);
     if (File.Exists(fileLocation))
     {
         File.Delete(fileLocation);
     }
 }
Esempio n. 16
0
        public string LoadFile(string title, string fileTypeName, string fileExtension, SavedFileType savedFileType)
        {
            var openDialogue =
                new OpenFileDialog
            {
                Title  = title,
                Filter = $"{fileTypeName} files (*.{fileExtension})|*.{fileExtension}",
            };

            SavedFileGroup savedFileGroup = null;

            if (pluginSettings.LatestPath.IsFilled() &&
                pluginSettings.SavedFiles.TryGetValue(pluginSettings.LatestPath, out savedFileGroup) &&
                savedFileGroup.SavedFiles.TryGetValue(savedFileType, out var savedFile) &&
                savedFile.Path.IsFilled())
            {
                openDialogue.FileName         = savedFile.Path;
                openDialogue.InitialDirectory = savedFile.Folder;
            }
            else
            {
                openDialogue.InitialDirectory = pluginSettings.LatestPath.IsEmpty() ? null : Path.GetDirectoryName(pluginSettings.LatestPath);
            }

            var result = openDialogue.ShowDialog();

            if (result != DialogResult.OK || openDialogue.FileName.IsEmpty())
            {
                return(null);
            }

            string text;

            using (var reader = new StreamReader(openDialogue.FileName))
            {
                text = reader.ReadToEnd();
            }

            var folder = Path.GetDirectoryName(openDialogue.FileName);
            var file   = Path.GetFileName(openDialogue.FileName);

            savedFile =
                new SavedFile
            {
                Folder = folder,
                File   = file
            };

            if (savedFileType == SavedFileType.Settings)
            {
                pluginSettings.LatestPath = savedFile.Path;
            }

            if (pluginSettings.LatestPath.IsFilled() && !pluginSettings.SavedFiles.TryGetValue(pluginSettings.LatestPath, out savedFileGroup))
            {
                savedFileGroup = new SavedFileGroup();
                pluginSettings.SavedFiles[pluginSettings.LatestPath] = savedFileGroup;
            }

            if (savedFileGroup != null)
            {
                savedFileGroup.SavedFiles[savedFileType] = savedFile;
            }

            SettingsManager.Instance.Save(typeof(TemplateCodeGeneratorPlugin), pluginSettings);

            return(text);
        }
Esempio n. 17
0
    }//fStatusText

    public void Save(string fileName)
    {
        SavedFile archivo; //clase para guardar

        Debug.Log("Save " + fileName);
        //crea una carpeta para guardar archivos
        DirectoryInfo ruta = Directory.CreateDirectory(Application.persistentDataPath + "/MapasGuardados");

        mapName = fileName;

        string subfolder;


        //Verifica si está online y asigna ruta
        if (online)
        {
            subfolder = Application.persistentDataPath + onlinePath; //Guarda ruta con nombre del usuario
        }
        else
        {
            subfolder = Application.persistentDataPath + offlinePath;
        }

        Directory.CreateDirectory(subfolder); //Crea carpeta con el nombre del usuario


        String linea;
        String json = "[";


        bool forzarGuardado = false;

        while (!forzarGuardado)
        {
            try {
                forzarGuardado = true;

                if (online)
                {
                    StartCoroutine(AddFile(fileName));  // Inicia corutina para guardar archivo
                }


                for (int x = 0; x < 24; x++)
                {
                    for (int y = 0; y < 24; y++)
                    {
                        if (cuadricula[x, y] != null && !(cuadricula[x, y].name == "Slave1(Clone)" || cuadricula[x, y].name == "Slave2(Clone)" || cuadricula[x, y].name == "Salida(Clone)"))
                        {
                            archivo = new SavedFile(cuadricula[x, y].getIDPiece(), x, y, cuadricula[x, y].getName(), cuadricula[x, y].getSociedad(), cuadricula[x, y].getTotalComp(), cuadricula[x, y].totalComp);
                            linea   = JsonUtility.ToJson(archivo, true);
                            json    = json + linea + ",";
                        } //fif
                    }     //ffor
                }         //ffor

                //remover ultimo char que es una ,
                json = json.Remove(json.Length - 1);

                if (json.Length > 0)
                {
                    //Agregar ultimo ]
                    json = json + "]";
                }

                //visualizar json creado
                Debug.Log(json);



                File.WriteAllText(subfolder + fileName + ".xplora2", json);


                //coloca de nuevo el campo en vacio
                fieldS.GetComponent <InputField>().text = "";
                Debug.Log("Archivo guardado");
                StatusText("Archivo guardado con exito", Color.green);

                if (online)
                {
                    //subir el archivo al servidor
                    GameObject.Find("Code").GetComponent <LevelUploader>().StartUpload(fileName);
                }
            }
            catch (Exception) {
                //
            }
        }
    } //fSave
Esempio n. 18
0
 public static string AutoSaveCampaignProgress(SavedFile file)
 {
     return(SaveFile(GenerateSaveStateFilePath(file.campaign.GetFileName()), file));
 }
Esempio n. 19
0
        public SavedFileGroup SaveFile(string title, string fileTypeName, string fileExtension, string defaultFileName,
                                       SavedFileType savedFileType, string textToSave, bool isForceDialogue = false)
        {
            var saveDialogue =
                new SaveFileDialog
            {
                Title           = title,
                OverwritePrompt = true,
                Filter          = $"{fileTypeName} files (*.{fileExtension})|*.{fileExtension}",
            };

            SavedFile savedFile = null;

            SavedFileGroup savedFileGroup = null;

            if (pluginSettings.LatestPath.IsFilled() &&
                pluginSettings.SavedFiles.TryGetValue(pluginSettings.LatestPath, out savedFileGroup) &&
                savedFileGroup.SavedFiles.TryGetValue(savedFileType, out savedFile) &&
                savedFile.Path.IsFilled())
            {
                saveDialogue.FileName         = savedFile.Path;
                saveDialogue.InitialDirectory = savedFile.Folder;
            }
            else
            {
                saveDialogue.FileName         = defaultFileName;
                saveDialogue.InitialDirectory = pluginSettings.LatestPath.IsEmpty() ? null : Path.GetDirectoryName(pluginSettings.LatestPath);
            }

            if (isForceDialogue || savedFile?.Path.IsEmpty() != false)
            {
                var result = saveDialogue.ShowDialog();

                if (result != DialogResult.OK || saveDialogue.FileName.IsEmpty())
                {
                    return(null);
                }

                if (!Path.HasExtension(saveDialogue.FileName))
                {
                    saveDialogue.FileName += $".{fileExtension}";
                }
            }

            using (var stream = (FileStream)saveDialogue.OpenFile())
            {
                var array = Encoding.UTF8.GetBytes(textToSave);
                stream.Write(array, 0, array.Length);
            }

            savedFile =
                new SavedFile
            {
                Folder = Path.GetDirectoryName(saveDialogue.FileName),
                File   = Path.GetFileName(saveDialogue.FileName)
            };

            if (savedFileType == SavedFileType.Settings)
            {
                pluginSettings.LatestPath = savedFile.Path;
            }

            if (pluginSettings.LatestPath.IsFilled() && !pluginSettings.SavedFiles.TryGetValue(pluginSettings.LatestPath, out savedFileGroup))
            {
                savedFileGroup = new SavedFileGroup();
                pluginSettings.SavedFiles[pluginSettings.LatestPath] = savedFileGroup;
            }

            if (savedFileGroup != null)
            {
                savedFileGroup.SavedFiles[savedFileType] = savedFile;
            }

            SettingsManager.Instance.Save(typeof(TemplateCodeGeneratorPlugin), pluginSettings);
            saveCallback(savedFileType, savedFileGroup);

            return(savedFileGroup);
        }
Esempio n. 20
0
 /// <summary>
 /// The OnSavedFile
 /// </summary>
 /// <param name="e">The e<see cref="SavedFileEventArgs"/></param>
 protected virtual void OnSavedFile(SavedFileEventArgs e)
 {
     SavedFile?.Invoke(this, e);
 }
Esempio n. 21
0
        /// <summary>
        /// Vytvoí okno s nabídkou uloženýc her a vezme volbu od uživatele kterou nahrát.
        /// </summary>
        /// <param name="SaveForLoad">Vrací název světa který se načte.</param>
        /// <returns>True pokud se bude načítat.</returns>
        private static bool DrawLoadMenu(out string SaveForLoad)
        {
            Console.Clear();
            ConsoleStuffs.DrawFrame();
            ConsoleStuffs.TextPrint("Načíst hru", 3, 3);

            //vytvoření listu se jmény uložených her
            List <string> SavedGames = new List <string>();

            //pokud složka neexistuje tak ji vytvořím
            if (!Directory.Exists(@"saves"))
            {
                Directory.CreateDirectory(@"saves");
            }

            //Procházení složky s uloženými hrami, hry se uloží do listu SavedGames
            var SavedFiles = Directory.EnumerateFiles(@"saves/");

            foreach (string SavedFile in SavedFiles)
            {
                //useknutí "saves/" na začátku a ".xml" na konci názvu
                string FileName = SavedFile.Remove(0, 6);
                FileName = FileName.Remove(FileName.Length - 4);
                SavedGames.Add(FileName);
            }

            //vytisknu si uložené hry
            int i = 0;

            foreach (string SavedGame in SavedGames)
            {
                //tisk do tří sloupků
                if (i >= 0 && i < 20)
                {
                    ConsoleStuffs.TextPrint(SavedGame, i + 5, 3);
                }
                else if (i >= 20 && i < 40)
                {
                    ConsoleStuffs.TextPrint(SavedGame, i - 15, 30);
                }
                else if (i >= 40 && i < 60)
                {
                    ConsoleStuffs.TextPrint(SavedGame, i - 35, 60);
                }
                else
                {
                    break;
                }
                i++;
            }
            if (SavedGames.Count == 0)
            {
                ConsoleStuffs.TextPrint("Nebyla nalezena žádná hra.", 5, 3);
            }


            ConsoleStuffs.TextPrint("Pro zadání hry k načtení stiskni \"L\" v opačném případě \"Q\"...", 28, 3);
            //pokud uživatel stiskne L bude se pokračovat dál a bude moct nahrát hru, v opačném případě se načítání ukončí
            bool HaveToLoad = false;

            while (!HaveToLoad)
            {
                switch (ConsoleStuffs.ReadKey().Key)
                {
                case ConsoleKey.L:
                    HaveToLoad = true;
                    break;

                case ConsoleKey.Q:
                    SaveForLoad = "";
                    return(false);

                default: break;
                }
            }
            ConsoleStuffs.TextPrint("                                                                 ", 28, 3);

            //nechám uživatele rozhodnout jaký save chce nahrát
            ConsoleStuffs.TextPrint("Zadej název souboru který chceš nahrát: ", 28, 3);

            do
            {
                ConsoleStuffs.TextPrint("                           ", 28, 43);

                Console.SetCursorPosition(43, 28);
                string ChosenFile = Console.ReadLine();

                foreach (string FileName in SavedGames)
                {
                    if (FileName == ChosenFile)
                    {
                        SaveForLoad = ChosenFile;
                        return(true);
                    }
                }

                ConsoleStuffs.TextPrint("Neplatná volba, pokračuj stiskem entru.", 27, 48);
                Console.ReadLine();
                ConsoleStuffs.TextPrint("                                       ", 27, 48);
            } while (true);
        }
Esempio n. 22
0
 //TODO
 //We should make this private at some point i think to force use of the save slot menu
 public static void SaveCampaignProgress(SavedFile file, string fileFpath)
 {
     SaveFile(fileFpath, file);
 }