Beispiel #1
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            #region 检查
            if (fileList.Count == 0)
            {
                MessageDxUtil.ShowTips("请选择文件");
                this.txtFile.Focus();
                return;
            }
            else if (string.IsNullOrEmpty(this.AttachmentDirectory))
            {
                MessageDxUtil.ShowTips("请设置目录分类");
                return;
            }
            #endregion

            if (!worker.IsBusy)
            {
                this.btnBrowse.Enabled = false;
                this.btnUpload.Enabled = false;
                this.txtFile.Text      = "";

                this.progressBar1.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
                object argument = this.chkNotCopyFile.Checked;
                worker.RunWorkerAsync(argument);
            }
        }
Beispiel #2
0
        private void menuDelete_Click(object sender, EventArgs e)
        {
            bool   sucess    = false;
            string lastError = "";

            try
            {
                foreach (ListViewItem item in this.listView1.CheckedItems)
                {
                    if (item != null && item.Tag != null)
                    {
                        string id = item.Tag.ToString();
                        sucess = BLLFactory <FileUpload> .Instance.Delete(id);
                    }
                }
            }
            catch (Exception ex)
            {
                lastError += ex.Message + "\r\n";
                LogTextHelper.Error(ex);
            }

            MessageDxUtil.ShowTips(sucess ? "操作成功" : "操作失败");
            //ProcessDataSaved(this.btnDelete, new EventArgs());
            BindData();
        }
Beispiel #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.listView1.CheckedItems.Count == 0)
            {
                MessageDxUtil.ShowTips("请勾选删除的文件!");
                return;
            }

            string lastError = "";
            bool   sucess    = false;

            foreach (ListViewItem item in this.listView1.CheckedItems)
            {
                if (item != null && item.Tag != null)
                {
                    string id = item.Tag.ToString();
                    try
                    {
                        sucess = BLLFactory <FileUpload> .Instance.Delete(id);
                    }
                    catch (Exception ex)
                    {
                        lastError += ex.Message + "\r\n";
                        LogTextHelper.Error(ex);
                    }
                }
            }
            MessageDxUtil.ShowTips(sucess ? "操作成功" : "操作失败");

            BindData();
        }
Beispiel #4
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            if (this.listView1.CheckedItems.Count == 0)
            {
                MessageDxUtil.ShowTips("请勾选下载的文件!");
                return;
            }

            string path = FileDialogHelper.OpenDir();

            if (!string.IsNullOrEmpty(path))
            {
                DirectoryUtil.AssertDirExist(Path.GetDirectoryName(path));

                #region  载保存图片
                bool hasError = false;

                foreach (ListViewItem item in this.listView1.CheckedItems)
                {
                    if (item != null && item.Tag != null)
                    {
                        string id = item.Tag.ToString();

                        try
                        {
                            FileUploadInfo fileInfo = BLLFactory <FileUpload> .Instance.Download(id);

                            if (fileInfo != null && fileInfo.FileData != null)
                            {
                                string filePath = Path.Combine(path, fileInfo.FileName);
                                FileUtil.CreateFile(filePath, fileInfo.FileData);
                            }
                        }
                        catch (Exception ex)
                        {
                            LogTextHelper.Error(ex);
                            hasError = true;
                        }
                    }
                }
                #endregion

                if (hasError)
                {
                    MessageDxUtil.ShowError("保存文件出现错误。具体请查看日志文件!");
                }
                else
                {
                    System.Diagnostics.Process.Start(path);
                }
            }
        }
        private void btnView_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(AttachmentDirectory))
            {
                MessageDxUtil.ShowTips("请设置附件的存储目录分类");
                return;
            }
            if (string.IsNullOrEmpty(m_AttachmentGUID))
            {
                MessageDxUtil.ShowTips("请设置附件组的GUID");
                return;
            }

            FrmAttachmentGroupView dlg = new FrmAttachmentGroupView();

            dlg.AttachmentDirectory = AttachmentDirectory;
            dlg.AttachmentGUID      = AttachmentGUID;
            dlg.UserId = userId;
            dlg.OwerId = OwerId;
            dlg.InitButtonStatus(this.ShowUpload, this.ShowDelete, this.ShowDownload);
            dlg.OnDataSaved += new EventHandler(dlg_OnDataSaved);
            dlg.ShowDialog();
        }