Esempio n. 1
0
        /// <summary>
        /// 保存附件
        /// </summary>
        public async Task <WebModelIsSucceed> SaveFile(Guid businessID)
        {
            using (OperationManagerDbContext db = new OperationManagerDbContext())
            {
                using (var dbContextTransaction = db.Database.BeginTransaction())
                {
                    HttpFileCollection picColl = HttpContext.Current.Request.Files;
                    //int maxLength = 10971520;
                    WebModelIsSucceed      isSucceed = new WebModelIsSucceed();
                    List <AttachmentModel> list      = new List <AttachmentModel>();
                    try
                    {
                        for (var i = 0; i < picColl.Count; i++)
                        {
                            HttpPostedFile file = picColl[i];
                            string         type = file.ContentType;
                            //重命名
                            string[] oldFileNameList = file.FileName.Split('.');
                            string   fileName        = oldFileNameList[0] + "_" + DateTime.Now.ToString("yyyy-MM-ddHH-mm-ss-fff") + "." + oldFileNameList[1];

                            attachment.SaveFile(file, fileName);
                            AttachmentModel model = new AttachmentModel
                            {
                                UUID         = System.Guid.NewGuid(),
                                CreateTime   = DateTime.Now,
                                ValidStatus  = 1,
                                FileName     = oldFileNameList[0],
                                FileType     = oldFileNameList[1],
                                RelativePath = fileName,
                                FileLength   = file.ContentLength / 1024,
                                BusinessID   = businessID,
                                FileFullPath = "C:\\Files\\" + fileName
                            };
                            list.Add(model);
                        }
                        db.Attachment.AddOrUpdate(list.ToArray());
                        isSucceed.IsSucceed = await db.SaveChangesAsync() > 0 ? true : false;

                        dbContextTransaction.Commit();
                        return(isSucceed);
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                        isSucceed.IsSucceed    = false;
                        isSucceed.ErrorMessage = ex.Message + "\r\n" + ex.StackTrace;
                        return(isSucceed);
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 添加用户组信息  邀请人信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <WebModelIsSucceed> AddOrUpdateRelation_UseGroup(Relation_UseGroup model)
        {
            WebModelIsSucceed isSucceed = new WebModelIsSucceed();

            using (OperationManagerDbContext db = new OperationManagerDbContext())
            {
                using (var dbContextTransaction = db.Database.BeginTransaction())
                {
                    List <Relation_UseGroup_User> list = new List <Relation_UseGroup_User>();
                    try
                    {
                        Relation_UseGroup rrelation_UseGroupModel = null; // new Relation_UseGroup();// useGroupAdapter.GetAll().Where(w => w.UseGroupID == model.UseGroupID).FirstOrDefault();
                        if (rrelation_UseGroupModel == null)              //添加
                        {
                            rrelation_UseGroupModel            = new Relation_UseGroup();
                            rrelation_UseGroupModel.UseGroupID = Guid.NewGuid();
                            rrelation_UseGroupModel.CreateTime = DateTime.Now;
                        }
                        rrelation_UseGroupModel.UseGroupName = model.UseGroupName;
                        rrelation_UseGroupModel.SponsorID    = model.SponsorID;
                        rrelation_UseGroupModel.Describe     = model.Describe;
                        rrelation_UseGroupModel.GroupType    = model.GroupType;
                        rrelation_UseGroupModel.Sort         = model.Sort;
                        if (model.Relation_UseGroup_User != null)//邀请人信息
                        {
                            foreach (var Relation_UseGroup_User in model.Relation_UseGroup_User)
                            {
                                Relation_UseGroup_User relation_UseGroup_User = new Relation_UseGroup_User();
                                relation_UseGroup_User.UUID           = Guid.NewGuid();
                                relation_UseGroup_User.UseGroupID     = rrelation_UseGroupModel.UseGroupID;
                                relation_UseGroup_User.SysUserID      = Relation_UseGroup_User.SysUserID;
                                relation_UseGroup_User.InvitationTime = DateTime.Now;
                                relation_UseGroup_User.Join           = 0;
                                relation_UseGroup_User.sort           = Relation_UseGroup_User.sort == null ? 0: Relation_UseGroup_User.sort;
                                list.Add(relation_UseGroup_User);
                            }
                            //加入创建组人信息 创建人自己
                            Relation_UseGroup_User relation_UseGroup_UserAdmin = new Relation_UseGroup_User();
                            relation_UseGroup_UserAdmin.UUID           = Guid.NewGuid();
                            relation_UseGroup_UserAdmin.UseGroupID     = rrelation_UseGroupModel.UseGroupID;
                            relation_UseGroup_UserAdmin.SysUserID      = model.SponsorID;
                            relation_UseGroup_UserAdmin.InvitationTime = DateTime.Now;
                            relation_UseGroup_UserAdmin.Join           = 1;
                            relation_UseGroup_UserAdmin.sort           = 0;
                            list.Add(relation_UseGroup_UserAdmin);
                        }

                        db.Relation_UseGroup.AddOrUpdate(rrelation_UseGroupModel);
                        if (list.Count > 0)
                        {
                            db.Relation_UseGroup_User.AddOrUpdate(list.ToArray());
                        }

                        isSucceed.IsSucceed = await db.SaveChangesAsync() > 0 ? true : false;

                        dbContextTransaction.Commit();
                        return(isSucceed);
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                        isSucceed.IsSucceed    = false;
                        isSucceed.ErrorMessage = ex.Message + "\r\n" + ex.StackTrace;
                        return(isSucceed);
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 添加文献信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <WebModelIsSucceed> AddOrUpdateProductionsField(ProductionsModel model)
        {
            WebModelIsSucceed isSucceed = new WebModelIsSucceed();

            using (OperationManagerDbContext db = new OperationManagerDbContext())
            {
                using (var dbContextTransaction = db.Database.BeginTransaction())
                {
                    List <ProductionsField> list = new List <ProductionsField>();

                    //作品文献表
                    try
                    {
                        #region 文献
                        Production productions = new Production();
                        productions.ProductionID     = Guid.NewGuid();
                        productions.TemplateID       = model.TemplateID;
                        productions.IsUploadFileFlag = model.IsUploadFileFlag;
                        productions.UserID           = model.UserID;
                        productions.DownloadNum      = 0;
                        productions.BrowseNum        = 0;
                        productions.CreateTime       = DateTime.Now;

                        foreach (var fieldList in model.DicProductionsField)
                        {
                            ProductionsField productionsField = new ProductionsField();
                            productionsField.UUID          = Guid.NewGuid();
                            productionsField.ProductionID  = productions.ProductionID;
                            productionsField.TemplateID    = model.TemplateID;
                            productionsField.MetaDataID    = fieldList.MetaDataID;
                            productionsField.FieldSequence = fieldList.FieldSequence;
                            productionsField.DefaultText   = fieldList.DefaultText;
                            productionsField.DefaultValue  = fieldList.DefaultValue;
                            productionsField.Remark        = fieldList.Remark;
                            productionsField.FieldValue    = fieldList.FieldValue;
                            list.Add(productionsField);
                        }

                        db.Production.AddOrUpdate(productions);
                        db.ProductionsField.AddOrUpdate(list.ToArray());
                        #endregion

                        #region 未认领
                        RelationUserClaimWorksModel rcw = new RelationUserClaimWorksModel();
                        rcw.ProductionID         = productions.ProductionID + "";
                        rcw.UserClaimWorksID     = Guid.NewGuid();
                        rcw.SysUserID            = model.UserID;
                        rcw.UserClaimWorksStatus = 0;
                        rcw.IsHave               = 0;
                        rcw.AuthorOrder          = 0;
                        rcw.CorrespondenceAuthor = 0;
                        rcw.ParticipatingAuthor  = 0;

                        db.RelationUserClaimWorks.AddOrUpdate(rcw);
                        #endregion

                        #region 大表
                        List <SYS_MetaData> list_Meta = await db.SYS_MetaData.ToListAsync();

                        StaticProductions staticProductions = new StaticProductions();

                        staticProductions.ProductionID = productions.ProductionID;
                        staticProductions.TemplateID   = productions.TemplateID.Value;
                        staticProductions.CreateTime   = DateTime.Now;
                        staticProductions.UserID       = productions.UserID;
                        staticProductions.DataType     = model.TemplateName;
                        #region 元数据赋值
                        staticProductions.Abstract             = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "abstract")).ToList());
                        staticProductions.Author               = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "author")).ToList());
                        staticProductions.Chemicallist         = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "chemicallist")).ToList());
                        staticProductions.Citations            = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "citations")).ToList());
                        staticProductions.Cn                   = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "cn")).ToList());
                        staticProductions.Cooperation          = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "cooperation")).ToList());
                        staticProductions.Correspondent        = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "correspondent")).ToList());
                        staticProductions.Correspondentemail   = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "correspondentemail")).ToList());
                        staticProductions.Dataset              = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "dataset")).ToList());
                        staticProductions.Department           = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "department")).ToList());
                        staticProductions.Discipline           = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "discipline")).ToList());
                        staticProductions.Doctype              = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "doctype")).ToList());
                        staticProductions.Doi                  = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "doi")).ToList());
                        staticProductions.Ei                   = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "Ei")).ToList());
                        staticProductions.EnglishAbstract      = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "EnglishAbstract")).ToList());
                        staticProductions.FirstAuthor          = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "FirstAuthor")).ToList());
                        staticProductions.Fulljournaltitle     = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "fulljournaltitle")).ToList());
                        staticProductions.Funder               = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "funder")).ToList());
                        staticProductions.Indexed              = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "indexed")).ToList());
                        staticProductions.Institution          = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "institution")).ToList());
                        staticProductions.Iso                  = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "iso")).ToList());
                        staticProductions.Issn                 = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "issn")).ToList());
                        staticProductions.Issue                = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "issue")).ToList());
                        staticProductions.Issued               = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "issued")).ToList());
                        staticProductions.Jigouyuanxi          = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "jigouyuanxi")).ToList());
                        staticProductions.Journalabbreviation  = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "journalabbreviation")).ToList());
                        staticProductions.Keyword              = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "keyword")).ToList());
                        staticProductions.Keywords_plus        = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "keywords_plus")).ToList());
                        staticProductions.Link                 = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "link")).ToList());
                        staticProductions.Orcid                = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "orcid")).ToList());
                        staticProductions.Pages                = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "pages")).ToList());
                        staticProductions.Pmid                 = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "pmid")).ToList());
                        staticProductions.Project              = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "project")).ToList());
                        staticProductions.Projectno            = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "projectno")).ToList());
                        staticProductions.Publisher            = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "Publisher")).ToList());
                        staticProductions.Rank                 = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "rank")).ToList());
                        staticProductions.Reference            = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "reference")).ToList());
                        staticProductions.Referencecount       = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "referencecount")).ToList());
                        staticProductions.Resulttype           = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "resulttype")).ToList());
                        staticProductions.Source               = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "source")).ToList());
                        staticProductions.Subjectword          = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "subjectword")).ToList());
                        staticProductions.Sumpages             = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "sumpages")).ToList());
                        staticProductions.Title                = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "Title")).ToList());
                        staticProductions.Ut                   = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "ut")).ToList());
                        staticProductions.Version              = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "version")).ToList());
                        staticProductions.Volume               = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "volume")).ToList());
                        staticProductions.Webofscience         = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "webofscience")).ToList());
                        staticProductions.Wos_headings         = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "wos_headings")).ToList());
                        staticProductions.Wos_subject          = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "wos_subject")).ToList());
                        staticProductions.Wos_subject_extended = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "wos_subject_extended")).ToList());
                        staticProductions.Woscitations         = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "woscitations")).ToList());
                        staticProductions.Wosid                = ListChangeString.GetString(list.Where(w => w.MetaDataID == GetMetaID(list_Meta, "wosid")).ToList());
                        #endregion


                        db.StaticProductions.AddOrUpdate(staticProductions);
                        #endregion
                        isSucceed.IsSucceed = await db.SaveChangesAsync() > 0 ? true : false;

                        OperationFiles operationFiles = new OperationFiles();
                        await operationFiles.SaveFile(productions.ProductionID);//上传文档信息

                        dbContextTransaction.Commit();
                        isSucceed.ErrorMessage = productions.ProductionID + "";
                        return(isSucceed);
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                        isSucceed.IsSucceed    = false;
                        isSucceed.ErrorMessage = ex.Message + "\r\n" + ex.StackTrace;
                        return(isSucceed);
                    }
                }
            }
        }