Beispiel #1
0
        static async Task Main(string[] args)
        {
            SetUpConfiguration();
            AirtableCredentials airtableCredentials = GetAirtableCredentials();

            Console.WriteLine($"BaseId is {airtableCredentials.BaseId}. ApiKey is {airtableCredentials.ApiKey}");

            Retriever retriever = new Retriever(airtableCredentials.BaseId, airtableCredentials.ApiKey);

            string tableName = Configuration.GetSection("airtableOptions").GetValue <string>("tableName");

            DateOptions dateOptions = GetDateOptions();

            Console.WriteLine($"Date1 is {dateOptions.FirstDateNonInclusive}. Date2 is {dateOptions.LastDateNonInclusive}");

            await DownloadAllCovers(retriever, @"c:\temp\MagCovers", tableName);

            /* Add Covers to Issues within a Time Range */
            // await AddCoversToIssuesInTimeRange(retriever, dateOptions, tableName);

            // /* Get a single record */
            //string recordId = "recDDgkAWOdzhugCS";
            //string recordJson = await retriever.GetRecord(tableName, recordId);
            //Console.WriteLine(recordJson);

            // /* Get a number of records via a formula */
            //string formula = @"Issue='1970-01'";
            //var records = await retriever.GetRecordsFromFormula(tableName, formula);
            //foreach (string rec in records) {
            //    Console.WriteLine(rec);
            //}

            // /* add Cover to Record */
            // await AddCoverToRecord(retriever);
        } // end Main
Beispiel #2
0
        static async Task AddCoversToIssuesInTimeRange(Retriever retriever, DateOptions dateOptions, string tableName)
        {
            var ids = GetIdsForIssuesInTimeRange(retriever, dateOptions, tableName);

            if (ids != null)
            {
                string[] idArray        = ids.Result.ToArray();
                int      idArrayCounter = 0;

                MagazineIssueDate issueDate = new MagazineIssueDate(dateOptions.FirstDateNonInclusive);

                if (PromptForConfirmation(idArray.Count()))
                {
                    while (idArrayCounter < idArray.Count())
                    {
                        issueDate.IncrementMonth();
                        if (!issueDate.IsSkipMonth())
                        {
                            await AddCoverToRecord(retriever, idArray[idArrayCounter], issueDate);

                            idArrayCounter++;
                        }
                    }
                }
            }
        }
Beispiel #3
0
        public static Tuple <DateTime, DateTime> GetCalendarViewPeriod(DateOptions dateOptions, string calendarScope)
        {
            Tuple <DateTime, DateTime> period;
            SimpleDate selDate = dateOptions.SelectedDate;

            if (calendarScope == "day")
            {
                DateTime dt = new DateTime(selDate.Year, selDate.Month, selDate.Day);
                period = new Tuple <DateTime, DateTime>(dt, dt.AddHours(23).AddMinutes(59).AddSeconds(59).AddMilliseconds(999));
            }
            else
            {
                DateTime firstDayOfCalendarView = (calendarScope == "week") ? new DateTime(selDate.Year, selDate.Month, selDate.Day) : new DateTime(selDate.Year, selDate.Month, 1);
                DateTime lastDayOfCalendarView  = (calendarScope == "week") ? new DateTime(selDate.Year, selDate.Month, selDate.Day) : new DateTime(selDate.Year, selDate.Month, DateTime.DaysInMonth(selDate.Year, selDate.Month));

                // get FIRST date of Calendar view
                while ((int)firstDayOfCalendarView.DayOfWeek != dateOptions.FirstDayOfWeek)
                {
                    firstDayOfCalendarView = firstDayOfCalendarView.AddDays(-1);
                }

                // get LAST date of Calendar view
                do
                {
                    lastDayOfCalendarView = lastDayOfCalendarView.AddDays(1);
                } while ((int)lastDayOfCalendarView.DayOfWeek != dateOptions.FirstDayOfWeek);

                period = new Tuple <DateTime, DateTime>(firstDayOfCalendarView, lastDayOfCalendarView.AddMilliseconds(-1));
            }

            return(period);
        }
Beispiel #4
0
        static async Task DownloadAllCovers(Retriever retriever, string targetFolder, string tableName)
        {
            DateTime year1     = new DateTime(1981, 1, 1);
            DateTime year2     = new DateTime(1981, 12, 1);
            DateTime finalDate = new DateTime(2018, 1, 1);

            DateOptions dateOptions = new DateOptions()
            {
                FirstDateNonInclusive = year1.AddMonths(-1),
                LastDateNonInclusive  = year2.AddMonths(1)
            };

            var serviceProvider   = new ServiceCollection().AddHttpClient().BuildServiceProvider();
            var httpClientFactory = serviceProvider.GetService <IHttpClientFactory>();
            var httpClient        = httpClientFactory.CreateClient();

            while (dateOptions.FirstDateNonInclusive < finalDate)
            {
                List <(string, string)> idsAndUrls = await GetIdsAndCoverUrlsForIssuesInTimeRange(retriever, dateOptions, tableName);

                foreach ((_, string url) in idsAndUrls)
                {
                    await DownloadAndSaveAttachment(httpClient, targetFolder, url);
                }

                // download attachment
                // add 1 year to dateOptions dates
                dateOptions.FirstDateNonInclusive = dateOptions.FirstDateNonInclusive.AddYears(1);
                dateOptions.LastDateNonInclusive  = dateOptions.LastDateNonInclusive.AddYears(1);
                Console.WriteLine($"{dateOptions.FirstDateNonInclusive}. {dateOptions.LastDateNonInclusive}");
            }
        }
 private DateOptions getAlternateDateOptions()
 {
     if (this.m_AlternateDateOptions == null)
     {
         this.m_AlternateDateOptions = new DateOptions(this.LocaleId.ToString(CultureInfo.InvariantCulture), this.AlternateCalendarType, this.WorkWeek, this.FirstDayOfWeek.ToString(CultureInfo.InvariantCulture), this.HijriAdjustment.ToString(CultureInfo.InvariantCulture), this.TimeZoneSpan.ToString(), this.SelectedDate);
     }
     return(this.m_AlternateDateOptions);
 }
 private DateOptions getDateOptions()
 {
     if (this.m_DateOptions == null)
     {
         this.m_DateOptions = new DateOptions(this.LocaleId.ToString(), this.CalendarType, this.WorkWeek, this.FirstDayOfWeek.ToString(), this.HijriAdjustment.ToString(), this.TimeZoneSpan.ToString(), this.SelectedDate);
     }
     return(this.m_DateOptions);
 }
Beispiel #7
0
        /// <summary>
        /// Creates new instance of <see cref="DateVM"/>.
        /// </summary>
        /// <param name="jd">Julian Day to be set in the editor</param>
        /// <param name="utcOffset">UTC offset, in hours</param>
        /// <param name="displayMode">Editor display mode</param>
        public DateVM(double jd, double utcOffset, DateOptions displayMode = DateOptions.DateTime)
        {
            var dateTimeFormat = CultureInfo.CurrentCulture.DateTimeFormat;

            ShortMonthsNames = dateTimeFormat.AbbreviatedMonthNames.Take(12).ToArray();
            FullMonthsNames  = dateTimeFormat.MonthNames.Take(12).ToArray();

            UtcOffset   = utcOffset;
            DisplayMode = displayMode;

            SetJulianDay(jd);
        }
Beispiel #8
0
        private static string GenerateTimeRangeFormula(DateOptions dateOptions)
        {
            DateTime firstDate = dateOptions.FirstDateNonInclusive;
            DateTime lastDate  = dateOptions.LastDateNonInclusive;

            string firstDateFormula = $"IS_AFTER(Date, '{firstDate:yyyy-MM-dd}')";
            string lastDateformula  = $"IS_BEFORE(Date,'{lastDate:yyyy-MM-dd}')";
            string formula          = $"AND({firstDateFormula}, {lastDateformula})";

            Console.WriteLine($"formula is {formula}");

            return(formula);
        }
Beispiel #9
0
        private static int HandleDate(DateOptions opts)
        {
            var datetime = new Chronic.Parser().Parse(opts.DateTime).Start;

            if (datetime == null)
            {
                Console.WriteLine("Parse failed");
            }
            else
            {
                Console.WriteLine(datetime);
            }
            return(0);
        }
Beispiel #10
0
        private static DateOptions GetDateOptions()
        {
            DateOptions           dateOptions        = new DateOptions();
            IConfigurationSection dateOptionsSection = Configuration.GetSection("dateOptions");

            dateOptions.FirstDateNonInclusive = dateOptionsSection.GetValue <DateTime>("firstDateInclusive")
                                                .AddMonths(-1);
            dateOptions.LastDateNonInclusive = dateOptionsSection.GetValue <DateTime>("lastDateInclusive")
                                               .AddMonths(1);

            if (dateOptions.FirstDateNonInclusive >= dateOptions.LastDateNonInclusive)
            {
                throw new ArgumentOutOfRangeException("First Date should be before Last Date");
            }
            return(dateOptions);
        }
Beispiel #11
0
 private void addDateParts(DateUnityWrapper date, List <string> dateParts, DateOptions dateOptions)
 {
     if (dateOptions.UseYear)
     {
         dateParts.Add(date.Date.Year.ToString());
     }
     if (dateOptions.UseMonth)
     {
         dateParts.Add(date.Date.GetLocalizedMonth());
     }
     if (dateOptions.UseDay)
     {
         string item = (!dateOptions.SubtractDay) ? date.Date.Day.ToString() : date.Date.AddDays(-1.0).Day.ToString();
         dateParts.Add(item);
     }
 }
Beispiel #12
0
        public void PrintText(Inline text, Inline separator, DateOptions options)
        {
            try
            {
                if (options.LogTime)
                {
                    LoggerText.Inlines.Add(GetLogTime(options.DateFormat, options.TextOptions));
                }

                LoggerText.Inlines.Add(separator);
                LoggerText.Inlines.Add(text);
                LoggerText.Inlines.Add(new Run(Environment.NewLine));
            }
            catch (Exception)
            {
                throw;
            }
        }
        public DateControl Date(Expression <Func <TModel, DateTime> > expression, DateOptions dateOptions = null)
        {
            var model = GetModel(expression);

            return(new DateControl(model, dateOptions));
        }
Beispiel #14
0
        static async Task <List <string> > GetIdsForIssuesInTimeRange(Retriever retriever, DateOptions dateOptions, string tableName)
        {
            string formula = GenerateTimeRangeFormula(dateOptions);

            Console.WriteLine($"Retrieving Ids for Issues between {dateOptions.FirstDateNonInclusive} & {dateOptions.LastDateNonInclusive} (non-inclusive)");

            List <string> fields = new List <string>()
            {
                "Date"
            };

            (bool success, string errorMessage, var ids) = await retriever.GetIdsFromRecordsFilterByFormula(tableName, formula, fields);

            if (!success)
            {
                Console.WriteLine(errorMessage);
                return(null);
            }
            else
            {
                return(ids);
            }
        }
Beispiel #15
0
 public AtawDateOptionCreator()
 {
     fDateOptions = new DateOptions();
     BaseOptions  = fDateOptions;
 }
        public static List <SPCalendarItem> GetInstanceEventsOfRecurrenceEvent(this SPCalendarItem calendarItem, string recurrenceData, Pair calendarPeriod, DateOptions dateOptions)
        {
            List <SPCalendarItem> instanceEvents = new List <SPCalendarItem>();

            if (string.IsNullOrEmpty(recurrenceData))
            {
                instanceEvents.Add(calendarItem);
                return(instanceEvents);
            }

            // init Event period inside Calendar view scope
            DateTime fromDate = (DateTime)calendarPeriod.First > calendarItem.StartDate ? ((DateTime)calendarPeriod.First).Date : calendarItem.StartDate.Date; // get MAX date
            DateTime toDate   = (DateTime)calendarPeriod.Second < calendarItem.EndDate ? ((DateTime)calendarPeriod.Second).Date : calendarItem.EndDate.Date;   // get MIN date

            if (fromDate > toDate)
            {
                return(instanceEvents);
            }

            XDocument recDoc   = XDocument.Parse(recurrenceData);
            XElement  repeatEl = recDoc.Descendants("repeat").FirstOrDefault();

            IEnumerable <DateTime> instanceDates = null;

            if (repeatEl.Element("daily") != null)
            {
                XAttribute attrDailyFrequency = repeatEl.Element("daily").Attribute("dayFrequency");
                if (attrDailyFrequency != null)
                {
                    // Daily-Frequency
                    // update from date
                    int _dayFrequency = Int32.Parse(attrDailyFrequency.Value);
                    int daysBetweenEventStartAndCalendarPeriod = fromDate.Subtract(calendarItem.StartDate.Date).Days;
                    if (daysBetweenEventStartAndCalendarPeriod > 0)
                    {
                        fromDate = calendarItem.StartDate.Date.AddDays((daysBetweenEventStartAndCalendarPeriod / _dayFrequency) * _dayFrequency); // move fromDate to the beginning of Calendar interval
                    }
                    // get dates
                    instanceDates = Enumerable.Range(0, 1 + toDate.Subtract(fromDate).Days).Select(c => fromDate.AddDays(c * _dayFrequency)).Where(x => (x >= fromDate && x <= toDate));
                }
                else
                {
                    // Daily-weekly
                    instanceDates = Enumerable.Range(0, 1 + toDate.Subtract(fromDate).Days).Select(c => fromDate.AddDays(c)).Where(x => (dateOptions.IsWorkDay((int)x.DayOfWeek) && x >= fromDate && x <= toDate));
                }
            }
            else if (repeatEl.Element("weekly") != null)
            {
                XElement weeklyEl = repeatEl.Element("weekly");
                int      weekFreq = Convert.ToInt32(weeklyEl.Attribute("weekFrequency").Value);
                var      days     = weeklyEl.Attributes().Where(x => x.Name.ToString().Length == 2).Select(x => Utils.GetDayOfWeekByDayShortName(x.Name.ToString()));
                // get real date of first event
                DateTime stRealDt = calendarItem.StartDate.Date;
                while (!days.Any(x => x == stRealDt.DayOfWeek))
                {
                    stRealDt = stRealDt.AddDays(1);
                }
                int weeksBetweenEventStartAndCalendarPeriod = fromDate.Subtract(stRealDt).Days / 7;
                if (weeksBetweenEventStartAndCalendarPeriod > 0)
                {
                    fromDate = stRealDt.AddDays((weeksBetweenEventStartAndCalendarPeriod / weekFreq) * weekFreq * 7); // move fromDate to the beginning of Calendar interval
                }
                //instanceDates = Enumerable.Range(0, 1 + (toDate.Subtract(fromDate).Days / 7)).Select(c => fromDate.AddDays(c)).Where(x => (dateOptions.IsWorkDay((int)x.DayOfWeek) && x >= fromDate && x <= toDate));
            }
            else if (repeatEl.Element("monthlyByDay") != null)
            {
            }
            else if (repeatEl.Element("monthly") != null)
            {
                XElement monthlyByDayEl = repeatEl.Element("monthly");
                int      monthFreq      = Convert.ToInt32(monthlyByDayEl.Attribute("monthFrequency").Value);
                int      day            = Convert.ToInt32(monthlyByDayEl.Attribute("day").Value);
                DateTime nextMonth      = calendarItem.StartDate.Date.AddMonths(1);
                fromDate = calendarItem.StartDate.Day <= day ? new DateTime(calendarItem.StartDate.Year, calendarItem.StartDate.Month, day) : new DateTime(nextMonth.Year, nextMonth.Month, day);
                if (toDate >= fromDate)
                {
                    instanceDates = Enumerable.Range(0, 1 + toDate.Subtract(fromDate).Days / 28).Select(c => fromDate.AddMonths(c * monthFreq)).Where(x => (x >= fromDate && x <= toDate));
                }
            }
            else if (repeatEl.Element("yearly") != null)
            {
                XElement yearlyEl = repeatEl.Element("yearly");
                int      month    = Convert.ToInt32(yearlyEl.Attribute("month").Value);
                int      day      = Convert.ToInt32(yearlyEl.Attribute("day").Value);
                DateTime yDt      = new DateTime(month == 1 ? toDate.Year : fromDate.Year, month, day);
                if (fromDate <= yDt && yDt <= toDate)
                {
                    instanceDates = new[] { yDt }
                }
                ;
            }
            else if (repeatEl.Element("yearlyByDay") != null)
            {
                XElement yearlyDbEl     = repeatEl.Element("yearlyByDay");
                int      month          = Convert.ToInt32(yearlyDbEl.Attribute("month").Value);
                string   weekdayOfMonth = yearlyDbEl.Attribute("weekdayOfMonth").Value;
                string   dayShortName   = yearlyDbEl.Attributes().Where(x => x.Name.ToString().Length == 2).Select(x => x.Name.ToString()).FirstOrDefault();
                DateTime yDt            = new DateTime(month == 1 ? toDate.Year : fromDate.Year, month, 1).GetDayOfMonth(dayShortName, weekdayOfMonth);
                if (fromDate <= yDt && yDt <= toDate)
                {
                    instanceDates = new[] { yDt }
                }
                ;
            }

            // COPY pattern to instances
            if (instanceDates != null)
            {
                int startHour   = calendarItem.StartDate.Hour;
                int startMinute = calendarItem.StartDate.Minute;
                int endHour     = calendarItem.EndDate.Hour;
                int endMinute   = calendarItem.EndDate.Minute;
                instanceEvents.AddRange(instanceDates.Select(x => new SPCalendarItem()
                {
                    CalendarType   = calendarItem.CalendarType,
                    DisplayFormUrl = calendarItem.DisplayFormUrl,
                    ItemID         = calendarItem.ItemID,
                    StartDate      = new DateTime(x.Year, x.Month, x.Day, startHour, startMinute, 0),
                    EndDate        = new DateTime(x.Year, x.Month, x.Day, endHour, endMinute, 0),
                    hasEndDate     = true,
                    Title          = calendarItem.Title,
                    Location       = calendarItem.Location,
                    Description    = calendarItem.Description,
                    IsAllDayEvent  = calendarItem.IsAllDayEvent,
                    IsRecurrence   = true
                }));
            }

            return(instanceEvents);
        }
Beispiel #17
0
 /// <summary>
 /// Shows date and time dialog
 /// </summary>
 /// <param name="jd">Julian day selected by default</param>
 /// <param name="utcOffset">UTC offset, in hours</param>
 /// <param name="displayMode">Dialog options</param>
 /// <returns>Julian day selected, or null</returns>
 public static double?ShowDateDialog(double jd, double utcOffset, DateOptions displayMode = DateOptions.DateTime)
 {
     return(viewManager.ShowDateDialog(jd, utcOffset, displayMode));
 }
 public DateControl Date(string name, DateTime value, string id = "",
                         string displayName = null, bool isRequired = false, LabelOption labelOption = LabelOption.None, DateOptions dateOptions = null)
 {
     return(Date(name, new DateTime?(value), id, displayName, isRequired, labelOption, dateOptions));
 }
        public IRequest Marshall(DefineIndexFieldRequest defineIndexFieldRequest)
        {
            IRequest request = new DefaultRequest(defineIndexFieldRequest, "AmazonCloudSearch");

            request.Parameters.Add("Action", "DefineIndexField");
            request.Parameters.Add("Version", "2013-01-01");
            if (defineIndexFieldRequest != null && defineIndexFieldRequest.IsSetDomainName())
            {
                request.Parameters.Add("DomainName", StringUtils.FromString(defineIndexFieldRequest.DomainName));
            }
            if (defineIndexFieldRequest != null)
            {
                IndexField indexField = defineIndexFieldRequest.IndexField;
                if (indexField != null && indexField.IsSetIndexFieldName())
                {
                    request.Parameters.Add("IndexField.IndexFieldName", StringUtils.FromString(indexField.IndexFieldName));
                }
                if (indexField != null && indexField.IsSetIndexFieldType())
                {
                    request.Parameters.Add("IndexField.IndexFieldType", StringUtils.FromString(indexField.IndexFieldType));
                }
                if (indexField != null)
                {
                    IntOptions intOptions = indexField.IntOptions;
                    if (intOptions != null && intOptions.IsSetDefaultValue())
                    {
                        request.Parameters.Add("IndexField.IntOptions.DefaultValue", StringUtils.FromLong(intOptions.DefaultValue));
                    }
                    if (intOptions != null && intOptions.IsSetSourceField())
                    {
                        request.Parameters.Add("IndexField.IntOptions.SourceField", StringUtils.FromString(intOptions.SourceField));
                    }
                    if (intOptions != null && intOptions.IsSetFacetEnabled())
                    {
                        request.Parameters.Add("IndexField.IntOptions.FacetEnabled", StringUtils.FromBool(intOptions.FacetEnabled));
                    }
                    if (intOptions != null && intOptions.IsSetSearchEnabled())
                    {
                        request.Parameters.Add("IndexField.IntOptions.SearchEnabled", StringUtils.FromBool(intOptions.SearchEnabled));
                    }
                    if (intOptions != null && intOptions.IsSetReturnEnabled())
                    {
                        request.Parameters.Add("IndexField.IntOptions.ReturnEnabled", StringUtils.FromBool(intOptions.ReturnEnabled));
                    }
                    if (intOptions != null && intOptions.IsSetSortEnabled())
                    {
                        request.Parameters.Add("IndexField.IntOptions.SortEnabled", StringUtils.FromBool(intOptions.SortEnabled));
                    }
                }
                if (indexField != null)
                {
                    DoubleOptions doubleOptions = indexField.DoubleOptions;
                    if (doubleOptions != null && doubleOptions.IsSetDefaultValue())
                    {
                        request.Parameters.Add("IndexField.DoubleOptions.DefaultValue", StringUtils.FromDouble(doubleOptions.DefaultValue));
                    }
                    if (doubleOptions != null && doubleOptions.IsSetSourceField())
                    {
                        request.Parameters.Add("IndexField.DoubleOptions.SourceField", StringUtils.FromString(doubleOptions.SourceField));
                    }
                    if (doubleOptions != null && doubleOptions.IsSetFacetEnabled())
                    {
                        request.Parameters.Add("IndexField.DoubleOptions.FacetEnabled", StringUtils.FromBool(doubleOptions.FacetEnabled));
                    }
                    if (doubleOptions != null && doubleOptions.IsSetSearchEnabled())
                    {
                        request.Parameters.Add("IndexField.DoubleOptions.SearchEnabled", StringUtils.FromBool(doubleOptions.SearchEnabled));
                    }
                    if (doubleOptions != null && doubleOptions.IsSetReturnEnabled())
                    {
                        request.Parameters.Add("IndexField.DoubleOptions.ReturnEnabled", StringUtils.FromBool(doubleOptions.ReturnEnabled));
                    }
                    if (doubleOptions != null && doubleOptions.IsSetSortEnabled())
                    {
                        request.Parameters.Add("IndexField.DoubleOptions.SortEnabled", StringUtils.FromBool(doubleOptions.SortEnabled));
                    }
                }
                if (indexField != null)
                {
                    LiteralOptions literalOptions = indexField.LiteralOptions;
                    if (literalOptions != null && literalOptions.IsSetDefaultValue())
                    {
                        request.Parameters.Add("IndexField.LiteralOptions.DefaultValue", StringUtils.FromString(literalOptions.DefaultValue));
                    }
                    if (literalOptions != null && literalOptions.IsSetSourceField())
                    {
                        request.Parameters.Add("IndexField.LiteralOptions.SourceField", StringUtils.FromString(literalOptions.SourceField));
                    }
                    if (literalOptions != null && literalOptions.IsSetFacetEnabled())
                    {
                        request.Parameters.Add("IndexField.LiteralOptions.FacetEnabled", StringUtils.FromBool(literalOptions.FacetEnabled));
                    }
                    if (literalOptions != null && literalOptions.IsSetSearchEnabled())
                    {
                        request.Parameters.Add("IndexField.LiteralOptions.SearchEnabled", StringUtils.FromBool(literalOptions.SearchEnabled));
                    }
                    if (literalOptions != null && literalOptions.IsSetReturnEnabled())
                    {
                        request.Parameters.Add("IndexField.LiteralOptions.ReturnEnabled", StringUtils.FromBool(literalOptions.ReturnEnabled));
                    }
                    if (literalOptions != null && literalOptions.IsSetSortEnabled())
                    {
                        request.Parameters.Add("IndexField.LiteralOptions.SortEnabled", StringUtils.FromBool(literalOptions.SortEnabled));
                    }
                }
                if (indexField != null)
                {
                    TextOptions textOptions = indexField.TextOptions;
                    if (textOptions != null && textOptions.IsSetDefaultValue())
                    {
                        request.Parameters.Add("IndexField.TextOptions.DefaultValue", StringUtils.FromString(textOptions.DefaultValue));
                    }
                    if (textOptions != null && textOptions.IsSetSourceField())
                    {
                        request.Parameters.Add("IndexField.TextOptions.SourceField", StringUtils.FromString(textOptions.SourceField));
                    }
                    if (textOptions != null && textOptions.IsSetReturnEnabled())
                    {
                        request.Parameters.Add("IndexField.TextOptions.ReturnEnabled", StringUtils.FromBool(textOptions.ReturnEnabled));
                    }
                    if (textOptions != null && textOptions.IsSetSortEnabled())
                    {
                        request.Parameters.Add("IndexField.TextOptions.SortEnabled", StringUtils.FromBool(textOptions.SortEnabled));
                    }
                    if (textOptions != null && textOptions.IsSetHighlightEnabled())
                    {
                        request.Parameters.Add("IndexField.TextOptions.HighlightEnabled", StringUtils.FromBool(textOptions.HighlightEnabled));
                    }
                    if (textOptions != null && textOptions.IsSetAnalysisScheme())
                    {
                        request.Parameters.Add("IndexField.TextOptions.AnalysisScheme", StringUtils.FromString(textOptions.AnalysisScheme));
                    }
                }
                if (indexField != null)
                {
                    DateOptions dateOptions = indexField.DateOptions;
                    if (dateOptions != null && dateOptions.IsSetDefaultValue())
                    {
                        request.Parameters.Add("IndexField.DateOptions.DefaultValue", StringUtils.FromString(dateOptions.DefaultValue));
                    }
                    if (dateOptions != null && dateOptions.IsSetSourceField())
                    {
                        request.Parameters.Add("IndexField.DateOptions.SourceField", StringUtils.FromString(dateOptions.SourceField));
                    }
                    if (dateOptions != null && dateOptions.IsSetFacetEnabled())
                    {
                        request.Parameters.Add("IndexField.DateOptions.FacetEnabled", StringUtils.FromBool(dateOptions.FacetEnabled));
                    }
                    if (dateOptions != null && dateOptions.IsSetSearchEnabled())
                    {
                        request.Parameters.Add("IndexField.DateOptions.SearchEnabled", StringUtils.FromBool(dateOptions.SearchEnabled));
                    }
                    if (dateOptions != null && dateOptions.IsSetReturnEnabled())
                    {
                        request.Parameters.Add("IndexField.DateOptions.ReturnEnabled", StringUtils.FromBool(dateOptions.ReturnEnabled));
                    }
                    if (dateOptions != null && dateOptions.IsSetSortEnabled())
                    {
                        request.Parameters.Add("IndexField.DateOptions.SortEnabled", StringUtils.FromBool(dateOptions.SortEnabled));
                    }
                }
                if (indexField != null)
                {
                    LatLonOptions latLonOptions = indexField.LatLonOptions;
                    if (latLonOptions != null && latLonOptions.IsSetDefaultValue())
                    {
                        request.Parameters.Add("IndexField.LatLonOptions.DefaultValue", StringUtils.FromString(latLonOptions.DefaultValue));
                    }
                    if (latLonOptions != null && latLonOptions.IsSetSourceField())
                    {
                        request.Parameters.Add("IndexField.LatLonOptions.SourceField", StringUtils.FromString(latLonOptions.SourceField));
                    }
                    if (latLonOptions != null && latLonOptions.IsSetFacetEnabled())
                    {
                        request.Parameters.Add("IndexField.LatLonOptions.FacetEnabled", StringUtils.FromBool(latLonOptions.FacetEnabled));
                    }
                    if (latLonOptions != null && latLonOptions.IsSetSearchEnabled())
                    {
                        request.Parameters.Add("IndexField.LatLonOptions.SearchEnabled", StringUtils.FromBool(latLonOptions.SearchEnabled));
                    }
                    if (latLonOptions != null && latLonOptions.IsSetReturnEnabled())
                    {
                        request.Parameters.Add("IndexField.LatLonOptions.ReturnEnabled", StringUtils.FromBool(latLonOptions.ReturnEnabled));
                    }
                    if (latLonOptions != null && latLonOptions.IsSetSortEnabled())
                    {
                        request.Parameters.Add("IndexField.LatLonOptions.SortEnabled", StringUtils.FromBool(latLonOptions.SortEnabled));
                    }
                }
                if (indexField != null)
                {
                    IntArrayOptions intArrayOptions = indexField.IntArrayOptions;
                    if (intArrayOptions != null && intArrayOptions.IsSetDefaultValue())
                    {
                        request.Parameters.Add("IndexField.IntArrayOptions.DefaultValue", StringUtils.FromLong(intArrayOptions.DefaultValue));
                    }
                    if (intArrayOptions != null && intArrayOptions.IsSetSourceFields())
                    {
                        request.Parameters.Add("IndexField.IntArrayOptions.SourceFields", StringUtils.FromString(intArrayOptions.SourceFields));
                    }
                    if (intArrayOptions != null && intArrayOptions.IsSetFacetEnabled())
                    {
                        request.Parameters.Add("IndexField.IntArrayOptions.FacetEnabled", StringUtils.FromBool(intArrayOptions.FacetEnabled));
                    }
                    if (intArrayOptions != null && intArrayOptions.IsSetSearchEnabled())
                    {
                        request.Parameters.Add("IndexField.IntArrayOptions.SearchEnabled", StringUtils.FromBool(intArrayOptions.SearchEnabled));
                    }
                    if (intArrayOptions != null && intArrayOptions.IsSetReturnEnabled())
                    {
                        request.Parameters.Add("IndexField.IntArrayOptions.ReturnEnabled", StringUtils.FromBool(intArrayOptions.ReturnEnabled));
                    }
                }
                if (indexField != null)
                {
                    DoubleArrayOptions doubleArrayOptions = indexField.DoubleArrayOptions;
                    if (doubleArrayOptions != null && doubleArrayOptions.IsSetDefaultValue())
                    {
                        request.Parameters.Add("IndexField.DoubleArrayOptions.DefaultValue", StringUtils.FromDouble(doubleArrayOptions.DefaultValue));
                    }
                    if (doubleArrayOptions != null && doubleArrayOptions.IsSetSourceFields())
                    {
                        request.Parameters.Add("IndexField.DoubleArrayOptions.SourceFields", StringUtils.FromString(doubleArrayOptions.SourceFields));
                    }
                    if (doubleArrayOptions != null && doubleArrayOptions.IsSetFacetEnabled())
                    {
                        request.Parameters.Add("IndexField.DoubleArrayOptions.FacetEnabled", StringUtils.FromBool(doubleArrayOptions.FacetEnabled));
                    }
                    if (doubleArrayOptions != null && doubleArrayOptions.IsSetSearchEnabled())
                    {
                        request.Parameters.Add("IndexField.DoubleArrayOptions.SearchEnabled", StringUtils.FromBool(doubleArrayOptions.SearchEnabled));
                    }
                    if (doubleArrayOptions != null && doubleArrayOptions.IsSetReturnEnabled())
                    {
                        request.Parameters.Add("IndexField.DoubleArrayOptions.ReturnEnabled", StringUtils.FromBool(doubleArrayOptions.ReturnEnabled));
                    }
                }
                if (indexField != null)
                {
                    LiteralArrayOptions literalArrayOptions = indexField.LiteralArrayOptions;
                    if (literalArrayOptions != null && literalArrayOptions.IsSetDefaultValue())
                    {
                        request.Parameters.Add("IndexField.LiteralArrayOptions.DefaultValue", StringUtils.FromString(literalArrayOptions.DefaultValue));
                    }
                    if (literalArrayOptions != null && literalArrayOptions.IsSetSourceFields())
                    {
                        request.Parameters.Add("IndexField.LiteralArrayOptions.SourceFields", StringUtils.FromString(literalArrayOptions.SourceFields));
                    }
                    if (literalArrayOptions != null && literalArrayOptions.IsSetFacetEnabled())
                    {
                        request.Parameters.Add("IndexField.LiteralArrayOptions.FacetEnabled", StringUtils.FromBool(literalArrayOptions.FacetEnabled));
                    }
                    if (literalArrayOptions != null && literalArrayOptions.IsSetSearchEnabled())
                    {
                        request.Parameters.Add("IndexField.LiteralArrayOptions.SearchEnabled", StringUtils.FromBool(literalArrayOptions.SearchEnabled));
                    }
                    if (literalArrayOptions != null && literalArrayOptions.IsSetReturnEnabled())
                    {
                        request.Parameters.Add("IndexField.LiteralArrayOptions.ReturnEnabled", StringUtils.FromBool(literalArrayOptions.ReturnEnabled));
                    }
                }
                if (indexField != null)
                {
                    TextArrayOptions textArrayOptions = indexField.TextArrayOptions;
                    if (textArrayOptions != null && textArrayOptions.IsSetDefaultValue())
                    {
                        request.Parameters.Add("IndexField.TextArrayOptions.DefaultValue", StringUtils.FromString(textArrayOptions.DefaultValue));
                    }
                    if (textArrayOptions != null && textArrayOptions.IsSetSourceFields())
                    {
                        request.Parameters.Add("IndexField.TextArrayOptions.SourceFields", StringUtils.FromString(textArrayOptions.SourceFields));
                    }
                    if (textArrayOptions != null && textArrayOptions.IsSetReturnEnabled())
                    {
                        request.Parameters.Add("IndexField.TextArrayOptions.ReturnEnabled", StringUtils.FromBool(textArrayOptions.ReturnEnabled));
                    }
                    if (textArrayOptions != null && textArrayOptions.IsSetHighlightEnabled())
                    {
                        request.Parameters.Add("IndexField.TextArrayOptions.HighlightEnabled", StringUtils.FromBool(textArrayOptions.HighlightEnabled));
                    }
                    if (textArrayOptions != null && textArrayOptions.IsSetAnalysisScheme())
                    {
                        request.Parameters.Add("IndexField.TextArrayOptions.AnalysisScheme", StringUtils.FromString(textArrayOptions.AnalysisScheme));
                    }
                }
                if (indexField != null)
                {
                    DateArrayOptions dateArrayOptions = indexField.DateArrayOptions;
                    if (dateArrayOptions != null && dateArrayOptions.IsSetDefaultValue())
                    {
                        request.Parameters.Add("IndexField.DateArrayOptions.DefaultValue", StringUtils.FromString(dateArrayOptions.DefaultValue));
                    }
                    if (dateArrayOptions != null && dateArrayOptions.IsSetSourceFields())
                    {
                        request.Parameters.Add("IndexField.DateArrayOptions.SourceFields", StringUtils.FromString(dateArrayOptions.SourceFields));
                    }
                    if (dateArrayOptions != null && dateArrayOptions.IsSetFacetEnabled())
                    {
                        request.Parameters.Add("IndexField.DateArrayOptions.FacetEnabled", StringUtils.FromBool(dateArrayOptions.FacetEnabled));
                    }
                    if (dateArrayOptions != null && dateArrayOptions.IsSetSearchEnabled())
                    {
                        request.Parameters.Add("IndexField.DateArrayOptions.SearchEnabled", StringUtils.FromBool(dateArrayOptions.SearchEnabled));
                    }
                    if (dateArrayOptions != null && dateArrayOptions.IsSetReturnEnabled())
                    {
                        request.Parameters.Add("IndexField.DateArrayOptions.ReturnEnabled", StringUtils.FromBool(dateArrayOptions.ReturnEnabled));
                    }
                }
            }

            return(request);
        }
        public double?ShowDateDialog(double jd, double utcOffset, DateOptions displayMode = DateOptions.DateTime)
        {
            var vm = new DateVM(jd, utcOffset, displayMode);

            return((ShowDialog(vm) ?? false) ? (double?)vm.JulianDay : null);
        }
        public DateControl Date(string name, DateTime?value = null, string id       = "",
                                string displayName          = null, bool isRequired = false, LabelOption labelOption = LabelOption.None, DateOptions dateOptions = null)
        {
            var model = new ControlModel <DateTime?>(id, name, value, displayName ?? GetDisplayName(name, name), labelOption: labelOption);

            model = ApplyRequiredRule(model, isRequired);

            return(new DateControl(model, dateOptions));
        }