/// <summary>
        /// <see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/>
        /// </summary>
        /// <param name="pagedCriteria"><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></param>
        /// <returns><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></returns>
        public List <Country> GetPagedCountries(PagedCriteria pagedCriteria)
        {
            try
            {
                //Resolve root dependencies and perform operations
                using (ICustomerManagementService customerService = IoCFactory.Instance.CurrentContainer.Resolve <ICustomerManagementService>())
                {
                    return(customerService.FindPagedCountries(pagedCriteria.PageIndex, pagedCriteria.PageCount));
                }
            }
            catch (ArgumentException ex)
            {
                //trace data for internal health system and return specific FaultException here!
                //Log and throw is a knowed anti-pattern but in this point ( entry point for clients this is admited!)

                //log exception for manage health system
                ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>();
                traceManager.TraceError(ex.Message);

                //propagate exception to client
                ServiceError detailedError = new ServiceError()
                {
                    ErrorMessage = Resources.Messages.exception_InvalidArguments
                };

                throw new FaultException <ServiceError>(detailedError);
            }
        }
        private IInfoList GetList(string filter, int pageNumber, int pageSize,
                               SortList sortColumns, string filterExpresion,
                               bool notCalculateAccessDeniedList)
        {
            var methodName = string.Format(CultureInfo.InvariantCulture, "Get{0}List", _currentProcessSystemName);

            try
            {
                var listType = _loadedAssembly.GetType(string.Format(CultureInfo.InvariantCulture, "Dynamic{0}.{0}List", _currentProcessSystemName), true);
                var criteria = new PagedCriteria
                                   {
                                       Filter = filter,
                                       PageNumber = pageNumber,
                                       PageSize = pageSize,
                                       SortColumns = sortColumns,
                                       FilterDefinition = filterExpresion,
                                       NotCalculateAccessDeniedList = notCalculateAccessDeniedList,
                                       LoadAllLocalizations = true,
                                       LoadRichText = true
                                   };

                var result = (IInfoList)MethodCaller.CallFactoryMethod(listType, methodName, criteria);

                return result;
            }
            catch (Exception ex)
            {
                throw new ApplicationException(
                    string.Format(
                    CultureInfo.InvariantCulture,
                        "Global Search Exception : AppDomain/ problem on Getting ElementsList {0} process  /Filter : {1}/PageNumber : {2}/PageSize {3}/FilterExpresion : {4}/",
                        _currentProcessSystemName, filter, pageNumber, pageSize, filterExpresion), ex);
            }
        }
        /// <summary>
        /// <see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/>
        /// </summary>
        /// <param name="pagedCriteria"><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></param>
        /// <returns><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></returns>
        public List <BankTransfer> GetPagedTransfers(PagedCriteria pagedCriteria)
        {
            try
            {
                using (IBankingManagementService bankingManagement = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>())
                {
                    return(bankingManagement.FindBankTransfers(pagedCriteria.PageIndex, pagedCriteria.PageCount));
                }
            }
            catch (ArgumentException ex)
            {
                //trace data for internal health system and return specific FaultException here!
                //Log and throw is a knowed anti-pattern but in this point ( entry point for clients this is admited!)

                //log exception for manage health system
                ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>();
                traceManager.TraceError(ex.Message);

                //propagate bussines exception to client
                ServiceError detailedError = new ServiceError()
                {
                    ErrorMessage = Resources.Messages.exception_InvalidArguments
                };

                throw new FaultException <ServiceError>(detailedError);
            }
        }
Beispiel #4
0
 private void ApplyPageNumberLogic(PagedCriteria criteria)
 {
     if (criteria.PageNumber == 0)
     {
         criteria.PageNumber = 1;
     }
 }
Beispiel #5
0
        public PagedResponse Search(PagedCriteria criteria)
        {
            ApplyCriteriaLogic(criteria);
            var posts = criteria.Posts.Where(p => p.IsActive == criteria.IsActive).OrderByDescending(p => p.PostDate);

            var query = posts.Where(p =>
                                    p.Title.ToLower().Contains(criteria.SearchCriteria.ToLower()) ||
                                    p.Snippet.ToLower().Contains(criteria.SearchCriteria.ToLower()) ||
                                    BlogContextManager.PostHtmlList.Where(h => h.Link.ToLower() == p.Link.ToLower() && h.Hmtl.Contains(criteria.SearchCriteria)).Count() > 0
                                    );

            if (query.ToList().Count > 0)
            {
                var results = posts.Where(p =>
                                          p.Title.ToLower().Contains(criteria.SearchCriteria.ToLower()) ||
                                          p.Snippet.ToLower().Contains(criteria.SearchCriteria.ToLower()) ||
                                          BlogContextManager.PostHtmlList.Where(h => h.Link.ToLower() == p.Link.ToLower() && h.Hmtl.Contains(criteria.SearchCriteria)).Count() > 0)
                              .Skip(_skip).Take(criteria.PageSize).OrderByDescending(p => p.PostDate);

                return(new PagedResponse()
                {
                    Total = query.ToList().Count(), Posts = results.ToList()
                });
            }
            else
            {
                return(new PagedResponse()
                {
                    Total = 0, Posts = null
                });
            }
        }
Beispiel #6
0
        public PagedResponse GetByTag(PagedCriteria criteria)
        {
            ApplyCriteriaLogic(criteria);
            var posts = criteria.Posts.Where(p => p.IsActive == criteria.IsActive).OrderByDescending(p => p.PostDate);

            var query = posts.Where(p =>
                                    p.Tags.Any(c => c.Name.ToLower().Trim() == criteria.SearchCriteria.ToLower().Trim())
                                    );

            if (query.ToList().Count > 0)
            {
                var results = posts.Where(p =>
                                          p.Tags.Any(c => c.Name.ToLower().Trim() == criteria.SearchCriteria.ToLower().Trim()))
                              .Skip(_skip).Take(criteria.PageSize).OrderByDescending(p => p.PostDate);

                return(new PagedResponse()
                {
                    Total = query.ToList().Count(), Posts = results.ToList()
                });
            }
            else
            {
                return(new PagedResponse()
                {
                    Total = 0, Posts = null
                });
            }
        }
Beispiel #7
0
        public PagedResponse GetAlsoOn(PagedCriteria criteria)
        {
            var posts = criteria.Posts.Where(p => p.IsActive == criteria.IsActive).OrderBy(p => p.PostDate);

            var post = posts.Where(p => p.Id == criteria.SearchCriteriaInt).SingleOrDefault();

            if (post != null)
            {
                var query = posts.Where(p => p.PostDate > post.PostDate && p.Id != criteria.SearchCriteriaInt).Take(2);
                if (query.ToList().Count >= 2)
                {
                    return new PagedResponse()
                           {
                               Total = query.ToList().Count(), Posts = query.ToList()
                           }
                }
                ;
                else
                {
                    return new PagedResponse()
                           {
                               Total = 0, Posts = null
                           }
                };
            }
            else
            {
                return(new PagedResponse()
                {
                    Total = 0, Posts = null
                });
            }
        }
Beispiel #8
0
        public PagedResponse GetByMonthAndYear(PagedCriteria criteria)
        {
            ApplyCriteriaLogic(criteria);
            var posts = criteria.Posts.Where(p => p.IsActive == criteria.IsActive).OrderByDescending(p => p.PostDate);

            var query = posts.Where(p =>
                                    p.PostDate.Month == criteria.MonthCriteria && p.PostDate.Year == criteria.YearCriteria
                                    );

            if (query.ToList().Count > 0)
            {
                var results = posts.Where(p =>
                                          p.PostDate.Month == criteria.MonthCriteria && p.PostDate.Year == criteria.YearCriteria)
                              .Skip(_skip).Take(criteria.PageSize).OrderByDescending(p => p.PostDate);

                return(new PagedResponse()
                {
                    Total = query.ToList().Count(), Posts = results.ToList(), ArchiveYear = criteria.YearCriteria, ArchiveMonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(criteria.MonthCriteria)
                });
            }
            else
            {
                return(new PagedResponse()
                {
                    Total = 0, Posts = null
                });
            }
        }
Beispiel #9
0
        public PagedResponse Get(PagedCriteria criteria)
        {
            ApplyCriteriaLogic(criteria);
            var posts = criteria.Posts.Where(p => p.IsActive == criteria.IsActive).OrderByDescending(p => p.PostDate);

            return(new PagedResponse()
            {
                Total = posts.Count(),
                Posts = posts.Skip(_skip).Take(criteria.PageSize).OrderByDescending(p => p.PostDate)
            });
        }
        /// <summary>
        /// <see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/>
        /// </summary>
        ///<param name="pagedCriteria"><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></param>
        /// <returns><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></returns>
        public List <BankAccount> GetPagedBankAccounts(PagedCriteria pagedCriteria)
        {
            try
            {
                //Resolve root dependency and perform operation

                IBankingManagementService bankingManagement = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>();

                List <BankAccount> bankAccounts = null;

                //perform work!
                bankAccounts = bankingManagement.FindPagedBankAccounts(pagedCriteria.PageIndex, pagedCriteria.PageCount);

                return(bankAccounts);
            }
            catch (ArgumentException ex)
            {
                //trace data for internal health system and return specific FaultException here!
                //Log and throw is a knowed anti-pattern but in this point ( entry point for clients this is admited!)

                //log exception for manage health system
                ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>();
                traceManager.TraceError(ex.Message);

                //propagate exception to client
                ServiceError detailedError = new ServiceError()
                {
                    ErrorMessage = Resources.Messages.exception_InvalidArguments
                };

                throw new FaultException <ServiceError>(detailedError);
            }
            catch (NullReferenceException ex)
            {
                //trace data for internal health system and return specific FaultException here!
                //Log and throw is a knowed anti-pattern but in this point ( entry point for clients this is admited!)

                //log exception for manage health system
                ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>();
                traceManager.TraceError(ex.Message);

                //propagate exception to client
                ServiceError detailedError = new ServiceError()
                {
                    ErrorMessage = Resources.Messages.exception_InvalidArguments
                };

                throw new FaultException <ServiceError>(detailedError);
            }
        }
        public async Task <IActionResult> Orders([FromQuery, Validator] PagedCriteria criteria)
        {
            //在正式项目中不建议暴露领域对象,建议加入Application层,用于协调WebApi与领域对象
            var result = await _repositoryBase.Tables()
                         .OrderByCreatedTime()
                         .Select(x => new //在正式项目中应创建DTO对象来进行映射,可使用automapper组件
            {
                OrderId     = x.Id,
                PaymentType = x.PaymentMethod.PaymentType.Name,
                x.CreatedTime,
                x.Address,
                Buyer = x.Buyer.Name,
                Item  = x.OrderItems.Select(o => new { o.ProductId, o.ProductName, o.ProductCount, o.ProductPrice })
            })
                         .ToPageResult(criteria.PageIndex, criteria.PageSize);

            return(Success(result));
        }
        private IInfoList<IInfoClass> GetSourceItems(FilterList filters)
        {
            var criteria = new PagedCriteria
                               {
                                   ProcessName = SourceDataProcessName,
                                   FilterDefinition = FilterDescriptor.GetFilterExpression(filters),
                                   PageNumber = 0,
                                   PageSize = int.MaxValue,
                                   LimitResultColumns = true,
                                   ResultColumns = new MobileList<string> { Constants.IdColumnName },
                                   NotCalculateAccessDeniedList = true
                               };

            return DynamicTypeManager.GetInfoList<IInfoClass>(criteria);
        }
        private void Refresh()
        {
            var criteria = new PagedCriteria
            {
                ProcessName = Dto.ProcessSystemName,
                ItemsToLoad = new MobileList<int>(Dto.ItemIds),
                PageNumber = CurrentPageNumber,
                PageSize = PageSize
            };

            //TODO async call fails on client (task.ContinueWith() is null) :(
            //PreviewItems = await TheDynamicTypeManager.Value.BeginGetListAsync<IInfoList>(criteria);
            //System.Diagnostics.Debug.WriteLine(t.ToString());
            //RaisePropertyChanged(() => PreviewItems);

            TheDynamicTypeManager.Value.BeginGetList<IInfoList>(criteria, (s, e) =>
            {
                WizardManager.ShowBusy(false);
                if (e.Error == null)
                {
                    PreviewItems = e.Object;
                }
                else
                {
                    ThePopupFactory.Value.NotifyFailure(e.Error);
                }
            });
        }
        private void Refresh()
        {
            IsBusy = true;

            var filter = FilterDescriptor.GetFilterExpression(GetFilter());
            var criteria = new PagedCriteria { PageSize = 20, PageNumber = PageIndex, FilterDefinition = filter, ProcessName = ProcessName, ResultColumns = new MobileList<string>(Columns.Select(x => x.ColumnName))};

            DynamicManager.BeginGetList<IInfoList>(criteria, (o, result) =>
            {
                if (result.Error != null)
                {
                    IsBusy = false;
                    return;
                }

                ItemList = result.Object;
                SetupSelectedItem();

                if (ItemList != null)
                {
                    var totalRowCountProperty = ItemList.GetType().GetProperty(Constants.TotalRowCountPropertyName);
                    if (totalRowCountProperty != null) TotalRowCount = (int)totalRowCountProperty.GetValue(ItemList, BindingFlags.Instance, null, null, null);

                    var pageIndexProperty = ItemList.GetType().GetProperty(Constants.PageNumberPropertyName);
                    if (pageIndexProperty != null) PageIndex = (int)pageIndexProperty.GetValue(ItemList, BindingFlags.Instance, null, null, null);

                    RaisePropertyChanged(() => TotalRowCount);
                }

                IsBusy = false;
            });
        }
        /// <summary>
        /// Gets all emails.
        /// </summary>
        /// <param name="sourceItem">
        /// The source item.
        /// </param>
        /// <returns>
        /// The collection of emails.
        /// </returns>
        public override IEnumerable<string> GetAllEmails(IEditableRoot sourceItem)
        {
            if (sourceItem == null)
                throw new ArgumentNullException("sourceItem");

            using (new BypassPropertyCheckContext())
            {
                var emailList = new List<string>();
                if (!string.IsNullOrEmpty(EmailFieldName))
                {
                    var email = sourceItem.GetValueByPropertyName(EmailFieldName);
                    if (!string.IsNullOrWhiteSpace(email))
                        emailList.Add(email);
                }

                if (!string.IsNullOrEmpty(ApprovalFieldName))
                {
                    var personIds = new List<int>();

                    // Add all approvers.
                    var approvalValue = (IApprovalEdit)sourceItem.GetValueByPropertyName(ApprovalFieldName);

                    foreach (var memberResult in approvalValue.MemberResults)
                    {
                        var personId = memberResult.Person;
                        if (personId.HasValue)
                            personIds.Add(personId.Value);
                    }

                    // Add override members.
                    personIds.AddRange(approvalValue.OverrideMembers.Select(overrideMember => overrideMember.Person.Id));

                    var resultColumns = new MobileList<string> { ReflectionHelper.GetPropertyName<IPersonInfo>(p => p.Email) };
                    var pagedCriteria = new PagedCriteria
                                            {
                                                ProcessName = Constants.BasePersonProcessName,
                                                PageNumber = 0,
                                                PageSize = int.MaxValue,
                                                LimitResultColumns = true,
                                                ResultColumns = resultColumns,
                                                ItemsToLoad = new MobileList<int>(personIds.Distinct())
                                            };

                    var personList = DynamicTypeManager.GetInfoList<IPersonInfo>(pagedCriteria);
                    emailList.AddRange(personList.Select(p => p.Email).Where(email => !string.IsNullOrWhiteSpace(email)));
                }

                return emailList.Where(email => !string.IsNullOrWhiteSpace(email)).Distinct();
            }
        }
Beispiel #16
0
 private void ApplySkipLogic(PagedCriteria criteria)
 {
     _skip = (criteria.PageNumber - 1) * criteria.PageSize;
 }
        private IInfoClass GetSourceItem(params IFilterDescriptor[] filters)
        {
            var criteria = new PagedCriteria
                               {
                                   ProcessName = SourceDataProcessName,
                                   FilterDefinition = FilterDescriptor.GetFilterExpression(new FilterList(filters)),
                                   PageNumber = 0,
                                   PageSize = 1,
                                   LimitResultColumns = true,
                                   ResultColumns = new MobileList<string> { Constants.IdColumnName },
                                   NotCalculateAccessDeniedList = true
                               };

            var list = DynamicTypeManager.GetInfoList<IInfoClass>(criteria);

            return list.FirstOrDefault();
        }
Beispiel #18
0
 private void ApplyCriteriaLogic(PagedCriteria criteria)
 {
     ApplyPageNumberLogic(criteria);
     ApplySkipLogic(criteria);
 }
Beispiel #19
0
 public ActionResult GetDataDictionaryTypePagedList(PagedCriteria criteria)
 {
     return(Ioc.Resolve <IDataDictionaryService>().GetDataDictionaryTypes().ToJqueryDataTableModel(criteria.draw));
 }
Beispiel #20
0
 public IActionResult GetList([FromQuery] PagedCriteria pagedCriteria)
 {
     return(Ok(new { version = "list-v1", pagedCriteria }));
 }
Beispiel #21
0
        /// <summary>
        /// Executes the command.
        /// </summary>
        /// <returns>
        /// The <see cref="ISearchResult"/>.
        /// </returns>
        public SearchCommandResult Execute()
        {
            var result = new SearchCommandResult();

            if (IncludeProcessMetadata)
            {
                result.ProcessDisplayName = Process.DisplayName;
                result.Filters = GetFilters();
                result.Layouts = !IncludeMetricsMetadata ? GetLayouts() : null;
                result.RelatedProcesses = GetRelatedProcesses();
            }

            var appliedFilter = GetAppliedFilter();
            if (appliedFilter != null && IncludeLayoutMetadata)
            {
                result.AppliedFilter = appliedFilter;
            }

            var layout = GetAppliedLayout(appliedFilter);
            var layoutMetadata = SearchUtils.CreateLayoutMetadata(layout, true);

            if (IncludeLayoutMetadata)
            {
                result.AppliedLayout = layoutMetadata;
            }

            result.ResultColumns.AddRange(layoutMetadata.Columns);

            var filterDescriptors = new FilterList();
            if (appliedFilter != null && !appliedFilter.IsEmpty())
            {
                var filterDescriptor = FilterDescriptorFactory.CreateFilterFromJSON(appliedFilter.FilterDefinition);

                if (filterDescriptor.ReplaceUdpValues(FilterParameters))
                {
                    filterDescriptors.Add(filterDescriptor);
                }
                else
                {
                    result.FilterParametersRequired = true;
                    return result;
                }
            }

            filterDescriptors.AddRange(GetMandatoryFilters());

            foreach (var filterDescriptor in filterDescriptors)
            {
                filterDescriptor.ReplacePredefinedValues(null);
            }

            if (IncludeMetricsMetadata)
            {
                result.Metrics = MetricsManager.GetMetrics(ProcessName);
            }

            if (MetricParameters != null)
            {
                result.MetricsData = MetricsManager.GetMetricData(ProcessName, MetricParameters, FilterDescriptorFactory.GetFilterDefinition(filterDescriptors));
                return result;
            }

            if (IncludeKpiMetadata)
            {
                result.KpiGadget = KpiManager.GetKpiGaugeList(ProcessName);
            }

            if (KpiParameters != null && KpiParameters.Any())
            {
                result.KpiGadgetData = KpiManager.GetKpiGadgetData(ProcessName, KpiParameters);
                return result;
            }

            if (FilterId == -1)
            {
                foreach(JObject filt in FilterParameters)
                {
                    var filter = filt.ToObject<KeyValuePair<string, string>>();

                    var filterByKey = new FilterDescriptor(filter.Key, FilterOperator.IsEqualTo, filter.Value);
                    filterByKey.MemberType = layoutMetadata.Columns.FirstOrDefault(x => x.SystemName == filter.Key).ColumnType.GetCSharpType();
                    filterDescriptors.Add(filterByKey);
                }
            }

            var criteria = new PagedCriteria
                               {
                                   ProcessName = ProcessName,
                                   PageNumber = PageNumber,
                                   PageSize = PageSize,
                                   Filter = SearchText,
                                   GroupColumn = GroupColumn,
                                   FilterDefinition = FilterDescriptorFactory.GetFilterDefinition(filterDescriptors),
                                   LimitResultColumns = true,
                                   ResultColumns = new MobileList<string>(layoutMetadata.Columns.Select(c => c.SystemName)),
                                   SortColumns = GetSortDescriptors(layoutMetadata),
                                   NotCalculateAccessDeniedList = true
                               };

            result.Items = DynamicTypeManager.GetInfoList<IInfoClass>(criteria);

            return result;
        }
Beispiel #22
0
 public ApiResult <PagedResult <ContactInfo> > Get([FromUri] PagedCriteria criteria)
 {
     return(Execute(() => Mapper.Map <PagedResult <ContactInfo> >(
                        _contactRepository.GetContacts(criteria.PageNumber, criteria.PageSize, criteria.Name))));
 }