Beispiel #1
0
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="newsEntity">实体</param>
 private void SetEntity(SQLBuilder sqlBuilder, BaseNewsEntity newsEntity)
 {
     if (newsEntity.Contents == null)
     {
         newsEntity.FileSize = 0;
     }
     else
     {
         newsEntity.FileSize = newsEntity.Contents.Length;
     }
     sqlBuilder.SetValue(BaseNewsEntity.FieldDepartmentId, newsEntity.DepartmentId);
     sqlBuilder.SetValue(BaseNewsEntity.FieldDepartmentName, newsEntity.DepartmentName);
     sqlBuilder.SetValue(BaseNewsEntity.FieldFolderId, newsEntity.FolderId);
     sqlBuilder.SetValue(BaseNewsEntity.FieldCategoryCode, newsEntity.CategoryCode);
     sqlBuilder.SetValue(BaseNewsEntity.FieldCode, newsEntity.Code);
     sqlBuilder.SetValue(BaseNewsEntity.FieldTitle, newsEntity.Title);
     sqlBuilder.SetValue(BaseNewsEntity.FieldFilePath, newsEntity.FilePath);
     sqlBuilder.SetValue(BaseNewsEntity.FieldIntroduction, newsEntity.Introduction);
     sqlBuilder.SetValue(BaseNewsEntity.FieldContents, newsEntity.Contents);
     sqlBuilder.SetValue(BaseNewsEntity.FieldSource, newsEntity.Source);
     sqlBuilder.SetValue(BaseNewsEntity.FieldKeywords, newsEntity.Keywords);
     sqlBuilder.SetValue(BaseNewsEntity.FieldFileSize, newsEntity.FileSize);
     sqlBuilder.SetValue(BaseNewsEntity.FieldImageUrl, newsEntity.ImageUrl);
     sqlBuilder.SetValue(BaseNewsEntity.FieldHomePage, newsEntity.HomePage);
     sqlBuilder.SetValue(BaseNewsEntity.FieldSubPage, newsEntity.SubPage);
     sqlBuilder.SetValue(BaseNewsEntity.FieldAuditStatus, newsEntity.AuditStatus);
     sqlBuilder.SetValue(BaseNewsEntity.FieldReadCount, newsEntity.ReadCount);
     sqlBuilder.SetValue(BaseNewsEntity.FieldDeletionStateCode, newsEntity.DeletionStateCode);
     sqlBuilder.SetValue(BaseNewsEntity.FieldDescription, newsEntity.Description);
     sqlBuilder.SetValue(BaseNewsEntity.FieldEnabled, newsEntity.Enabled);
     sqlBuilder.SetValue(BaseNewsEntity.FieldSortCode, newsEntity.SortCode);
     SetEntityExpand(sqlBuilder, newsEntity);
 }
Beispiel #2
0
        public int Update(BaseNewsEntity fileEntity, out string statusCode)
        {
            statusCode = string.Empty;
            int returnValue = this.UpdateEntity(fileEntity);

            if (returnValue > 0)
            {
                statusCode = StatusCode.OKUpdate.ToString();
            }
            else
            {
                statusCode = StatusCode.ErrorDeleted.ToString();
            }
            return(returnValue);
        }
Beispiel #3
0
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="newsEntity">实体</param>
        public int UpdateEntity(BaseNewsEntity newsEntity)
        {
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);

            sqlBuilder.BeginUpdate(this.CurrentTableName);
            this.SetEntity(sqlBuilder, newsEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseNewsEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseNewsEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseNewsEntity.FieldModifiedOn);
            sqlBuilder.SetWhere(BaseNewsEntity.FieldId, newsEntity.Id);
            return(sqlBuilder.EndUpdate());
        }
Beispiel #4
0
        public string Upload(string folderId, string title, string contents)
        {
            // 检查是否已经存在
            string returnValue = this.GetId(new KeyValuePair <string, object>(BaseNewsEntity.FieldFolderId, folderId), new KeyValuePair <string, object>(BaseNewsEntity.FieldTitle, title));

            if (!String.IsNullOrEmpty(returnValue))
            {
                // 更新数据
                this.UpdateFile(returnValue, title, contents);
            }
            else
            {
                // 添加数据
                BaseNewsEntity fileEntity = new BaseNewsEntity();
                fileEntity.FolderId = folderId;
                fileEntity.Title    = title;
                fileEntity.Contents = contents;
                returnValue         = this.AddEntity(fileEntity);
            }
            return(returnValue);
        }
Beispiel #5
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(BaseNewsEntity 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>(BaseNewsEntity.FieldFolderId, fileEntity.FolderId));
            parameters.Add(new KeyValuePair <string, object>(BaseNewsEntity.FieldTitle, fileEntity.Title));
            parameters.Add(new KeyValuePair <string, object>(BaseNewsEntity.FieldDeletionStateCode, 0));

            if (this.Exists(parameters))
            {
                // 名称已重复
                statusCode = StatusCode.ErrorNameExist.ToString();
            }
            else
            {
                returnValue = this.AddEntity(fileEntity);
                // 运行成功
                statusCode = StatusCode.OKAdd.ToString();
            }
            return(returnValue);
        }
Beispiel #6
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="newsEntity">实体</param>
 /// <returns>主键</returns>
 public string Add(BaseNewsEntity newsEntity)
 {
     return(this.AddEntity(newsEntity));
 }
Beispiel #7
0
 partial void SetEntityExpand(SQLBuilder sqlBuilder, BaseNewsEntity newsEntity);
Beispiel #8
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="newsEntity">实体</param>
        public string AddEntity(BaseNewsEntity newsEntity)
        {
            string sequence = string.Empty;

            sequence = newsEntity.Id;
            if (newsEntity.SortCode == 0)
            {
                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                sequence            = sequenceManager.GetSequence(this.CurrentTableName);
                newsEntity.SortCode = int.Parse(sequence);
            }
            if (newsEntity.Id is string)
            {
                this.Identity = false;
            }
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, BaseNewsEntity.FieldId);
            if (!this.Identity)
            {
                sqlBuilder.SetValue(BaseNewsEntity.FieldId, newsEntity.Id);
            }
            else
            {
                if (!this.ReturnId && DbHelper.CurrentDbType == DbTypes.Oracle)
                {
                    sqlBuilder.SetFormula(BaseNewsEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                }
                else
                {
                    if (this.Identity && DbHelper.CurrentDbType == DbTypes.Oracle)
                    {
                        if (string.IsNullOrEmpty(newsEntity.Id))
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            newsEntity.Id = sequence;
                        }
                        sqlBuilder.SetValue(BaseNewsEntity.FieldId, newsEntity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, newsEntity);
            if (UserInfo != null)
            {
                newsEntity.CreateUserId = UserInfo.Id;
                newsEntity.CreateBy     = UserInfo.RealName;
                sqlBuilder.SetValue(BaseNewsEntity.FieldCreateUserId, newsEntity.CreateUserId);
                sqlBuilder.SetValue(BaseNewsEntity.FieldCreateBy, newsEntity.CreateBy);
                newsEntity.ModifiedBy = UserInfo.RealName;
                sqlBuilder.SetValue(BaseNewsEntity.FieldModifiedUserId, newsEntity.CreateUserId);
                sqlBuilder.SetValue(BaseNewsEntity.FieldModifiedBy, newsEntity.CreateBy);
            }
            sqlBuilder.SetDBNow(BaseNewsEntity.FieldCreateOn);
            sqlBuilder.SetDBNow(BaseNewsEntity.FieldModifiedOn);

            /*
             * if (UserInfo != null)
             * {
             *  sqlBuilder.SetValue(BaseNewsEntity.FieldModifiedUserId, UserInfo.Id);
             *  sqlBuilder.SetValue(BaseNewsEntity.FieldModifiedBy, UserInfo.RealName);
             * }
             * sqlBuilder.SetDBNow(BaseNewsEntity.FieldModifiedOn);
             */
            if (DbHelper.CurrentDbType == DbTypes.SqlServer && this.Identity)
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
Beispiel #9
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="id">主键</param>
        public BaseNewsEntity GetEntity(string id)
        {
            BaseNewsEntity newsEntity = new BaseNewsEntity(this.GetDataTable(new KeyValuePair <string, object>(BaseNewsEntity.FieldId, id)));

            return(newsEntity);
        }
Beispiel #10
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="newsEntity">实体</param>
 public int Update(BaseNewsEntity newsEntity)
 {
     return(this.UpdateEntity(newsEntity));
 }
Beispiel #11
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="newsEntity">实体</param>
 /// <param name="identity">自增量方式</param>
 /// <param name="returnId">返回主鍵</param>
 /// <returns>主键</returns>
 public string Add(BaseNewsEntity newsEntity, bool identity, bool returnId)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return(this.AddEntity(newsEntity));
 }