/// <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;
 }
        /// <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;
        }
        public EditorAutoAllotEntity GetContributeAutoAllotInfo(EditorAutoAllotQuery query)
        {
            try
            {
                IEditorAutoAllotService cSetService = ServiceContainer.Instance.Container.Resolve<IEditorAutoAllotService>();
                EditorAutoAllotEntity cSetEntity = cSetService.GetEditorAutoAllot(query);
                if (cSetEntity == null)
                {
                    cSetEntity = new EditorAutoAllotEntity();
                    cSetEntity.SubjectAuthorMap = new List<SubjectAuthorMapEntity>();
                }
                else
                {
                    if (cSetEntity.SubjectAuthorMap == null)
                    {
                        cSetEntity.SubjectAuthorMap = new List<SubjectAuthorMapEntity>();
                    }
                }
                if (cSetEntity.SubjectAuthorMap.Count == 0)
                {
                    # region 获取学科分类

                    IDictValueService service = ServiceContainer.Instance.Container.Resolve<IDictValueService>();
                    DictValueQuery dictQuery = new DictValueQuery();
                    dictQuery.JournalID = query.JournalID;
                    dictQuery.DictKey = EnumDictKey.SubjectCat.ToString();
                    List<DictValueEntity> listDictValue = service.GetDictValueList(dictQuery);
                    SubjectAuthorMapEntity subjectItem = null;
                    foreach (DictValueEntity item in listDictValue)
                    {
                        subjectItem = new SubjectAuthorMapEntity();
                        subjectItem.SubjectCategoryID = item.ValueID;
                        subjectItem.CategoryName = item.ValueText;
                        subjectItem.AuthorID = 0;
                        cSetEntity.SubjectAuthorMap.Add(subjectItem);
                    }

                    # endregion
                }
                else
                {
                    IDictValueService service = ServiceContainer.Instance.Container.Resolve<IDictValueService>();
                    IDictionary<int, string> dictValues = service.GetDictValueDcit(query.JournalID, EnumDictKey.SubjectCat.ToString());
                    string subjectCategoryName = "";
                    foreach (SubjectAuthorMapEntity item in cSetEntity.SubjectAuthorMap)
                    {
                         dictValues.TryGetValue(item.SubjectCategoryID,out subjectCategoryName);
                         item.CategoryName = subjectCategoryName;
                         subjectCategoryName = "";
                    }
                }
                return cSetEntity;
            }