/// <summary>
        /// 获取目前新增的文件集合
        /// </summary>
        /// <returns></returns>
        private Dictionary <string, Model.FileModel> GetAddFiles()
        {
            Dictionary <string, Model.FileModel> retDics = new Dictionary <string, Model.FileModel>();

            if (FileWinexploer.NeedAddOrMordifyFiles == null || FileWinexploer.NeedAddOrMordifyFiles.Count == 0)
            {
                return(retDics);
            }

            foreach (var item in FileWinexploer.NeedAddOrMordifyFiles.Keys)
            {
                if (string.IsNullOrEmpty(item))
                {
                    continue;
                }

                Model.FileModel mode = FileWinexploer.NeedAddOrMordifyFiles[item];
                if (DoneAddOrMordifyFiles.ContainsKey(item))
                {
                    continue;
                }
                if (mode == null || mode.ActionNum != 10)
                {
                    continue;
                }
                DoneAddOrMordifyFiles.Add(item, mode);
                retDics.Add(item, mode);
            }
            return(retDics);
        }
示例#2
0
        public FrmFileProperty(int actionType, int type, Model.FileModel file)
        {
            InitializeComponent();
            this.type = type;
            this.file = file;
            //文件夹
            if (type == 1)
            {
                this.skinRadioButton_file.Enabled = false;
                this.skinRadioButton_forder.Select();
                this.skinTextBox_size.Visible = false;
            }
            else
            {
                this.skinRadioButton_forder.Enabled = false;
                this.skinRadioButton_file.Select();
            }

            //初始化人员信息
            InitCreateUser();
            InitUiView();

            ///如果是属性查看,禁止所有可修改控件
            if (actionType == 0)
            {
                this.btnOK.Enabled = false;
                this.skinTextBox_addTime.SkinTxt.ReadOnly    = true;
                this.skinTextBox_modifyTime.SkinTxt.ReadOnly = true;
                this.skinTextBox_name.SkinTxt.ReadOnly       = true;
                this.skinComboBox_createUser.Enabled         = false;
                this.skinTextBox_clientPath.SkinTxt.ReadOnly = true;
            }
        }
        public static void FileLog(Model.FileVersion fileVerModel, Model.FileModel fileModel, string actionCode, ActionType logType)
        {
            if (fileVerModel == null && fileModel == null)
            {
                return;
            }
            string remark = string.Empty;

            Model.UserModel UserInfo = SystemBll.UserInfo;

            if (logType == ActionType.RENAME)
            {
                remark    = string.Format("{0}({1})重命名文件:{2}为==>:", UserInfo.UserName, UserInfo.RealName, fileModel.File_Name);
                fileModel = new BLL.FileBll().GetModel(fileModel.ID);
                remark    = remark + fileModel.File_Name;
            }

            if (logType == ActionType.ONEDELFILE)
            {
                remark = string.Format("{0}({1})删除文件:{2}:", UserInfo.UserName, UserInfo.RealName, fileModel.File_Name);
            }

            if (fileModel == null && fileVerModel != null)
            {
                fileModel = new BLL.FileBll().GetModel(fileVerModel.File_Id);
            }

            if (fileModel != null && fileVerModel == null)
            {
                FileBll fileBll = new FileBll();
                fileVerModel = fileBll.GetFileLastVer(fileModel.ID);
            }

            ActionLogAsyn(fileVerModel, fileModel, remark, actionCode, logType);
        }
        /// <summary>
        /// 记录用户操作日志
        /// </summary>
        /// <param name="projectId"></param>
        /// <param name="projectName"></param>
        /// <param name="clientPath"></param>
        /// <param name="action"></param>
        public static void ActionLog(Model.FileVersion fileVerModel, Model.FileModel fileModel, string remark, string actionCode, ActionType action)
        {
            // 用户信息
            Model.UserModel UserInfo = SystemBll.UserInfo;

            BLL.FileLogBll     logBll   = new FileLogBll();
            Model.FileLogModel logModel = new FileLogModel();
            logModel.AddTime      = DateTime.Now;
            logModel.UserID       = UserInfo.ID;
            logModel.UserName     = UserInfo.UserName;
            logModel.UserRealName = UserInfo.RealName;
            //logModel.Ip = SystemBll.GetIP();
            logModel.Ip = SystemBll.GetComputerName();

            logModel.ProjectID   = 0;
            logModel.ProjectName = string.Empty;
            logModel.ClientPath  = fileVerModel.ClientPath;

            logModel.ActionType = action.ToString();
            logModel.ActionName = GetActionName(action);

            logModel.FileID   = fileVerModel.File_Id > 0 ? fileVerModel.File_Id : fileModel.ID;
            logModel.FileName = fileModel.File_Name;


            logModel.FileType  = 0;
            logModel.FileVer   = fileVerModel.Ver;
            logModel.FileVerID = fileVerModel.ID;

            logModel.ParentForderId = fileModel.File_DirId;
            logModel.Remark         = remark;
            logModel.ActionCode     = actionCode;

            logBll.Add(logModel);
        }
        /// <summary>
        /// 文件操作日志
        /// </summary>
        /// <param name="logType"></param>
        /// <param name="fileModel"></param>
        public static void FileLog(Model.FileVersion fileVerModel, Model.FileModel fileModel, ActionType logType)
        {
            if (fileVerModel == null && fileModel == null)
            {
                return;
            }
            string remark = string.Empty;

            if (logType == ActionType.RENAME)
            {
                remark    = string.Format("文件:{0}重命名为:", fileModel.File_Name);
                fileModel = new BLL.FileBll().GetModel(fileModel.ID);
                remark    = remark + fileModel.File_Name;
            }

            if (fileModel == null && fileVerModel != null)
            {
                fileModel = new BLL.FileBll().GetModel(fileVerModel.File_Id);
            }

            if (fileModel != null && fileVerModel == null)
            {
                FileBll fileBll = new FileBll();
                fileVerModel = fileBll.GetFileLastVer(fileModel.ID);
            }

            ActionLogAsyn(fileVerModel, fileModel, remark, string.Empty, logType);
        }
示例#6
0
        private void SpecialForder(DirectoryInfo item)
        {
            // 20160515 添加特殊文件夹判断,如果是特殊文件夹全部上传
            bool isSpecialItemForder = ForderSpecialControl.IsSpecialForder(item);

            if (isSpecialItemForder)
            {
                // 如果特殊文件夹需要更新
                if (ForderSpecialControl.ZipSpecialForder(item))
                {
                    string zipFile = Path.Combine(item.Parent.FullName, item.Name + ".ztlj");

                    var file = new Model.FileModel()
                    {
                        ActionNum        = 2,
                        ClientPath       = item.FullName,
                        File_Ext         = item.Extension,
                        File_Size        = (int)new FileInfo(zipFile).Length,
                        File_Name        = item.Name,
                        File_Modify_Time = item.LastAccessTime.Ticks
                    };

                    if (file != null)
                    {
                        AddFileToCache(file.ClientPath, file);
                    }
                }
            }
        }
示例#7
0
        private bool CheckSpecialFileUploadToDb(FileInfo item, int forderId, string userName, int projectId)
        {
            string md5 = "";
            //上传文件之前判断文件是否已经存在
            FileDalEx        fileDal = new FileDalEx("FM_");
            int              fileID  = fileDal.GetFileID(this.connection, forderId, item.Name, md5);
            FileVersionDalEx fVerDal = new FileVersionDalEx("FM_");

            //返回文件信息
            Model.FileModel file = null;
            if (fileID > 0)
            {
                //判断是否需要创建版本
                int curVer      = 0;
                var lastFileVer = fileDal.GetFileLastVer(this.connection, fileID);
                if (lastFileVer != null)
                {
                    curVer = lastFileVer.Ver;
                }

                //如果文件已经存在相同文件的版本,则忽略上传
                if (curVer <= 0 || (lastFileVer != null && lastFileVer.File_Modify_Time < item.LastWriteTime.Ticks))
                {
                    return(true);
                }
            }
            else
            {
                // 文件不存在
                return(true);
            }

            return(false);
        }
示例#8
0
        /// <summary>
        /// 获取文件夹下所有文件为对象格式
        /// </summary>
        /// <param name="dirInfo"></param>
        /// <returns></returns>
        private List <Model.FileModel> GetAllFiles(DirectoryInfo dirInfo)
        {
            List <Model.FileModel> fileModels = new List <Model.FileModel>();
            var files = dirInfo.GetFiles();

            //文件上传
            foreach (var item in files)
            {
                totalNum++;
                this.textBox1.AppendText("\r\n文件:" + item.FullName);
                Application.DoEvents();
                Model.FileModel f = new Model.FileModel()
                {
                    ActionNum        = 1,
                    ClientPath       = item.FullName,
                    File_Ext         = item.Extension,
                    File_Size        = (int)item.Length,
                    File_Name        = item.Name,
                    File_Modify_Time = item.LastAccessTime.Ticks
                };
                fileModels.Add(f);
            }
            var suvDirs = dirInfo.GetDirectories();

            if (suvDirs != null && suvDirs.Length > 0)
            {
                foreach (var item in suvDirs)
                {
                    fileModels.AddRange(GetAllFiles(item));
                }
            }
            return(fileModels);
        }
        /// <summary>
        /// 异步记录用户操作日志
        /// </summary>
        /// <param name="projectId"></param>
        /// <param name="projectName"></param>
        /// <param name="clientPath"></param>
        /// <param name="action"></param>
        public static void ActionLogAsyn(Model.FileVersion fileVerModel, Model.FileModel fileModel, string remark, string actionCode, ActionType action)
        {
            ActionLogHandler handler = new ActionLogHandler(ActionLog);

            Model.UserModel user = Bll.SystemBll.UserInfo;
            handler.BeginInvoke(fileVerModel, fileModel, remark, actionCode, action, IAsyncMenthod, null);
        }
        /// <summary>
        /// 定时刷新
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timer1_Tick(object sender, EventArgs e)
        {
            #region 测试
            int length = SPEED_MAX;
            if (this.skinFileTransfersItem1.TotalTransfersSize + length > skinFileTransfersItem1.FileSize)
            {
                this.skinFileTransfersItem1.TotalTransfersSize = 0;
                //换新文件
                Model.FileModel fileModel = LastActionFileName();
                if (fileModel != null)
                {
                    skinFileTransfersItem1.FileName = fileModel.File_Name;
                    skinFileTransfersItem1.FileSize = fileModel.File_Size;
                }
            }
            else
            {
                this.skinFileTransfersItem1.TotalTransfersSize += length;
            }
            #endregion

            #region 刷新左侧列表
            bool thisTimeHaveFile = false;
            foreach (DataGridViewRow row in this.skinDataGridView10.Rows)
            {
                if (row.Cells[4].Value.ToString() == "已完成")
                {
                    continue;
                }
                string key = row.Cells[0].Value.ToString();
                if (IsActionEnd(key))
                {
                    row.Cells[4].Value           = "已完成";
                    row.Cells[4].Style.ForeColor = Color.Red;
                }
                else
                {
                    thisTimeHaveFile = true;
                }
            }

            if (!thisTimeHaveFile)
            {
                this.skinFileTransfersItem1.Enabled = false;
                this.skinFileTransfersItem1.Visible = false;

                if (fileTansfersContainer1.Controls.Count > 0)
                {
                    SkinFileTransfersItem item = (SkinFileTransfersItem)fileTansfersContainer1.Controls[fileTansfersContainer1.Controls.Count - 1];

                    fileTansfersContainer1.RemoveItem(item);
                }
                this.fileTansfersContainer1.Visible = false;
                this.skinPictureBox1.Visible        = true;
                this.skinLabel19.Visible            = true;
            }

            #endregion
        }
        public void FrmFileUp()
        {
            var    cacheToActionFiles    = FileWinexploer.NeedAddOrMordifyFiles;
            string actionName            = actionType == 0 ? "上传文件到服务器" : "下载文件到客户端本地";
            FileTransfersItemStyle style = actionType == 0 ? FileTransfersItemStyle.Send : FileTransfersItemStyle.Receive;

            if (cacheToActionFiles != null && cacheToActionFiles.Count > 0)
            {
                //item = fileTansfersContainer1.AddItem(
                //    actionName,
                //    "",
                //    Resources._14,
                //    totalSize,
                //    style);
                //item.BaseColor = _baseColor;
                //item.BorderColor = _borderColor;
                //item.ProgressBarBarColor = _progressBarBarColor;
                //item.ProgressBarBorderColor = _progressBarBorderColor;
                //item.ProgressBarTextColor = _progressBarTextColor;
                //item.CancelButtonClick += new EventHandler(item_CancelButtonClick);

                this.skinFileTransfersItem1.Text     = actionName;
                this.skinFileTransfersItem1.FileName = "sssssssssss";
                this.skinFileTransfersItem1.FileSize = 0;
                this.skinFileTransfersItem1.Text     = actionName;
                this.skinFileTransfersItem1.Image    = Resources._14;
                this.skinFileTransfersItem1.Style    = style;

                //this.skinFileTransfersItem1.BaseColor = _baseColor;
                //this.skinFileTransfersItem1.BorderColor = _borderColor;
                this.skinFileTransfersItem1.ProgressBarBarColor    = _progressBarBarColor;
                this.skinFileTransfersItem1.ProgressBarBorderColor = _progressBarBorderColor;
                this.skinFileTransfersItem1.ProgressBarTextColor   = _progressBarTextColor;
                this.skinFileTransfersItem1.CancelButtonClick     += new EventHandler(item_CancelButtonClick);
                this.skinFileTransfersItem1.Start();
            }

            DataTable dt = new DataTable();

            dt.Columns.Add("key");
            dt.Columns.Add("file_type");
            dt.Columns.Add("file_name");
            dt.Columns.Add("file_size");
            dt.Columns.Add("state");

            foreach (var item in cacheToActionFiles)
            {
                Model.FileModel file = item.Value;
                DataRow         row  = dt.NewRow();
                row[0] = file.ClientPath;
                row[1] = "文件";
                row[2] = file.File_Name;
                row[3] = file.File_Size;
                row[4] = GetActionName(file.ActionNum);
                dt.Rows.Add(row);
                totalSize += file.File_Size;
            }
            this.skinDataGridView10.DataSource = dt;
        }
        /// <summary>
        /// 定时刷新
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timer1_Tick(object sender, EventArgs e)
        {
            int addCount   = GetNotEndCount();
            int totalCount = FileWinexploer.NeedAddOrMordifyFiles.Count;

            // 更新已经上传的文件
            var addItems = GetAddFiles();

            if (addItems.Count > 0)
            {
                foreach (var item in addItems.Keys)
                {
                    Model.FileModel mode = addItems[item];

                    if (!FileWinexploer.NotSuccessFiles.ContainsKey(item))
                    {
                        this.textBox1.AppendText(string.Format("\r\n文件{0}成功:客户端路径{1}", actionType == 1 ? "下载" : "上传", item));
                        Application.DoEvents();
                    }
                }
            }

            if (addCount > 0)
            {
                this.skinProgressBar1.Value = FileWinexploer.NeedAddOrMordifyFiles.Count - addCount;
                this.skinLabel1.Text        = string.Format("总共需要{2}{0}个文件,目前已{2}{1}个文件;!", totalCount, this.skinProgressBar1.Value, actionType == 1 ? "下载" : "上传");
                Application.DoEvents();
            }
            else
            {
                this.skinProgressBar1.Value = FileWinexploer.NeedAddOrMordifyFiles.Count - addCount;
                this.skinLabel1.Text        = string.Format("总共需要{2}{0}个文件,目前已{2}{1}个文件;已经完成!", totalCount, this.skinProgressBar1.Value, actionType == 1 ? "下载" : "上传");
                Application.DoEvents();

                this.skinLabel_tip.Visible = true;
                this.skinLabel_tip.Text    = string.Format("恭喜您,{0}完成!", actionType == 1 ? "下载" : "上传");
                Application.DoEvents();

                timer1.Stop();
            }

            // 更新已经上传的文件
            var addNotSuccessItems = GetNotSuccessFiles();

            if (addNotSuccessItems.Count > 0)
            {
                foreach (var item in addNotSuccessItems.Keys)
                {
                    this.textBox2.AppendText(string.Format("\r\n文件{0}没有成功:客户端路径{1}", actionType == 1 ? "下载" : "上传", item));
                    Application.DoEvents();
                }
            }

            this.skinLabel_success.Text = string.Format("成功{1}文件:{0}个", (this.skinProgressBar1.Value - DoneNotSuccessFiles.Count).ToString(), actionType == 1 ? "下载" : "上传");
            this.skinLabel_fail.Text    = string.Format("未成功{1}文件:{0}个", DoneNotSuccessFiles.Count, actionType == 1 ? "下载" : "上传");
            Application.DoEvents();
        }
示例#13
0
        /// <summary>
        /// 单个文件检查
        /// </summary>
        /// <param name="item"></param>
        private Model.FileModel CheckFileUploadToDb(FileInfo item, int forderId, string userName, int projectId)
        {
            //string md5 = GetMD5HashFromFile(item.FullName);
            string md5 = "";

            //上传文件之前判断文件是否已经存在
            FileDalEx fileDal = new FileDalEx("FM_");
            int       fileID  = fileDal.GetFileID(this.connection, forderId, item.Name, md5);
            //int fileID = 1;
            FileVersionDalEx fVerDal = new FileVersionDalEx("FM_");

            //返回文件信息
            Model.FileModel file = null;
            //文件信息不存在,则新建一个
            if (fileID > 0)
            {
                //判断是否需要创建版本
                //int curVer = fileBll.GetFileLastVer(fileID, item.LastWriteTime);
                int curVer      = 0;
                var lastFileVer = fileDal.GetFileLastVer(this.connection, fileID);
                if (lastFileVer != null)
                {
                    curVer = lastFileVer.Ver;
                }

                //如果文件已经存在相同文件的版本,则忽略上传
                if (curVer <= 0 || (lastFileVer != null && lastFileVer.File_Modify_Time < item.LastWriteTime.Ticks))
                {
                    file = new Model.FileModel()
                    {
                        ActionNum        = 2,
                        ClientPath       = item.FullName,
                        File_Ext         = item.Extension,
                        File_Size        = (int)item.Length,
                        File_Name        = item.Name,
                        File_Modify_Time = item.LastAccessTime.Ticks
                    };
                    AddNeedAllUploadFilesToCache(item.FullName, file);
                }
            }
            //文件信息不存在,则新建一个
            else
            {
                file = new Model.FileModel()
                {
                    ActionNum        = 1,
                    ClientPath       = item.FullName,
                    File_Ext         = item.Extension,
                    File_Size        = (int)item.Length,
                    File_Name        = item.Name,
                    File_Modify_Time = item.LastAccessTime.Ticks
                };

                AddNeedAllUploadFilesToCache(item.FullName, file);
            }
            return(file);
        }
示例#14
0
 public static void AddNeedAllUploadFilesToCache(string key, Model.FileModel file)
 {
     lock (_lockToActionFile)
     {
         if (!FileWinexploer.needAllUploadFiles.ContainsKey(key))
         {
             FileWinexploer.needAllUploadFiles.Add(key, file);
         }
     }
 }
        public FrmFileHistoryListView(Model.FileModel file)
        {
            InitializeComponent();
            this.file = file;
            InitData();

            LinkLabel linkLabel = new LinkLabel();

            linkLabel.Click += new EventHandler(linkLabel_Click);
        }
        /// <summary>
        /// 获取未完成数量
        /// </summary>
        /// <returns></returns>
        private int GetNotEndCount()
        {
            int totalCount = 0;

            if (FileWinexploer.NeedAddOrMordifyFiles != null && FileWinexploer.NeedAddOrMordifyFiles.Count > 0)
            {
                foreach (var item in FileWinexploer.NeedAddOrMordifyFiles.Keys)
                {
                    Model.FileModel mode = FileWinexploer.NeedAddOrMordifyFiles[item];
                    if (mode != null && mode.ActionNum != 10)
                    {
                        totalCount++;
                    }
                }
            }
            return(totalCount);
        }
 public static Model.FileModel LastActionFileName()
 {
     ///为防止程序死掉,默认都是完成状态
     if (FileWinexploer.NeedAddOrMordifyFiles == null || FileWinexploer.NeedAddOrMordifyFiles.Count == 0)
     {
         return(null);
     }
     foreach (var item in FileWinexploer.NeedAddOrMordifyFiles.Keys)
     {
         Model.FileModel mode = FileWinexploer.NeedAddOrMordifyFiles[item];
         if (mode != null && mode.ActionNum != 10)
         {
             return(mode);
         }
     }
     return(null);
 }
 public FrmFileRename(int type, Model.FileModel file, Model.ForderModel forder)
 {
     InitializeComponent();
     this.type   = type;
     this.file   = file;
     this.forder = forder;
     if (type == 1)
     {
         this.skinRadioButton_file.Enabled = false;
         this.skinRadioButton_forder.Select();
         this.skinTextBox_oldName.SkinTxt.Text = forder.Title;
     }
     else
     {
         this.skinRadioButton_forder.Enabled = false;
         this.skinRadioButton_file.Select();
         this.skinTextBox_oldName.SkinTxt.Text = file.File_Name;
     }
     this.skinTextBox_oldName.SkinTxt.ReadOnly = true;
 }
        /// <summary>
        /// 修改属性
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                FileBll         fileBll   = new FileBll();
                Model.FileModel fileModel = fileBll.GetModel(this.file.ID);

                if (fileModel == null || string.IsNullOrEmpty(fileModel.File_Name))
                {
                    MessageBoxEx.Show("该文件的信息异常!");
                    return;
                }

                FileVersionBll verBll = new FileVersionBll();

                var fileVer = new BLL.FileVersionBll().GetModel(this.fileLog.FileVerID);
                var content = verBll.GetContent(fileVer.ID);

                // 获取文件信息
                this.saveFileDialog1.Filter = string.Format("*{0}|*.*", fileModel.File_Ext);;
                this.saveFileDialog1.ShowDialog();
                string fileSavePath = this.saveFileDialog1.FileName;

                if (string.IsNullOrEmpty(fileSavePath))
                {
                    return;
                }

                //文件存放路径
                string newPath = fileSavePath.EndsWith(fileModel.File_Ext) ? fileSavePath : fileSavePath + fileModel.File_Ext;
                FileWinexploer.CreateFile(content, newPath, fileVer.File_Modify_Time);
                MessageBoxEx.Show("保存成功!");
            }
            catch (Exception ee)
            {
                this.DialogResult = System.Windows.Forms.DialogResult.None;
                MessageBoxEx.Show("存储失败!" + ee.Message);
            }
        }
示例#20
0
        /// <summary>
        /// 获取文件夹下所有文件为对象格式
        /// </summary>
        /// <param name="dirInfo"></param>
        /// <returns></returns>
        private List <Model.FileModel> GetAllFiles(DirectoryInfo dirInfo)
        {
            List <Model.FileModel> fileModels = new List <Model.FileModel>();

            try
            {
                try
                {
                    var files = dirInfo.GetFiles();
                    //文件上传
                    foreach (var item in files)
                    {
                        if ((item.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)   //必须进行与运算,因为默认文件是“Hidden”+归档(二进制11)。而Hidden是10.因此与运算才可以判断
                        {
                            continue;
                        }
                        totalNum++;
                        //this.textBox1.AppendText("\r\n文件:" + item.FullName);
                        Application.DoEvents();

                        Model.FileModel f = new Model.FileModel()
                        {
                            ActionNum        = 1,
                            ClientPath       = item.FullName,
                            File_Ext         = item.Extension,
                            File_Size        = (int)item.Length,
                            File_Name        = item.Name,
                            File_Modify_Time = item.LastAccessTime.Ticks
                        };
                        fileModels.Add(f);
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog("Error", ex.Message + "\r\n" + ex.StackTrace);
                }

                try
                {
                    var suvDirs = dirInfo.GetDirectories();
                    if (suvDirs != null && suvDirs.Length > 0)
                    {
                        foreach (var item in suvDirs)
                        {
                            if ((item.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)   //必须进行与运算,因为默认文件是“Hidden”+归档(二进制11)。而Hidden是10.因此与运算才可以判断
                            {
                                continue;
                            }
                            SpecialForder(item);

                            fileModels.AddRange(GetAllFiles(item));
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog("Error", ex.Message + "\r\n" + ex.StackTrace);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("Error", ex.Message + "\r\n" + ex.StackTrace);
            }
            return(fileModels);
        }
        /// <summary>
        /// 版本历史记录单元格事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void skinDataGridView_history_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex >= 80)
            {
                try
                {
                    #region 文件下载和同步处理
                    int             fileID    = int.Parse(this.skinDataGridView_history.Rows[e.RowIndex].Cells[10].Value.ToString());
                    int             verID     = int.Parse(this.skinDataGridView_history.Rows[e.RowIndex].Cells[0].Value.ToString());
                    FileBll         fileBll   = new FileBll();
                    Model.FileModel fileModel = fileBll.GetModel(fileID);

                    if (fileModel == null || string.IsNullOrEmpty(fileModel.File_Name))
                    {
                        MessageBoxEx.Show("该文件的信息异常!");
                        return;
                    }

                    FileVersionBll verBll  = new FileVersionBll();
                    var            content = verBll.GetContent(verID);
                    var            fileVer = verBll.GetModel(verID);

                    //同步
                    if (e.ColumnIndex == 8)
                    {
                        if (string.IsNullOrEmpty(fileModel.ClientPath))
                        {
                            MessageBoxEx.Show("该文件的客户端路径不正确!");
                            return;
                        }

                        FileWinexploer.CreateFile(content, fileModel.ClientPath, fileVer.File_Modify_Time);
                        MessageBoxEx.Show("同步到客户端成功!");
                        return;
                    }

                    //另存为
                    if (e.ColumnIndex == 9)
                    {
                        //获取文件信息
                        this.saveFileDialog1.Filter = string.Format("*{0}|*.*", fileModel.File_Ext);;
                        this.saveFileDialog1.ShowDialog();
                        string fileSavePath = this.saveFileDialog1.FileName;

                        if (string.IsNullOrEmpty(fileSavePath))
                        {
                            return;
                        }

                        //文件存放路径
                        string newPath = fileSavePath.EndsWith(fileModel.File_Ext)?fileSavePath: fileSavePath + fileModel.File_Ext;
                        FileWinexploer.CreateFile(content, newPath, fileVer.File_Modify_Time);
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    MessageBoxEx.Show(ex.Message);
                }
            }
        }
 public static void FileLogForderRename(Model.FileVersion fileVerModel, Model.FileModel fileModel, string remark, string actionCode, ActionType logType)
 {
     Model.UserModel UserInfo = SystemBll.UserInfo;
     ActionLogAsyn(fileVerModel, fileModel, remark, actionCode, logType);
 }
        public void FrmFileUp()
        {
            //propertyGrid1.SelectedObject = fileTansfersContainer1;
            //_random = new Random();

            var cacheToActionFiles = FileWinexploer.NeedAddOrMordifyFiles;
            //List<Model.FileModel> models = new List<Model.FileModel>();
            //foreach (var item in cacheToActionFiles.Values)
            //{
            //    if (item.ActionNum != 10)
            //    {
            //        models.Add(item);
            //    }
            //}

            string actionName            = actionType == 0 ? "上传文件到服务器" : "下载文件到客户端本地";
            FileTransfersItemStyle style = actionType == 0 ? FileTransfersItemStyle.Send : FileTransfersItemStyle.Receive;

            foreach (var fileItem in cacheToActionFiles)
            {
                Model.FileModel file = fileItem.Value;
                if (file.ActionNum != 10)
                {
                    SkinFileTransfersItem item;
                    item = fileTansfersContainer1.AddItem(
                        actionName,
                        file.File_Name,
                        Resources._14,
                        file.File_Size,
                        style);

                    item.Tag = file.ClientPath;

                    item.BaseColor              = _baseColor;
                    item.BorderColor            = _borderColor;
                    item.ProgressBarBarColor    = _progressBarBarColor;
                    item.ProgressBarBorderColor = _progressBarBorderColor;
                    item.ProgressBarTextColor   = _progressBarTextColor;
                    item.CancelButtonClick     += new EventHandler(item_CancelButtonClick);
                }
            }

            DataTable dt = new DataTable();

            dt.Columns.Add("key");
            dt.Columns.Add("file_type");
            dt.Columns.Add("file_name");
            dt.Columns.Add("file_size");
            dt.Columns.Add("state");

            foreach (var item in cacheToActionFiles)
            {
                Model.FileModel file = item.Value;
                DataRow         row  = dt.NewRow();
                row[0] = file.ClientPath;
                row[1] = "文件";
                row[2] = file.File_Name;
                row[3] = file.File_Size;
                row[4] = GetActionName(file.ActionNum);
                dt.Rows.Add(row);
            }
            this.skinDataGridView10.DataSource = dt;
        }
 public FrmFileHistoryRecord(Model.FileModel file)
 {
     InitializeComponent();
     this.file = file;
     InitData();
 }