Пример #1
0
 public override void process()
 {
     using (WebCBEntities entity = WebCBEntitiesFactory.CreateWebEntitie()) {
         NLog.LogManager.GetCurrentClassLogger().Error("sasdasdasd");
         Console.WriteLine("asdfasdf2");
     }
 }
Пример #2
0
        public override void process()
        {
            List <EvaluateArticle> list = new List <EvaluateArticle>();
            var cbEntity = WebCBEntitiesFactory.CreateWebEntitie();
            var datas    = (from pne in cbEntity.pub_newsofweibo.Where(p => !p.synch && p.commitDate.HasValue)
                            select new
            {
                Id = pne.id,
                userId = pne.userid,
                cbNewsId = pne.sourceId,
                strAuthorId = "",
                pne.content,
                txtContent = pne.content,
                title = pne.content,
                pageview = 0,
                evaluateCategoryId = 0,
                articleType = 4,
                publishDate = pne.commitDate.Value,
                fromWhere = pne.fromwhere,
                pne.fabulousNumber,
                pne.forwardsNumber,
                pne.commentsNumber,
                pne.disseminationNumber,
                ReprintChannelNumber = 0,
                ReprintChannelTime = 0,
                ReprintMediaNumber = 0,
                ReprintNumber = 0,
                ReadingNumber = 0
            }).Union(
                from pn in cbEntity.pub_newsofweixin.Where(p => !p.synch && p.commitDate.HasValue && p.txtContent != null)
                select new
            {
                Id          = pn.id,
                userId      = pn.userid,
                cbNewsId    = pn.fromNewsId,
                strAuthorId = pn.strAuthorId,
                pn.content,
                pn.txtContent,
                pn.title,
                pageview            = 0,
                evaluateCategoryId  = pn.evaluateCategoryId,
                articleType         = 3,
                publishDate         = pn.commitDate.Value,
                fromWhere           = pn.strAuthor,
                fabulousNumber      = 0,
                forwardsNumber      = 0,
                commentsNumber      = 0,
                disseminationNumber = pn.DisseminationNumber,
                pn.ReprintChannelNumber,
                pn.ReprintChannelTime,
                pn.ReprintMediaNumber,
                pn.ReprintNumber,
                pn.ReadingNumber
            }).Union(from pne in cbEntity.pub_newsofwebsite.Where(p => !p.synch && p.commitDate.HasValue)
                     select new
            {
                Id          = pne.id,
                userId      = pne.userid,
                cbNewsId    = pne.sourceId,
                strAuthorId = "",
                pne.content,
                txtContent          = pne.txtContent,
                title               = pne.title,
                pageview            = 0,
                evaluateCategoryId  = 0,
                articleType         = 1,
                publishDate         = pne.commitDate.Value,
                fromWhere           = pne.fromwhere,
                fabulousNumber      = 0,
                forwardsNumber      = 0,
                commentsNumber      = 0,
                disseminationNumber = pne.DisseminationNumber,
                pne.ReprintChannelNumber,
                pne.ReprintChannelTime,
                pne.ReprintMediaNumber,
                pne.ReprintNumber,
                pne.ReadingNumber
            });

            foreach (var data in datas)
            {
                var authorIds = data.strAuthorId.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(p => int.Parse(p));
                var authors   = cbEntity.v_user_info.Where(p => authorIds.Contains(p.userid) && p.typeId == 0).Select(p => new Author
                {
                    authorId       = p.userid,
                    authorName     = p.realname,
                    departmentId   = p.departmentId ?? 0,
                    departmentName = p.departmentName
                }).ToArray();
                var kv = cbEntity.sys_dictionary.SingleOrDefault(p => p.id == data.evaluateCategoryId);
                var evaluateCategoryName = "";
                if (kv == null)
                {
                    NLog.LogManager.GetCurrentClassLogger().Error(string.Format("稿件分类未在字典中找到值,字典Id:{0},稿件Id:{1}", data.evaluateCategoryId, data.Id));
                }
                else
                {
                    evaluateCategoryName = kv.keyValue;
                }
                var art = new EvaluateArticle
                {
                    id                   = data.Id,
                    cbNewsId             = data.cbNewsId,
                    txtContent           = data.txtContent,
                    title                = data.title,
                    pageView             = data.pageview,
                    evaluateCategoryId   = data.evaluateCategoryId,
                    evaluateCategoryName = evaluateCategoryName,
                    articleType          = data.articleType,
                    authors              = authors,
                    hasPic               = regImg.Matches(data.content).Count > 0,
                    hasAudio             = regAudio.Matches(data.content).Count > 0,
                    hasVedio             = regVideo.Matches(data.content).Count > 0,
                    publishDate          = new DateTime(data.publishDate.Year, data.publishDate.Month, data.publishDate.Day),
                    paperId              = GetPaperId(data.fromWhere),
                    fromWhere            = data.fromWhere,
                    disseminationNumber  = data.disseminationNumber,
                    commentsNumber       = data.commentsNumber,
                    fabulousNumber       = data.fabulousNumber,
                    forwardsNumber       = data.forwardsNumber,
                    ReadingNumber        = data.ReadingNumber,
                    ReprintChannelNumber = data.ReprintChannelNumber,
                    ReprintChannelTime   = data.ReprintChannelTime,
                    ReprintMediaNumber   = data.ReprintMediaNumber,
                    ReprintNumber        = data.ReprintNumber
                };
                art.baseScore = 0;
                list.Add(art);
            }
            cbEntity.Dispose();
            List <Tuple <int, int> > synchIds = new List <Tuple <int, int> >();

            using (RemunerationEntities entity = RemunerationEntities.Create())
            {
                foreach (var a in list)
                {
                    synchIds.Add(new Tuple <int, int>(a.id, a.articleType));
                    if (entity.art_article.Count(p => p.matchFromCB == a.id && p.publishType == a.articleType) > 0)
                    {
                        continue;
                    }
                    using (var tran = new TransactionScope())
                    {
                        //var fromType = fromWhere[a.fromWhere];
                        var fromType = 0;
                        Remuneration.Dal.cb_news news = null;
                        if (a.cbNewsId > 0)
                        {
                            news = (from n in entity.cb_news.Where(p => p.cbNewsId == a.cbNewsId && p.fromType == fromType)
                                    join art in entity.art_article.Where(p => p.picCount == 0)
                                    on n.id equals art.newsId
                                    select n).FirstOrDefault();
                        }
                        var strtitle = a.title;
                        if (strtitle.Length > 30)
                        {
                            strtitle = strtitle.Substring(0, 30);
                        }

                        if (news == null)
                        {
                            news = new Remuneration.Dal.cb_news()
                            {
                                cbNewsId          = a.cbNewsId,
                                fromType          = fromType,
                                title             = strtitle,
                                publishDate       = a.publishDate,
                                setDate           = DateTime.Now,
                                hasEvaluate       = false,
                                paperId           = a.paperId,
                                baseScore         = 0,
                                otherPlaceScale   = 0,
                                isHolidy          = false,
                                specialScore      = 0,
                                transmissionScore = 0,
                                score             = 0,
                                flowRecord        = "",
                                evaluateContent   = "",
                                affiliatedScore   = ""
                            };
                            entity.cb_news.Add(news);
                            entity.SaveChanges();
                        }
                        else
                        {
                            news.hasEvaluate = false;
                        }
                        #region 保存art_article
                        entity.art_article.Add(new art_article
                        {
                            leadTitle          = "",
                            title              = strtitle,
                            subTitle           = "",
                            txtContent         = a.txtContent,
                            wordCount          = a.txtContent.Length,
                            author             = string.Join(",", a.authors.Select(p => p.authorName)),
                            authorIds          = string.Join(",", a.authors.Select(p => p.authorId)),
                            departmentIds      = string.Join(",", a.authors.Select(p => p.departmentId)),
                            departmentNames    = string.Join(",", a.authors.Select(p => p.departmentName)),
                            picCount           = 0,
                            publishDate        = a.publishDate,
                            coordinate         = "",
                            verOfPagePicWidth  = 0,
                            verOfPagePicHeight = 0,
                            verOfPagePicPath   = "",
                            picPath            = "",
                            setdate            = DateTime.Now,
                            paperId            = a.paperId,
                            paperName          = "",
                            verOfPageId        = 0,
                            verOfPageName      = "",
                            orderOfPageId      = 0,
                            orderOfPageName    = "",
                            stat                 = 0,
                            auditUserId          = 0,
                            auditUserName        = "",
                            auditDate            = null,
                            categoryId           = a.evaluateCategoryId,
                            categoryName         = a.evaluateCategoryName,
                            editer               = "",
                            setLevelUserId       = 0,
                            setLevelUserName     = "",
                            levelId              = 0,
                            levelName            = "",
                            sendType             = "",
                            unit                 = "",
                            salary               = 0,
                            remark               = a.fromWhere,
                            flowRecord           = "",
                            isBackToUpdate       = 0,
                            patchNewsTypeId      = 0,
                            baseScore            = a.baseScore,
                            score                = 0,
                            otherPlace           = 0,
                            otherPlaceScore      = 0,
                            holidy               = 0,
                            holidyScore          = 0,
                            other                = 0,
                            otherScore           = 0,
                            specialScore         = 0,
                            transmissionQuantity = a.pageView,
                            transmissionScore    = 0,
                            evaluateContent      = "",
                            matchFromCB          = a.id,
                            publishType          = a.articleType,
                            hasPic               = a.hasPic,
                            hasAudio             = a.hasAudio,
                            hasVedio             = a.hasVedio,
                            @abstract            = "",
                            newsId               = news.id,
                            levelScore           = 0,
                            forwardsNumber       = a.forwardsNumber,
                            fabulousNumber       = a.fabulousNumber,
                            commentsNumber       = a.commentsNumber,
                            disseminationNumber  = a.disseminationNumber,
                            ReprintNumber        = a.ReprintNumber,
                            ReprintMediaNumber   = a.ReprintMediaNumber,
                            ReadingNumber        = a.ReadingNumber,
                            ReprintChannelNumber = a.ReprintChannelNumber,
                            ReprintChannelTime   = a.ReprintChannelTime
                        });
                        #endregion
                        foreach (var author in a.authors)
                        {
                            if (entity.cb_author.Count(p => p.newsId == news.id && p.authorId == author.authorId && p.typeSign == 0) > 0)
                            {
                                continue;
                            }
                            entity.cb_author.Add(new cb_author
                            {
                                newsId          = news.id,
                                authorId        = author.authorId,
                                typeSign        = 0,
                                authorName      = author.authorName,
                                coefficient     = 0,
                                scoreScale      = 0,
                                score           = 0,
                                salary          = 0,
                                ymd             = int.Parse(a.publishDate.ToString("yyyyMM")),
                                paperId         = a.paperId,
                                affiliatedScore = ""
                            });
                        }
                        entity.SaveChanges();
                        tran.Complete();
                        System.Threading.Thread.Sleep(50);
                    }
                }
            }
            using (cbEntity = WebCBEntitiesFactory.CreateWebEntitie())
            {
                foreach (var data in synchIds)
                {
                    switch (data.Item2)
                    {
                    case 1:
                    {
                        var pne = cbEntity.pub_newsofwebsite.SingleOrDefault(p => p.id == data.Item1);
                        if (pne != null)
                        {
                            pne.synch = true;
                        }
                        break;
                    }

                    case 2:
                    {
                        var pne = cbEntity.pub_newsofapp_evaluate.SingleOrDefault(p => p.Id == data.Item1);
                        if (pne != null)
                        {
                            pne.synch = true;
                        }
                        break;
                    }

                    case 3:
                    {
                        var pne = cbEntity.pub_newsofweixin.SingleOrDefault(p => p.id == data.Item1);
                        if (pne != null)
                        {
                            pne.synch = true;
                        }
                        break;
                    }

                    case 4:
                    {
                        var pne = cbEntity.pub_newsofweibo.SingleOrDefault(p => p.id == data.Item1);
                        if (pne != null)
                        {
                            pne.synch = true;
                        }
                        break;
                    }

                    default:
                        break;
                    }
                }
                cbEntity.SaveChanges();
            }
            Console.WriteLine("Finish");
        }
 public override void process()
 {
     using (RemunerationEntities entity = RemunerationEntities.Create())
     {
         var depts    = entity.sys_assessmentDepartment.GroupBy(p => p.paperId).Select(p => new { paperId = p.Key, departmentIds = p.Select(d => d.departmentId) }).ToArray();
         var postions = entity.sys_user_position.ToArray();
         foreach (var dept in depts)
         {
             var cbEntity = WebCBEntitiesFactory.CreateWebEntitie();
             var users    = (from u in cbEntity.v_user_info.Where(p => dept.departmentIds.Contains(p.departmentId.Value) && p.deleted == 0).ToArray()
                             join p in postions
                             on u.userid equals p.userId into Postions
                             from p in Postions.DefaultIfEmpty()
                             select new { user = u, positionId = p == null ? 0 : p.positionId, postionName = p == null ? "" : p.positionName }).ToArray();
             cbEntity.Dispose();
             int ymd = int.Parse(DateTime.Now.ToString("yyyyMM"));
             foreach (var user in users)
             {
                 var item = entity.rpt_authorEvaluateScoreList.SingleOrDefault(p => p.authorId == user.user.userid && p.ymd == ymd && p.paperId == dept.paperId);
                 if (item == null)
                 {
                     entity.rpt_authorEvaluateScoreList.Add(new rpt_authorEvaluateScoreList
                     {
                         authorId              = user.user.userid,
                         authorName            = user.user.realname,
                         departmentId          = user.user.departmentId.Value,
                         departmentName        = user.user.departmentName,
                         positionId            = user.positionId,
                         positionName          = user.postionName,
                         ymd                   = ymd,
                         score                 = 0,
                         achievementsSalary    = 0,
                         circumstancesScore    = 0,
                         levelId               = 0,
                         levelName             = "",
                         finishVerOfPageNum    = 0,
                         finishVerOfPageSalary = 0,
                         finishVerOfPageScore  = 0,
                         departmentTotalSalary = 0,
                         departmentSalary      = 0,
                         departmentPeopleNum   = 0,
                         paperId               = dept.paperId,
                         assessmentSalary      = 0,
                         addSalary             = 0,
                         vacationSalary        = 0,
                         workSalary            = 0,
                         totalAmount           = 0,
                         addRemark             = "",
                         fixedAmount           = 0,
                         noJoinAssessment      = 0
                     });
                     entity.SaveChanges();
                 }
                 if (user.positionId == DirectorPositionId && entity.sys_user_noJoinAssessment.Count(p => p.userId == user.user.userid && p.ymd == ymd) == 0)
                 {
                     entity.sys_user_noJoinAssessment.Add(new sys_user_noJoinAssessment
                     {
                         userId = user.user.userid,
                         ymd    = ymd
                     });
                     entity.SaveChanges();
                 }
             }
         }
     }
 }