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


C# DataGroup.ToString方法代码示例

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


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

示例1: GetFeedData

        public void GetFeedData(out List<string> json, DataGroup group, DateTime exportDate, int firstRow = 1, int maxRows = 0, string extraFields = "")
        {
            var range = "";
            json = new List<string>();
            using (var resultStream = GetFeedData(group, exportDate, firstRow, maxRows, extraFields))
            {
                if (resultStream == null) return;
                if (!resultStream.CanRead)
                {
                    resultStream.Close();
                    return;
                }

            #if DEBUG_FEED
                var filename = string.Format("C:\\Temp\\{0}{1}-{2}.json", Alias, group.ToString(), exportDate.ToString("yyyy-MM"));
                var mode = _lastJsonGroup.Equals(group) ? FileMode.Append : FileMode.Create;
                _lastJsonGroup = group;

                using (var fileStream = File.Open(filename, mode))
                {
                    resultStream.CopyTo(fileStream);
                }
                resultStream.Seek(0, SeekOrigin.Begin);
            #endif
                json = Input.GetRows(ApplyMapping(resultStream), Rules.ApiRowEnd, Rules.ApiTrimChars);
            }

            var rowCheck = maxRows;
            if (firstRow == 1 || !Rules.ApiHeaderIsOnlyOnFirstRow)
            {
                rowCheck++; //add one row for the column header row
                for (var i = 0; i < Rules.ApiExtraHeaders; i++)
                    if (json.Count > 0) json.RemoveAt(0); //remove extra header rows
            }
            #if DEBUG
            if (maxRows > 0 && json.Count != rowCheck)
                    Log.WriteEntry(EventLogEntryType.Warning,
                        string.Format("Feed Count Mismatch: expected {0}, received {1}", maxRows, json.Count), "", Alias);
            #else
            if (json.Count < rowCheck)
                Log.WriteEntry(EventLogEntryType.Warning,
                    string.Format("Feed Count Mismatch: expected {0}, received {1}", maxRows, json.Count), "", Alias);
            #endif
        }
开发者ID:dougadams4,项目名称:CartExtractorTestSite,代码行数:44,代码来源:CartExtractorBase.cs

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