Example #1
0
        public override string ToString()
        {
            string s = $"{DateTimeConvert.StandardString(Time)}|{Long}|{AFK}|{CpuPer}|" +
                       $"{RamFree}|{SysDriveFree}|{AppCpuPer}|{AppRamUsed}";

            return(s);
        }
Example #2
0
        /// <summary>
        /// 初始读取文件并备份
        /// </summary>
        public void DefaultBackupFile(string path)
        {
            //读取本地文件夹中的所有文件列表
            List <string> files = FileTool.GetAllFile(path);

            if (ListTool.HasElements(files))
            {
                foreach (var file in files)
                {
                    try
                    {
                        string lastwritetime = DateTimeConvert.StandardString(File.GetLastWriteTime(file));
                        using (var db = new Muse())
                        {
                            BackupFiles backfile = db.Get <BackupFiles>(x => x.FullPath == file && x.LastWriteTime == lastwritetime, null);
                            if (backfile == null)
                            {
                                AddToBackupFiles(file);
                            }
                        }
                    }
                    catch (Exception e) { }
                }
            }
        }
 private void WriteTask()
 {
     if (!IsWrite)
     {
         Task.Factory.StartNew(() =>
         {
             IsWrite = true;
             while (!IsDisposed)
             {
                 //处理输出过长(截断到一半)
                 UIConsoleCut();
                 if (Lines.Any() && Lines.Count > 0)
                 {
                     try
                     {
                         StringBuilder sb = new StringBuilder();
                         for (int i = 0; i < Lines.Count; i++)
                         {
                             if (Lines.TryDequeue(out string s))
                             {
                                 ConsoleLine++;
                                 //显示行号
                                 if (CBNumber.Checked)
                                 {
                                     sb.Append($"【{ConsoleLine}】");
                                 }
                                 //显示时间
                                 if (CBTime.Checked)
                                 {
                                     sb.Append($"【{DateTimeConvert.StandardString(DateTime.Now)}】");
                                 }
                                 sb.Append(s);
                                 sb.Append(Environment.NewLine);
                             }
                         }
                         if (sb.Length > 0)
                         {
                             UIConsole(sb.ToString());
                         }
                     }
                     catch { }
                 }
                 Thread.Sleep(WriteInterval);
             }
         });
     }
 }
Example #4
0
 /// <summary>
 /// 备份文件
 /// </summary>
 /// <param name="path"></param>
 /// <param name="newpath"></param>
 private void BackupFile(string path, string newpath, string md5)
 {
     using (var db = new Muse())
     {
         try
         {
             if (DirTool.Create(DirTool.GetFilePath(newpath)))
             {
                 string lastwritetime = DateTimeConvert.StandardString(File.GetLastWriteTime(path));
                 File.Copy(path, newpath, true);
                 db.Add(new BackupFiles()
                 {
                     FullPath       = path,
                     BackupFullPath = newpath,
                     Size           = FileTool.Size(path),
                     BackupTime     = DateTimeConvert.StandardString(DateTime.Now),
                     LastWriteTime  = lastwritetime,
                     Md5            = md5,
                 });
             }
         }
         catch (Exception e) { }
     }
 }