Esempio n. 1
0
        /// <summary>
        /// 得到投稿自动分配配置
        /// </summary>
        /// <param name="autoAllotQuery"></param>
        /// <returns></returns>
        public EditorAutoAllotEntity GetEditorAutoAllot(EditorAutoAllotQuery autoAllotQuery)
        {
            EditorAutoAllotEntity editorAutoAllotEntity = null;
            StringBuilder         sqlCommandText        = new StringBuilder();

            sqlCommandText.Append("SELECT TOP 1  PKID,JournalID,AllotPattern,AuthorID,OddAuthorID,AddDate FROM dbo.EditorAutoAllot WITH(NOLOCK)");
            sqlCommandText.Append(" WHERE  JournalID=@JournalID");
            DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString());

            db.AddInParameter(cmd, "@JournalID", DbType.Int64, autoAllotQuery.JournalID);

            using (IDataReader dr = db.ExecuteReader(cmd))
            {
                editorAutoAllotEntity = MakeEditorAutoAllot(dr);
                if (editorAutoAllotEntity != null)
                {
                    // 如果是按照学科分类设置,则取学科分类的明细
                    if (editorAutoAllotEntity.AllotPattern == 1)
                    {
                        editorAutoAllotEntity.SubjectAuthorMap = new List <SubjectAuthorMapEntity>();
                        StringBuilder sqlGetSubjectCategoryText = new StringBuilder();
                        sqlGetSubjectCategoryText.Append("SELECT SubjectCategoryID,AuthorID FROM dbo.SubjectAuthorMap WITH(NOLOCK)");
                        sqlGetSubjectCategoryText.Append(" WHERE  JournalID=@JournalID");
                        DbCommand cmdGetSubjectCategory = db.GetSqlStringCommand(sqlGetSubjectCategoryText.ToString());
                        db.AddInParameter(cmdGetSubjectCategory, "@JournalID", DbType.Int64, autoAllotQuery.JournalID);
                        using (IDataReader drSubject = db.ExecuteReader(cmdGetSubjectCategory))
                        {
                            SubjectAuthorMapEntity subjectMap = null;
                            while (drSubject.Read())
                            {
                                subjectMap = new SubjectAuthorMapEntity();
                                subjectMap.SubjectCategoryID = TypeParse.ToInt(drSubject["SubjectCategoryID"]);
                                subjectMap.AuthorID          = TypeParse.ToInt(drSubject["AuthorID"]);
                                subjectMap.JournalID         = autoAllotQuery.JournalID;
                                editorAutoAllotEntity.SubjectAuthorMap.Add(subjectMap);
                            }
                            drSubject.Close();
                        }
                    }
                }
                dr.Close();
            }
            return(editorAutoAllotEntity);
        }
Esempio n. 2
0
        /// <summary>
        /// 得到投稿自动分配配置
        /// </summary>
        /// <param name="autoAllotQuery"></param>
        /// <returns></returns>
        public bool CheckSubjectMapIsExists(SubjectAuthorMapEntity subjectMap)
        {
            bool          flag = false;
            StringBuilder sqlGetSubjectCategoryText = new StringBuilder();

            sqlGetSubjectCategoryText.Append("SELECT SubjectCategoryID,AuthorID FROM dbo.SubjectAuthorMap WITH(NOLOCK)  WHERE JournalID=@JournalID AND SubjectCategoryID=@SubjectCategoryID");
            DbCommand cmdGetSubjectCategory = db.GetSqlStringCommand(sqlGetSubjectCategoryText.ToString());

            db.AddInParameter(cmdGetSubjectCategory, "@JournalID", DbType.Int64, subjectMap.JournalID);
            db.AddInParameter(cmdGetSubjectCategory, "@SubjectCategoryID", DbType.Int64, subjectMap.SubjectCategoryID);
            using (IDataReader drSubject = db.ExecuteReader(cmdGetSubjectCategory))
            {
                if (drSubject.Read())
                {
                    flag = true;
                }
                drSubject.Close();
            }
            return(flag);
        }