Ejemplo n.º 1
0
        public static Mother3Project CreateNew(IFileSystem fileSystem, string romDataPath,
                                               string romConfigPath)
        {
            var binaryManager = new BinaryFileManager(fileSystem);
            var jsonManager   = new JsonFileManager(fileSystem);

            var romData         = binaryManager.ReadFile <Block>(romDataPath);
            var romConfig       = jsonManager.ReadJson <Mother3RomConfig>(romConfigPath);
            var projectSettings = Mother3ProjectSettings.CreateDefault();

            var project = new Mother3Project(romData, romConfig, projectSettings);

            // Do some ROM config prep before reading the modules
            if (romConfig.IsJapanese)
            {
                romConfig.AddJapaneseCharsToLookup(romData);
            }

            if (romConfig.ScriptEncodingParameters != null)
            {
                romConfig.ReadEncodingPadData(romData);
            }

            romConfig.UpdateLookups();

            foreach (var module in project.Modules)
            {
                module.ReadFromRom(romData);
            }

            return(project);
        }
Ejemplo n.º 2
0
        public ActionResult Create(RequestViewModel model)
        {
            string path = Server.MapPath("../JsonFilesTemporary/jsonRequest.json");

            JsonFileManager.LoadJson(ref requests, path);



            // Simulo tener un  id de BD
            Random rnd      = new Random();
            var    randomid = rnd.Next(1, 100);

            model.IdRequestCustomer = randomid;
            model.idDocumentType    = Convert.ToInt32(model.SelectedDocumentType);
            model.Date          = DateTime.Now;
            model.DocumentTypes = null;

            // Save the request
            requests.Add(model);


            JsonFileManager.saveRequests(requests, path);



            return(RedirectToAction("index", "chat", new { idRequest = model.IdRequestCustomer, Name = model.CustomerName }));

            //return View(model);
        }
Ejemplo n.º 3
0
        public MusicLoaderPage()
        {
            InitializeComponent();

            var dir = SettingsManager.Get(SettingsRequisites.Directory);

            TbUid.Text = SettingsManager.Get(SettingsRequisites.DownloadForUid);
            if (string.IsNullOrEmpty(TbUid.Text))
            {
                TbUid.Text = SettingsManager.Get(SettingsRequisites.Uid);
                SettingsManager.Set(SettingsRequisites.DownloadForUid, TbUid.Text);
            }
            if (string.IsNullOrEmpty(dir))
            {
                BtRefresh.IsEnabled = false;
                return;
            }

            LbDirectory.Content = dir;
            var pathName    = Path.Combine(SettingsManager.Get(SettingsRequisites.Directory), ".playlist");
            var idsDownload = new JsonFileManager().ReadFile <List <VkSongModel> >(pathName);

            LbIdDownloader.Content = $"{idsDownload?.Count ?? 0} файлов";

            SyncLabels();
        }
Ejemplo n.º 4
0
        public void SyncLabels()
        {
            var pathName    = Path.Combine(SettingsManager.Get(SettingsRequisites.Directory), ".playlist");
            var idsDownload = new JsonFileManager().ReadFile <List <VkSongModel> >(pathName);

            if (idsDownload == null)
            {
                return;
            }
            var sync = new SongsFileSynchronizer();

            LbIndexed.Content = $"{sync.GetSongsIntersect(idsDownload)} файлов";

            var countToDownload = sync.SongsToDownloadCount(idsDownload);

            LbToDownload.Content = $"+ {countToDownload} файлов";
            if (countToDownload > 0)
            {
                LbToDownload.Foreground = new SolidColorBrush(Colors.Green);
            }

            var countToDelete = sync.SongsToDeleteCount(idsDownload);

            LbToDelete.Content = $"- {countToDelete} файлов";
            if (countToDelete > 0)
            {
                LbToDelete.Foreground = new SolidColorBrush(Colors.Red);
            }
        }
Ejemplo n.º 5
0
        public ActionResult getCustomer(int idAgent)
        {
            RequestAgentModel agentRequested  = new RequestAgentModel();
            RequestViewModel  customerRequest = new RequestViewModel();

            // conversation Id, this set of varibles are sent back to the client...
            int    requestAgent     = 0;
            string customerName     = "";
            bool   isAgentRequested = false;

            var requestPath       = Server.MapPath("../JsonFilesTemporary/jsonRequest.json");
            var requestAgentsPath = Server.MapPath("../JsonFilesTemporary/requestAgents.json");

            List <RequestViewModel>  requests      = new List <RequestViewModel>();
            List <RequestAgentModel> requestAgents = new List <RequestAgentModel>();

            JsonFileManager.LoadJson(ref requests, requestPath);
            JsonFileManager.LoadJson(ref requestAgents, requestAgentsPath);

            agentRequested = requestAgents.Where(r => r.idAgent == idAgent).FirstOrDefault();

            if (agentRequested != null)
            {
                isAgentRequested = true;

                requestAgent = agentRequested.idRequestAgent;

                customerRequest = requests.Where(r => r.IdRequestCustomer == agentRequested.idCustomerRequest).FirstOrDefault();

                customerName = customerRequest.CustomerName + " " + customerRequest.Email;
            }

            return(Json(new { isAgentRequested = isAgentRequested, requestAgent = requestAgent, customerName = customerName }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 6
0
        public ActionResult Login(Agent agent)
        {
            // Logic to login and make the agent available.


            Random rnd      = new Random();
            var    randomid = rnd.Next(1, 1000);


            string path = Server.MapPath("../JsonFilesTemporary/jsonAgentsAvailable.json");

            agent.AgentId = randomid;


            JsonFileManager.LoadJson(ref _agentes, path);

            _agentes.Add(new AgentAvailableModel {
                AgentId = agent.AgentId, AgentName = agent.AgentUser, Available = true
            });


            JsonFileManager.saveRequests(_agentes, path);


            return(RedirectToAction("index", "chat", new { idRequest = 0, Name = agent.AgentUser, idAgent = agent.AgentId }));
        }
Ejemplo n.º 7
0
        public string GetElementName()
        {
            bool   nameSelection = true;
            string elementName   = "";

            while (nameSelection)
            {
                nameSelection = false;

                Console.Write("Element name: ");
                elementName = Console.ReadLine();

                Console.Clear();

                List <Element> loadedElements = new JsonFileManager().LoadElements("../../../../AppData/Elements.json");

                if (loadedElements != null && loadedElements.Any())
                {
                    foreach (Element element in new JsonFileManager().LoadElements("../../../../AppData/Elements.json"))
                    {
                        if (element.Name == elementName)
                        {
                            nameSelection = true;
                            Console.WriteLine("This element already exist");
                        }
                    }
                }
            }

            return(elementName);
        }
Ejemplo n.º 8
0
        public void OnSaveButtonClick()
        {
            JsonFileManager jsonFileManager = new JsonFileManager();

            jsonFileManager.SaveGame(game);
            OnResumeButtonClick();
        }
Ejemplo n.º 9
0
        public void LoadDatabase(CmdParser parser)
        {
            var dbFilename = parser.GetAttribute("file") ?? parser.GetAttribute(0);

            fileManager = new JsonFileManager(dbFilename, false);
            Initialize();
            Console.WriteLine("Loaded {0}.", dbFilename);
        }
        public SettingsManager(ISimpleLogger logger, JsonFileManager jsonFileManager, ISettingsBindable settings)
        {
            this._logger          = logger;
            this._jsonFileManager = jsonFileManager;
            this._settings        = settings;

            LoadDefault();
        }
Ejemplo n.º 11
0
        public CreateDirectory(string currentDirectory, JsonFileManager fileManager, Action <string> action)
        {
            InitializeComponent();

            var model = new Models.CreateDirectoryModel(currentDirectory, fileManager, action);
            var vm    = new ViewModels.CreateDirectoryViewModel(this, model);

            DataContext = vm;
        }
Ejemplo n.º 12
0
 public static AppInfo GetAppInfo(bool refresh = false)
 {
     if (_appInfo == null || refresh)
     {
         var fileManager = new JsonFileManager();
         _appInfo = fileManager.GetOrCreate <AppInfo>();
     }
     return(_appInfo);
 }
Ejemplo n.º 13
0
        public void MakeDatabase(CmdParser parser)
        {
            var dbFilename  = parser.GetAttribute("file") ?? parser.GetAttribute(0);
            var checkHash   = parser.GetAttribute("hash") ?? parser.GetAttribute(1);
            var isCheckHash = checkHash == null ? true : false;

            fileManager = new JsonFileManager(dbFilename, true, isCheckHash);
            Initialize();
            Console.WriteLine("Loaded {0}.", dbFilename);
        }
Ejemplo n.º 14
0
        public void LoadContentAsTest()
        {
            RunBeforeTests(_listTest);
            var fileManager     = new JsonFileManager();
            var resultingObject = fileManager.LoadContentAs <IEnumerable <FieldConfig> >(FilePath);
            var fieldConfigs    = resultingObject.ToList();
            var top1            = fieldConfigs.FirstOrDefault();

            Assert.IsNotNull(top1);
            Assert.IsTrue(top1.Required);
        }
Ejemplo n.º 15
0
        public JsonFileManagerTests()
        {
            saverMock   = new Mock <IFileSaver>();
            removerMock = new Mock <IFileRemover>();

            var facMock = new Mock <IFileSaverFactory>();

            facMock.Setup(fm => fm.GetSaver(It.IsAny <SaverType>())).Returns(saverMock.Object);

            imageManager = new JsonFileManager(facMock.Object, removerMock.Object);
        }
Ejemplo n.º 16
0
        public void Save(IFileSystem fileSystem, string projectSettingsPath)
        {
            var jsonManager = new JsonFileManager(fileSystem);

            jsonManager.WriteJson(projectSettingsPath, ProjectSettings);
            jsonManager.WriteJson(ProjectSettings.RomConfigPath, RomConfig);

            foreach (var module in Modules)
            {
                module.WriteToFiles(fileSystem);
            }
        }
Ejemplo n.º 17
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        jsonFM = GameObject.Find("GameManager").GetComponent<JsonFileManager>();
    }
Ejemplo n.º 18
0
        private void StartDownloadOnClick(object sender, System.Windows.RoutedEventArgs e)
        {
            MarkerToStopDownload = false;
            Task.Run(async() =>
            {
                var vkService     = new VkDownloadService();
                var pathName      = Path.Combine(SettingsManager.Get(SettingsRequisites.Directory), ".playlist");
                var audioPlaylist = new JsonFileManager().ReadFile <List <VkSongModel> >(pathName);

                var audioToDownload = new SongsFileSynchronizer().GetSongsToDownload(audioPlaylist);

                await vkService.DeleteAndDownload(audioToDownload, new SongsFileSynchronizer().GetSongsToDelete(audioPlaylist));
            });
        }
Ejemplo n.º 19
0
        public ActionResult GetAvailableAgent(int idRequest)
        {
            bool isAgentFound = false;


            RequestAgentModel requestAgent = new RequestAgentModel();

            requestAgent.idRequestAgent = 0;

            AgentAvailableModel assignedAgent = null;
            var agentsAvailablePath           = Server.MapPath("../JsonFilesTemporary/jsonAgentsAvailable.json");
            var requestAgentsPath             = Server.MapPath("../JsonFilesTemporary/requestAgents.json");

            JsonFileManager.LoadJson(ref agentsAvailable, agentsAvailablePath);

            var items = agentsAvailable.Where(a => a.Available == true).Count();

            if (items > 0)
            {
                assignedAgent = agentsAvailable.Where(a => a.Available == true).First();

                isAgentFound = true;

                agentsAvailable.First(a => a.AgentId == assignedAgent.AgentId).Available = false;

                JsonFileManager.saveRequests(agentsAvailable, agentsAvailablePath);

                JsonFileManager.LoadJson(ref requestAgents, requestAgentsPath);


                Random rnd      = new Random();
                var    randomid = rnd.Next(1, 1000);


                requestAgent = new RequestAgentModel
                {
                    idRequestAgent    = randomid,
                    idAgent           = assignedAgent.AgentId,
                    idCustomerRequest = idRequest,
                    isFinished        = false
                };

                requestAgents.Add(requestAgent);

                JsonFileManager.saveRequests(requestAgents, requestAgentsPath);
            }

            return(Json(new { data = assignedAgent, result = isAgentFound, idRequestAgent = requestAgent.idRequestAgent }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 20
0
        static GameData loadGameData(Map map)
        {
            List <Enemy> enemies = new JsonFileManager().LoadMobs("../../../AppData/Mobs.json");

            /*foreach (Enemy enemy in loadedEnemies)
             * {
             *  enemies.Add(enemy);
             * }*/

            //Enemy loadedEnemy = enemies[rn.Next(enemies.Count)];

            Enemy loadedEnemy = map.Enemies[rn.Next(map.Enemies.Count)];

            return(new GameData(map, new Player(), loadedEnemy, new List <CriticalEffect>(), new List <CriticalEffect>()));
        }
Ejemplo n.º 21
0
        public void OnLoadGameButtonClick()
        {
            JsonFileManager jsonFileManager = new JsonFileManager();

            try
            {
                Game game = jsonFileManager.LoadGame();
                this.baseViewModel.SelectedPageView = new GameView()
                {
                    DataContext = new GameViewModel(game, baseViewModel)
                };
            }
            catch (NoPathSelectedException)
            {
            }
        }
Ejemplo n.º 22
0
        public void PersistContentTest()
        {
            _listTest.Add(new FieldConfig
            {
                Name      = "Test 2",
                IsVisible = false,
                Required  = false
            });

            RunBeforeTests(_listTest);

            var fileManager     = new JsonFileManager();
            var resultingObject = fileManager.LoadContentAs <IEnumerable <FieldConfig> >(FilePath);
            var fieldConfigs    = resultingObject.ToList();

            Assert.IsTrue(fieldConfigs.Count == 2);
        }
Ejemplo n.º 23
0
        public static Mother3Project Load(IFileSystem fileSystem, string projectSettingsPath)
        {
            var jsonManager     = new JsonFileManager(fileSystem);
            var projectSettings = jsonManager.ReadJson <Mother3ProjectSettings>(projectSettingsPath);
            var romConfig       = jsonManager.ReadJson <Mother3RomConfig>(projectSettings.RomConfigPath);

            var binaryManager = new BinaryFileManager(fileSystem);
            var romData       = binaryManager.ReadFile <Block>(projectSettings.BaseRomPath);

            var project = new Mother3Project(romData, romConfig, projectSettings);

            foreach (var module in project.Modules)
            {
                module.ReadFromFiles(fileSystem);
            }

            return(project);
        }
Ejemplo n.º 24
0
        public override void WriteToFiles(IFileSystem fileSystem)
        {
            var jsonManager = new JsonFileManager(fileSystem);

            jsonManager.WriteJson(@"text\room-descriptions.json", RoomDescriptions);
            jsonManager.WriteJson(@"text\item-names.json", ItemNames);
            jsonManager.WriteJson(@"text\item-descriptions.json", ItemDescriptions);
            jsonManager.WriteJson(@"text\char-names.json", CharNames);
            jsonManager.WriteJson(@"text\party-char-names.json", PartyCharNames);
            jsonManager.WriteJson(@"text\enemy-names.json", EnemyNames);
            jsonManager.WriteJson(@"text\psi-names.json", PsiNames);
            jsonManager.WriteJson(@"text\psi-descriptions.json", PsiDescriptions);
            jsonManager.WriteJson(@"text\statuses.json", Statuses);
            jsonManager.WriteJson(@"text\default-char-names.json", DefaultCharNames);
            jsonManager.WriteJson(@"text\skills.json", Skills);
            jsonManager.WriteJson(@"text\skill-descriptions.json", SkillDescriptions);
            jsonManager.WriteJson(@"text\main-script.json", MainScript);
        }
Ejemplo n.º 25
0
        public void ReturnRecivedIdFromSaver()
        {
            saverMock = new Mock <IFileSaver>();
            saverMock.Setup(sm => sm.SaveFile(
                                It.IsAny <string>(),
                                It.IsAny <string>(),
                                It.IsAny <string>()))
            .Returns("id");

            var facMock = new Mock <IFileSaverFactory>();

            facMock.Setup(fm => fm.GetSaver(It.IsAny <SaverType>())).Returns(saverMock.Object);

            imageManager = new JsonFileManager(facMock.Object, removerMock.Object);

            var id = imageManager.SaveFile("data", "test/");

            Assert.Equal("id", id);
        }
Ejemplo n.º 26
0
 private void Compare(string args, Type[] commandsTypes, string funcName, bool removeFile = true)
 {
     try
     {
         var test   = this.GetTestData(args, commandsTypes);
         var result = TestHelper.CompareObjects <TestAppHistory>(test, null, funcName);
         Assert.True(result);
     }
     catch
     {
         throw;
     }
     finally
     {
         var fileManager = new JsonFileManager();
         fileManager.SaveInRootFolderWhenIsDebug = false;
         fileManager.Remove(ArgsHistoryCommand.FILE_NAME);
     }
 }
Ejemplo n.º 27
0
        public ActionResult BroadCastMessage(MessagesModel message)
        {
            bool result       = true;
            var  messagesPath = Server.MapPath("../JsonFilesTemporary/jsonMessages.json");

            Random rnd      = new Random();
            var    randomid = rnd.Next(1, 1000);

            message.IdMessage = randomid;
            try
            {
                JsonFileManager.LoadJson(ref _messages, messagesPath);
                _messages.Add(message);
                JsonFileManager.saveRequests(_messages, messagesPath);
            }
            catch (Exception)
            {
                result = false;
            }
            return(Json(new { result = result }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 28
0
        public ActionResult GetMessages(int idConversation, string sender)
        {
            // variables to return;

            bool result = true;

            string messagesClient = "";


            List <MessagesModel> allMessages = new List <MessagesModel>();
            List <MessagesModel> newMessages = new List <MessagesModel>();

            var messagesPath = Server.MapPath("../JsonFilesTemporary/jsonMessages.json");

            JsonFileManager.LoadJson(ref allMessages, messagesPath);


            try
            {
                newMessages = (from message in allMessages
                               where message.IdConversation == idConversation &&
                               message.Read == false && message.Sender != sender
                               select message).ToList <MessagesModel>();


                allMessages.Where(m => m.IdConversation == idConversation && m.Read == false && m.Sender != sender).ToList <MessagesModel>().ForEach(mes => mes.Read = true);
                JsonFileManager.saveRequests(allMessages, messagesPath);
                messagesClient = JsonConvert.SerializeObject(newMessages);
            }
            catch (Exception)
            {
                result = false;
            }



            return(Json(new { isSuccess = result, newMessages = messagesClient }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 29
0
        public void Test_HistorySave_WithSaveAndLoad_SaveAndLoad()
        {
            var strWriter     = new StringWriter();
            var commandsTypes = GetCmds(
                new Common.Commands.T31.Command1(),
                new Common.Commands.T31.Command2(),
                new Common.Commands.T31.Command3()
                );

            try
            {
                var list = new List <TestData>();
                list.Add(this.GetTestData("--prop1 value history-save key1", commandsTypes));
                list.Add(this.GetTestData("--prop1 \"TWO \\\"quote\\\"\" save 1 save 2 history-save key2", commandsTypes));
                list.Add(this.GetTestData("--prop2 0.1099 history-save key1", commandsTypes));
                list.Add(this.GetTestData("history-list", commandsTypes));
                list.Add(this.GetTestData("save history-list", commandsTypes));
                list.Add(this.GetTestData("history-load key2", commandsTypes));
                list.Add(this.GetTestData("save 1 history-load key2", commandsTypes));
                list.Add(this.GetTestData("history-load key1 history-load key2", commandsTypes));
                list.Add(this.GetTestData("history-delete key2", commandsTypes));
                list.Add(this.GetTestData("history-list", commandsTypes));

                var result = TestHelper.CompareObjects <TestAppHistory>(list, null, TestHelper.GetCurrentMethodName());
                Assert.True(result);
            }
            catch
            {
                throw;
            }
            finally
            {
                var fileManager = new JsonFileManager();
                fileManager.SaveInRootFolderWhenIsDebug = false;
                fileManager.Remove(ArgsHistoryCommand.FILE_NAME);
            }
        }
Ejemplo n.º 30
0
 public BaseStateManager(string name)
 {
     this.StateFilePath = ONI_Common.Paths.GetStateFilePath(name);
     this.Logger        = new ONI_Common.IO.Logger(name + "Log.txt");
     this.JsonLoader    = new JsonFileManager(new JsonManager(), Logger);
 }
Ejemplo n.º 31
0
        public override void ReadFromFiles(IFileSystem fileSystem)
        {
            var jsonManager = new JsonFileManager(fileSystem);

            MainScript = jsonManager.ReadJson <List <List <string> > >(@"text\main-script.json");
        }