コード例 #1
0
        public Dictionary <Referee, bool> Search(IConnectionHandler connectionHandler, string txt, Guid pivotId, Guid congressId)
        {
            var predicateBuilder = new PredicateBuilder <Referee>();

            predicateBuilder.And(x => x.CongressId == congressId);
            if (!string.IsNullOrEmpty(txt))
            {
                var txtSearch = txt.ToLower();
                predicateBuilder.And((x => x.Username.Contains(txtSearch) || x.EnterpriseNode.RealEnterpriseNode.FirstName.Contains(txtSearch) || x.EnterpriseNode.RealEnterpriseNode.LastName.Contains(txtSearch) ||
                                      x.EnterpriseNode.RealEnterpriseNode.NationalCode.Contains(txtSearch) || x.EnterpriseNode.RealEnterpriseNode.IDNumber.Contains(txtSearch) || x.EnterpriseNode.Address.Contains(txtSearch) ||
                                      x.EnterpriseNode.Website.Contains(txtSearch) || x.EnterpriseNode.Email.Contains(txtSearch) || x.EnterpriseNode.Tel.Contains(txtSearch)));
            }
            var dictionary = new Dictionary <Referee, bool>();
            var byFilter   = new RefereePivotBO().Select(connectionHandler, x => x.RefereeId, x => x.PivotId == pivotId);
            var list       = new RefereeBO().Where(connectionHandler, predicateBuilder.GetExpression());

            foreach (var referee in list)
            {
                if (dictionary.Any(x => x.Key.Id == referee.Id))
                {
                    continue;
                }
                var added = byFilter.Any(x => x.Equals(referee.Id));
                dictionary.Add(referee, added);
            }
            return(dictionary);
        }
コード例 #2
0
        public IEnumerable <Tools.ModelView.ReportChartModel> ChartNumberArticleByReferee(
            IConnectionHandler connectionHandler, Guid congressId)
        {
            var models = new List <Tools.ModelView.ReportChartModel>();
            var list   = new RefereeCartableBO().GroupBy(connectionHandler,
                                                         new Expression <Func <RefereeCartable, object> >[] { c => c.RefereeId },
                                                         new GroupByModel <RefereeCartable>[]
            {
                new GroupByModel <RefereeCartable>()
                {
                    Expression           = c => c.ArticleId,
                    AggrigateFuntionType = AggrigateFuntionType.Count
                },
            }, c => c.Referee.CongressId == congressId);

            var refList = new RefereeBO().Select(connectionHandler,
                                                 new Expression <Func <Referee, object> >[]
            {
                x => x.Id,
                x =>
                x.EnterpriseNode.RealEnterpriseNode.FirstName + " " +
                x.EnterpriseNode.RealEnterpriseNode.LastName
            }, x => x.CongressId == congressId);

            foreach (var o in refList)
            {
                if (!(o.FirstNameAndLastName is string))
                {
                    continue;
                }
                var model = new Tools.ModelView.ReportChartModel {
                    Value = o.FirstNameAndLastName
                };
                var firstOrDefault = list.FirstOrDefault(x => x.RefereeId == o.Id);
                if (firstOrDefault != null && firstOrDefault.CountArticleId is int)
                {
                    model.Count = firstOrDefault.CountArticleId;
                }
                else
                {
                    model.Count = 0;
                }
                models.Add(model);
            }

            return(models);
        }
コード例 #3
0
ファイル: RefereeBO.cs プロジェクト: davoodkosari/Zibasazi
        public void InformRefereeAddArticle(IConnectionHandler connectionHandler, Guid congressId, ModelView.InFormEntitiyList <RefereeCartable> keyValuePairs)
        {
            if (!keyValuePairs.Any())
            {
                return;
            }
            var refereeBo = new RefereeBO();
            var arti      = keyValuePairs.FirstOrDefault();
            var referee   = refereeBo.Get(connectionHandler, arti.obj.RefereeId);
            var homa1     = new HomaBO().Get(connectionHandler, congressId);
            var articleBo = new ArticleBO();
            var config    = homa1.Configuration;

            if (config.RefereeInformType == null)
            {
                return;
            }
            CustomMessage custommessage = new CustomMessageBO().FirstOrDefault(connectionHandler, x => x.CongressId == congressId && x.Type == Enums.MessageInformType.RefereeArticle);

            foreach (var article in keyValuePairs)
            {
                var article1 = articleBo.Get(connectionHandler, article.obj.ArticleId);
                if (article1 == null)
                {
                    continue;
                }
                var name                       = referee.EnterpriseNode.DescriptionFieldWithGender;
                var homaCompleteUrl            = homa1.GetHomaCompleteUrl();
                var homaArticleRefereePanelUrl = homa1.GetHomaArticleRefereePanelUrl(article1.Id, referee.Id);
                var email                      = string.Format(article.EmailBody, homa1.CongressTitle, name, article1.Title, homaCompleteUrl, homaArticleRefereePanelUrl);
                var sms = string.Format(article.SmsBody, homa1.CongressTitle, name, article1.Code);

                if (custommessage != null)
                {
                    if (!string.IsNullOrEmpty(custommessage.EmailText))
                    {
                        email = custommessage.EmailText.Replace($"[{Enums.RefereeArticleMessageKey.FullName.ToString()}]", name);
                        email = email.Replace($"[{Enums.RefereeArticleMessageKey.Username.ToString()}]", referee.Username);
                        email = email.Replace($"[{Enums.RefereeArticleMessageKey.ArticleCode.ToString()}]", article1.Code.ToString());
                        email = email.Replace($"[{Enums.RefereeArticleMessageKey.ArticleTitle.ToString()}]", article1.Title);
                        email = email.Replace($"[{Enums.RefereeArticleMessageKey.CongressTitle.ToString()}]", homa1.CongressTitle);
                        email = email.Replace($"[{Enums.RefereeArticleMessageKey.CongressAddress.ToString()}]", homaCompleteUrl);
                    }
                    if (!string.IsNullOrEmpty(custommessage.SmsText))
                    {
                        sms = custommessage.SmsText.Replace($"[{Enums.RefereeArticleMessageKey.FullName.ToString()}]", name);
                        sms = sms.Replace($"[{Enums.RefereeArticleMessageKey.Username.ToString()}]", referee.Username);
                        sms = sms.Replace($"[{Enums.RefereeArticleMessageKey.ArticleCode.ToString()}]", article1.Code.ToString());
                        sms = sms.Replace($"[{Enums.RefereeArticleMessageKey.ArticleTitle.ToString()}]", article1.Title);
                        sms = sms.Replace($"[{Enums.RefereeArticleMessageKey.CongressTitle.ToString()}]", homa1.CongressTitle);
                        sms = sms.Replace($"[{Enums.RefereeArticleMessageKey.CongressAddress.ToString()}]", homaCompleteUrl);
                    }
                }


                var inform = new Message.Tools.ModelView.MessageModel()
                {
                    Email      = referee.EnterpriseNode.Email,
                    Mobile     = referee.EnterpriseNode.Cellphone,
                    EmailTitle = homa1.CongressTitle,
                    EmailBody  = email,
                    SMSBody    = sms
                };
                new HomaBO().SendInform((byte)config.RefereeInformType, inform, config, homa1.CongressTitle);
                MessageComponenet.SentInternalMessageInstance.MailBoxFacade.SendInternalMail(homa1.OwnerId, config.CongressId,
                                                                                             new[] { referee.EnterpriseNode.Id.ToString() }, homa1.CongressTitle, inform.SMSBody);
            }
        }
コード例 #4
0
ファイル: RefereeBO.cs プロジェクト: davoodkosari/Zibasazi
        internal Dictionary <Referee, List <string> > ImportFromExcel(IConnectionHandler connectionHandler, HttpPostedFileBase fileBase, Guid congressId)
        {
            try
            {
                var keyValuePairs = new Dictionary <Referee, List <string> >();
                if (fileBase == null)
                {
                    return(keyValuePairs);
                }
                var excelReader = ExcelReaderFactory.CreateOpenXmlReader(fileBase.InputStream);
                excelReader.IsFirstRowAsColumnNames = true;
                var result = excelReader.AsDataSet();
                if (result == null)
                {
                    return(keyValuePairs);
                }
                var refereeBo = new RefereeBO();
                foreach (DataTable table in result.Tables)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        var resultStatus = new List <string>();
                        var referee      = new Referee()
                        {
                            Id             = Guid.NewGuid(),
                            CongressId     = congressId,
                            EnterpriseNode =
                                new EnterpriseNode.DataStructure.EnterpriseNode()
                            {
                                RealEnterpriseNode = new RealEnterpriseNode()
                            }
                        };

                        if (string.IsNullOrEmpty(row[0].ToString()))
                        {
                            resultStatus.Add(Resources.Congress.PleaseEnterYourEmail);
                        }
                        else
                        {
                            referee.EnterpriseNode.Email = row[0].ToString();
                            referee.Username             = row[0].ToString();
                            if (!Utils.IsEmail(referee.EnterpriseNode.Email))
                            {
                                resultStatus.Add(Resources.Congress.UnValid_Enter_Email);
                            }
                            var byUserName = refereeBo.FirstOrDefault(connectionHandler, x => x.EnterpriseNode.Email == referee.EnterpriseNode.Email & x.CongressId == congressId);
                            if (byUserName != null)
                            {
                                resultStatus.Add(Resources.Congress.UserNameIsRepeate);
                                referee       = byUserName;
                                referee.State = Framework.ObjectState.Dirty;
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(referee.Username))
                                {
                                    referee.Password = StringUtils.HashPassword(referee.Username.Substring(0, 5));
                                }
                            }
                        }
                        if (string.IsNullOrEmpty(row[1].ToString()))
                        {
                            resultStatus.Add(Resources.Congress.Please_Enter_YourName);
                            referee.EnterpriseNode.RealEnterpriseNode.FirstName = string.Empty;
                        }
                        else
                        {
                            referee.EnterpriseNode.RealEnterpriseNode.FirstName = row[1].ToString();
                        }
                        if (string.IsNullOrEmpty(row[2].ToString()))
                        {
                            resultStatus.Add(Resources.Congress.Please_Enter_YourLastName);
                            referee.EnterpriseNode.RealEnterpriseNode.LastName = string.Empty;
                        }
                        else
                        {
                            referee.EnterpriseNode.RealEnterpriseNode.LastName = row[2].ToString();
                        }
                        if (string.IsNullOrEmpty(row[3].ToString()))
                        {
                            resultStatus.Add(Resources.Congress.Please_Enter_YourGender);
                            referee.EnterpriseNode.RealEnterpriseNode.Gender = null;
                        }
                        else
                        {
                            switch (row[3].ToString().ToLower())
                            {
                            case "men":
                            case "مرد":
                                referee.EnterpriseNode.RealEnterpriseNode.Gender = true;
                                break;

                            case "women":
                            case "زن":
                                referee.EnterpriseNode.RealEnterpriseNode.Gender = false;
                                break;

                            default:
                                referee.EnterpriseNode.RealEnterpriseNode.Gender = null;
                                break;
                            }
                        }
                        if (string.IsNullOrEmpty(row[4].ToString()))
                        {
                            resultStatus.Add(Resources.Congress.Please_Enter_YourMobile);
                            referee.EnterpriseNode.Cellphone = string.Empty;
                        }
                        else
                        {
                            referee.EnterpriseNode.Cellphone = row[4].ToString();
                        }

                        if (!string.IsNullOrEmpty(row[5].ToString()))
                        {
                            var NationalCode = row[5].ToString().ToLong();
                            var national     = string.Format("{0:D10}", NationalCode);
                            if (!Radyn.Utility.Utils.ValidNationalID(national))
                            {
                                resultStatus.Add("کد ملی صحیح نمیباشد");
                            }
                            else
                            {
                                referee.EnterpriseNode.RealEnterpriseNode.NationalCode = national;
                            }
                        }
                        else
                        {
                            referee.EnterpriseNode.RealEnterpriseNode.NationalCode = string.Empty;
                        }
                        referee.EnterpriseNode.Address = !string.IsNullOrEmpty(row[6].ToString()) ? row[6].ToString() : string.Empty;

                        keyValuePairs.Add(referee, resultStatus);
                    }
                }
                return(keyValuePairs);
            }
            catch (KnownException ex)
            {
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex);
            }
        }
コード例 #5
0
        public bool AnswerArticle(IConnectionHandler connectionHandler, IConnectionHandler filemanagerconnection, Guid congressId,
                                  RefereeCartable refereeCartable, Guid answeredrefreeId, string comments,
                                  HttpPostedFileBase attachment)
        {
            var articleBo     = new ArticleBO();
            var articleFlowBo = new ArticleFlowBO();
            var config        = new ConfigurationBO().ValidConfig(connectionHandler, congressId);
            var refree        = new RefereeBO().Get(connectionHandler, answeredrefreeId);


            if (!this.ModifyCartabl(connectionHandler, refereeCartable.ArticleId, answeredrefreeId,
                                    refereeCartable.Status, refereeCartable.Visited, false))
            {
                return(false);
            }

            var article = articleBo.Get(connectionHandler, refereeCartable.ArticleId);

            article.FinalState = (byte)Enums.FinalState.WaitForAnswer;
            if (config.SentArticleSpecialReferee)
            {
                article.Status = refree.IsSpecial
                    ? (byte)Enums.ArticleState.WaitForScientificTeacher
                    : (byte)Enums.ArticleState.WaitforSpecialRefereeOpinion;
            }
            else
            {
                article.Status = (byte)Enums.ArticleState.WaitForScientificTeacher;
            }

            if (!articleBo.Update(connectionHandler, article))
            {
                throw new Exception(string.Format(Resources.Congress.ErrorInEditArticleCongress, Extention.GetAtricleTitle(article.CongressId)));
            }

            var lastSenderId = new ArticleFlowBO().SelectFirstOrDefault(connectionHandler, x => x.SenderId,
                                                                        x => x.ReceiverId == answeredrefreeId && x.ArticleId == article.Id,
                                                                        new OrderByModel <ArticleFlow>()
            {
                Expression = x => x.SaveDate + "" + x.SaveTime,
                OrderType  = OrderType.DESC
            });


            var lastrefree = new RefereeBO().Get(connectionHandler, lastSenderId);

            if (lastrefree != null && lastrefree.IsSpecial)
            {
                var lastrefereeCartable = new RefereeCartable();
                lastrefereeCartable = this.FirstOrDefaultWithOrderByDescending(connectionHandler, x => x.InsertDate,
                                                                               x => x.ArticleId == article.Id && x.RefereeId == lastrefree.Id);

                if (lastrefereeCartable != null)
                {
                    if (!this.ModifyCartabl(connectionHandler, lastrefereeCartable.ArticleId, lastSenderId,
                                            (byte)Enums.FinalState.RefereeAnswered, lastrefereeCartable.Visited, false))
                    {
                        return(false);
                    }
                }
                else
                {
                    if (!this.ModifyCartabl(connectionHandler, article.Id, lastSenderId, (byte)Enums.FinalState.WaitForAnswer, false, true))
                    {
                        return(false);
                    }
                }

                if (!articleFlowBo.AddFlow(connectionHandler, filemanagerconnection, answeredrefreeId, lastSenderId != Guid.Empty ? lastSenderId : (Guid?)null, refereeCartable.ArticleId,
                                           refereeCartable.Status, comments, attachment))
                {
                    return(false);
                }
            }
            else
            {
                var articleFlow =
                    articleFlowBo.FirstOrDefaultWithOrderBy(connectionHandler, x => x.SaveDate + " " + x.SaveTime,
                                                            x => x.ArticleId == refereeCartable.ArticleId && x.ReceiverId == answeredrefreeId);
                var senderId = articleFlow != null ? articleFlow.SenderId : (Guid?)null;
                if (!articleFlowBo.AddFlow(connectionHandler, filemanagerconnection, answeredrefreeId, senderId,
                                           refereeCartable.ArticleId, refereeCartable.Status, comments, attachment))
                {
                    return(false);
                }
            }

            return(true);
        }