public virtual bool SendDirectory(string localFullDirectoryName, string remoteDirectory, string remoteName)
        {
            bool result = false;

            try
            {
                if (!string.IsNullOrEmpty(remoteName) && !string.IsNullOrEmpty(remoteName) &&
                    Directory.Exists(localFullDirectoryName) && this.Client.IsLogin)
                {
                    var info = new DirectoryInfo(localFullDirectoryName);
                    CreateDirectoryParamDto craeateParam = new CreateDirectoryParamDto()
                    {
                        Directory     = remoteDirectory,
                        Name          = remoteName,
                        CreationTime  = info.CreationTime,
                        LastWriteTime = info.LastWriteTime
                    };
                    result = this.Client.Request <bool, CreateDirectoryParamDto>(MsgCmd.CreateDirectory, craeateParam);
                }
            }
            catch (Exception ex)
            {
                LogUtils.Error("【FileInfoClient.SendDirectory】", ex);
            }

            return(result);
        }
示例#2
0
        public ActionResult CreateDirectory(CreateDirectoryParamDto vm)
        {
            if (vm != null && !string.IsNullOrEmpty(vm.Name) &&
                vm.CreationTime != DateTime.MinValue && vm.LastWriteTime != DateTime.MinValue)
            {
                var  fileService = this.GetService <IFileService>();
                bool result      = fileService.CreateDirectory(vm);

                return(Success(result));
            }

            return(Error());
        }
示例#3
0
        public virtual bool CreateDirectory(CreateDirectoryParamDto vm)
        {
            bool result = false;

            if (!string.IsNullOrEmpty(vm.Name) && vm.CreationTime != DateTime.MinValue && vm.LastWriteTime != DateTime.MinValue)
            {
                string fullname = Utils.Combine(ConfigUtils.FileRootPath, vm.Directory, vm.Name);
                if (!Directory.Exists(fullname))
                {
                    Directory.CreateDirectory(fullname);
                    Directory.SetCreationTime(fullname, vm.CreationTime);
                    Directory.SetLastAccessTime(fullname, vm.LastWriteTime);
                }

                var fileInfoRepository = this.GetRepository <IFileInfoRepository>();
                var m = fileInfoRepository.Get(vm.Directory, vm.Name, FileInfoType.Directory);
                if (m == null)
                {
                    m = new FileInfoDto()
                    {
                        Type          = FileInfoType.Directory,
                        Directory     = vm.Directory,
                        Name          = vm.Name,
                        CreationTime  = vm.CreationTime,
                        LastWriteTime = vm.LastWriteTime,
                        IsDelete      = false,
                    };
                    var parent = FileInfoService.Instance.GetParent(vm.Directory);
                    if (parent != null)
                    {
                        m.ParentId = parent.Id;
                    }
                    fileInfoRepository.AddOrUpdate(m);
                }
                result = true;

                string log = string.Format("创建目录, Directory: {0}, Name: {1}, CreationTime: {2:yyyy-MM-dd HH:mm:ss}, LastWriteTime: {3:yyyy-MM-dd HH:mm:ss}", m.Directory, m.Name, m.Length, m.CreationTime, m.LastWriteTime);
                OptionLogService.Instance.Add(OptionLogType.CreateDirectory, log);
            }

            return(result);
        }