Example #1
0
 public bool UpdateEntity(int id, ServArchiveFileModel newentity)
 {
     throw new NotImplementedException();
 }
Example #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model"></param>
        public int UpdateArchiveFileById(ServArchiveFileModel model)
        {

            int result = mapContext.Update("UpdateArchiveFile", model);
            return result;
        }
Example #3
0
        /// <summary>
        /// 修改卷宗
        /// </summary>
        /// <param name="servArchiveInfoModel"></param>
        /// <param name="ServFileInfoList"></param>
        /// <param name="servArhiveUpdateLog"></param>
        /// <returns></returns>
        public bool UpdateservArchiveInfo(ServArchiveInfoModel servArchiveInfoModel, List <ServFileInfoModel> ServFileInfoList, ServArhiveUpdateLogModel servArhiveUpdateLog)
        {
            mapContext.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted);//创建事务
            try
            {
                bool result = false;
                //向卷宗信息表中添加信息
                int regId = (int)mapContext.Update("UpdateArchiveInfo", servArchiveInfoModel);
                if (regId > 0)
                {
                    result = true;
                    List <ServArchiveFileModel> servArchiveFileModel = mapContext.QueryForList <ServArchiveFileModel>("GetArchiveFileByRegId", servArchiveInfoModel.id).ToList();
                    for (var i = 0; i < servArchiveFileModel.Count(); i++)
                    {
                        int fileId = (int)mapContext.Delete("DeleteFileInfoById", servArchiveFileModel[i].relate_id);
                        if (fileId > -1)
                        {
                            result = true;
                        }
                        else
                        {
                            mapContext.RollBackTransaction();
                            result = false;
                            break;
                        }
                    }
                    if (result == true)
                    {
                        int Id = (int)mapContext.Delete("DeleteArchiveFileInfoById", servArchiveInfoModel.id);
                        if (Id > -1)
                        {
                            //向文件表中添加数据
                            for (var i = 0; i < ServFileInfoList.Count(); i++)
                            {
                                int fileId = (int)mapContext.Insert("InsertFileInfo", ServFileInfoList[i]);
                                if (fileId > 0)
                                {
                                    //向关联表中添加信息
                                    ServArchiveFileModel archiveFile = new ServArchiveFileModel();
                                    archiveFile.archive_id = servArchiveInfoModel.id;
                                    archiveFile.relate_id  = fileId;
                                    archiveFile.type       = ServFileInfoList[i].file_type;
                                    int relationId = (int)mapContext.Insert("InsertArchiveFile", archiveFile);
                                    if (relationId > 0)
                                    {
                                        result = true;
                                    }
                                    else
                                    {
                                        result = false;
                                        break;
                                    }
                                }
                            }
                        }
                        if (result == true)
                        {
                            //向日志表里添加信息
                            int fileId = (int)mapContext.Insert("InsertArhiveUpdateLog", servArhiveUpdateLog);
                            if (fileId > 0)
                            {
                                result = true;
                            }
                            else
                            {
                                result = false;
                            }
                        }
                        else
                        {
                            result = false;
                        }
                    }
                }
                else
                {
                    mapContext.RollBackTransaction();
                    result = false;
                }
                if (result == true)
                {
                    mapContext.CommitTransaction();//提交事务
                    return(result);
                }
                else
                {
                    mapContext.RollBackTransaction();//事务回滚
                    return(result);
                }
            }


            catch (Exception ex)
            {
                mapContext.RollBackTransaction();
                throw ex;
            }

            finally
            {
                //mapContext.CommitTransaction();
            }
        }
Example #4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="entity"></param>
 public int AddEntity(ServArchiveFileModel entity)
 {
     int id = (int)mapContext.Insert("InsertArchiveFile", entity);
     return id;
 }
Example #5
0
        /// <summary>
        /// 添加卷宗条例
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="fileInfo"></param>
        /// <returns></returns>
        public bool AddservArchiveInfo(ServArchiveInfoModel entity, List <ServFileInfoModel> fileInfo)
        {
            mapContext.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted);//创建事务
            try
            {
                bool result = false;
                //向卷宗信息表中添加信息
                int regId = (int)mapContext.Insert("InsertArchiveInfo", entity);
                if (regId > 0)
                {
                    result = true;
                    //向文件表中添加数据
                    for (var i = 0; i < fileInfo.Count(); i++)
                    {
                        int fileId = (int)mapContext.Insert("InsertFileInfo", fileInfo[i]);
                        if (fileId > 0)
                        {
                            //向关联表中添加信息
                            ServArchiveFileModel archiveFile = new ServArchiveFileModel();
                            archiveFile.archive_id = regId;
                            archiveFile.relate_id  = fileId;
                            archiveFile.type       = fileInfo[i].file_type;
                            int relationId = (int)mapContext.Insert("InsertArchiveFile", archiveFile);
                            if (relationId > 0)
                            {
                                result = true;
                            }
                            else
                            {
                                result = false;
                            }
                        }
                        else
                        {
                            result = false;
                        }
                    }
                }
                else
                {
                    mapContext.RollBackTransaction();
                    result = false;
                }
                if (result == true)
                {
                    mapContext.CommitTransaction();//提交事务
                    return(result);
                }
                else
                {
                    mapContext.RollBackTransaction();//事务回滚
                    return(result);
                }
            }


            catch (Exception ex)
            {
                mapContext.RollBackTransaction();
                throw ex;
            }

            finally
            {
                //mapContext.CommitTransaction();
            }
        }