Ejemplo n.º 1
0
        private async void CreateOpacityMap()
        {
            DisableControls(true);
            opacityMapInfoLabel.Visible = true;

            try
            {
                string filePath      = filePathTextBox.Text;
                string resultDirPath = GlobalData.ResultFileDirectory;
                FileDataManager.CreateDirectoryIfNotExists(resultDirPath);

                ArgbProcessor argbProc           = new ArgbProcessor(filePath);
                PacketObjMsg  fileCreationPacket = await argbProc.CreateOpacityMapAndNonTransparentImageTaskStart(resultDirPath);

                bool success = (bool)fileCreationPacket.Obj;

                if (!String.IsNullOrEmpty(fileCreationPacket.Msg))
                {
                    MessageBox.Show(fileCreationPacket.Msg);
                }

                if (success)
                {
                    MessageBox.Show("Pomyślnie utworzono pliki!");
                    Process.Start(resultDirPath);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show($"Błąd tworzenia mapy przezroczystości: {exception.Message}");
            }

            opacityMapInfoLabel.Visible = false;
            DisableControls(false);
        }
Ejemplo n.º 2
0
        public void mustWriteDocumentIfDoesntExists()
        {
            var fileManager = new FileDataManager();

            var model = new NetWorth
            {
                RecordId = "bingo",
                Entries  = new List <FinancialRecord>
                {
                    new FinancialRecord {
                        Id         = 3,
                        Currency   = "CDN",
                        RecordType = RecordType.ShortTermAsset,
                        Name       = "Chequing",
                        Rate       = 10.5,
                        Value      = 1000
                    },
                    new FinancialRecord {
                        Id         = 4,
                        Currency   = "CDN",
                        RecordType = RecordType.ShortTermLiability,
                        Name       = "Mortgage",
                        Rate       = 10.5,
                        Value      = 1000
                    }
                }
            };

            fileManager.CreateOrUpdate(model);

            var foundModel = fileManager.Read(model.RecordId);

            Assert.IsNotNull(foundModel);
        }
Ejemplo n.º 3
0
        private void SaveTcpConnectionSettings(TcpConnectionSettings settings)
        {
            FileDataManager fdm = new FileDataManager(this);

            fdm.InsertOrUpdateValueByKey("tcp_ip", settings.Ip);
            fdm.InsertOrUpdateValueByKey("tcp_port", settings.Port.ToString());
            fdm.SaveData();
        }
Ejemplo n.º 4
0
 private DataManager()
 {
     var database = new VCSEntities();
     userManager = new UserDataManager(database);
     repositoryManager = new RepositoryDataManager(database, this);
     fileManager = new FileDataManager(database);
     changeManager = new ChangeDataManager(database, this);
     commitManager = new CommitDataManager(database, this);
 }
Ejemplo n.º 5
0
        public void TestLoadObj()
        {
            var testObj = new FileDataManager().Get <TestSave>("test");

            if (testObj.A != 222 || testObj.B != "333")
            {
                throw new Exception();
            }
        }
Ejemplo n.º 6
0
 public LazuriteCore()
 {
     Singleton.Add(WarningHandler = new WarningHandler());
     Singleton.Add(new DataEncryptor());
     Singleton.Add(DataManager = new FileDataManager());
     Singleton.Add(new StoredPropertiesManager());
     Singleton.Add(SystemUtils            = new SystemUtils());
     Singleton.Add(AddictionalDataManager = new AddictionalDataManager());
 }
Ejemplo n.º 7
0
        public void Setup()
        {
            var fileManager = new FileDataManager();
            var database    = fileManager.ReadAll();

            if (database != null)
            {
                database.ForEach(x => fileManager.Delete(x.RecordId));
            }
        }
Ejemplo n.º 8
0
        public void LoadSettings()
        {
            var fileDataManager = new FileDataManager();

            if (fileDataManager.Has(LauncherSettingsKey))
            {
                Settings = fileDataManager.Get <LauncherSettings>(LauncherSettingsKey);
                SaveSettings();
            }
        }
        public void TestExtModulesAcrossSerializing_part1()
        {
            var dataManager = new FileDataManager();

            Singleton.Add(dataManager);
            var     manager    = new PluginsManager();
            IAction testAction = manager.CreateInstance(manager.GetModules().First(), null);

            testAction.SetValue(null, DateTime.Now.ToString());
            dataManager.Set("testAction", testAction);
        }
Ejemplo n.º 10
0
        public void GetFileData_No_Argument()
        {
            FileDetails     fileDetails = new FileDetails();
            FileDataManager manager     = new FileDataManager(fileDetails);

            var arguments = new string[] {
                "f:/test.txt"
            };

            var result = manager.GetFileData(arguments);

            Assert.AreEqual("No valid input", result);
        }
Ejemplo n.º 11
0
        public void GetFileData_No_Valid_File_Path()
        {
            FileDetails     fileDetails = new FileDetails();
            FileDataManager manager     = new FileDataManager(fileDetails);

            var arguments = new string[] {
                "--size",
            };

            var result = manager.GetFileData(arguments);

            Assert.AreEqual("No valid input", result);
        }
Ejemplo n.º 12
0
        public void GetFileData_Size()
        {
            FileDetails     fileDetails = new FileDetails();
            FileDataManager manager     = new FileDataManager(fileDetails);

            var arguments = new string[] {
                "-S",
                "f:/test.txt"
            };

            var result = manager.GetFileData(arguments);

            Assert.IsTrue(result.Contains("File size:"));
        }
Ejemplo n.º 13
0
        public void GetFileData_No_Valid_Argument()
        {
            FileDetails     fileDetails = new FileDetails();
            FileDataManager manager     = new FileDataManager(fileDetails);

            var arguments = new string[] {
                "----R",
                "f:/test.txt"
            };

            var result = manager.GetFileData(arguments);

            Assert.IsTrue(result.Contains("Invalid argument(s) supplied"));
        }
Ejemplo n.º 14
0
        public void GetFileData_Verions_Mixed_case()
        {
            FileDetails     fileDetails = new FileDetails();
            FileDataManager manager     = new FileDataManager(fileDetails);

            var arguments = new string[] {
                "--VeRsiOn",
                "f:/test.txt",
            };

            var result = manager.GetFileData(arguments);

            Assert.IsTrue(result.Contains("File version:"));
        }
Ejemplo n.º 15
0
        public void GetFileData_Verions_Mixed_case_Invalid_Symbol()
        {
            FileDetails     fileDetails = new FileDetails();
            FileDataManager manager     = new FileDataManager(fileDetails);

            var arguments = new string[] {
                "--VeRsiOn//",
                "f:/test.txt",
            };

            var result = manager.GetFileData(arguments);

            Assert.IsTrue(result.Contains("Invalid argument(s) supplied"));
        }
Ejemplo n.º 16
0
        public void TestExtModulesAcrossSerializing_part2()
        {
            var dataManager = new FileDataManager();

            Singleton.Add(dataManager);
            var     modulesManager = new PluginsManager();
            IAction testAction     = dataManager.Get <IAction>("testAction");

            Debug.WriteLine(testAction.GetValue(null));
            if (!testAction.GetType().Equals(modulesManager.GetModules().First()))
            {
                throw new Exception();
            }
        }
Ejemplo n.º 17
0
        public void GetFileData_Version_Third_Pattern()
        {
            FileDetails     fileDetails = new FileDetails();
            FileDataManager manager     = new FileDataManager(fileDetails);

            var arguments = new string[] {
                "--v",
                "f:/test.txt"
            };

            var result = manager.GetFileData(arguments);

            Assert.IsTrue(result.Contains("File version:"));
        }
Ejemplo n.º 18
0
        public void Correct_File_Data_Returns_Object()
        {
            //arrage
            var dataManager = new FileDataManager
            {
                EntryFile  = AppDomain.CurrentDomain.BaseDirectory + @"..\..\..\files\dataTest.txt",
                OutputFile = AppDomain.CurrentDomain.BaseDirectory + @"..\..\..\files\resultTest.txt"
            };

            //act
            var actual = dataManager.GetData().FirstOrDefault();

            //assert
            Assert.NotNull(actual);
        }
Ejemplo n.º 19
0
        public void File_Data_NumericSystem_IsNotInvalid_Throws_ArgumentException()
        {
            //arrage
            var dataManager = new FileDataManager
            {
                EntryFile  = AppDomain.CurrentDomain.BaseDirectory + @"..\..\..\files\dataTestIncorrect.txt",
                OutputFile = AppDomain.CurrentDomain.BaseDirectory + @"..\..\..\files\resultTest.txt"
            };

            //act
            Action actual = () => dataManager.GetData().FirstOrDefault();

            //assert
            Assert.Throws <ArgumentException>(actual);
        }
Ejemplo n.º 20
0
        public void GetFileData_Verions_Size_Arugments_Different_Position()
        {
            FileDetails     fileDetails = new FileDetails();
            FileDataManager manager     = new FileDataManager(fileDetails);

            var arguments = new string[] {
                "--version",
                "f:/test.txt",
                "--size"
            };

            var result = manager.GetFileData(arguments);

            Assert.IsTrue(result.Contains("File version:"));
            Assert.IsTrue(result.Contains("File size:"));
        }
Ejemplo n.º 21
0
        public void GetFileData_More_File_Paths()
        {
            FileDetails     fileDetails = new FileDetails();
            FileDataManager manager     = new FileDataManager(fileDetails);

            var arguments = new string[] {
                "--VeRsiOn//",
                "f:/test.txt",
                "f:/test.txt",
                "f:/test.txt",
            };

            var result = manager.GetFileData(arguments);

            Assert.AreEqual("No valid input", result);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Loads local settings from configuration file
        /// </summary>
        public void LoadLocalSettings()
        {
            try
            {
                FileDataManager fdm = new FileDataManager(this);

                #region MySQL settings
                //MYSQL SETTINGS
                string server = fdm.GetValueByKey("mysql_server");
                int    port   = 3306;
                Int32.TryParse(fdm.GetValueByKey("mysql_port"), out port);
                string database      = fdm.GetValueByKey("mysql_database");
                string user          = fdm.GetValueByKey("mysql_user");
                string passEncrypted = fdm.GetValueByKey("mysql_pass");
                string passDecrypted =
                    (
                        !String.IsNullOrWhiteSpace(passEncrypted) ?
                        Crypto.DecryptStringAES(passEncrypted, GlobalData.PassKey) :
                        ""
                    );

                SetMySqlSettings
                (
                    server,
                    port,
                    database,
                    user,
                    passDecrypted
                );

                #endregion

                #region TCP connection settings
                //TCP CONN. SETTINGS
                string tcpIp   = fdm.GetValueByKey("tcp_ip");
                int    tcpPort = 2222;
                Int32.TryParse(fdm.GetValueByKey("tcp_port"), out tcpPort);

                SetTcpConnectionSettings(tcpIp, tcpPort);

                #endregion
            }
            catch (Exception exception)
            {
                UpdateLog($"An error occured during mySQL settings loading: {exception.Message}");
            }
        }
Ejemplo n.º 23
0
        public void GetFileData_Verions_Size_More_Arguments()
        {
            FileDetails     fileDetails = new FileDetails();
            FileDataManager manager     = new FileDataManager(fileDetails);

            var arguments = new string[] {
                "--version",
                "f:/test.txt",
                "--size",
                "--size",
                "--size",
            };

            var result = manager.GetFileData(arguments);

            Assert.AreEqual("No valid input", result);
        }
Ejemplo n.º 24
0
        // const int DataSize = 4096;

        static void Main([NotNull][ItemNotNull] string[] args)
        {
            if (args.Length != 2)
            {
                PrintUsage();
                return;
            }

            string source      = args[0];
            string destination = args[1];

            if (!File.Exists(source))
            {
                Console.WriteLine("Source file does not exist");
                return;
            }

            var          initialLogger = new PrefixLogger("[Initial] ");
            var          infoLogger    = new PrefixLogger("[Sorter] ");
            IDataManager manager       = new FileDataManager(source, destination);

            string[] environmentArgs = new string[0];
            using (new Environment(ref environmentArgs))
            {
                var world = Communicator.world;
                initialLogger.Assert(world != null, "Could not retrieve world");
                int processors = world.Size;
                initialLogger.Assert(processors.IsPowerOfTwo(), "Number of processors should be power of two");
                int[] batch         = GetDataBatch(world, initialLogger, manager, processors);
                var   sorter        = new Sorter(batch, world, infoLogger);
                int   numberOfSteps = world.Size.IntegralBinaryLogarithm();

                for (int step = numberOfSteps - 1; step >= 0; step -= 1)
                {
                    sorter.Exchange(step);
                }

                var gathered = world.Gather(sorter.Sort(), 0);
                if (gathered != null)
                {
                    manager.SinkResult(gathered);
                }
            }
        }
Ejemplo n.º 25
0
        private void SaveMySqlSettings(MySqlConnectionSettings mySqlConnSettings)
        {
            FileDataManager fdm = new FileDataManager(this);

            fdm.InsertOrUpdateValueByKey("mysql_server", mySqlConnSettings.Server);
            fdm.InsertOrUpdateValueByKey("mysql_port", mySqlConnSettings.Port.ToString());
            fdm.InsertOrUpdateValueByKey("mysql_database", mySqlConnSettings.Database);
            fdm.InsertOrUpdateValueByKey("mysql_user", mySqlConnSettings.User);
            fdm.InsertOrUpdateValueByKey
            (
                "mysql_pass",
                (
                    !String.IsNullOrWhiteSpace(mySqlConnSettings.Pass) ?
                    Crypto.EncryptStringAES(mySqlConnSettings.Pass, GlobalData.PassKey) :
                    ""
                )
            );

            fdm.SaveData();
        }
Ejemplo n.º 26
0
        private void SaveResultImage()
        {
            try
            {
                if (this.resultBitmap == null)
                {
                    throw new Exception("nie wygenerowano obrazu (NULL)!");
                }

                string resultDirPath = GlobalData.ResultFileDirectory;
                FileDataManager.CreateDirectoryIfNotExists(resultDirPath);
                string filePath = $"{resultDirPath}\\hairTex_{DateTime.Now.ToString("yyyy_MM_dd_HH-mm-ss")}.png";
                this.resultBitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);

                MessageBox.Show("Pomyślnie zapisano obraz!");
                Process.Start(resultDirPath);
            }
            catch (Exception exception)
            {
                MessageBox.Show($"Błąd zapisu obrazu wynikowego: {exception.Message}");
            }
        }
Ejemplo n.º 27
0
        public void ProcessData_Create_New_File_With_Data()
        {
            //arrage
            var dataManager = new FileDataManager
            {
                OutputFile = AppDomain.CurrentDomain.BaseDirectory + @"..\..\..\files\resultTest.txt"
            };

            //act
            dataManager.ProcessData(new DataStruct
            {
                From   = NumericSystem.Decimal,
                To     = NumericSystem.Hexadecimal,
                Value  = "10",
                Result = "a"
            });

            var first = System.IO.File.ReadAllLines(AppDomain.CurrentDomain.BaseDirectory + @"..\..\..\files\resultTest.txt")[0];

            //assert
            Assert.Equal("10|10|16|a", first);
        }
Ejemplo n.º 28
0
        static void Main(string[] args)
        {
            try
            {
                var file = new FileDataManager();
                Console.WriteLine("File path (read data):");
                file.EntryFile = Console.ReadLine();

                Console.WriteLine("File path (write data result):");
                file.OutputFile = Console.ReadLine();

                NumericSystems.Convert(file);
                Console.Write("The process has finished");
            }
            catch (Exception ex)
            {
                Console.Write($"An error has occurred: {ex}");
            }
            finally
            {
                Console.ReadKey();
            }
        }
Ejemplo n.º 29
0
        public void mustUpdateDocumentIftExists()
        {
            var fileManager = new FileDataManager();

            var model = new NetWorth
            {
                RecordId = "bingo",
                Entries  = new List <FinancialRecord>
                {
                    new FinancialRecord {
                        Id         = 3,
                        Currency   = "CDN",
                        RecordType = RecordType.ShortTermAsset,
                        Name       = "Chequing",
                        Rate       = 10.5,
                        Value      = 1000
                    },
                    new FinancialRecord {
                        Id         = 4,
                        Currency   = "CDN",
                        RecordType = RecordType.ShortTermLiability,
                        Name       = "Mortgage",
                        Rate       = 10.5,
                        Value      = 1000
                    }
                }
            };

            fileManager.CreateOrUpdate(model);

            var model2 = new NetWorth
            {
                RecordId = "bingo",
                Entries  = new List <FinancialRecord>
                {
                    new FinancialRecord {
                        Id         = model.Entries[0].Id,
                        Currency   = "CDN",
                        RecordType = RecordType.ShortTermAsset,
                        Name       = "Chequing",
                        Rate       = 999,
                        Value      = 1000
                    },
                    new FinancialRecord {
                        Id         = model.Entries[1].Id,
                        Currency   = "CDN",
                        RecordType = RecordType.ShortTermLiability,
                        Name       = "Mortgage",
                        Rate       = 999,
                        Value      = 1000
                    }
                }
            };

            fileManager.CreateOrUpdate(model2);

            var found = fileManager.Read("bingo");

            Assert.IsNotNull(found);
            Assert.AreEqual(model2.Entries[0].Rate, found.Entries[0].Rate);
        }
Ejemplo n.º 30
0
        public void SaveSettings()
        {
            var fileDataManager = new FileDataManager();

            fileDataManager.Set(LauncherSettingsKey, Settings);
        }