Example #1
0
        /// <summary>
        /// 清理日志文件
        /// </summary>
        public static void CleanLogFile()
        {
            Task.Factory.StartNew(() =>
            {
                if (IsCleaning == false)
                {
                    IsCleaning = true;

                    List <string> all_log    = GetAllLogFile();
                    List <string> expire_log = GetExpireLogFile(all_log, out long allSize, out long expireSize);

                    if (Ls.Ok(expire_log))
                    {
                        foreach (var file in expire_log)
                        {
                            FileTool.Delete(file);
                        }

                        R.SystemStatus.DriveTotal = DriveTool.GetDriveTotalSize(R.Paths.App);
                        R.SystemStatus.DriveAvail = DriveTool.GetDriveAvailableSize(R.Paths.App);
                        LogCleaner.LogFileAnalyse();
                    }

                    IsCleaning = false;
                }
            });
        }
Example #2
0
        private void GetFileToDatabase()
        {
            var drives = FileQueryEngine.GetReadyNtfsDrives().OrderBy(x => x.Name);

            if (ListTool.HasElements(drives))
            {
                foreach (var drive in drives)
                {
                    NewFileCount = 0;
                    //if (!drive.Name.Contains("J")) continue;//测试只读取D盘
                    //if (drive.Name.Contains("D")) continue;//测试时跳过D盘
                    //if (drive.Name.Contains("F")) continue;//测试时跳过F盘

                    using (var db = new Muse())
                    {
                        //检测磁盘是否格式化,如果格式化则清空USN记录
                        DateTime dt1 = DriveTool.GetLastFormatTime(drive.Name);
                        var      ds  = db.Get <UsnDrives>(x => x.Name == drive.Name, null);
                        if ((ds == null) || (ds != null && ds.LastFormatTime != dt1.ToString()))
                        {
                            var deleteSql = db.Context.Database.ExecuteSqlCommand("DELETE FROM usnfiles WHERE drive = @p0;", drive.Name);

                            if (ds == null)
                            {
                                db.Add(new UsnDrives()
                                {
                                    Name = drive.Name, LastFormatTime = dt1.ToString()
                                });
                            }
                            else
                            {
                                ds.LastFormatTime = dt1.ToString();
                                db.Update(ds, true);
                            }
                        }

                        //查询上次读取到的位置(最后一条记录)
                        ulong filenumber = 0;
                        long  usn        = 0;
                        if (db.Any <UsnFiles>(x => x.Drive == drive.Name, null))
                        {
                            int      lastId  = db.Do <UsnFiles>().Where(x => x.Drive == drive.Name).Max(x => x.Id);
                            UsnFiles lastRec = db.Get <UsnFiles>(x => x.Id == lastId, null);

                            usn        = lastRec.Usn;
                            filenumber = NumberStringTool.ToUlong(lastRec.Number);

                            //usn = db.Do<UsnFiles>().Where(x => x.Drive == drive.Name).Max(x => x.Usn);
                            //string filenumberstr = db.Do<UsnFiles>().Where(x => x.Drive == drive.Name).Max(x => x.Number);
                            //filenumber = NumberStringTool.ToUlong(filenumberstr);
                        }
                        //从上次FileNumber记录开始读取
                        var usnOperator = new UsnOperator(drive);
                        usnOperator.GetEntries(usn, filenumber, GetFileToDatabaseEvent, 1000);
                    }
                }
            }
        }
        /// <summary>
        /// 1分钟任务
        /// </summary>
        public static void Do()
        {
            R.SystemStatus.DriveTotal = DriveTool.GetDriveTotalSize(R.Paths.App);
            R.SystemStatus.DriveAvail = DriveTool.GetDriveAvailableSize(R.Paths.App);

            LogCleaner.LogFileAnalyse();

            if (R.IsAutoDeleteExpiredLog)
            {
                LogCleaner.CleanLogFile();
            }
        }
Example #4
0
        /// <summary>
        /// 1分钟任务
        /// </summary>
        public static void Do()
        {
            R.SystemStatus.DriveTotal = DriveTool.GetDriveTotalSize(R.Paths.App);
            R.SystemStatus.DriveAvail = DriveTool.GetDriveAvailableSize(R.Paths.App);

            LogCleaner.LogFileAnalyse();
            R.Log.I($"全部日志文件:{R.SystemStatus.AllLogCount} 个, 共计:{ByteConvertTool.Cvt(R.SystemStatus.AllLogSize, "MB")} GB");
            R.Log.I($"过期日志文件:{R.SystemStatus.ExpireLogCount} 个, 共计:{ByteConvertTool.Cvt(R.SystemStatus.ExpireLogSize, "MB")} GB");

            //string toMail = "*****@*****.**";
            //string subject = $"服务器状态报表:日报:{DateTime.Now.ToString("yyyy年MM月dd日")}";
            //string emailBody = "测试内容";
            //EmailTool et = new EmailTool(
            //    "*****@*****.**",
            //    toMail, subject, emailBody,
            //    "bigbird_server","bigbird528");
            //et.Send();
        }
Example #5
0
    /// <summary>
    /// Creates the toolManager object which holds a list of all ITOOL interfaces
    /// </summary>
    /// <param name="wandObject_"></param>
    /// <param name="holder_"></param>
    public ToolManager(GameObject wandObject_, GameObject wandControls_, GameObject TopLevelUniCAVE_, double deadZone, float rotationSpeed, float movementSpeed, Text tool_, bool negateAnalogX_, bool negateAnalogY_)
    {
        wandObject      = wandObject_;
        tool            = tool_;
        wandControls    = wandControls_;
        TopLevelUniCAVE = TopLevelUniCAVE_;
        negativeAnalogX = negateAnalogX_;
        negativeAnalogY = negateAnalogY_;

        list = new List <ITool>();

        //fill the list with all the tool interfaces
        list.Add(wandControls.GetComponent <WarpTool>());
        list.Add(wandControls.GetComponent <GrabberTool>());
        list.Add(wandControls.GetComponent <ButtonTool>());
        list.Add(wandControls.GetComponent <RotatorTool>());

        driveTool = new DriveTool(TopLevelUniCAVE, wandObject, deadZone, rotationSpeed, movementSpeed, negativeAnalogX, negativeAnalogY);

        toolNumber = 0;
        updateToolName(tool);
    }