Example #1
0
        public static Guid GenerateNextCharakterGUID()
        {
            var guid  = Guid.NewGuid();
            var files = FileManagment.GetFilesDictionary(CharakterSaveFolder, out DSAError error);
            var list  = new List <Guid>();

            foreach (var file in files)
            {
                var stringguid = System.IO.Path.ChangeExtension(file, null);

                if (Guid.TryParse(stringguid, out Guid result))
                {
                    list.Add(result);
                }
            }

            while (list.Contains(guid))
            {
                guid = new Guid();
            }

            return(guid);
        }
Example #2
0
    private void SaveResults()
    {
        SaveData save = FileManagment.ReadFile <SaveData>("save.dat");

        int index = SceneManager.GetActiveScene().buildIndex - 1; // because of level selection Scene

        if (index == save.Levels.Count - 1)
        {
            save.Levels.Add(new Level());
        }

        if (save.Levels[index].Coins < MyPlayer.CoinsAmount)
        {
            save.Coins += MyPlayer.CoinsAmount - save.Levels[index].Coins;
            save.Levels[index].Coins = MyPlayer.CoinsAmount;
        }

        if (save.Levels[index].SecretItems < MyPlayer.CoinsAmount)
        {
            save.Levels[index].SecretItems = MyPlayer.SecretItemsAmount;
        }

        FileManagment.WriteFile("save.dat", save);
    }
Example #3
0
        public static void CharakterSave(out DSAError error)
        {
            error = null;
            try
            {
                var saveFile = Charakter.CreateSave();
                var filePath = Path.Combine(CharakterSaveFolder, Charakter.ID.ToString() + ".save");
                FileManagment.WriteToFile(saveFile.JSONContent, filePath, Windows.Storage.CreationCollisionOption.ReplaceExisting, out error);

                #region Sicherungskopie
                var task = new Task(async() =>
                {
                    try
                    {
                        var folder = await StorageFolder.GetFolderFromPathAsync("D:\\Dropbox\\07_DSA_PNP_D&D\\DSA_Save");
                        var sfile  = await folder.CreateFileAsync(Charakter.ID.ToString() + ".save", CreationCollisionOption.ReplaceExisting);
                        await FileIO.AppendTextAsync(sfile, saveFile.JSONContent);
                    }
                    catch (Exception)
                    {
                        Logger.Log(LogLevel.ErrorLog, "Sicherung konnte nicht erstellt werden");
                        //"https://support.microsoft.com/de-de/help/4468237/windows-10-file-system-access-and-privacy-microsoft-privacy"
                    }
                });
                task.Start();
                #endregion
            }
            catch (Exception ex)
            {
                error = new DSAError
                {
                    ErrorCode = ErrorCode.Error,
                    Message   = ex.Message
                };
            }
        }
Example #4
0
        public void QATest()
        {
            CSVHandler CSV = new CSVHandler();

            Excel.Worksheet Sheet = CSV.OpenCSV(@"C:\Users\Milijana\Desktop\ddt6.csv");
            int             rows = Sheet.UsedRange.Rows.Count;
            int             columns = Sheet.UsedRange.Columns.Count;
            string          name, description, expected, FirstName, LastName, Email, UN, P, CP;
            bool            IsExpected = true;

            for (int i = 2; i <= rows; i++)
            {
                TestContext.Write("Name of Test Case: {0},Description: {1},Expected: {2}    ", Sheet.Cells[i, 1].Value, Sheet.Cells[i, 2].Value, Sheet.Cells[i, 3].Value);
                FileManagment.Scrivi("Name of Test Case: " + Sheet.Cells[i, 1].Value.ToString() + "  Description: " + Sheet.Cells[i, 2].Value.ToString() + "  Expected: " + Sheet.Cells[i, 3].Value);
                name        = Sheet.Cells[i, 1].Value;
                description = Sheet.Cells[i, 2].Value;
                expected    = Sheet.Cells[i, 3].Value;
                FirstName   = Sheet.Cells[i, 4].Value;
                LastName    = Sheet.Cells[i, 5].Value;
                Email       = Sheet.Cells[i, 6].Value;
                UN          = Sheet.Cells[i, 7].Value;
                P           = Sheet.Cells[i, 8].Value;
                CP          = Sheet.Cells[i, 9].Value;
                ShopHomePage pocetna = new ShopHomePage(driver);
                pocetna.GoToPage();
                Register R;
                R       = pocetna.ClicReg();
                pocetna = R.ClickButtonRegister(FirstName, LastName, Email, UN, P, CP);
                if (pocetna.Uspeh != null)
                {
                    if (expected == "pass")
                    {
                        TestContext.WriteLine("  Successful Test!!!  ");
                        FileManagment.Scrivere("  Successful Test!!!  ");
                    }
                    else
                    {
                        TestContext.WriteLine("  The test is failed!!!  ");
                        FileManagment.Scrivere("  The test is failed!!!  ");
                        IsExpected = false;
                    }
                }
                else
                {
                    if (expected == "fail")
                    {
                        TestContext.WriteLine("  Successful Test!!!  ");
                        FileManagment.Scrivere("  Successful Test!!!  ");
                    }
                    else
                    {
                        TestContext.WriteLine("  The test is failed!!!  ");
                        FileManagment.Scrivere("  Successful Test!!!  ");
                        IsExpected = false;
                    }
                }

                TestContext.WriteLine("----------------------------------------------------------------------------------------------------------------------------------------------");
                FileManagment.Scrivere("---------------------------------------------------------------------------------------------------------------------------------------------");
            }
            if (IsExpected == true)
            {
                Assert.Pass("Great job!!!");
            }
            else
            {
                Assert.Fail("Some test has an unexpected result!!!");
            }
            CSV.Close();
        }
Example #5
0
        private void Compile(DeviceConfig config)
        {
            MoveProgressBar(0);
            string deviceName               = Enum.GetName(typeof(DeviceConfig.Devices), config.Device);
            string proyectFolder            = config.Origin;
            string destinyFolder            = config.Destiny;
            string modulesFolder            = System.IO.Path.Combine(proyectFolder, config.ModulesFolder);
            string defaultContainerFilePath = System.IO.Path.Combine(modulesFolder, config.DefaultContainerFileName);
            string defaultHeaderFilePath    = System.IO.Path.Combine(modulesFolder, "header", config.DefaultHeaderFileName);
            string defaultFooterFilePath    = System.IO.Path.Combine(modulesFolder, "footer", config.DefaultFooterFileName);

            if (Directory.Exists(proyectFolder))         // existe el proyecto
            {
                if (Directory.Exists(destinyFolder))     // existe la carpeta destino
                {
                    if (Directory.Exists(modulesFolder)) // existe la carpeta con los modulos
                    {
                        // chequeo que exista el archivo base en donde se compilaran los modulos
                        if (!File.Exists(defaultContainerFilePath))
                        {
                            txtResult.Text += String.Format("{0} - No existe el archivo: {1} en el directorio raiz del proyecto: {2} {3}", deviceName, defaultFileName, proyectFolder, Environment.NewLine);
                            return;
                        }

                        string defaultContainerFileContent = string.Empty;
                        string defaultHeaderFileContent    = string.Empty;
                        string defaultFooterFileContent    = string.Empty;

                        string defaultCompleteContent = defaultContainerFileContent = System.IO.File.ReadAllText(defaultContainerFilePath, Encoding.UTF8);

                        if (File.Exists(defaultHeaderFilePath))
                        {
                            defaultHeaderFileContent = System.IO.File.ReadAllText(defaultHeaderFilePath, Encoding.UTF8);
                            defaultCompleteContent   = ReplaceInstructionPlace(defaultCompleteContent, "header", defaultHeaderFileContent);
                        }
                        if (File.Exists(defaultFooterFilePath))
                        {
                            defaultFooterFileContent = System.IO.File.ReadAllText(defaultFooterFilePath, Encoding.UTF8);
                            defaultCompleteContent   = ReplaceInstructionPlace(defaultCompleteContent, "footer", defaultFooterFileContent);
                        }

                        // Obtengo la lista de archivos a ser compilados
                        List <string> filePaths = Directory.GetFiles(System.IO.Path.Combine(modulesFolder, "body")).ToList();

                        // Genero Htmls
                        double percentage = (1.0 / Convert.ToDouble(filePaths.Count)) * 50; // Supongo el compilado de archivos el 50% del total
                        foreach (string filePath in filePaths)                              // recorro los archivos del body
                        {
                            string headerContent    = defaultHeaderFileContent;             // contenido default del header
                            string footerContent    = defaultFooterFileContent;             // contenido default del footer
                            string cointanerContent = defaultContainerFileContent;
                            string completeContent  = defaultCompleteContent;

                            string bodyFileName = System.IO.Path.GetFileNameWithoutExtension(filePath);
                            string bodyContent  = System.IO.File.ReadAllText(filePath, Encoding.UTF8); // seteo el contenido del body

                            List <Dictionary <CompilerProperty, string> > bodyInstructions = GetInstructions(bodyContent);

                            if (bodyInstructions.Count > 0)
                            {
                                foreach (Dictionary <CompilerProperty, string> Instruction in bodyInstructions) // Recorro las instrucciones del body
                                {
                                    string        position, fileName, vars, device;
                                    string        contentBeenModified = string.Empty;
                                    List <string> kvVars;
                                    Instruction.TryGetValue(CompilerProperty.Position, out position);
                                    Instruction.TryGetValue(CompilerProperty.FileName, out fileName);
                                    Instruction.TryGetValue(CompilerProperty.Vars, out vars);
                                    Instruction.TryGetValue(CompilerProperty.Device, out device);

                                    if (position != null)
                                    {
                                        if (device != null && config.Device != (DeviceConfig.Devices)Enum.Parse(typeof(DeviceConfig.Devices), device, true))
                                        {
                                            continue; // si la instruccion es especifica de algun dispositivo, solo aplico a ese
                                        }

                                        if (fileName != null)
                                        {
                                            try
                                            {
                                                contentBeenModified = System.IO.File.ReadAllText(System.IO.Path.Combine(proyectFolder, fileName), Encoding.UTF8);
                                            }
                                            catch
                                            {
                                                txtResult.Text += string.Format("{0} - El nombre del archivo {1} esta mal formateado o no existe {2}", deviceName, fileName, Environment.NewLine);
                                            }
                                        }

                                        if (fileName == null && vars != null) // Si solo planeo cargar vars en algun archivo default
                                        {
                                            switch (position)                 // asigno el archivo default corresdpondiente a la posicion al contenido que esta siendo modificado
                                            {
                                            case "header":
                                                contentBeenModified = headerContent;
                                                break;

                                            case "body":
                                                contentBeenModified = cointanerContent;
                                                break;

                                            case "footer":
                                                contentBeenModified = footerContent;
                                                break;
                                            }
                                        }

                                        if (vars != null)                      // Busco si hay variables a remplazar en el html parcial a cargar
                                        {
                                            kvVars = vars.Split(',').ToList(); // TODO: cambiar "," por variable
                                            foreach (var kvVar in kvVars)
                                            {
                                                if (kvVar.Split(':').Length > 1) // si no tiene valor no remplazo // TODO: cambiar ":" por variable
                                                {
                                                    contentBeenModified = ReplaceInstructionVar(kvVar.Split(':')[0].Trim(), kvVar.Split(':')[1].Trim(), contentBeenModified);
                                                }
                                            }
                                        }

                                        // TODO: Aca si correspondiera deberia de forma recursiva cargar mas html para el contenido siendo modificado

                                        switch (position) // asigno el contenido modificado a la seccion correspondiente
                                        {
                                        case "header":
                                            headerContent = contentBeenModified;
                                            break;

                                        case "body":
                                            cointanerContent = contentBeenModified;
                                            break;

                                        case "footer":
                                            footerContent = contentBeenModified;
                                            break;
                                        }
                                    }
                                }
                                completeContent = ReplaceInstructionPlace(cointanerContent, "header", headerContent);
                                completeContent = ReplaceInstructionPlace(completeContent, "footer", footerContent);
                            }

                            string moduleContent = ReplaceInstructionPlace(completeContent, "body", bodyContent); // index con header, body y footer ya remplazado
                            moduleContent = RemoveInstructions(moduleContent);                                    // remuevo las instrucciones que puedan haber quedado

                            string destinyFilePath = Path.Combine(destinyFolder, string.Concat(bodyFileName, ".html"));
                            FileManagment.CreateFileFromString(moduleContent, destinyFilePath);

                            // Move status bar
                            MoveProgressBar(percentage);
                        }

                        // Copy Resources
                        if ((bool)config.CopyResources)
                        {
                            List <string> lResourcesFolders = config.ResourcesFolders.Split(',').ToList();
                            //TODO: copiar carpetas especificadas y no las que a mi se me cantó
                            string resFileName = string.Empty;
                            string resDestName = string.Empty;
                            int    i           = 1;
                            foreach (string rFolder in lResourcesFolders)
                            {
                                var  sFolder = rFolder.Trim();
                                bool minify  = false;
                                // TODO: agregar una variable minificar js
                                //if (rFolder == "js") {
                                //    minify = (bool)config.MinifyJs;
                                //} else {
                                //    minify = (bool)config.MinifyCss;
                                //}
                                minify = (bool)config.MinifyCss;
                                string originPath  = System.IO.Path.Combine(proyectFolder, sFolder);
                                string destinyPath = System.IO.Path.Combine(destinyFolder, sFolder);
                                FileManagment.DirectoryCopy(originPath, destinyPath, true, minify);
                                MoveProgressBar(50 + (40 / lResourcesFolders.Count * i));
                                i++;
                            }

                            /*
                             * // Css Minify
                             * string cssOriginPath = System.IO.Path.Combine(proyectFolder, "css");
                             * string cssDestinyPath = System.IO.Path.Combine(destinyFolder, "css");
                             * DirectoryCopy(cssOriginPath, cssDestinyPath, true, (bool)config.MinifyCss);
                             * MoveProgressBar(65);
                             *
                             * // Js Minify
                             * string jsOriginPath = System.IO.Path.Combine(proyectFolder, "js");
                             * string jsDestinyPath = System.IO.Path.Combine(destinyFolder, "js");
                             * DirectoryCopy(jsOriginPath, jsDestinyPath, true, (bool)config.MinifyCss);
                             * MoveProgressBar(80);
                             *
                             * // Image Reduction
                             * string imgOriginPath = System.IO.Path.Combine(proyectFolder, "img");
                             * string imgDestinyPath = System.IO.Path.Combine(destinyFolder, "img");
                             * DirectoryCopy(imgOriginPath, imgDestinyPath, true, (bool)config.MinifyCss);
                             * MoveProgressBar(90);*/
                        }

                        // Show Log

                        // Finish Status Bar
                        txtResult.Text += String.Format("{0} - Compilacion Finalizada Correctamente! {1}", deviceName, Environment.NewLine);
                        MoveProgressBar(100);
                    }
                    else
                    {
                        txtResult.Text += String.Format("{0} - El directorio de los modulos a compilar no existe o no tiene permisos de lectura {1}", deviceName, Environment.NewLine);
                        MoveProgressBar(0);
                    }
                }
                else
                {
                    txtResult.Text += String.Format("{0} - El directorio de destino del proyecto no existe o no tiene permisos de lectura/escritura {1}", deviceName, Environment.NewLine);
                    MoveProgressBar(0);
                }
            }
            else
            {
                txtResult.Text += String.Format("{0} - El directorio del proyecto no existe o no tiene permisos de lectura {1}", deviceName, Environment.NewLine);
                MoveProgressBar(0);
            }
        }
Example #6
0
 private void SaveProject(string filePath)
 {
     SaveDevice(SelectedDevice);
     FileManagment.CreateFileFromString(JSONHelper.Serialize <Project>(OpenProject), filePath);
 }
Example #7
0
 public void SaveOptions()
 {
     FileManagment.WriteFile("preferences", optionsData);
 }
Example #8
0
 private void LoadScions_Click(object sender, RoutedEventArgs e)
 {
     CS = FileManagment.LoadCharacters(FileLocationBox.Text);
 }
Example #9
0
 private void SaveScion_Click(object sender, RoutedEventArgs e)
 {
     FileManagment.CharacterSaver(FileLocationBox.Text, CS);
 }
Example #10
0
 private void SaveMonsters_Click(object sender, RoutedEventArgs e)
 {
     FileManagment.MonsterSaver(FileLocationBox.Text, MonsterList);
 }
Example #11
0
 private void Log(string Message)
 {
     FileManagment.Scrivi(Message);
     TestContext.Write(Message);
 }
Example #12
0
 private void LogLine(string Message)
 {
     FileManagment.Scrivere(Message);
     TestContext.WriteLine(Message);
 }
Example #13
0
        //idk
        public bool Upload(int IgraID, IFormFile Image)
        {
            FileManagment p = new FileManagment();

            return(p.DodajSliku(IgraID, 0, Image, db));
        }
Example #14
0
        public static void SaveTalent(ITalent talent, GameType gameType, out DSAError error)
        {
            error = null;
            #region Talenttype
            List <JSONTalent> jTalentList = null;
            List <ITalent>    talentList  = null;
            var talenttype = talent.GetType().ToString();
            var lastIndex  = talenttype.LastIndexOf(".");
            talenttype = talenttype.Substring(lastIndex + 1);
            #endregion
            #region GameType
            if (gameType == GameType.DSA)
            {
                if (jSON_talentLocal.Talente == null)
                {
                    jSON_talentLocal.Talente = new List <JSONTalent>();
                }
                jTalentList = jSON_talentLocal.Talente;
                talentList  = TalentList;
            }
            else
            {
                throw new Exception();
            }
            #endregion

            try
            {
                var jsonTalent = TalentHelper.CreateJSON(
                    talent: talent);

                #region Doppelte Elemente Entfernen
                var jdoppledID = jTalentList.Where(x => x.ID == talent.ID).ToList();
                if (jdoppledID.Count > 0)
                {
                    jTalentList.Remove(jdoppledID[0]);
                }
                var tdoppledID = talentList.Where(x => x.ID == talent.ID).ToList();
                if (tdoppledID.Count > 0)
                {
                    tdoppledID.Remove(tdoppledID[0]);
                }
                #endregion
                #region Speichern
                jTalentList.Add(jsonTalent);

                if (!talentList.Contains(talent))
                {
                    talentList.Add(talent);
                }
                FileManagment.WriteToFile(jSON_talentLocal.JSONContent, talentSaveFile, Windows.Storage.CreationCollisionOption.ReplaceExisting, out error);
                #endregion
            }
            catch (Exception ex)
            {
                error = new DSAError
                {
                    ErrorCode = ErrorCode.InvalidValue,
                    Message   = ex.Message
                };
            }
        }