예제 #1
0
        void WriteLog(Array TaskInfo, SaveStat saveStat)
        {
            string Filename = DateTime.Now.ToString("MM.dd.yyyy") + "JsonLog.json";

            if (File.Exists(Filename))
            {
                //Creating Json object
                JsonLog save1 = new JsonLog()
                {
                    LastUpdate = DateTime.Now.ToString("dd/mm/yy HH:mm"), FileSource = saveStat.source, FileDestination = saveStat.destination, FileSize = saveStat.totalsize, TaskName = TaskInfo.GetValue(0).ToString()
                };

                //Writing Json object in the file
                string jsonSerializedObj1 = JsonConvert.SerializeObject(save1, Formatting.Indented);
                System.IO.File.AppendAllText(Filename, jsonSerializedObj1);
            }
            else
            {
                //Creating Json object
                JsonLog save = new JsonLog()
                {
                    LastUpdate = DateTime.Now.ToString("dd/mm/yy HH:mm"), FileSource = saveStat.source, FileDestination = saveStat.destination, FileSize = saveStat.totalsize, TaskName = TaskInfo.GetValue(0).ToString()
                };

                //Writing Json object in the file
                string jsonSerializedObj = JsonConvert.SerializeObject(save, Formatting.Indented);
                File.WriteAllText(Filename, jsonSerializedObj);
            }
        }
        public void save(Array TaskInfo)
        {
            //Object that allow to get the values for the Log files
            differential = new SaveStat();
            JsonLogD     = new JsonLog();

            PathAsker(TaskInfo);
            FileDetector();
            FileCopier();
            JsonLogD.CreateLog(TaskInfo, differential);

            Console.ReadLine();
        }
        public void RefreshSaveStat(SaveStat saveStat)
        {
            //Creating Json object
            LogPattern save = new LogPattern()
            {
                LastUpdate = DateTime.Now.ToString("dd/mm/yy HH:mm"), FilesNumber = saveStat.filecount, FilesSize = saveStat.totalsize, FilesRemaining = saveStat.remainingfiles, SizeRemaining = saveStat.remainingsize, LastWork = saveStat.currentfiletocopy, Progression = 100 - ((saveStat.remainingsize + 1 / (saveStat.totalsize + 1)) * 100) + "%", Duration = saveStat.time
            };
            //Serializing the object to fit the Json file

            string jsonSerializedObj = JsonConvert.SerializeObject(save, Formatting.Indented);

            //Writing at the end of Json file without deleting is content
            File.WriteAllText("SaveStat.json", jsonSerializedObj);
        }
        public void save(Array TaskInfo)
        {
            mirror   = new SaveStat();
            JsonLogM = new JsonLog();


            PathAsker(TaskInfo);
            FileDetector();
            FileCopier();



            JsonLogM.CreateLog(TaskInfo, mirror);
            Console.ReadLine();
        }
예제 #5
0
 public void CreateLog(Array TaskInfo, SaveStat saveStat)
 {
     log = new SaveStat();
     WriteLog(TaskInfo, saveStat);
 }