当前位置: 首页>>代码示例>>C#>>正文


C# DataGroup.Equals方法代码示例

本文整理汇总了C#中DataGroup.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# DataGroup.Equals方法的具体用法?C# DataGroup.Equals怎么用?C# DataGroup.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataGroup的用法示例。


在下文中一共展示了DataGroup.Equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetQueryParams

        protected NameValueCollection GetQueryParams(DataGroup group, DateTime exportDate, string range = "", string extraFields = "", bool countFlag = false)
        {
            //ServicePointManager.DefaultConnectionLimit = 48; //recommended to be 12 * number of logical CPUs
            //ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);
            //if (Rules.Expect100Continue)
            //  ServicePointManager.Expect100Continue = true;
            //if (Rules.ForceProtocolSsl3)
            //  ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

            var queryParams = new NameValueCollection();
            if (!string.IsNullOrEmpty(Rules.ApiAliasParam))
                queryParams.Add(Rules.ApiAliasParam, _migrationSlave ? Rules.MigrationRules.MigrationAlias : Alias);
            if (!string.IsNullOrEmpty(Rules.ApiKeyParam))
                queryParams.Add(Rules.ApiKeyParam, Rules.ApiKey);

            if (GetFeedType(group).Equals(FeedType.SingleApi))
            {
                var groupParam = Rules.ApiVersion < 3 && countFlag
                                                     ? "DataCount"
                                                     : "DataGroup";
                queryParams.Add(groupParam, group.ToString());
                if (Rules.ApiVersion >= 3 && countFlag)
                    queryParams.Add("ResultType", "Count");
            }

            switch (group)
            {
                case DataGroup.Sales:
                case DataGroup.Customers:
                    var month = exportDate.Month;
                    var year = exportDate.Year;
                    if (!string.IsNullOrEmpty(Rules.ApiMonthParam)
                            && !string.IsNullOrEmpty(Rules.ApiYearParam))
                    {
                        queryParams.Add(Rules.ApiMonthParam, month.ToString("D2"));
                        queryParams.Add(Rules.ApiYearParam, year.ToString("D4"));
                    }
                    else if ((group.Equals(DataGroup.Sales) && Rules.ApiSalesDateRangeEnabled)
                        || (group.Equals(DataGroup.Customers) && Rules.ApiCustomerDateRangeEnabled))
                    {
                        var dateParam = string.IsNullOrEmpty(Rules.ApiDateRangeParam)
                                                            ? "DateRange"
                                                            : Rules.ApiDateRangeParam;
                        var lastDay = DateTime.DaysInMonth(year, month);
                        queryParams.Add(dateParam, string.Format("{0}-{1}-01,{0}-{1}-{2}",
                                                                    year.ToString("D4"), month.ToString("D2"), lastDay.ToString("D2")));
                    }
                    break;
                case DataGroup.Catalog:
                    if (!string.IsNullOrEmpty(range) && Rules.ApiVersion < 3) //older API IdRange only applied to catalog
                    {
                        var rangeParam = string.IsNullOrEmpty(Rules.ApiIdRangeParam)
                                                        ?  "IdRange"
                                                        : Rules.ApiIdRangeParam;
                        queryParams.Add(rangeParam, range);
                    }
                    if (!string.IsNullOrEmpty(extraFields) && !Rules.OmitExtraFields)
                    {
                        var fieldParam = string.IsNullOrEmpty(Rules.ApiFieldParam)
                                                             ? "ExtraFields"
                                                             : Rules.ApiFieldParam;
                        queryParams.Add(fieldParam, extraFields);
                    }
                    break;
                case DataGroup.CategoryNames:
                    break;
                case DataGroup.ManufacturerNames:
                    break;
                case DataGroup.DepartmentNames:
                    break;
                case DataGroup.Inventory:
                    break;
                default:
                    throw new ArgumentOutOfRangeException("group");
            }

            //Newer API RowRange can apply to all data groups
            if (!string.IsNullOrEmpty(range) && Rules.ApiVersion >= 3)
            {
                var rangeParam = string.IsNullOrEmpty(Rules.ApiRowRangeParam)
                                                ? "RowRange"
                                                : Rules.ApiRowRangeParam;
                queryParams.Add(rangeParam, range);
            }

            //get any additional query params defined in site rules
            if (Rules.ApiAddQueries != null && Rules.ApiAddQueries.Any())
            {
                NameValueCollection queries;
                if (Rules.ApiAddQueries.TryGetValue(group, out queries))
                {
                    queryParams.Add(queries);
                    //foreach (var q in queries)
                    //  queryParams.Add(q);
                }
                if (Rules.ApiAddQueries.TryGetValue(DataGroup.All, out queries)) //some extra queries apply to all requests
                {
                    queryParams.Add(queries);
                }
            }
//.........这里部分代码省略.........
开发者ID:dougadams4,项目名称:CartExtractorTestSite,代码行数:101,代码来源:CartExtractorBase.cs


注:本文中的DataGroup.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。