public static async Task <GenerationReturn> CopyCleanResizeImage(ImageContent dbEntry,
                                                                         IProgress <string> progress)
        {
            if (dbEntry == null)
            {
                return(await GenerationReturn.Error("Null Image Content submitted to Copy Clean and Resize"));
            }

            progress?.Report($"Starting Copy, Clean and Resize for {dbEntry.Title}");

            if (string.IsNullOrWhiteSpace(dbEntry.OriginalFileName))
            {
                return(await GenerationReturn.Error($"Image {dbEntry.Title} has no Original File", dbEntry.ContentId));
            }

            var imageDirectory = UserSettingsSingleton.CurrentSettings().LocalSiteImageContentDirectory(dbEntry);

            var syncCopyResults = await FileManagement.CheckImageFileIsInMediaAndContentDirectories(dbEntry, progress);

            if (!syncCopyResults.HasError)
            {
                return(syncCopyResults);
            }

            CleanDisplayAndSrcSetFilesInImageDirectory(dbEntry, true, progress);

            ResizeForDisplayAndSrcset(new FileInfo(Path.Combine(imageDirectory.FullName, dbEntry.OriginalFileName)),
                                      false, progress);

            return(await GenerationReturn.Success($"{dbEntry.Title} Copied, Cleaned, Resized", dbEntry.ContentId));
        }
Exemplo n.º 2
0
        private void FindOption(int choice)
        {
            Helpers.TextBreak();
            if (choice == 1)
            {
                string message = Helpers.GetString("Please provide a message:");
                Helpers.TextBreak();
                StartEncode(message);
            }
            else if (choice == 2)
            {
                string fileName = Helpers.GetString(string.Format("Please provide the file name:\n" + @"(write only file name, file should be in {0}\ToEncode)", Helpers.DirectoryPath));
                Helpers.TextBreak();
                FileManagement fileManagement = new FileManagement();
                string         message        = fileManagement.ReadFileToEncode(fileName.Trim());

                if (message == null)
                {
                    FileNotFound();
                }

                StartEncode(message);
            }
            else if (choice == -1)
            {
                GetMessage();
            }
            else
            {
                Helpers.Error();
            }
        }
Exemplo n.º 3
0
        public async Task <Process> Install()
        {
            string version = await GetRemoteBuild();

            if (version == null)
            {
                return(null);
            }
            string tarName = $"vs_server_{version}.tar.gz";
            string address = $"https://cdn.vintagestory.at/gamefiles/stable/{tarName}";
            string tarPath = ServerPath.GetServersServerFiles(_serverData.ServerID, tarName);

            // Download vs_server_{version}.tar.gz from https://cdn.vintagestory.at/gamefiles/stable/
            using (WebClient webClient = new WebClient())
            {
                try { await webClient.DownloadFileTaskAsync(address, tarPath); }
                catch
                {
                    Error = $"Fail to download {tarName}";
                    return(null);
                }
            }

            // Extract vs_server_{version}.tar.gz
            if (!await FileManagement.ExtractTarGZ(tarPath, Directory.GetParent(tarPath).FullName))
            {
                Error = $"Fail to extract {tarName}";
                return(null);
            }

            // Delete vs_server_{version}.tar.gz, leave it if fail to delete
            await FileManagement.DeleteAsync(tarPath);

            return(null);
        }
Exemplo n.º 4
0
        public static Transaction StoreTransaction(int accountNumber, int accountNumberToo, decimal amount, decimal balance)
        {
            var transaction = new Transaction(accountNumber, accountNumberToo, amount, balance);

            FileManagement.SaveTransactionToTxt(transaction);
            return(transaction);
        }
Exemplo n.º 5
0
 public ActionResult UploadFile(HttpPostedFileBase fileUpload)
 {
     try
     {
         if (!string.IsNullOrEmpty(folderUpload))
         {
             if (fileUpload != null)
             {
                 string name = "";
                 FileManagement.UploadImage(fileUpload, folderUpload, ref name);
                 return(RedirectToAction("Index"));
             }
             else
             {
                 TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.FAIL));
                 return(RedirectToAction("Index"));
             }
         }
         else
         {
             TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, "Vui lòng chọn thư mục cần tải hình lên");
             return(RedirectToAction("Index"));
         }
     }
     catch (Exception ex)
     {
         Logger.LogError(ex);
         TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.ERROR, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_INSERT, ApplicationGenerator.TypeResult.ERROR));
         return(View());
     }
 }
Exemplo n.º 6
0
        public static async Task <(GenerationReturn generationReturn, FileContent fileContent)> SaveAndGenerateHtml(
            FileContent toSave, FileInfo selectedFile, bool overwriteExistingFiles, DateTime?generationVersion,
            IProgress <string> progress)
        {
            var validationReturn = await Validate(toSave, selectedFile);

            if (validationReturn.HasError)
            {
                return(validationReturn, null);
            }

            Db.DefaultPropertyCleanup(toSave);
            toSave.Tags = Db.TagListCleanup(toSave.Tags);

            toSave.OriginalFileName = selectedFile.Name;
            FileManagement.WriteSelectedFileContentFileToMediaArchive(selectedFile);
            await Db.SaveFileContent(toSave);

            WriteFileFromMediaArchiveToLocalSite(toSave, overwriteExistingFiles, progress);
            GenerateHtml(toSave, generationVersion, progress);
            await Export.WriteLocalDbJson(toSave, progress);

            DataNotifications.PublishDataNotification("File Generator", DataNotificationContentType.File,
                                                      DataNotificationUpdateType.LocalContent, new List <Guid> {
                toSave.ContentId
            });

            return(await GenerationReturn.Success($"Saved and Generated Content And Html for {toSave.Title}"), toSave);
        }
        public async Task <ActionResult> Edit(DepartmentViewModel model, HttpPostedFileBase fileUpload)
        {
            if (ModelState.IsValid)
            {
                if (fileUpload != null)
                {
                    model.Img = fileUpload.FileName;
                }

                //Call API Provider
                string strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_UPDATE);
                var    result = await APIProvider.Authorize_DynamicTransaction <DepartmentViewModel, bool>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.Edit);

                if (result)
                {
                    if (fileUpload != null)
                    {
                        FileManagement.UploadImage(fileUpload, ValueConstant.IMAGE_DEPARTMENT_PATH);
                    }

                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.SUCCESS));
                }
                else
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.FAIL));
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                // TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(ValueConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.FAIL));
                return(View());
            }
        }
Exemplo n.º 8
0
        public void WriteLocalHtml()
        {
            WriteRss();

            foreach (var loopPosts in IndexContent.Take(_numberOfContentItemsToDisplay))
            {
                if (BracketCodeCommon.ContainsSpatialBracketCodes(loopPosts) ||
                    loopPosts.GetType() == typeof(PointContentDto))
                {
                    IncludeSpatialScripts = true;
                }
            }

            var parser  = new HtmlParser();
            var htmlDoc = parser.ParseDocument(TransformText());

            var stringWriter = new StringWriter();

            htmlDoc.ToHtml(stringWriter, new PrettyMarkupFormatter());

            var htmlString = stringWriter.ToString();

            var htmlFileInfo =
                new FileInfo($@"{UserSettingsSingleton.CurrentSettings().LocalSiteRootDirectory}\index.html");

            if (htmlFileInfo.Exists)
            {
                htmlFileInfo.Delete();
                htmlFileInfo.Refresh();
            }

            FileManagement.WriteAllTextToFileAndLog(htmlFileInfo.FullName, htmlString);
        }
Exemplo n.º 9
0
    public int numberOfCars  = 0; // How many cars can spawn at once

    // Use this for initialization
    // ------------------------------------------------------------------------------------------------------ //
    // --------------------------------- S T A R T  &  U P D A T E ------------------------------------------ //
    // ------------------------------------------------------------------------------------------------------ //
    void Start()
    {
        carbehaviour       = GameObject.FindGameObjectWithTag("Player").GetComponent <CarBehaviour>();
        fileManagement     = GameObject.FindGameObjectWithTag("fileManager").GetComponent <FileManagement>();
        difficultySettings = GameObject.FindGameObjectWithTag("Difficulty").GetComponent <DifficultySettings>();
        block = GameObject.FindGameObjectWithTag("block").GetComponent <BlockManager>();

        // Start spawning further down so we get an edge at the bottom on start
        planeEdgeZ = -1000f; SpawnNewPlane(0);

        difficultyLvl = 0;
        counter       = 1; seconds = 0;
        startTimer    = false; timer = -3f;
        first         = true; times = 0;
        previousLanes = 0;

        // Data File created
        fileManagement.createDataFile();
        filePath = fileManagement.getFilePath();

        spawnCarX = 0; spawnCarY = 0; spawnCarZ = 0;

        //PlayerPrefs.DeleteAll();

        PlayerPrefs.SetInt("startingNewBlock", 0);
        PlayerPrefs.SetInt("numberOfBlocks", PlayerPrefs.GetInt("numberOfBlocks") + 1);
    }
Exemplo n.º 10
0
        public async Task WriteLocalHtml()
        {
            var settings = UserSettingsSingleton.CurrentSettings();

            await LineData.WriteLocalJsonData(DbEntry);

            var parser  = new HtmlParser();
            var htmlDoc = parser.ParseDocument(TransformText());

            var stringWriter = new StringWriter();

            htmlDoc.ToHtml(stringWriter, new PrettyMarkupFormatter());

            var htmlString = stringWriter.ToString();

            var htmlFileInfo =
                new FileInfo(
                    $"{Path.Combine(settings.LocalSiteLineContentDirectory(DbEntry).FullName, DbEntry.Slug)}.html");

            if (htmlFileInfo.Exists)
            {
                htmlFileInfo.Delete();
                htmlFileInfo.Refresh();
            }

            await FileManagement.WriteAllTextToFileAndLogAsync(htmlFileInfo.FullName, htmlString);
        }
 /*
  * Class constructor
  */
 public SeleniumBaseClass()
 {
     this._file = new FileManagement
     {
         FileName = @"C:\Kurs\SeleniumLog.txt"
     };
 }
Exemplo n.º 12
0
        public async Task <ActionResult> Edit(LanguageViewModel model, HttpPostedFileBase fileUpload)
        {
            if (ModelState.IsValid)
            {
                if (fileUpload != null)
                {
                    model.Icon = FileManagement.ImageToByteArray(fileUpload);
                }

                //Call API Provider
                string strUrl = APIProvider.APIGenerator(controllerName, APIConstant.ACTION_UPDATE);
                var    result = await APIProvider.Authorize_DynamicTransaction <LanguageViewModel, bool>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CMS, ARS.IgnoredARS);

                if (result)
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.SUCCESS, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.SUCCESS));
                }
                else
                {
                    TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.FAIL));
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                TempData["Alert"] = ApplicationGenerator.RenderResult(ApplicationGenerator.TypeResult.FAIL, ApplicationGenerator.GeneralActionMessage(APIConstant.ACTION_UPDATE, ApplicationGenerator.TypeResult.FAIL));
                return(View());
            }
        }
Exemplo n.º 13
0
        public static async Task WriteLocalJsonData(MapComponentDto dto)
        {
            var dtoElementGuids = dto.Elements.Select(x => x.ElementContentId).ToList();

            var db = await Db.Context();

            var pointGuids = await db.PointContents.Where(x => dtoElementGuids.Contains(x.ContentId))
                             .Select(x => x.ContentId).ToListAsync();

            var lineGuids = await db.LineContents.Where(x => dtoElementGuids.Contains(x.ContentId))
                            .Select(x => x.ContentId).ToListAsync();

            var geoJsonGuids = await db.GeoJsonContents.Where(x => dtoElementGuids.Contains(x.ContentId))
                               .Select(x => x.ContentId).ToListAsync();

            var showDetailsGuid = dto.Elements.Where(x => x.ShowDetailsDefault).Select(x => x.MapComponentContentId)
                                  .Distinct().ToList();

            var mapDtoJson = new MapSiteJsonData(dto.Map, geoJsonGuids, lineGuids, pointGuids, showDetailsGuid);

            var dataFileInfo = new FileInfo(Path.Combine(
                                                UserSettingsSingleton.CurrentSettings().LocalSiteMapComponentDataDirectory().FullName,
                                                $"Map-{dto.Map.ContentId}.json"));

            if (dataFileInfo.Exists)
            {
                dataFileInfo.Delete();
                dataFileInfo.Refresh();
            }

            await FileManagement.WriteAllTextToFileAndLogAsync(dataFileInfo.FullName,
                                                               JsonSerializer.Serialize(mapDtoJson));
        }
Exemplo n.º 14
0
            internal static IEnumerable <AlternateStreamInformation> GetAlternateStreamInformation(string path)
            {
                List <AlternateStreamInformation> streams = new List <AlternateStreamInformation>();

                path = Paths.AddExtendedPrefix(path);
                using (var fileHandle = FileManagement.CreateFile(
                           path,
                           // To look at metadata we don't need read or write access
                           0,
                           FileShare.ReadWrite,
                           FileMode.Open,
                           FileManagement.AllFileAttributeFlags.FILE_FLAG_BACKUP_SEMANTICS))
                {
                    using (BackupReader reader = new BackupReader(fileHandle))
                    {
                        StreamInfo?info;
                        while ((info = reader.GetNextInfo()).HasValue)
                        {
                            if (info.Value.Type == BackupStreamType.BACKUP_ALTERNATE_DATA)
                            {
                                streams.Add(new AlternateStreamInformation {
                                    Name = info.Value.Name, Size = info.Value.Size
                                });
                            }
                        }
                    }
                }

                return(streams);
            }
Exemplo n.º 15
0
        public void WriteLocalHtmlRssAndJson()
        {
            var settings = UserSettingsSingleton.CurrentSettings();

            var parser  = new HtmlParser();
            var htmlDoc = parser.ParseDocument(TransformText());

            var stringWriter = new StringWriter();

            htmlDoc.ToHtml(stringWriter, new PrettyMarkupFormatter());

            var htmlString = stringWriter.ToString();

            var htmlFileInfo = settings.LocalSiteLinkListFile();

            if (htmlFileInfo.Exists)
            {
                htmlFileInfo.Delete();
                htmlFileInfo.Refresh();
            }

            FileManagement.WriteAllTextToFileAndLog(htmlFileInfo.FullName, htmlString);

            WriteContentListRss();
        }
Exemplo n.º 16
0
    // ------------------------------------------------------------------------------------------------------ //
    // --------------------------------- S T A R T  &  U P D A T E ------------------------------------------ //
    // ------------------------------------------------------------------------------------------------------ //
    void Start()
    {
        carbehaviour       = GameObject.FindGameObjectWithTag("Player").GetComponent <CarBehaviour>();
        baseline           = GameObject.FindGameObjectWithTag("baseline").GetComponent <Baseline>();
        fileManagement     = GameObject.FindGameObjectWithTag("fileManager").GetComponent <FileManagement>();
        difficultySettings = GameObject.FindGameObjectWithTag("Difficulty").GetComponent <DifficultySettings>();
        block = GameObject.FindGameObjectWithTag("block").GetComponent <BlockManager>();


        // Start spawning further down so we get an edge at the bottom on start
        planeEdgeZ = -1000f; times = 0; previousLanes = 0;
        SpawnNewPlane(0);

        seconds    = 0; timer = -3f;
        startTimer = false; first = true; createBaselineNow = true;
        spawnCarX  = 0; spawnCarY = 0; spawnCarZ = 0;

        // When the start the game, the game is easier spawing less cars with longer distances between them
        startDistance = 500; numberOfCars = 1; distance = 300; difficultyLvl = 1;

        fileManagement.createDataFile();
        filePath = fileManagement.getFilePath();

        PlayerPrefs.SetInt("startingNewBlock", 0);
        PlayerPrefs.SetInt("numberOfBlocks", PlayerPrefs.GetInt("numberOfBlocks") + 1);
    }
        public long Add(FileManagement entity)
        {
            var addedEntity = _cmsDbContext.FileManager.Add(entity);

            _cmsDbContext.SaveChanges();
            return(addedEntity.Entity.Id);
        }
Exemplo n.º 18
0
        public void Experiment3()
        {
            String        filename = "Function3";
            StringBuilder expected = new StringBuilder();
            StringBuilder result   = new StringBuilder();

            int fuzzySetsCount = 10;

            Range           range     = new Range(-5, 5);
            IFunction       function  = FunctionsHelper.GetConcreteFunction(FunNumber.F3);
            List <FuzzySet> fuzzySets = FuzzySet.coverRangeWithFuzzySets(range, fuzzySetsCount);

            SimpleFuzzyRules3D fuzzyRules = new SimpleFuzzyRules3D(generateRandom2DPoints(range, RANDOM_POINTS_COUNT), function, fuzzySets);

            double[][] testPoints = generateRandom2DPoints(range, RANDOM_POINTS_COUNT);

            foreach (double[] xs in testPoints)
            {
                double output = fuzzyRules.getOutput(xs);

                //			Console.WriteLine(String.format("f(" + Arrays.toString(xs) + ") = %.2f, expected %.2f", output, function.evaluate(xs)));

                expected.Append(StringUtils.Join(xs, " ") + " " + output + "\n");
                result.Append(StringUtils.Join(xs, " ") + " " + function.evaluate(xs) + "\n");
            }

            // Save results to files.
            FileManagement.WriteToFile(outputDirectory + "//fuzzy_" + filename + "_expected.dat", expected.ToString());
            FileManagement.WriteToFile(outputDirectory + "//fuzzy_" + filename + "_result.dat", result.ToString());

            double error = fuzzyRules.getError(testPoints);

            Console.WriteLine("Error = " + error);
        }
Exemplo n.º 19
0
        /// <summary>
        ///   Writes the file represented by the given byte array to the given path.
        /// </summary>
        /// <remarks>
        ///   This method writes the given data as a file at the given path, if it is owned
        ///   by the fomod being upgraded. If the specified data file is not owned by the fomod
        ///   being upgraded, the file is instead written to the overwrites directory.
        ///   If the file was not previously installed by the fomod, then the normal install rules apply,
        ///   including confirming overwrite if applicable.
        /// </remarks>
        /// <param name="p_strPath">The path where the file is to be created.</param>
        /// <param name="p_bteData">The data that is to make up the file.</param>
        /// <returns>
        ///   <lang langref="true" /> if the file was written; <lang langref="false" /> if the user chose
        ///   not to overwrite an existing file.
        /// </returns>
        /// <exception cref="IllegalFilePathException">
        ///   Thrown if <paramref name="p_strPath" /> is
        ///   not safe.
        /// </exception>
        public override bool GenerateDataFile(string p_strPath, byte[] p_bteData)
        {
            PermissionsManager.CurrentPermissions.Assert();
            FileManagement.AssertFilePathIsSafe(p_strPath);

            IList <string> lstInstallers = InstallLog.Current.GetInstallingMods(p_strPath);

            if (lstInstallers.Contains(Fomod.BaseName))
            {
                string strWritePath;
                if (!lstInstallers[lstInstallers.Count - 1].Equals(Fomod.BaseName))
                {
                    var strDirectory  = Path.GetDirectoryName(p_strPath);
                    var strBackupPath = Path.Combine(Program.GameMode.OverwriteDirectory, strDirectory);
                    var strOldModKey  = InstallLog.Current.GetModKey(Fomod.BaseName);
                    var strFile       = strOldModKey + "_" + Path.GetFileName(p_strPath);
                    strWritePath = Path.Combine(strBackupPath, strFile);
                }
                else
                {
                    strWritePath = Path.Combine(Program.GameMode.PluginsPath, p_strPath);
                }
                Installer.TransactionalFileManager.WriteAllBytes(strWritePath, p_bteData);
                Installer.MergeModule.AddFile(p_strPath);
                return(true);
            }

            return(base.GenerateDataFile(p_strPath, p_bteData));
        }
Exemplo n.º 20
0
        private SyncLibraryHandler ExecuteSyncHandler(string[] files, FileManagement fileManagement, ITagData tag = null)
        {
            SyncLibraryHandler handler = null;

            try
            {
                handler = new SyncLibraryHandler(DataSourceAdapter, DirectoryDataSourceAdapter,
                                                 AppConfiguration.GameFileDirectory, AppConfiguration.TempDirectory, AppConfiguration.DateParseFormats, fileManagement);
                handler.SyncFileChange     += syncHandler_SyncFileChange;
                handler.GameFileDataNeeded += syncHandler_GameFileDataNeeded;

                handler.Execute(files);

                if (m_pendingZdlFiles != null)
                {
                    SyncPendingZdlFiles();
                    m_pendingZdlFiles = null;
                }

                if (tag != null)
                {
                    TagSyncFiles(handler, tag);
                }
            }
            catch (Exception ex)
            {
                Util.DisplayUnexpectedException(this, ex);
            }

            return(handler);
        }
Exemplo n.º 21
0
    void checkToRecord()
    {
        if (isRecording)
        {
            return;
        }

        if (inputSongTrack.text == "")
        {
            statusLabel.text = "Song File Required. Ready.";
            return;
        }

        if (inputSongName.text == "")
        {
            statusLabel.text = "Song Name Required. Ready.";
            return;
        }

        if (FileManagement.CheckExistingFile("Songs/" + inputSongName.text))
        {
            statusLabel.text = "Song Name Already Exists. Ready.";
            return;
        }

        countdownRecord = true;
    }
 public void SaveOwlVoxelModel(OwlVoxelModel ovm, string name)
 {
     FileManagement.SaveOwlVoxelModel(
         FindObjectOfType <VoxelDisplay>().GenerateOVM(),
         FindObjectOfType <InputField>().text
         );
 }
Exemplo n.º 23
0
        private void projectToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            OpenFileDialog choofdlog = new OpenFileDialog();

            choofdlog.InitialDirectory = Application.StartupPath;

            choofdlog.Filter      = "Telltale Script Editor Project (*.tseproj)|*.tseproj";
            choofdlog.FilterIndex = 1;
            choofdlog.Multiselect = false;

            if (choofdlog.ShowDialog() == DialogResult.OK)
            {
                string sFileName = choofdlog.FileName;
                WorkingDirectory = Path.GetDirectoryName(sFileName);
                fileManager      = new FileManagement(operationProgressBar, projectFileTree, WorkingDirectory, this);
                if (fileManager.LoadProject(sFileName))
                {
                    fileManager.PopulateFileGUI();
                }
                else
                {
                    fileManager = null;
                }
            }
        }
Exemplo n.º 24
0
        public FileInfo ResizeTo(FileInfo toResize, int width, int quality, string imageTypeString, bool addSizeString,
                                 IProgress <string> progress)
        {
            if (!toResize.Exists)
            {
                return(null);
            }

            var newFile = Path.Combine(toResize.Directory?.FullName ?? string.Empty, $"{Guid.NewGuid()}.jpg");

            var newFileInfo = new FileInfo(newFile);

            if (newFileInfo.Exists)
            {
                newFileInfo.Delete();
            }

            var settings = new ProcessImageSettings {
                Width = width, JpegQuality = quality
            };

            using var outStream = new FileStream(newFileInfo.FullName, FileMode.Create);
            var results = MagicImageProcessor.ProcessImage(toResize.FullNameWithLongFilePrefix(), outStream, settings);

            outStream.Dispose();

            var finalFileName = Path.Combine(toResize.Directory?.FullName ?? string.Empty,
                                             $"{Path.GetFileNameWithoutExtension(toResize.Name)}--{imageTypeString}{(addSizeString ? $"--{width}w--{results.Settings.Height}h" : string.Empty)}.jpg");

            FileManagement.MoveFileAndLog(newFileInfo.FullName, finalFileName);

            newFileInfo = new FileInfo(finalFileName);

            return(newFileInfo);
        }
Exemplo n.º 25
0
        public void Process()
        {
            string Last   = "";
            string middle = "";
            string first  = "";
            int    a      = 0;

            try
            {
                Last   = PrivateKey[0].ToString();
                middle = PrivateKey[4].ToString();
                first  = PrivateKey[8].ToString();
                a      = Convert.ToInt32(PrivateKey[9].ToString() + PrivateKey[10].ToString());
            }
            catch
            {
                Helpers.Error();
            }


            EncodedMessage = DecodeSI(a, first, EncodedMessage);
            EncodedMessage = DecodeS(middle, EncodedMessage);
            Message        = DecodeS(Last, EncodedMessage);

            FileManagement fileManagement = new FileManagement(Message);

            fileManagement.CreateDeocdedFile();

            End e = new End(Message);

            e.EndDecode();
        }
Exemplo n.º 26
0
        public void EncoidingMessage()
        {
            int S  = Helpers.Randomize(1, 6);
            int S1 = Helpers.Randomize(1, 5);

            do
            {
                S1 = Helpers.Randomize(1, 5);
            }while (S == S1);
            int S2 = Helpers.Randomize(1, 2);

            CipherStrModel    cipher_1 = new CipherStrModel();
            CipherStrModel    cipher_2 = new CipherStrModel();
            CipherStrIntModel cipher_3 = new CipherStrIntModel();

            cipher_1 = FindCipherStr(S);
            cipher_2 = FindCipherStr(S1);
            cipher_3 = FindCipherStrInt(S2);


            Message    = cipher_1.Encode(Message);
            Message    = cipher_2.Encode(Message);
            Message    = cipher_3.Encode(Message, (cipher_3.GetCode.ToString().Contains("F")? Helpers.Randomize(3, 6) : Helpers.Randomize(7, 19)));
            Message   += ".";
            PrivateKey = CreatePrivateKey(cipher_1, cipher_2, cipher_3);
            PublicKey  = CreatePublicKey(PrivateKey, FindCipherStr(S));

            FileManagement fileManagement = new FileManagement(Message, PrivateKey, PublicKey);

            fileManagement.CreateEncodedFile();

            End e = new End(PublicKey, PrivateKey, Message);

            e.EndEncode();
        }
Exemplo n.º 27
0
        public static async Task WriteLocalJsonData()
        {
            var db = await Db.Context();

            var allPointIds = await db.PointContents.Select(x => x.ContentId).ToListAsync();

            var extendedPointInformation = await Db.PointAndPointDetails(allPointIds, db);

            var settings = UserSettingsSingleton.CurrentSettings();

            var pointJson = JsonSerializer.Serialize(extendedPointInformation.Select(x =>
                                                                                     new
            {
                x.ContentId,
                x.Title,
                x.Longitude,
                x.Latitude,
                x.Slug,
                PointPageUrl     = settings.PointPageUrl(x),
                DetailTypeString = string.Join(", ", PointDetailUtilities.PointDtoTypeList(x))
            }).ToList());

            var dataFileInfo = new FileInfo($"{settings.LocalSitePointDataFile()}");

            if (dataFileInfo.Exists)
            {
                dataFileInfo.Delete();
                dataFileInfo.Refresh();
            }

            await FileManagement.WriteAllTextToFileAndLogAsync(dataFileInfo.FullName, pointJson);
        }
Exemplo n.º 28
0
        public async void SaveResume(Resume.Resume cv)
        {
            //throw new NotImplementedException("Async ?")
            //var file_saving = FileManagement.Save_File(cv);
            var temp = FindResume(cv.Name);

            if (temp == null)
            {
                var tempRes = new PreventSavingTemplateWithoutNameDialog();
                await tempRes.ShowAsync();

                if (tempRes.Result == SavingTemplateResult.Validate && tempRes.CV_name != "")
                {
                    cv.Name = tempRes.CV_name;
                    FileManagement.Save_File(cv);
                    SaveResumeInResumes(cv);
                }
            }
            else
            {
                FileManagement.Save_File(cv);
                SaveResumeInResumes(cv);
            }

            //await file_saving;
        }
Exemplo n.º 29
0
        public async Task LoadResumes()
        {
            // async ?
            Resumes = new List <Resume.Resume>
            {
                // ResumeTest.GetResumeTest(),
                //ResumeTest.GetResumeTest2()
            };

            //charger les cv déjà remplis
            var storagelist = await FileManagement.GetResumeFoldersList();

            foreach (var stlist in storagelist)
            {
                var files = await stlist.GetFilesAsync();

                foreach (var file in files)
                {
                    if (Path.GetExtension(file.Name) == ".cv")
                    {
                        var temp = await FileManagement.Read_file(Path.GetFileNameWithoutExtension(file.Name), stlist);

                        Resumes.Add(temp);
                    }
                }
            }

            // var temp = await FileManagement.Read_file("CV_test");
            // Resumes.Add(temp);
        }
Exemplo n.º 30
0
        public Settings()
        {
            InitializeComponent();

            organization.Text = Register.OrgName;

            try
            {
                FileManagement.checkReceiptSavingLocation();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            receiptSavingLocationTextbox.Text = FileManagement.ReceiptSavingPath;

            //for changing password
            try
            {
                var           userList     = Login_TableData.getAllUsers();
                List <string> usernameList = new List <string>();

                foreach (DAL.Login item in userList)
                {
                    usernameList.Add(item.Username);
                }

                usernameCombo.ItemsSource = usernameList;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 31
0
 protected void btnSearch_Click(object sender, EventArgs e)
 {
     DataTable dt = new DataTable();
     FileManagement fm = new FileManagement();
     odsSearch.Select();
     gvSearch.DataBind();
     mvSearch.SetActiveView(mvSearch.Views[1]);
 }
Exemplo n.º 32
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        FileManagement flMgmt = new FileManagement();
        Guid FileId = new Guid(ddlOffice.SelectedValue);
        decimal FileNo = Convert.ToDecimal(txtFileSlNo.Text);
        decimal FileYear = Convert.ToDecimal(txtFileYear.Text);
        string FilePreFix = txtFilePrefix.Text;
        string curfileid = (flMgmt.GetFileIDByFileNoAndOffice(FileId, FileNo, FilePreFix, FileYear)).ToString();
        Session["fileId"] = curfileid;
        if (Session["fileId"].ToString() == (Guid.Empty).ToString())
        {

        }
        else
        {
            //mvUpload.SetActiveView(mvUpload.Views[1]);
        }
    }
Exemplo n.º 33
0
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     FileManagement ds = new FileManagement();
     global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
     any1.Namespace = "http://www.w3.org/2001/XMLSchema";
     any1.MinOccurs = new decimal(0);
     any1.MaxOccurs = decimal.MaxValue;
     any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any1);
     global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
     any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1";
     any2.MinOccurs = new decimal(1);
     any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any2);
     global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute1.Name = "namespace";
     attribute1.FixedValue = ds.Namespace;
     type.Attributes.Add(attribute1);
     global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute2.Name = "tableTypeName";
     attribute2.FixedValue = "FileRemarksDataTable";
     type.Attributes.Add(attribute2);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
Exemplo n.º 34
0
 public virtual int Update(FileManagement dataSet) {
     return this.Adapter.Update(dataSet, "FileForwards");
 }
Exemplo n.º 35
0
 public virtual int Update(FileManagement.FileForwardsDataTable dataTable) {
     return this.Adapter.Update(dataTable);
 }
Exemplo n.º 36
0
 public virtual int Update(FileManagement dataSet) {
     return this.Adapter.Update(dataSet, "DepartmentMasterForFile");
 }
Exemplo n.º 37
0
 public virtual int Update(FileManagement.DepartmentMasterForFileDataTable dataTable) {
     return this.Adapter.Update(dataTable);
 }
Exemplo n.º 38
0
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     FileManagement ds = new FileManagement();
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny();
     any.Namespace = ds.Namespace;
     sequence.Items.Add(any);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }