コード例 #1
0
 /// <summary>
 /// 加载窗体
 /// </summary>
 public override void FormOnLoad()
 {
     // DataTable dtFile = DotNetService.Instance.FileService.Get(UserInfo, this.EntityId);
     this.FileEntity = new BaseFileEntity();
     this.FileEntity.Contents = DotNetService.Instance.FileService.Download(UserInfo, this.EntityId);
     // 显示内容
     this.ShowEntity(this.FileEntity);
     // 设置焦点
     this.ActiveControl = this.txtFileName;
     this.txtFileName.Focus();
 }
コード例 #2
0
ファイル: FrmPicture.cs プロジェクト: huoxudong125/DotNet
 private void DownLoadFile(string fileId)
 {
     // DataTable dataTable = DotNetService.Instance.FileService.GetEntity(UserInfo, fileId);
     BaseFileEntity fileEntity = new BaseFileEntity();
     SaveFileDialog saveFileDialog = new SaveFileDialog();
     saveFileDialog.Filter = "位图文件(*.bmp)|*.bmp|JPEG(*.JPG;*.JPEG;*.JPE;*.JFIF)|*.JPG;*.JPEG;*.JPE;*.JFIF|GIF(*.GIF)|*.GIF|TIFF(*.TIF;*.TIIF)|*.TIF;*.TIIF|PNG(*.PNG)|*.PNG|ICO(*.ICO)|*.ICO|所有图片文件|(*.bmp;*.JPG;*.JPEG;*.JPE;*.JFIF;*.GIF;*.TIF;*.TIIF;*.PNG;*.ICO)|所有文件|*.*";
     saveFileDialog.FilterIndex = 7;
     saveFileDialog.FileName = fileEntity.FileName;
     if (saveFileDialog.ShowDialog() == DialogResult.OK)
     {
         string fileName = saveFileDialog.FileName;
         FileUtil.SaveFile(DotNetService.Instance.FileService.Download(UserInfo, fileId), fileName);
         this.Close();
     }
 }
コード例 #3
0
 /// <summary>
 /// 添加文件
 /// </summary>
 /// <param name="folderId">文件夹主键</param>
 /// <param name="fileName">文件名</param>
 /// <param name="file">文件</param>
 /// <param name="category">文件分类</param>
 /// <param name="enabled">有效</param>
 /// <param name="statusCode">状态</param>
 /// <returns>主键</returns>
 private string Add(string folderId, string fileName, string file, byte[] byteFile, string description, bool enabled, out string statusCode)
 {
     statusCode = string.Empty;
     BaseFileEntity fileEntity = new BaseFileEntity();
     fileEntity.FolderId = folderId;
     fileEntity.FileName = fileName;
     fileEntity.Contents = byteFile;
     fileEntity.Description = description;
     fileEntity.Enabled = enabled ? 1:0;
     string returnValue = string.Empty;
     // 检查是否重复
     if (this.Exists(new KeyValuePair<string, object>(BaseFileEntity.FieldFolderId, fileEntity.FolderId), new KeyValuePair<string, object>(BaseFileEntity.FieldFileName, fileEntity.FileName)))
     {
         // 名称已重复
         statusCode = StatusCode.ErrorNameExist.ToString();
     }
     else
     {
         returnValue = this.AddEntity(fileEntity);
         // 运行成功
         statusCode = StatusCode.OKAdd.ToString();
     }
     return returnValue;
 }
コード例 #4
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="fileEntity">文件夹的基类表结构定义</param>
 /// <param name="statusCode">状态返回码</param>
 /// <returns>影响行数</returns>
 public int Update(BaseFileEntity fileEntity, out string statusCode)
 {
     int returnValue = 0;
     //if (DbLogic.IsModifed(DbHelper, BaseFolderEntity.TableName, fileEntity.Id, fileEntity.ModifiedUserId, fileEntity.ModifiedOn))
     //{
     //    // 数据已经被修改
     //    statusCode = StatusCode.ErrorChanged.ToString();
     //}
     //else
     //{
         // 检查文件夹名是否重复
     if (this.Exists(new KeyValuePair<string, object>(BaseFileEntity.FieldFolderId, fileEntity.FolderId), new KeyValuePair<string, object>(BaseFileEntity.FieldFileName, fileEntity.FileName), fileEntity.Id))
         {
             // 文件夹名已重复
             statusCode = StatusCode.ErrorNameExist.ToString();
         }
         else
         {
             returnValue = this.UpdateEntity(fileEntity);
             if (returnValue == 1)
             {
                 // 运行成功
                 statusCode = StatusCode.OKUpdate.ToString();
             }
             else
             {
                 statusCode = StatusCode.ErrorDeleted.ToString();
             }
         }
     //}
     return returnValue;
 }
コード例 #5
0
        public string Upload(string folderId, string fileName, byte[] file, bool enabled)
        {
            // 检查是否已经存在
            //string returnValue = this.GetId(new KeyValuePair<string, object>(BaseFileEntity.FieldFolderId, folderId), new KeyValuePair<string, object>(BaseFileEntity.FieldFileName, fileName));
            // 检查是否已经存在,加入删除状态为0的条件
            List<KeyValuePair<string, object>> parametersList = new List<KeyValuePair<string, object>>();
            parametersList.Add(new KeyValuePair<string, object>(BaseFileEntity.FieldFolderId, folderId));
            parametersList.Add(new KeyValuePair<string, object>(BaseFileEntity.FieldFileName, fileName));
            parametersList.Add(new KeyValuePair<string, object>(BaseFileEntity.FieldDeletionStateCode, 0));
            string returnValue = this.GetId(parametersList);

            if (!String.IsNullOrEmpty(returnValue))
            {
                // 更新数据
                this.UpdateFile(returnValue, fileName, file);
                //在能够真实模仿C/S中的提示确定信息对话框的B/S版本出来之前,先做如下处理:前面的文件有重复的,打删除标志来处理,因为客户不会闲着没事,老传文件,且服务器都是几百个G的空间
                // 删除数据
                BaseFileManager manager = new BaseFileManager();
                int intReturnValue = manager.SetDeleted(returnValue);
                // 添加数据
                BaseFileEntity fileEntity = new BaseFileEntity();
                fileEntity.FolderId = folderId;
                fileEntity.FileName = fileName;
                fileEntity.Contents = file;
                fileEntity.Enabled = enabled ? 1 : 0;
                returnValue = this.AddEntity(fileEntity);
            }
            else
            {
                // 添加数据
                BaseFileEntity fileEntity = new BaseFileEntity();
                fileEntity.FolderId = folderId;
                fileEntity.FileName = fileName;
                fileEntity.Contents = file;
                fileEntity.Enabled = enabled ? 1:0;
                returnValue = this.AddEntity(fileEntity);
            }
            return returnValue;
        }
コード例 #6
0
 /// <summary>
 /// 批量进行保存
 /// </summary>
 /// <param name="dataTable">数据表</param>
 /// <returns>影响行数</returns>
 public override int BatchSave(DataTable dataTable)
 {
     int returnValue = 0;
     BaseFileEntity fileEntity = new BaseFileEntity();
     foreach (DataRow dataRow in dataTable.Rows)
     {
         // 删除状态
         if (dataRow.RowState == DataRowState.Deleted)
         {
             string id = dataRow[BaseFileEntity.FieldId, DataRowVersion.Original].ToString();
             if (id.Length > 0)
             {
                 returnValue += this.Delete(id);
             }
         }
         // 被修改过
         if (dataRow.RowState == DataRowState.Modified)
         {
             string id = dataRow[BaseFileEntity.FieldId, DataRowVersion.Original].ToString();
             if (id.Length > 0)
             {
                 fileEntity.GetFrom(dataRow);
                 // 判断是否允许编辑
                 returnValue += this.UpdateEntity(fileEntity);
             }
         }
         // 添加状态
         if (dataRow.RowState == DataRowState.Added)
         {
             fileEntity.GetFrom(dataRow);
             returnValue += this.AddEntity(fileEntity).Length > 0 ? 1 : 0;
         }
         if (dataRow.RowState == DataRowState.Unchanged)
         {
             continue;
         }
         if (dataRow.RowState == DataRowState.Detached)
         {
             continue;
         }
     }
     return returnValue;
 }
コード例 #7
0
 /// <summary>
 /// 获取信息
 /// </summary>
 /// <param name="id">主键</param>
 /// <returns>数据权限</returns>
 public BaseFileEntity GetEntity(string id)
 {
     string sqlQuery = string.Empty;
     sqlQuery = " SELECT " + BaseFileEntity.FieldId
             + "        ," + BaseFileEntity.FieldFolderId
             + "        ," + BaseFileEntity.FieldFileName
             + "        ," + BaseFileEntity.FieldFilePath
             + "        ," + BaseFileEntity.FieldFileSize
             + "        ," + BaseFileEntity.FieldReadCount
             + "        ," + BaseFileEntity.FieldDescription
             + "        ," + BaseFileEntity.FieldEnabled
             + "        ," + BaseFileEntity.FieldDeletionStateCode
             + "        ," + BaseFileEntity.FieldSortCode
             + "        ," + BaseFileEntity.FieldCreateUserId
             + "        ," + BaseFileEntity.FieldCreateBy
             + "        ," + BaseFileEntity.FieldCreateOn
             + "        ," + BaseFileEntity.FieldModifiedUserId
             + "        ," + BaseFileEntity.FieldModifiedBy
             + "        ," + BaseFileEntity.FieldModifiedOn
                 + " FROM " + this.CurrentTableName
                 + " WHERE " + BaseFileEntity.FieldId + " = " + DbHelper.GetParameter(BaseFileEntity.FieldId);
     DataTable dataTable = new DataTable(BaseFileEntity.TableName);
     DbHelper.Fill(dataTable, sqlQuery, new IDbDataParameter[] { DbHelper.MakeParameter(BaseFileEntity.FieldId, id) });
     BaseFileEntity fileEntity = new BaseFileEntity(dataTable);
     return fileEntity;
 }
コード例 #8
0
 /// <summary>
 /// 显示内容
 /// </summary>
 private void ShowEntity(BaseFileEntity fileEntity)
 {
     this.txtFileName.Text = fileEntity.FileName;
     this.txtContent.Text = string.Empty;
     if (fileEntity.Contents != null)
     {
         this.txtContent.Text = System.Text.Encoding.Default.GetString(fileEntity.Contents);
     }
     this.txtDescription.Text = fileEntity.Description;
     this.chbEnabled.Checked = fileEntity.Enabled == 1;
 }
コード例 #9
0
ファイル: FileService.cs プロジェクト: huoxudong125/DotNet
        /// <summary>
        /// 发送文件
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="fileName">文件名</param>
        /// <param name="file">文件内容</param>
        /// <param name="toUserId">发送给谁主键</param>
        /// <returns>文件主键</returns>
        public string Send(BaseUserInfo userInfo, string fileName, byte[] file, string toUserId)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
                LogOnService.UserIsLogOn(userInfo);
            #endif

            string returnValue = string.Empty;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseFolderEntity folderEntity = new BaseFolderEntity();
                    BaseFolderManager folderManager = new BaseFolderManager(dbHelper, userInfo);
                    // 检查相应的系统必备文件夹
                    folderManager.FolderCheck();
                    BaseUserEntity userEntity = new BaseUserManager(dbHelper, userInfo).GetEntity(toUserId);
                    if (!string.IsNullOrEmpty(userEntity.Id))
                    {
                        // 04:判断发送者的空间是否存在?
                        // 05:判断已收文件夹是否存在?
                        if (!folderManager.Exists(userEntity.Id.ToString()))
                        {
                            folderEntity.FolderName = userEntity.RealName + AppMessage.FileService_File;
                            folderEntity.ParentId = "UserSpace";
                            folderEntity.Id = userEntity.Id.ToString();
                            folderEntity.Enabled = 1;
                            folderEntity.DeletionStateCode = 0;
                            folderManager.AddEntity(folderEntity);
                        }
                        // 06:判断来自谁的文件夹是否存在?
                        // 07:判断发给谁的文件夹是否存在?
                        if (!folderManager.Exists(toUserId + "_Receive"))
                        {
                            folderEntity.FolderName = AppMessage.FileService_ReceiveFile;
                            folderEntity.ParentId = toUserId;
                            folderEntity.Id = toUserId + "_Receive";
                            folderEntity.Enabled = 1;
                            folderEntity.DeletionStateCode = 0;
                            folderManager.AddEntity(folderEntity);
                        }
                        if (!folderManager.Exists(userInfo.Id + "_Send_" + toUserId))
                        {
                            folderEntity.FolderName = userEntity.RealName + "(" + userEntity.UserName + ")";
                            folderEntity.ParentId = userInfo.Id + "_Send";
                            folderEntity.Id = userInfo.Id + "_Send_" + toUserId;
                            folderEntity.Enabled = 1;
                            folderEntity.DeletionStateCode = 0;
                            folderManager.AddEntity(folderEntity);
                        }
                        if (!folderManager.Exists(toUserId + "_Receive_" + userInfo.Id))
                        {
                            folderEntity.FolderName = userInfo.RealName + "(" + userInfo.UserName + ")";
                            folderEntity.ParentId = toUserId + "_Receive";
                            folderEntity.Id = toUserId + "_Receive_" + userInfo.Id;
                            folderEntity.Enabled = 1;
                            folderEntity.DeletionStateCode = 0;
                            folderManager.AddEntity(folderEntity);
                        }
                        // 08:已发送文件夹多一个文件。
                        // 09:已接收文件夹多一个文件。
                        BaseFileEntity fileEntity = new BaseFileEntity();
                        fileEntity.FileName = fileName;
                        fileEntity.Contents = file;
                        fileEntity.Enabled = 1;
                        fileEntity.ReadCount = 0;
                        fileEntity.FolderId = userInfo.Id + "_Send_" + toUserId;
                        // 把修改人显示出来
                        fileEntity.ModifiedBy = userInfo.RealName;
                        fileEntity.ModifiedUserId = userInfo.Id;
                        fileEntity.ModifiedOn = DateTime.Now;
                        BaseFileManager fileManager = new BaseFileManager(dbHelper, userInfo);
                        fileManager.AddEntity(fileEntity);
                        fileEntity.FolderId = toUserId + "_Receive_" + userInfo.Id;
                        returnValue = fileManager.AddEntity(fileEntity);
                        // string webHostUrl = BaseSystemInfo.WebHostUrl;
                        // if (string.IsNullOrEmpty(webHostUrl))
                        // {
                        //    webHostUrl = "WebHostUrl";
                        // }
                        // 10:应该还发一个短信提醒一下才对。
                        BaseMessageEntity messageEntity = new BaseMessageEntity();
                        messageEntity.Id = Guid.NewGuid().ToString();
                        messageEntity.CategoryCode = MessageCategory.Send.ToString();
                        messageEntity.FunctionCode = MessageFunction.Message.ToString();
                        messageEntity.ObjectId = returnValue;
                        messageEntity.ReceiverId = toUserId;
                        // target=\"_blank\"
                        messageEntity.Contents = AppMessage.FileService_SendFileFrom + " <a href={WebHostUrl}Download.aspx?Id=" + returnValue + ">" + fileName + "</a>" + AppMessage.FileService_CheckReceiveFile;
                        messageEntity.IsNew = (int)MessageStateCode.New;
                        messageEntity.ReadCount = 0;
                        messageEntity.DeletionStateCode = 0;
                        messageEntity.Enabled = 1;
                        BaseMessageManager messageManager = new BaseMessageManager(dbHelper, userInfo);
                        returnValue = messageManager.Add(messageEntity);
                    }
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            // 写入调试信息
            #if (DEBUG)
                BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif

            return returnValue;
        }
コード例 #10
0
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="BaseFileEntity">实体</param>
 private void SetEntity(SQLBuilder sqlBuilder, BaseFileEntity fileEntity)
 {
     sqlBuilder.SetValue(BaseFileEntity.FieldFolderId, fileEntity.FolderId);
     sqlBuilder.SetValue(BaseFileEntity.FieldFileName, fileEntity.FileName);
     sqlBuilder.SetValue(BaseFileEntity.FieldFilePath, fileEntity.FilePath);
     sqlBuilder.SetValue(BaseFileEntity.FieldContents, fileEntity.Contents);
     if (fileEntity.Contents != null)
     {
         sqlBuilder.SetValue(BaseFileEntity.FieldFileSize, fileEntity.Contents.Length);
     }
     else
     {
         sqlBuilder.SetValue(BaseFileEntity.FieldFileSize, fileEntity.FileSize);
     }
     sqlBuilder.SetValue(BaseFileEntity.FieldReadCount, fileEntity.ReadCount);
     sqlBuilder.SetValue(BaseFileEntity.FieldDeletionStateCode, fileEntity.DeletionStateCode);
     sqlBuilder.SetValue(BaseFileEntity.FieldDescription, fileEntity.Description);
     sqlBuilder.SetValue(BaseFileEntity.FieldEnabled, fileEntity.Enabled);
     sqlBuilder.SetValue(BaseFileEntity.FieldSortCode, fileEntity.SortCode);
     SetEntityExpand(sqlBuilder, fileEntity);
 }
コード例 #11
0
partial         void SetEntityExpand(SQLBuilder sqlBuilder, BaseFileEntity fileEntity);
コード例 #12
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="BaseFileEntity">实体</param>
 public int Update(BaseFileEntity fileEntity)
 {
     return this.UpdateEntity(fileEntity);
 }
コード例 #13
0
 /// <summary>
 /// 更新实体
 /// </summary>
 /// <param name="fileEntity">实体</param>
 public int UpdateEntity(BaseFileEntity fileEntity)
 {
     SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);
     sqlBuilder.BeginUpdate(this.CurrentTableName);
     this.SetEntity(sqlBuilder, fileEntity);
     if (UserInfo != null)
     {
         sqlBuilder.SetValue(BaseFileEntity.FieldModifiedUserId, UserInfo.Id);
         sqlBuilder.SetValue(BaseFileEntity.FieldModifiedBy, UserInfo.RealName);
     }
     sqlBuilder.SetDBNow(BaseFileEntity.FieldModifiedOn);
     sqlBuilder.SetWhere(BaseFileEntity.FieldId, fileEntity.Id);
     return sqlBuilder.EndUpdate();
 }
コード例 #14
0
 /// <summary>
 /// 添加实体
 /// </summary>
 /// <param name="fileEntity">实体</param>
 public string AddEntity(BaseFileEntity fileEntity)
 {
     string sequence = string.Empty;
     sequence = fileEntity.Id;
     if (fileEntity.SortCode == 0)
     {
         BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
         sequence = sequenceManager.GetSequence(this.CurrentTableName);
         fileEntity.SortCode = int.Parse(sequence);
     }
     if (fileEntity.Id is string)
     {
         this.Identity = false;
     }
     SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);
     sqlBuilder.BeginInsert(this.CurrentTableName, BaseFileEntity.FieldId);
     if (!this.Identity)
     {
         sqlBuilder.SetValue(BaseFileEntity.FieldId, fileEntity.Id);
     }
     else
     {
         if (!this.ReturnId && DbHelper.CurrentDbType == DbTypes.Oracle)
         {
             sqlBuilder.SetFormula(BaseFileEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
         }
         else
         {
             if (this.Identity && DbHelper.CurrentDbType == DbTypes.Oracle)
             {
                 if (string.IsNullOrEmpty(fileEntity.Id))
                 {
                     if (string.IsNullOrEmpty(sequence))
                     {
                         BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                         sequence = sequenceManager.GetSequence(this.CurrentTableName);
                     }
                     fileEntity.Id = sequence;
                 }
                 sqlBuilder.SetValue(BaseFileEntity.FieldId, fileEntity.Id);
             }
         }
     }
     this.SetEntity(sqlBuilder, fileEntity);
     if (UserInfo != null)
     {
         sqlBuilder.SetValue(BaseFileEntity.FieldCreateUserId, UserInfo.Id);
         sqlBuilder.SetValue(BaseFileEntity.FieldCreateBy, UserInfo.RealName);
     }
     sqlBuilder.SetDBNow(BaseFileEntity.FieldCreateOn);
     // 这里主要是为了列表里的数据库更好看
     sqlBuilder.SetValue(BaseFileEntity.FieldModifiedUserId, fileEntity.ModifiedUserId);
     sqlBuilder.SetValue(BaseFileEntity.FieldModifiedBy, fileEntity.ModifiedBy);
     sqlBuilder.SetValue(BaseFileEntity.FieldModifiedOn, fileEntity.ModifiedOn);
     if (DbHelper.CurrentDbType == DbTypes.SqlServer && this.Identity)
     {
         sequence = sqlBuilder.EndInsert().ToString();
     }
     else
     {
         sqlBuilder.EndInsert();
     }
     return sequence;
 }
コード例 #15
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="fileEntity">实体</param>
 /// <param name="identity">自增量方式</param>
 /// /// <param name="returnId">返回主鍵</param>
 /// <returns>主键</returns>
 public string Add(BaseFileEntity fileEntity, bool identity, bool returnId)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return this.AddEntity(fileEntity);
 }
コード例 #16
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="fileEntity">实体</param>
 /// <returns>主键</returns>
 public string Add(BaseFileEntity fileEntity)
 {
     return this.AddEntity(fileEntity);
 }
コード例 #17
0
        /// <summary>
        /// 添加文件
        /// </summary>
        /// <param name="folderId">文件夹主键</param>
        /// <param name="fileName">文件名</param>
        /// <param name="file">文件</param>
        /// <param name="category">文件分类</param>
        /// <param name="enabled">有效</param>
        /// <param name="statusCode">状态</param>
        /// <returns>主键</returns>
        public string Add(BaseFileEntity fileEntity, out string statusCode)
        {
            statusCode = string.Empty;
            string returnValue = string.Empty;
            // 检查是否重复
            List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>();
            parameters.Add(new KeyValuePair<string, object>(BaseFileEntity.FieldFolderId, fileEntity.FolderId));
            parameters.Add(new KeyValuePair<string, object>(BaseFileEntity.FieldFileName, fileEntity.FileName));
            parameters.Add(new KeyValuePair<string, object>(BaseFileEntity.FieldDeletionStateCode, 0));

            if (this.Exists(parameters))
            {
                // 名称已重复
                statusCode = StatusCode.ErrorNameExist.ToString();
            }
            else
            {
                returnValue = this.AddEntity(fileEntity);
                // 运行成功
                statusCode = StatusCode.OKAdd.ToString();
            }
            return returnValue;
        }
コード例 #18
0
ファイル: FrmFileEdit.cs プロジェクト: huoxudong125/DotNet
 private void DownLoadFile(string fileId)
 {
     // DataTable dataTable = DotNetService.Instance.FileService.GetEntity(UserInfo, fileId);
     BaseFileEntity fileEntity = new BaseFileEntity();
     SaveFileDialog saveFileDialog = new SaveFileDialog();
     saveFileDialog.FileName = fileEntity.FileName;
     if (saveFileDialog.ShowDialog() == DialogResult.OK)
     {
         string fileName = saveFileDialog.FileName;
         FileUtil.SaveFile(DotNetService.Instance.FileService.Download(UserInfo, fileId), fileName);
         this.Close();
     }
 }
コード例 #19
0
 /// <summary>
 /// 获取实体
 /// </summary>
 /// <returns>名片类</returns>
 private BaseFileEntity GetEntity(BaseFileEntity fileEntity)
 {
     fileEntity.FileName = this.txtFileName.Text;
     fileEntity.Contents = System.Text.Encoding.Default.GetBytes(this.txtContent.Text);
     fileEntity.Enabled = this.chbEnabled.Checked ? 1:0;
     fileEntity.Description = this.txtDescription.Text;
     return fileEntity;
 }
コード例 #20
0
ファイル: FrmFileAdmin.cs プロジェクト: huoxudong125/DotNet
 /// <summary>
 /// 编辑模块
 /// </summary>
 private void EditGrid()
 {
     //if (BaseInterfaceLogic.CheckInputSelectOne(this.grdFile, "colSelected"))
     //{
     string id = BaseInterfaceLogic.GetDataGridViewEntityId(this.grdFile, BaseModuleEntity.FieldId);
     // DataTable dtFile = DotNetService.Instance.FileService.Get(UserInfo, id);
     BaseFileEntity fileEntity = new BaseFileEntity();
     Form frmFileEdit = null;
     // frmFileEdit = new FrmDocumentEdit(id);
     frmFileEdit = new FrmFileEdit(id);
     if (frmFileEdit.ShowDialog(this) == DialogResult.OK)
     {
         this.FormLoaded = false;
         // 绑定屏幕数据
         this.GetFileList();
         this.FormLoaded = true;
     }
     //}
 }
コード例 #21
0
ファイル: FrmFileEdit.cs プロジェクト: huoxudong125/DotNet
 /// <summary>
 /// 显示内容
 /// </summary>
 public override void ShowEntity()
 {
     BaseFileEntity fileEntity = new BaseFileEntity();
     fileEntity = DotNetService.Instance.FileService.GetEntity(UserInfo, this.FileId);
     // 从数据权限获得类
     //fileEntity.GetSingle(this.DTFile);
     // 将类转显示到页面
     this.ucFolder.SelectedId = fileEntity.FolderId;
     this.txtFileName.Text = fileEntity.FileName;
     this.txtDescription.Text = fileEntity.Description;
 }
コード例 #22
0
ファイル: FileService.cs プロジェクト: huoxudong125/DotNet
        /// <summary>
        /// 重命名
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <param name="newName">新名称</param>
        /// <param name="enabled">有效</param>
        /// <param name="statusCode">状态码</param>
        /// <param name="statusMessage">状态信息</param>
        /// <returns>影响行数</returns>
        public int Rename(BaseUserInfo userInfo, string id, string newName, bool enabled, out string statusCode, out string statusMessage)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
            LogOnService.UserIsLogOn(userInfo);
            #endif

            statusCode = string.Empty;
            statusMessage = string.Empty;

            int returnValue = 0;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseFileEntity fileEntity = new BaseFileEntity();
                    BaseFileManager fileManager = new BaseFileManager(dbHelper, userInfo);
                    DataTable dataTable = fileManager.GetDataTableById(id);
                    fileEntity.GetSingle(dataTable);
                    fileEntity.FileName = newName;
                    fileEntity.Enabled = enabled ? 1 : 0;
                    returnValue = fileManager.Update(fileEntity, out statusCode);
                    statusMessage = fileManager.GetStateMessage(statusCode);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            // 写入调试信息
            #if (DEBUG)
                BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif

            return returnValue;
        }