Example #1
0
        private void StartCheckFileInfo(object obj)
        {
            try
            {
                var fileInfoRepository     = this.GetRepository <IFileInfoRepository>();
                CheckFileInfoStatus status = GetCheckStatus();
                if (!string.IsNullOrEmpty(ConfigUtils.FileRootPath))
                {
                    if (status == CheckFileInfoStatus.None)
                    {
                        fileInfoRepository.ResetCheckStatus();
                        status = CheckFileInfoStatus.RestCheckStatus;
                        this.SetCheckStatus(status);
                    }

                    if (status == CheckFileInfoStatus.RestCheckStatus)
                    {
                        this.ReadFileInfo("\\");
                        status = CheckFileInfoStatus.ReadRootPath;
                        this.SetCheckStatus(status);
                    }

                    if (status == CheckFileInfoStatus.ReadRootPath)
                    {
                        var readPathInfoRepository = this.GetRepository <IReadPathInfoRepository>();
                        List <ReadPathDto> list    = readPathInfoRepository.GetList(20);
                        while (list.Count > 0)
                        {
                            foreach (var m in list)
                            {
                                this.ReadFileInfo(m.Path);
                                readPathInfoRepository.Delete(m.Id);
                            }
                            list = readPathInfoRepository.GetList(20);
                        }
                        status = CheckFileInfoStatus.ReadPathInfo;
                        this.SetCheckStatus(status);
                    }

                    if (status == CheckFileInfoStatus.ReadPathInfo)
                    {
                        fileInfoRepository.DeleteCheckStatus();
                        status = CheckFileInfoStatus.Completed;
                        this.SetCheckStatus(status);
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtils.Error("【FileInfoService.StartCheckFileInfo】", ex);
            }
            isCheckFileInfo = false;
        }
Example #2
0
        public virtual bool RestCheckStatus()
        {
            bool result = false;
            CheckFileInfoStatus status = this.GetCheckStatus();

            result = status == CheckFileInfoStatus.None;
            if (status == CheckFileInfoStatus.Completed)
            {
                this.SetCheckStatus(0);
                result = true;
            }

            return(result);
        }
Example #3
0
        private bool SetCheckStatus(CheckFileInfoStatus status)
        {
            bool result = false;
            var  sysConfigRepository = this.GetRepository <ISysConfigRepository>();
            var  list = sysConfigRepository.GetList(ConfigType.CheckFileInfoStatus);

            if (list.Count == 0)
            {
                var m = new SysConfigDto()
                {
                    Type  = ConfigType.CheckFileInfoStatus,
                    Key   = "CheckFileInfoStatus",
                    Value = CheckFileInfoStatus.None.ToString()
                };
                list.Add(m);
            }
            list[0].Value = status.ToString();
            sysConfigRepository.AddOrUpdate(list, ConfigType.CheckFileInfoStatus);

            return(result);
        }
Example #4
0
        public virtual CheckFileInfoStatus GetCheckStatus()
        {
            CheckFileInfoStatus status = CheckFileInfoStatus.None;
            var sysConfigRepository    = this.GetRepository <ISysConfigRepository>();
            var list = sysConfigRepository.GetList(ConfigType.CheckFileInfoStatus);

            if (list.Count == 0)
            {
                var m = new SysConfigDto()
                {
                    Type  = ConfigType.CheckFileInfoStatus,
                    Key   = "CheckFileInfoStatus",
                    Value = CheckFileInfoStatus.None.ToString()
                };
                list.Add(m);
                sysConfigRepository.AddOrUpdate(list, ConfigType.CheckFileInfoStatus);
            }
            Enum.TryParse(list[0].Value, true, out status);

            return(status);
        }