Esempio n. 1
0
 public static long InsertWorks(ContestDll.Works dr)
 {
     using (ContestEntities db = new ContestEntities())
     {
         ContestDll.Works file = new ContestDll.Works();
         file.AllotTimes        = dr.AllotTimes;
         file.BackReason        = dr.BackReason;
         file.Comment           = dr.Comment;
         file.Created           = dr.Created;
         file.CreatedBy         = dr.CreatedBy;
         file.DemoURL           = dr.DemoURL;
         file.DesignIdeas       = dr.DesignIdeas;
         file.Flag              = dr.Flag;
         file.InstallationGuide = dr.InstallationGuide;
         file.IsSample          = dr.IsSample;
         file.KeyPoints         = dr.KeyPoints;
         file.Score             = dr.Score;
         file.WorksCode         = dr.WorksCode;
         file.WorksName         = dr.WorksName;
         file.WorksState        = dr.WorksState;
         file.WorksTypeID       = dr.WorksTypeID;
         file.PeriodID          = dr.PeriodID;
         file.SubmitProfile     = dr.SubmitProfile;
         file.DemoURL           = dr.DemoURL;
         file.DesignIdeas       = dr.DesignIdeas;
         file.KeyPoints         = dr.KeyPoints;
         file.Score             = dr.Score;
         file.Flag              = dr.Flag;
         db.Works.Add(file);
         db.SaveChanges();
         return(file.WorksID);
     }
 }
Esempio n. 2
0
 public static ContestDll.Works    GetWorksAllotTimesByWorsID(long WorksID)
 {
     using (ContestEntities db = new ContestEntities())
     {
         ContestDll.Works works = db.Works.SingleOrDefault(p => p.WorksID == WorksID);
         return(works);
     }
 }
Esempio n. 3
0
 public static long UpdateWorksSubmit(ContestEntities db, CSWorksWorksType dr)
 {
     ContestDll.Works works = db.Works.SingleOrDefault(p => p.WorksID == dr.WorksID);
     works.WorksState = dr.WorksState;
     works.Score      = dr.Score;
     db.SaveChanges();
     return(1);
 }
Esempio n. 4
0
 /// <summary>
 /// 将数据表中某一列生成数组
 /// </summary>
 /// <param name="dt"></param>
 /// <param name="columnname"></param>
 /// <returns></returns>
 public static string[] TableTostrArray(List <ContestDll.Works> dt)
 {
     string[] arrayA = new string[dt.Count];
     for (int i = 0; i < dt.Count; i++)
     {
         ContestDll.Works dr = dt[i];
         arrayA[i] = Convert.ToString(dr.WorksID);
     }
     return(arrayA);
 }
Esempio n. 5
0
 //
 public static long UpdateWorksCode(ContestDll.Works dr)
 {
     using (ContestEntities db = new ContestEntities())
     {
         ContestDll.Works file = db.Works.SingleOrDefault(p => p.WorksID == dr.WorksID);
         file.WorksCode = dr.WorksCode;
         db.SaveChanges();
         return(1);
     }
 }
Esempio n. 6
0
        /// <summary>
        /// 期次作品互评分配
        /// </summary>
        /// <param name="periodId"></param>
        /// <param name="resulDt"></param>
        public static void WorksAlloting(long periodId)
        {
            //long workscount = long.Parse(DAL.Works.GetWorksNumByPeriodID(periodId).Tables[0].Rows[0][0].ToString());//获取当前期次上传的作品数量,不包含样例作品

            long         allotNum     = BLL.Period.SetallotNum(DAL.Works.GetWorksNumByPeriodID(periodId));
            List <long?> dtWaitedUser = DAL.User.GetUserIdByPeriodId(periodId); //初始化数据表以保存待分配的用户ID

            if (dtWaitedUser.Count > 0)                                         //确定本期次可以参与互评的人数
            {
                for (int i = 0; i < dtWaitedUser.Count; i++)
                {
                    long expertId = (long)dtWaitedUser[i];
                    List <CSVWorksForMe> vWorksForMe = DAL.Works.GetWorksForMeByPeriodId(periodId, expertId);
                    long hasAlloted = vWorksForMe.Count;
                    if (hasAlloted < allotNum)                                                                           //获取该用户已经分配的作品数,若未满则继续分配,否则则跳过
                    {
                        List <ContestDll.Works> dtWaitedWorks = DAL.Works.GetWorksToAllot(expertId, periodId, allotNum); //
                        if (dtWaitedWorks.Count > 0)
                        {
                            string[] arrayWaitedWorks = DAL.Common.TableTostrArray(dtWaitedWorks); //待分配作品表转化为数组

                            long     shortOf      = allotNum - hasAlloted;                         //获取该用户还差需要分配的作品数
                            string[] arrayToAllot = DAL.Common.GetRandomsArray(shortOf, arrayWaitedWorks);

                            for (int j = 0; j < arrayToAllot.Length; j++)//插入评分分配新纪录
                            {
                                long worksId         = long.Parse(arrayToAllot[j].ToString());
                                CSWorksExpertUser dr = new CSWorksExpertUser();
                                dr.WorksID  = worksId;  //作品ID
                                dr.ExpertID = expertId; //评分用户ID
                                dr.Flag     = 1;
                                long aaa = DAL.Works.InsertWorksComments(dr);
                                //为作品分配计数+1,最后一次重置作品状态为2:已分配,评分中
                                ContestDll.Works dtAllotTimes = DAL.Works.GetWorksAllotTimesByWorsID(worksId);
                                int allottimes = (int)dtAllotTimes.AllotTimes;
                                ContestDll.Works drAllotTimes = dtAllotTimes;
                                drAllotTimes.WorksID    = worksId;
                                drAllotTimes.AllotTimes = allottimes + 1;
                                if (allottimes == allotNum - 1)
                                {
                                    drAllotTimes.WorksState = 2; //最后一次分配,将作品状态置为2:作品评分中
                                }
                                else
                                {
                                    drAllotTimes.WorksState = (int)drAllotTimes.WorksState;   //分配未完成,保持状态不变
                                }
                                DAL.Works.UpdateWorksAllotTimes(drAllotTimes);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 7
0
        public static long UpdateWorksInfo(ContestDll.Works dr)
        {
            using (ContestEntities db = new ContestEntities())
            {
                ContestDll.Works file = db.Works.SingleOrDefault(p => p.WorksID == dr.WorksID);
                file.WorksName     = dr.WorksName;
                file.WorksTypeID   = dr.WorksTypeID;
                file.WorksCode     = dr.WorksCode;
                file.PeriodID      = dr.PeriodID;
                file.SubmitProfile = dr.SubmitProfile;
                file.DesignIdeas   = dr.DesignIdeas;
                file.KeyPoints     = dr.KeyPoints;
                file.DemoURL       = dr.DemoURL;
                file.Created       = dr.Created;
                file.CreatedBy     = dr.CreatedBy;
                file.WorksState    = dr.WorksState;
                file.Score         = dr.Score;
                file.Flag          = dr.Flag;

                db.SaveChanges();
                return(1);
            }
        }