//public List<T> GetArticleListByFilter<T>(string appId, string strCateSub, string keywords, PageCondition con) where T : IViewModel, new()
        //{
        //    StringBuilder sb = new StringBuilder();
        //    sb.AppendFormat("SELECT * FROM ArticleInfo WHERE 1=1 AND ArticleStatus Like '{0}'", ConstData.STATUS_PUBLISH);
        //    if (!string.IsNullOrEmpty(appId))
        //    {
        //        int appid;
        //        if (int.TryParse(appId, out appid))
        //        {
        //            sb.AppendFormat(" AND AppId={0}", appid);
        //        }
        //    }

        //    if (!string.IsNullOrEmpty(strCateSub))
        //    {
        //        int cate;
        //        if (int.TryParse(strCateSub, out cate))
        //        {
        //            sb.AppendFormat(" AND CategoryId={0}", cate);
        //        }
        //    }

        //    if (!string.IsNullOrEmpty(keywords))
        //    {
        //        keywords = keywords.Trim();
        //        var keys = keywords.Split(' ');
        //        if (keys.Length > 0)
        //        {
        //            string filter = string.Empty;
        //            foreach (var key in keys)
        //            {
        //                filter += string.Format(" ArticleTitle LIKE N'%{0}%' OR ArticleContent LIKE N'%{0}%' OR", key);
        //            }
        //            sb.AppendFormat(" AND ({0})", filter.TrimEnd('O', 'R'));
        //        }
        //    }

        //    sb.Append(" ORDER BY CreatedDate DESC, Id DESC");

        //    var source = this.Repository.SqlQuery(sb.ToString());

        //    if (con.SortConditions == null || con.SortConditions.Count == 0)
        //    {
        //        source = source.OrderByDescending(a => a.Id);
        //    }
        //    else
        //    {
        //        int count = 0;
        //        dynamic orderSource = null;
        //        foreach (SortCondition sortCondition in con.SortConditions)
        //        {
        //            orderSource = count == 0
        //                ? CollectionPropertySorter<ArticleInfo>.OrderBy(source, sortCondition.SortField, sortCondition.ListSortDirection)
        //                : CollectionPropertySorter<ArticleInfo>.ThenBy(orderSource, sortCondition.SortField, sortCondition.ListSortDirection);
        //            count++;
        //        }
        //        source = orderSource;
        //    }
        //    con.RowCount = source.ToList().Count;
        //    var lst = source != null
        //       ? source.Skip((con.PageIndex - 1) * con.PageSize).Take(con.PageSize)
        //       : Enumerable.Empty<ArticleInfo>();

        //    return lst.ToList().Select(n => (T)(new T().ConvertAPIModel(n))).ToList();
        //}



        public bool CheckMessagePushRule(int appId, int AccountMangageID, IList <int> selectedDepartmentIds, IList <int> selectedTagIds, IList <string> selectedWeChatUserIDs, out CheckResult checkResult, bool isToAllUsers)
        {
            checkResult = new CheckResult();
            var appInfo = WeChatCommonService.GetAppInfo(appId);

            IList <string> allAssignedUsers;

            if (!CheckVisualRange(AccountMangageID, appInfo, out allAssignedUsers, () => GenerateTagInfoDictionary(appInfo)))
            {
                checkResult.ErrorUsers       = selectedWeChatUserIDs;
                checkResult.ErrorDepartments = GetErrorDepartments(selectedDepartmentIds, AccountMangageID);
                //checkResult.ErrorTags = GetErrorDepartments(selectedTagIds);
                return(false);
            }

            if (isToAllUsers)
            {
                return(CheckUser(AccountMangageID, allAssignedUsers, selectedWeChatUserIDs, checkResult));
            }

            var isDepartmentPass = CheckDepartment(appInfo, selectedDepartmentIds, checkResult, AccountMangageID);

            //var isTagPass = CheckTag(appInfo, selectedTagIds, allAssignedUsers, checkResult);

            var isUserPass = CheckUser(AccountMangageID, allAssignedUsers, selectedWeChatUserIDs, checkResult);

            return(isDepartmentPass && isUserPass);
        }
예제 #2
0
        public void GetSubDepartments()
        {
            var appInfo = WeChatCommonService.GetAppInfo(14);

            if (!appInfo.allow_partys.partyid.Any())
            {
                return;
            }

            var departments = WeChatCommonService.GetSubDepartments(appInfo.allow_partys.partyid);

            Assert.IsTrue(departments.Count() == 5);
        }
예제 #3
0
        public Result <object> PushCheck(TargetInfoObject entity, int appId, ContentType contentType)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            if (appId < 0)
            {
                throw new ArgumentException("appId");
            }

            var result = new Result <object>
            {
                Status = 200,
            };

            var history = new PushHistoryEntity
            {
                ContentId   = entity.ContentId,
                AppId       = appId,
                ContentType = contentType.ToString(),
                TargetType  = entity.IsToAllUsers ? TargetType.AllUser.ToString() : TargetType.Config.ToString()
            };

            _pushHistoryService.Repository.Insert(history);

            result.Data = history.Id;

            if (entity.IsToAllUsers)
            {
                return(result);
            }

            var appInfo = WeChatCommonService.GetAppInfo(appId);

            var verifyResult = _pushFacadeService.Verify(new ConfigedInfo(appInfo), entity, contentType);

            var passPart = verifyResult.Data.Success;

            //string.Join(",", passPart.ToDepartments.Select(JsonHelper.ToJson)) string.Join(",", passPart.ToTags.Select(JsonHelper.ToJson))
            history.ToDepartments = (passPart.ToDepartments != null && passPart.ToDepartments.Any()) ? JsonHelper.ToJson(passPart.ToDepartments) : null;
            history.ToTags        = passPart.ToTags != null?JsonHelper.ToJson(passPart.ToTags) : null;

            history.ToUsers = passPart.ToUsers != null?string.Join("|", passPart.ToUsers) : null;

            //updated
            _pushHistoryService.Repository.Update(history, new List <string> {
                "ToDepartments", "ToTags", "ToUsers"
            });

            if (verifyResult.Status == 200)
            {
                return(result);
            }

            result.Status = verifyResult.Status;

            var errorResult = verifyResult.Data.Error;

            _historyDetailService.Repository.Insert(new PushHistoryDetailEntity
            {
                HistoryId        = history.Id,
                ErrorDepartments = errorResult.ErrorDepartments != null ? JsonHelper.ToJson(errorResult.ErrorDepartments) : null,
                ErrorTags        = errorResult.ErrorTags != null ? JsonHelper.ToJson(errorResult.ErrorTags) : null,
                ErrorUsers       = errorResult.ErrorUsers != null ? string.Join("|", errorResult.ErrorUsers) : null,
                ErrorType        = ErrorType.Checked.ToString(),
            });

            return(result);
        }