Exemplo n.º 1
0
        public void GetDate_WithFormAnswers_ReturnCorrectDate()
        {
            var formAnswers = new FormAnswers
            {
                Pages = new List <PageAnswers>
                {
                    new PageAnswers
                    {
                        Answers = new List <Answers>
                        {
                            new Answers
                            {
                                QuestionId = $"test-date{DateInput.YEAR_EXTENSION}",
                                Response   = "2020"
                            },
                            new Answers
                            {
                                QuestionId = $"test-date{DateInput.MONTH_EXTENSION}",
                                Response   = "01"
                            },
                            new Answers
                            {
                                QuestionId = $"test-date{DateInput.DAY_EXTENSION}",
                                Response   = "01"
                            }
                        }
                    }
                }
            };

            DateTime?result = DateInput.GetDate(formAnswers, "test-date");

            Assert.True(result.HasValue);
            Assert.True(result.Value == new DateTime(2020, 1, 1));
        }
        /// <summary>
        /// Заполнить поле 'Дата'
        /// </summary>
        /// <param name="date">Дата</param>
        public ScheduleMainPage FillDateField(DateTime date)
        {
            CustomTestContext.WriteLine($"Заполнить поле 'Дата' значением {date}");
            DateInput.SendKeys(date.ToString("dd/M/yyyy", CultureInfo.InvariantCulture));

            return(LoadPage());
        }
Exemplo n.º 3
0
        public void GetDate_ReturnNull_IfKeyNotPresent()
        {
            var      viewModel = new Dictionary <string, dynamic>();
            DateTime?result    = DateInput.GetDate(viewModel, "test-date");

            Assert.False(result.HasValue);
        }
 public void SetCourseRun(string courseName,
                          string providerCourseRef,
                          DateInput startDate,
                          bool?flexibleStartDate,
                          bool?nationalDelivery,
                          IEnumerable <string> subRegionIds,
                          string courseWebPage,
                          string cost,
                          string costDescription,
                          int?duration,
                          CourseDurationUnit?durationUnit,
                          CourseStudyMode?studyMode,
                          CourseAttendancePattern?attendancePattern,
                          Guid?venueId)
 {
     CourseName        = courseName;
     ProviderCourseRef = providerCourseRef;
     StartDate         = startDate;
     FlexibleStartDate = flexibleStartDate;
     NationalDelivery  = nationalDelivery;
     SubRegionIds      = subRegionIds;
     CourseWebPage     = courseWebPage;
     Cost              = cost;
     CostDescription   = costDescription;
     Duration          = duration;
     DurationUnit      = durationUnit;
     AttendancePattern = attendancePattern;
     StudyMode         = studyMode;
     VenueId           = venueId;
 }
Exemplo n.º 5
0
        public static FrameworkElement Render(TypedElement element, RenderContext context)
        {
            DateInput input = (DateInput)element;

            if (context.Config.SupportsInteractivity)
            {
                var datePicker = new DatePicker();
                datePicker.ToolTip = input.Placeholder;
                DateTime value;
                if (DateTime.TryParse(input.Value, out value))
                {
                    datePicker.SelectedDate = value;
                }
                DateTime minValue;
                if (DateTime.TryParse(input.Min, out minValue))
                {
                    datePicker.DisplayDateStart = minValue;
                }
                DateTime maxValue;
                if (DateTime.TryParse(input.Max, out maxValue))
                {
                    datePicker.DisplayDateEnd = maxValue;
                }
                datePicker.Style       = context.GetStyle("Adaptive.Input.Date");
                datePicker.DataContext = input;
                context.InputBindings.Add(input.Id, () => datePicker.Text);
                return(datePicker);
            }
            else
            {
                var textBlock = TypedElementConverter.CreateElement <TextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;
                return(context.Render(textBlock));
            }
        }
Exemplo n.º 6
0
        public static FrameworkElement Render(TypedElement element, RenderContext context)
        {
            DateInput input = (DateInput)element;

            if (context.Config.SupportsInteractivity)
            {
                var textBox = new TextBox()
                {
                    Text = input.Value
                };
                textBox.SetPlaceholder(input.Placeholder);
                textBox.Style = context.GetStyle($"Adaptive.Input.Text.Date");
                textBox.SetContext(input);
                context.InputBindings.Add(input.Id, () => textBox.Text);
                return(textBox);
            }
            else
            {
                Container container = TypedElementConverter.CreateElement <Container>();
                container.Separation = input.Separation;
                TextBlock textBlock = TypedElementConverter.CreateElement <TextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;
                container.Items.Add(textBlock);
                if (input.Value != null)
                {
                    textBlock       = TypedElementConverter.CreateElement <TextBlock>();
                    textBlock.Text  = input.Value;
                    textBlock.Color = TextColor.Accent;
                    textBlock.Wrap  = true;
                    container.Items.Add(textBlock);
                }
                return(context.Render(container));
            }
        }
Exemplo n.º 7
0
        protected static HtmlTag DateInputRender(TypedElement element, RenderContext context)
        {
            DateInput input = (DateInput)element;

            var uiDateInput = new HtmlTag("input")
                              .Attr("name", input.Id)
                              .Attr("type", "date")
                              .AddClass("ac-input")
                              .AddClass("ac-dateInput")
                              .Style("width", "100%");

            if (!string.IsNullOrEmpty(input.Value))
            {
                uiDateInput.Attr("value", input.Value);
            }

            if (!string.IsNullOrEmpty(input.Min))
            {
                uiDateInput.Attr("min", input.Min);
            }

            if (!string.IsNullOrEmpty(input.Max))
            {
                uiDateInput.Attr("max", input.Max);
            }

            return(uiDateInput);
        }
        /// <summary>
        /// Заполнить поле 'Дата'
        /// </summary>
        /// <param name="date">Дата</param>
        public ScheduleMainPage FillDateField(string date)
        {
            CustomTestContext.WriteLine($"Заполнить поле 'Дата' значением {date}");
            DateInput.Clear();
            DateInput.SendKeys(date);

            return(LoadPage());
        }
Exemplo n.º 9
0
            public static DQueryDom GetQueryDom(QueryContainer mQueryContainer, DateInput sd, DateInput ed)
            {
                var domainID     = DomainContext.Current.ID;
                var outputQuery  = GetOutputQuery(domainID, mQueryContainer, sd, ed);
                var instoreQuery = GetInStoreQuery(domainID, mQueryContainer, sd, ed);

                outputQuery.UnionNext.Select = instoreQuery;
                outputQuery.UnionNext.Type   = UnionType.All;
                return(outputQuery);
            }
Exemplo n.º 10
0
        Control CreateDataRangePanel()
        {
            var hPanel = new HLayoutPanel();

            hPanel.Add(new SimpleLabel("日期"));
            sd = hPanel.Add(new DateInput());
            hPanel.Add(new LiteralControl("→"));
            ed = hPanel.Add(new DateInput());
            return(hPanel);
        }
Exemplo n.º 11
0
        public IEnumerable <string> GetDateFormats()
        {
            int optionsCount = FormatOptions.Options.Count;

            for (int i = 0; i < optionsCount; i++)
            {
                FormatOptions.SelectByIndex(i);
                yield return(DateInput.GetAttribute("value"));
            }
        }
Exemplo n.º 12
0
 //暂时先不用
 static void AddDateCondition(JoinAlias main, DQueryDom query, string dtFile, DateInput sd, DateInput ed)
 {
     if (sd.Value.HasValue)
     {
         query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual(main, dtFile, sd.Value.Value));
     }
     if (ed.Value.HasValue)
     {
         query.Where.Conditions.Add(DQCondition.LessThanOrEqual(main, dtFile, ed.Value.Value));
     }
 }
Exemplo n.º 13
0
        HLayoutPanel CreateDataRangePanel()
        {
            var hPanel = new HLayoutPanel();

            hPanel.Add(new SimpleLabel("日期"));
            dateInput       = new DateInput();
            dateInput.Value = DateTime.Today.AddDays(-1);

            hPanel.Add(dateInput);
            return(hPanel);
            //            hPanel.Add(QueryCreator.DateRange(_mainInfo.Fields["Date"], mQueryContainer, "MinDate", "MaxDate"));
        }
        public ValidationResult Validate(Element element, Dictionary <string, dynamic> viewModel, FormSchema baseForm)
        {
            if ((!element.Type.Equals(EElementType.DatePicker) &&
                 !element.Type.Equals(EElementType.DateInput)) ||
                string.IsNullOrEmpty(element.Properties.IsDateBeforeAbsolute))
            {
                return(new ValidationResult {
                    IsValid = true
                });
            }

            DateTime?dateValue = new DateTime();

            if (element.Type.Equals(EElementType.DatePicker))
            {
                dateValue = DatePicker.GetDate(viewModel, element.Properties.QuestionId);
            }

            if (element.Type.Equals(EElementType.DateInput))
            {
                dateValue = DateInput.GetDate(viewModel, element.Properties.QuestionId);
            }

            if (!dateValue.HasValue)
            {
                return new ValidationResult {
                           IsValid = true
                }
            }
            ;

            if (!DateTime.TryParse(element.Properties.IsDateBeforeAbsolute, out DateTime comparisonDateValue))
            {
                throw new FormatException("IsDateBeforeAbsoluteValidator: The comparison date format was incorrect");
            }

            if (dateValue < comparisonDateValue)
            {
                return new ValidationResult {
                           IsValid = true
                }
            }
            ;

            return(new ValidationResult {
                IsValid = false,
                Message = !string.IsNullOrEmpty(element.Properties.IsDateBeforeValidationMessage)
                    ? element.Properties.IsDateBeforeValidationMessage
                    : string.Format(ValidationConstants.IS_DATE_BEFORE_VALIDATOR_DEFAULT, element.Properties.IsDateBeforeAbsolute)
            });
        }
    }
}
Exemplo n.º 15
0
        public void GetDate_ReturnNull_IfOnlyPartialCorrectDate()
        {
            var viewModel = new Dictionary <string, dynamic>
            {
                { $"test-date{DateInput.YEAR_EXTENSION}", "2020" },
                { $"test-date{DateInput.MONTH_EXTENSION}", "01" },
            };

            var result = DateInput.GetDate(viewModel, "test-date");

            Assert.False(result.HasValue);
        }
Exemplo n.º 16
0
        protected override void Execute(CodeActivityContext executionContext)
        {
            ITracingService             tracingService = executionContext.GetExtension <ITracingService>();
            IWorkflowContext            context        = executionContext.GetExtension <IWorkflowContext>();
            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();
            IOrganizationService        service        = serviceFactory.CreateOrganizationService(context.UserId);

            string   dateInput     = DateInput.Get <string>(executionContext);
            DateTime formattedDate = new DateTime();

            DateTime.TryParse(dateInput, out formattedDate);
            DateOutput.Set(executionContext, formattedDate);
        }
        public IActionResult DateInput([Bind("Date1, Date2")] DateInput dateInput)
        {
            if (dateInput.Date1.CompareTo(dateInput.Date2) >= 0)
            {
                ModelState.AddModelError(nameof(dateInput.Date1), "DateTime entered is incorrect!,The second date needs to happen after the first date!");
                return(View(new DateInput()));
            }

            HttpContext.Session.SetString("Date1", dateInput.Date1.ToString());
            HttpContext.Session.SetString("Date2", dateInput.Date2.ToString());


            return(RedirectToAction("ViewTransaction", "Transactions"));
        }
Exemplo n.º 18
0
        public void GetDate_ReturnCorrectDate()
        {
            var viewModel = new Dictionary <string, dynamic>
            {
                { $"test-date{DateInput.YEAR_EXTENSION}", "2020" },
                { $"test-date{DateInput.MONTH_EXTENSION}", "01" },
                { $"test-date{DateInput.DAY_EXTENSION}", "01" }
            };

            DateTime?result = DateInput.GetDate(viewModel, "test-date");

            Assert.True(result.HasValue);
            Assert.True(result.Value == new DateTime(2020, 1, 1));
        }
        void ReleaseDesignerOutlets()
        {
            if (Backward != null)
            {
                Backward.Dispose();
                Backward = null;
            }

            if (DateInput != null)
            {
                DateInput.Dispose();
                DateInput = null;
            }

            if (FeedName != null)
            {
                FeedName.Dispose();
                FeedName = null;
            }

            if (FeedSelection != null)
            {
                FeedSelection.Dispose();
                FeedSelection = null;
            }

            if (Forward != null)
            {
                Forward.Dispose();
                Forward = null;
            }

            if (NoContent != null)
            {
                NoContent.Dispose();
                NoContent = null;
            }

            if (NoMenu != null)
            {
                NoMenu.Dispose();
                NoMenu = null;
            }

            if (WebView != null)
            {
                WebView.Dispose();
                WebView = null;
            }
        }
Exemplo n.º 20
0
 public void TestDateInput()
 {
     try
     {
         IHtmlFormatter dateInput     = new DateInput();
         IDictionary    configuration = new Hashtable();
         configuration.Add("dateFormat", "dd/MM/yyyy");
         dateInput.SetConfiguration(configuration);
         DateTime date = (DateTime)dateInput.ParseHttpParameter("11/11/2004", null);
         Assert.IsNotNull(date);
         Assert.IsTrue(date.Year == 2004);
         Assert.IsTrue(date.Month == 11);
         Assert.IsTrue(date.Day == 11);
     }
     catch (Exception ex)
     {
         Assert.Fail(ex.Message);
     }
 }
Exemplo n.º 21
0
        public void RenderTest()
        {
            var dt = new System.DateTime(2008, 11, 15);

            DateInput target = new DateInput();

            Assert.AreEqual("<input type=\"text\" name=\"test\" />",
                            target.Render("test", null));
            Assert.AreEqual("<input type=\"text\" name=\"test\" value=\"2008-11-15\" />",
                            target.Render("test", dt));
            Assert.AreEqual("<input type=\"text\" name=\"test\" value=\"123\" />",
                            target.Render("test", 123));

            target.Format = "MM/dd/yyyy";
            Assert.AreEqual("<input type=\"text\" name=\"test\" />",
                            target.Render("test", null));
            Assert.AreEqual("<input type=\"text\" name=\"test\" value=\"11/15/2008\" />",
                            target.Render("test", dt));
        }
Exemplo n.º 22
0
        protected static HtmlTag DateInputRender(TypedElement element, RenderContext context)
        {
            DateInput input     = (DateInput)element;
            var       container = new Container {
                Separation = input.Separation
            };

            container.Items.Add(new TextBlock {
                Text = GetFallbackText(input) ?? input.Placeholder
            });
            if (input.Value != null)
            {
                container.Items.Add(new TextBlock
                {
                    Text  = input.Value,
                    Color = TextColor.Accent,
                    Wrap  = true
                });
            }
            return(context.Render(container));
        }
Exemplo n.º 23
0
 public void SetRandom()
 {
     if (Checkbox.IsPresent)
     {
         Checkbox.Set(true);
     }
     else if (Select.IsPresent)
     {
         Select.Set(Select.Options[Randomizer.GetInt(0, Select.Options.Count - 1)].Value);
     }
     else if (TextInput.IsPresent)
     {
         TextInput.SetRandom();
     }
     else if (DateInput.IsPresent)
     {
         DateInput.SetRandom();
     }
     else if (EmailInput.IsPresent)
     {
         EmailInput.Set(Randomizer.GetString("{0}@{0}.com"));
     }
 }
Exemplo n.º 24
0
        public async Task <ActionResult> SearchByReleased(DateInput dateInput)
        {
            // make another games API call
            // call for Games, with a title of 'titleToSearchBy'
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("https://api.rawg.io/api/games");

            HttpResponseMessage response = await client.GetAsync("?search=" + dateInput.DateToSearchBy);

            List <Item> itemsToChooseFrom = new List <Item>();

            if (response.IsSuccessStatusCode)
            {
                string data = await response.Content.ReadAsStringAsync();

                JObject jsonResults = JsonConvert.DeserializeObject <JObject>(data);


                for (int i = 0; i < 10; i++)
                {
                    JToken name     = jsonResults["results"][i]["name"];
                    JToken Released = jsonResults["results"][i]["released"];

                    Item randomItem = new Item();
                    randomItem.Name     = name.ToString();
                    randomItem.Released = Released.ToString();



                    itemsToChooseFrom.Add(randomItem);
                }
            }

            return(View("GamesIndex", itemsToChooseFrom));
        }
Exemplo n.º 25
0
 private void ClearInput()
 {
     TitleInput.Clear();
     DateInput.Clear();
     DescriptionInput.Clear();
 }
Exemplo n.º 26
0
 public void DateInputConstructorTest()
 {
     DateInput target = new DateInput();
 }
Exemplo n.º 27
0
        public virtual async Task DatePickerAsync(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            var      temp = await result as Activity;
            DateTime dtStartDate;
            DateTime dtEndDate;
            var      datePresent  = DateTime.TryParse(temp.Text, out dtStartDate);
            var      datePresent1 = DateTime.TryParse(temp.Text, out dtEndDate);

            dtStartDate = DateTime.Now;

            if (!datePresent && temp.Value != null)
            {
                var jObjectValue = temp.Value as JObject;

                strStartDate = jObjectValue.Value <string>("StartDate");
                strEndDate   = jObjectValue.Value <string>("EndDate");

                if (!string.IsNullOrEmpty(strStartDate))
                {
                    dtStartDate  = DateTime.ParseExact(strStartDate, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                    strStartDate = dtStartDate.ToString("dd-MMM-yyyy");
                    datePresent  = true;
                    dtEndDate    = DateTime.ParseExact(strEndDate, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                    strEndDate   = dtEndDate.ToString("dd-MMM-yyyy");
                    datePresent1 = true;
                }
            }

            if (!datePresent)
            {
                //since the user did not send a date, show the card
                AdaptiveCard card = new AdaptiveCard();

                card.Body.Add(new TextBlock()
                {
                    Text = "Please provide start date and end date?",
                    // Size = TextSize.Large,
                    // Weight = TextWeight.Bolder
                });

                DateInput diStartDate = new DateInput()
                {
                    Id          = "StartDate",
                    Placeholder = "Start Date",
                    Value       = dtStartDate.ToString("yyyy-MM-dd")
                };

                DateInput diEndDate = new DateInput()
                {
                    Id          = "EndDate",
                    Placeholder = "End Date",
                    Value       = dtStartDate.ToString("yyyy-MM-dd")
                };

                card.Body.Add(diStartDate);
                card.Body.Add(diEndDate);
                card.Actions.Add(new SubmitAction()
                {
                    Title = "OK"
                });


                Attachment cardAttachment = new Attachment()
                {
                    ContentType = "application/vnd.microsoft.card.adaptive",
                    Content     = card
                };

                var message = context.MakeMessage();
                message.Attachments = new List <Attachment>();
                message.Attachments.Add(cardAttachment);
                await context.PostAsync(message);
            }
            else
            {
                // await context.PostAsync($"Confirm Your Leavedates: {dtStartDate} {dtEndDate}");
                await context.PostAsync("Please confirm your Leave Details \r\n \r\n\r\n Leave Category : " + strLeaveCat + " \r\n Leave Start Date : " + strStartDate + " \r\n Leave End Date : " + strEndDate + " \r\n");

                PromptDialog.Choice(context, EndoptionAsync, new List <string> {
                    "Yes", "No"
                },
                                    "Confirm Your Leavedetails :", "Sorry, I didn't get that",
                                    3);
            }
        }
Exemplo n.º 28
0
        public virtual async Task DatePickAsync(IDialogContext context, IAwaitable <IMessageActivity> argument)
        {
            var      temp = await argument as Activity;
            DateTime dtStartDate;
            var      datePresent = DateTime.TryParse(temp.Text, out dtStartDate);
            DateTime today       = DateTime.Today;

            dtStartDate = DateTime.Now;

            if (!datePresent && temp.Value != null)
            {
                var jObjectValue = temp.Value as JObject;

                strStartDate = jObjectValue.Value <string>("StartDate");

                if (!string.IsNullOrEmpty(strStartDate))
                {
                    dtStartDate  = DateTime.ParseExact(strStartDate, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                    strStartDate = dtStartDate.ToString("dd-MMM-yyyy");
                    datePresent  = true;
                }
            }

            if (!datePresent)
            {
                //since the user did not send a date, show the card
                AdaptiveCard card = new AdaptiveCard();

                card.Body.Add(new TextBlock()
                {
                    Text = "Please provide \r\n Expected date of response ",
                    // Size = TextSize.Large,
                    // Weight = TextWeight.Bolder
                });

                DateInput diStartDate = new DateInput()
                {
                    Id          = "StartDate",
                    Placeholder = "Start Date",
                    Value       = dtStartDate.ToString("yyyy-MM-dd")
                };
                //dtStartDate = DateTime.Now;
                //if (temp.Value == null)
                //{
                //    if (TQClosureType != "Hold Work")
                //    {
                //        dtStartDate = DateTime.Now.AddDays(2);
                //        datePresent = true;
                //        strStartDate = dtStartDate.ToString("dd-MMM-yyyy");
                //    }
                //}
                card.Body.Add(diStartDate);

                card.Actions.Add(new SubmitAction()
                {
                    Title = "OK"
                });

                Attachment cardAttachment = new Attachment()
                {
                    ContentType = "application/vnd.microsoft.card.adaptive",
                    Content     = card
                };

                var message = context.MakeMessage();

                message.Attachments = new List <Attachment>();
                message.Attachments.Add(cardAttachment);
                await context.PostAsync(message);
            }
            else
            {
                //  await context.PostAsync($"your selected date ", strStartDate);
                result1 = new string[ds.Tables[0].Rows.Count];
                strArry = "";
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (strArry == "")
                    {
                        strArry = dr[1].ToString();
                    }
                    else
                    {
                        strArry = strArry + "," + dr[1].ToString();
                    }
                }
                List <string> resultArry = strArry.Split(',').ToList();

                PromptDialog.Choice(context, ContractnoAsync, resultArry,
                                    "Please select Holding Contract ", "Sorry, I didn't get that",
                                    3);
            }
        }
Exemplo n.º 29
0
 public virtual void Visit(DateInput inputDate)
 {
 }
Exemplo n.º 30
0
        static void AddCondition(JoinAlias main, JoinAlias goodsAlias, DQueryDom query, string dtFile, QueryContainer mQueryContainer, DateInput sd, DateInput ed)
        {
            var goodsName = mQueryContainer.GetControl <DFTextBox>("Goods_Name").Text;
            var goodsCode = mQueryContainer.GetControl <DFTextBox>("Goods_Code").Text;

            if (!string.IsNullOrEmpty(goodsName))
            {
                query.Where.Conditions.Add(DQCondition.Or(DQCondition.Like(goodsAlias, "Name", goodsName), DQCondition.Like(goodsAlias, "Spell", goodsName)));
            }
            if (!string.IsNullOrEmpty(goodsCode))
            {
                query.Where.Conditions.Add(DQCondition.Like(goodsAlias, "Code", goodsCode));
            }
            if (sd.Value.HasValue)
            {
                query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual(main, dtFile, sd.Value.Value));
            }
            if (ed.Value.HasValue)
            {
                query.Where.Conditions.Add(DQCondition.LessThanOrEqual(main, dtFile, ed.Value.Value));
            }
        }