示例#1
0
        //Can create a save work from simple parameters
        public void CreateWork(string _name, string _sourcePath, string _destinationPath, SaveWorkType _type)
        {
            SaveWork tempSave = new SaveWork(_name, _sourcePath, _destinationPath, _type);

            UpdateSaveFile(tempSave);
            CreateLogLine("Creation of a new save work , name : " + tempSave.name + ", source path : " + tempSave.sourcePath + ", destination path : " + tempSave.destinationPath + ", type : " + tempSave.type);
        }
示例#2
0
        public void UpdateSaveFile(SaveWork saveW)
        {
            //Check is a save protocol is active or not
            if (saveW.isActive)
            {
                long sizeDifference = saveW.saveProgress.totalSize - saveW.saveProgress.sizeRemaining;

                //Check if the difference in size is equal to 0, to avoid division by 0
                if (sizeDifference != 0)
                {
                    saveW.saveProgress.progressState = ((saveW.saveProgress.totalSize - saveW.saveProgress.sizeRemaining) / saveW.saveProgress.totalSize * 100);
                }
            }

            if (!File.Exists("state.json"))
            {
                backupJobList.Add(saveW);
                String stringjson = JsonConvert.SerializeObject(backupJobList, Formatting.Indented);


                File.WriteAllText("state.json", stringjson);
            }
            else
            {
                string json = File.ReadAllText("state.json");
                //Console.WriteLine(json);
                backupJobList = JsonConvert.DeserializeObject <List <SaveWork> >(json);
                backupJobList.Add(saveW);
                String stringjson = JsonConvert.SerializeObject(backupJobList, Formatting.Indented);
                File.WriteAllText("state.json", stringjson);
            }
        }
示例#3
0
        //Modify value of save works objects stored in workList, if there is any null parameters the value attached isn't changed
        public void ChangeWork(int _nb, string _name, string _sourcePath, string _destinationPath, SaveWorkType _type)
        {
            //modify the stateFile
            SaveWork backUpJobModified = new SaveWork(_name, _sourcePath, _destinationPath, _type);

            modifyStateFile(backUpJobModified, _nb);

            CreateLogLine("Modification of a existing save work in position " + _nb + ", current parameters : name : " + backupJobList[_nb - 1].name + ", source path : " + backupJobList[_nb - 1].sourcePath + ", destination path : " + backupJobList[_nb - 1].destinationPath + ", type : " + backupJobList[_nb - 1].type);
        }
示例#4
0
        public void modifyStateFile(SaveWork backUpJobModified, int _nb)
        {
            string json = File.ReadAllText("state.json");

            backupJobList          = JsonConvert.DeserializeObject <List <SaveWork> >(json);
            backupJobList[_nb - 1] = backUpJobModified;
            String stringjson = JsonConvert.SerializeObject(backupJobList, Formatting.Indented);

            File.WriteAllText("state.json", stringjson);
        }
示例#5
0
        //Can initiate a type of save from the numbers of the save work in workList.
        public void DoSave(int _nb)
        {
            SaveWork work = backupJobList[_nb - 1];

            if (Directory.Exists(backupJobList[_nb - 1].sourcePath))
            {
                if (work.type == SaveWorkType.complete)
                {
                    CompleteSave(_nb);
                }
                else if (work.type == SaveWorkType.differencial)
                {
                    DifferencialSave(_nb);
                }
            }
        }