示例#1
0
        private void BinddgEvents()
        {
            DataTable dt = CalendarEntry.GetListEventsUpdatedForUserDataTable(NumOfDays, ProjectID);

            ViewState["EventsRowCount"] = dt.Rows.Count;

            if (dt.Rows.Count == 0 ||
                (pc["ProjectUSetup_ShowEvents"] != null && pc["ProjectUSetup_ShowEvents"] == "False"))
            {
                sep4.Visible = false;
                Pan4.Visible = false;
            }
            else if (PageSize >= dt.Rows.Count)
            {
                dgEvents.PagerStyle.Visible = false;
            }

            dgEvents.PageSize = PageSize;
            dgEvents.Columns[0].HeaderText = LocRM.GetString("Title");
            dgEvents.Columns[1].HeaderText = LocRM.GetString("UpdatedBy");
            dgEvents.Columns[2].HeaderText = LocRM.GetString("Modify");
            dgEvents.CurrentPageIndex      = (int)ViewState["dgEvents"];
            dgEvents.DataSource            = dt.DefaultView;
            dgEvents.DataBind();
        }
示例#2
0
 private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (checkedListBox1.SelectedIndex < 0)
     {
         labelEventName.Text     = "-";
         dateTimePicker1.Enabled = false;
         dateTimePicker2.Enabled = false;
         textBox1.Enabled        = false;
         textBox2.Enabled        = false;
         textBox3.Enabled        = false;
         buttonSave.Enabled      = false;
     }
     else
     {
         CalendarEntry ce = checkedListBox1.Items[checkedListBox1.SelectedIndex] as CalendarEntry;
         dateTimePicker1.Enabled = true;
         dateTimePicker1.Value   = ce.StartTime;
         dateTimePicker2.Enabled = true;
         dateTimePicker2.Value   = ce.EndTime;
         textBox1.Enabled        = true;
         textBox1.Text           = ce.Location;
         textBox2.Enabled        = true;
         textBox2.Text           = ce.Summary;
         textBox3.Enabled        = true;
         textBox3.Text           = ce.Description;
         buttonSave.Enabled      = true;
         labelEventName.Text     = ce.ToString();;
     }
 }
示例#3
0
 private void BindCategories()
 {
     lbCategory.DataSource     = CalendarEntry.GetListCategoriesAll();
     lbCategory.DataTextField  = "CategoryName";
     lbCategory.DataValueField = "CategoryId";
     lbCategory.DataBind();
 }
示例#4
0
 public IActionResult Delete([FromHeader(Name = "ApiKey")] string carerApiKey, [FromQuery(Name = "id")] string entryId)
 {
     try
     {
         CalendarEntry entry       = (CalendarEntry)DbService.GetEntityByPrimaryKey(_ctx, entryId, DbService.Collection.calendars).GetAwaiter().GetResult();
         bool          entryExists = DbService.GetEntityByPrimaryKey(_ctx, entryId, DbService.Collection.calendars).GetAwaiter().GetResult() != null;
         if (entryExists)
         {
             Carer carer      = (Carer)DbService.GetEntityByForeignKey(_ctx, carerApiKey, DbService.Collection.carers);
             bool  authorised = (carer.AssignedPatientIds != null && carer.AssignedPatientIds.Contains(entry.PatientId));
             if (authorised)
             {
                 bool success = DbService.DeleteEntityByPrimaryKey(_ctx, entryId, DbService.Collection.calendars).GetAwaiter().GetResult();
                 if (success)
                 {
                     return(Ok("Calendar entry deleted successfully."));
                 }
                 return(BadRequest("Failed to delete calendar entry."));
             }
             return(Unauthorized("You are not assigned to that patient."));
         }
         return(NotFound("Could not find an entry with that id."));
     }
     catch (Exception e)
     {
         return(BadRequest(e));
     }
 }
        private void ValidateCalendarEntryOnModify(CalendarEntry calendarEntry)
        {
            ValidateCalendarEntryIsNotNull(calendarEntry);

            Validate
            (
                (Rule: IsInvalidX(calendarEntry.Id), Parameter: nameof(CalendarEntry.Id)),
                (Rule: IsInvalidX(calendarEntry.Label), Parameter: nameof(CalendarEntry.Label)),
                (Rule: IsInvalidX(calendarEntry.Description), Parameter: nameof(CalendarEntry.Description)),
                (Rule: IsInvalidX(calendarEntry.StartDate), Parameter: nameof(CalendarEntry.StartDate)),
                (Rule: IsInvalidX(calendarEntry.EndDate), Parameter: nameof(CalendarEntry.EndDate)),
                (Rule: IsInvalidX(calendarEntry.RemindAtDateTime), Parameter: nameof(CalendarEntry.RemindAtDateTime)),
                (Rule: IsInvalidX(calendarEntry.CreatedBy), Parameter: nameof(CalendarEntry.CreatedBy)),
                (Rule: IsInvalidX(calendarEntry.UpdatedBy), Parameter: nameof(CalendarEntry.UpdatedBy)),
                (Rule: IsInvalidX(calendarEntry.CreatedDate), Parameter: nameof(CalendarEntry.CreatedDate)),
                (Rule: IsInvalidX(calendarEntry.UpdatedDate), Parameter: nameof(CalendarEntry.UpdatedDate)),
                (Rule: IsNotRecent(calendarEntry.UpdatedDate), Parameter: nameof(CalendarEntry.UpdatedDate)),

                (Rule: IsSame(
                     firstDate: calendarEntry.UpdatedDate,
                     secondDate: calendarEntry.CreatedDate,
                     secondDateName: nameof(CalendarEntry.CreatedDate)),
                 Parameter: nameof(CalendarEntry.UpdatedDate)),

                (Rule: IsBefore(
                     firstDate: calendarEntry.EndDate,
                     secondDate: calendarEntry.StartDate,
                     secondDateName: nameof(CalendarEntry.StartDate)),
                 Parameter: nameof(CalendarEntry.EndDate))

            );
        }
示例#6
0
 private void HandleCalendarEventUnselected(CalendarEventUnselected message)
 {
     if (CurrentlySelectedCalendarEntry?.ID == message.CalendarEntry.ID)
     {
         CurrentlySelectedCalendarEntry = null;
     }
 }
示例#7
0
        public void OAuth3LeggedAuthenticationTest()
        {
            Tracing.TraceMsg("Entering OAuth3LeggedAuthenticationTest");

            CalendarService service = new CalendarService("OAuthTestcode");

            GOAuthRequestFactory requestFactory = new GOAuthRequestFactory("cl", "OAuthTestcode");

            requestFactory.ConsumerKey    = this.oAuthConsumerKey;
            requestFactory.ConsumerSecret = this.oAuthConsumerSecret;
            requestFactory.Token          = this.oAuthToken;
            requestFactory.TokenSecret    = this.oAuthTokenSecret;
            service.RequestFactory        = requestFactory;

            CalendarEntry calendar = new CalendarEntry();

            calendar.Title.Text = "Test OAuth";

            Uri           postUri         = new Uri("https://www.google.com/calendar/feeds/default/owncalendars/full");
            CalendarEntry createdCalendar = (CalendarEntry)service.Insert(postUri, calendar);

            // delete the guy again

            createdCalendar.Delete();
        }
        private void ValidateCalendarEntryAuditFieldsOnModify(CalendarEntry calendarEntry)
        {
            switch (calendarEntry)
            {
            case { } when IsInvalid(input: calendarEntry.CreatedBy) :
                throw new InvalidCalendarEntryException(
                          parameterName: nameof(CalendarEntry.CreatedBy),
                          parameterValue: calendarEntry.CreatedBy);

            case { } when IsInvalid(input: calendarEntry.CreatedDate) :
                throw new InvalidCalendarEntryException(
                          parameterName: nameof(CalendarEntry.CreatedDate),
                          parameterValue: calendarEntry.CreatedDate);

            case { } when IsInvalid(input: calendarEntry.UpdatedBy) :
                throw new InvalidCalendarEntryException(
                          parameterName: nameof(CalendarEntry.UpdatedBy),
                          parameterValue: calendarEntry.UpdatedBy);

            case { } when IsInvalid(input: calendarEntry.UpdatedDate) :
                throw new InvalidCalendarEntryException(
                          parameterName: nameof(CalendarEntry.UpdatedDate),
                          parameterValue: calendarEntry.UpdatedDate);

            case { } when calendarEntry.UpdatedDate == calendarEntry.CreatedDate:
                throw new InvalidCalendarEntryException(
                          parameterName: nameof(CalendarEntry.UpdatedDate),
                          parameterValue: calendarEntry.UpdatedDate);

            case { } when IsDateNotRecent(calendarEntry.UpdatedDate):
                throw new InvalidCalendarEntryException(
                          parameterName: nameof(CalendarEntry.UpdatedDate),
                          parameterValue: calendarEntry.UpdatedDate);
            }
        }
 private static void ValidateCalendarEntryIsNotNull(CalendarEntry CalendarEntry)
 {
     if (CalendarEntry is null)
     {
         throw new NullCalendarEntryException();
     }
 }
示例#10
0
 private static void validateConcurrencyStamp(CalendarEntryDTO entryDTO, CalendarEntry entry)
 {
     if (entry.ConcurrencyStamp.Length != entryDTO.ConcurrencyStamp.Length || entry.ConcurrencyStamp.Any(x => !entryDTO.ConcurrencyStamp.Contains(x)))
     {
         throw new ValuesChangedByAnotherUserException();
     }
 }
示例#11
0
 public static bool CanWork(int ObjectTypeId, int ObjectId)
 {
     if (ObjectTypeId == (int)ObjectTypes.Task)
     {
         return(Task.CanViewFinances(ObjectId));
     }
     else if (ObjectTypeId == (int)ObjectTypes.CalendarEntry)
     {
         return(CalendarEntry.CanViewFinances(ObjectId));
     }
     else if (ObjectTypeId == (int)ObjectTypes.Document)
     {
         return(Document.CanViewFinances(ObjectId));
     }
     else if (ObjectTypeId == (int)ObjectTypes.Issue)
     {
         return(Incident.CanViewFinances(ObjectId));
     }
     else if (ObjectTypeId == (int)ObjectTypes.ToDo)
     {
         return(ToDo.CanViewFinances(ObjectId));
     }
     else if (ObjectTypeId == (int)ObjectTypes.Project)
     {
         return(Project.CanEditFinances(ObjectId));
     }
     else
     {
         return(false);
     }
 }
        public ActionResult EditEvent(int id, CalendarEntry newEvent)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (newEvent == null)
            {
                return(NotFound());
            }

            var calendarEvent = DbContext.CalendarEntries.Find(id);

            calendarEvent.ApptEndDate   = newEvent.ApptEndDate;
            calendarEvent.ApptStartDate = newEvent.ApptStartDate;
            calendarEvent.ApptStartTime = newEvent.ApptStartTime;
            calendarEvent.ApptEndTime   = newEvent.ApptEndTime;
            calendarEvent.Description   = newEvent.Description;
            calendarEvent.Title         = newEvent.Title;

            DbContext.CalendarEntries.Update(calendarEvent);
            DbContext.SaveChanges();
            return(Ok(newEvent));
        }
        public async Task ShouldRetrieveCalendarEntryByIdAsync()
        {
            // given
            Guid           randomCalendarEntryId = Guid.NewGuid();
            Guid           inputCalendarEntryId  = randomCalendarEntryId;
            DateTimeOffset randomDateTime        = GetRandomDateTime();
            CalendarEntry  randomCalendarEntry   = CreateRandomCalendarEntry(randomDateTime);
            CalendarEntry  storageCalendarEntry  = randomCalendarEntry;
            CalendarEntry  expectedCalendarEntry = storageCalendarEntry;

            this.storageBrokerMock.Setup(broker =>
                                         broker.SelectCalendarEntryByIdAsync(inputCalendarEntryId))
            .ReturnsAsync(storageCalendarEntry);

            // when
            CalendarEntry actualCalendarEntry =
                await this.calendarEntryService.RetrieveCalendarEntryByIdAsync(
                    inputCalendarEntryId);

            // then
            actualCalendarEntry.Should().BeEquivalentTo(expectedCalendarEntry);

            this.dateTimeBrokerMock.Verify(broker =>
                                           broker.GetCurrentDateTime(),
                                           Times.Never);

            this.storageBrokerMock.Verify(broker =>
                                          broker.SelectCalendarEntryByIdAsync(inputCalendarEntryId),
                                          Times.Once);

            this.dateTimeBrokerMock.VerifyNoOtherCalls();
            this.storageBrokerMock.VerifyNoOtherCalls();
            this.storageBrokerMock.VerifyNoOtherCalls();
        }
        public async void ShouldThrowValidationExceptionOnModifyWhenUpdatedDateIsSameAsCreatedDateAndLogItAsync()
        {
            // given
            DateTimeOffset dateTime            = GetRandomDateTime();
            CalendarEntry  randomCalendarEntry = CreateRandomCalendarEntry(dateTime);
            CalendarEntry  inputCalendarEntry  = randomCalendarEntry;

            var invalidCalendarEntryInputException = new InvalidCalendarEntryException(
                parameterName: nameof(CalendarEntry.UpdatedDate),
                parameterValue: inputCalendarEntry.UpdatedDate);

            var expectedCalendarEntryValidationException =
                new CalendarEntryValidationException(invalidCalendarEntryInputException);

            // when
            ValueTask <CalendarEntry> modifyCalendarEntryTask =
                this.calendarEntryService.ModifyCalendarEntryAsync(inputCalendarEntry);

            // then
            await Assert.ThrowsAsync <CalendarEntryValidationException>(() =>
                                                                        modifyCalendarEntryTask.AsTask());

            this.loggingBrokerMock.Verify(broker =>
                                          broker.LogError(It.Is(SameExceptionAs(expectedCalendarEntryValidationException))),
                                          Times.Once);

            this.storageBrokerMock.Verify(broker =>
                                          broker.SelectCalendarEntryByIdAsync(It.IsAny <Guid>()),
                                          Times.Never);

            this.dateTimeBrokerMock.VerifyNoOtherCalls();
            this.loggingBrokerMock.VerifyNoOtherCalls();
            this.storageBrokerMock.VerifyNoOtherCalls();
        }
        public async Task ShouldThrowValidationExceptionOnModifyWhenCalendarEntryLabelIsInvalidAndLogItAsync(
            string invalidCalendarEntryLabel)
        {
            // given
            CalendarEntry randomCalendarEntry  = CreateRandomCalendarEntry(DateTime.Now);
            CalendarEntry invalidCalendarEntry = randomCalendarEntry;

            invalidCalendarEntry.Label = invalidCalendarEntryLabel;

            var invalidCalendarEntryInputException = new InvalidCalendarEntryException(
                parameterName: nameof(CalendarEntry.Label),
                parameterValue: invalidCalendarEntry.Label);

            var expectedCalendarEntryValidationException =
                new CalendarEntryValidationException(invalidCalendarEntryInputException);

            // when
            ValueTask <CalendarEntry> modifyCalendarEntryTask =
                this.calendarEntryService.ModifyCalendarEntryAsync(invalidCalendarEntry);

            // then
            await Assert.ThrowsAsync <CalendarEntryValidationException>(() =>
                                                                        modifyCalendarEntryTask.AsTask());

            this.loggingBrokerMock.Verify(broker =>
                                          broker.LogError(It.Is(SameExceptionAs(expectedCalendarEntryValidationException))),
                                          Times.Once);

            this.loggingBrokerMock.VerifyNoOtherCalls();
            this.storageBrokerMock.VerifyNoOtherCalls();
            this.dateTimeBrokerMock.VerifyNoOtherCalls();
        }
示例#16
0
        public EventEntry 创建活动(string 标题, string 说明, string 地点, DateTime 开始时间, DateTime 结束时间, Reminder.ReminderMethod 提醒方式, TimeSpan 提前提醒时间)
        {
            if (提醒方式 != Reminder.ReminderMethod.none && 提前提醒时间.TotalMinutes < 1)
            {
                throw new Exception("提前提醒时间不得小于1分钟,因为低于分钟的单位将被忽略");
            }

            var q = new EventEntry(标题, 说明, 地点);

            q.Times.Add(new When(开始时间, 结束时间));
            q.Reminder = new Reminder {
                Minutes = 提前提醒时间.Minutes, Days = 提前提醒时间.Days, Hours = 提前提醒时间.Hours, Method = Reminder.ReminderMethod.all
            };

            if (操作日历名称 == null)
            {
                return(日历服务.Insert(new Uri(访问网址), q) as EventEntry);
            }
            else
            {
                var           query = new CalendarQuery(访问网址);
                CalendarEntry c     = null;
                foreach (CalendarEntry f in 日历服务.Query(query).Entries)
                {
                    if (f.Title.Text == 操作日历名称)
                    {
                        c = f;
                    }
                }
                return(日历服务.Insert(new Uri(c.Content.AbsoluteUri), q) as EventEntry);
            }
        }
        public ActionResult EditEventForm(EditEventModel e)
        {
            List <EventLocation> locations = this._db.Query <EventLocation>("SELECT * FROM ec_locations").ToList();

            locations.Insert(0, new EventLocation()
            {
                LocationName = "No Location", Id = 0
            });
            SelectList list = new SelectList(locations, "Id", "LocationName", e.selectedLocation);

            e.locations = list;
            if (!ModelState.IsValid)
            {
                TempData["StatusEditEvent"] = "Invalid";
                return(PartialView("EditEventForm", e));
            }
            TempData["StatusEditEvent"] = "Valid";
            CalendarEntry entry = new CalendarEntry()
            {
                allDay      = e.allday,
                calendarId  = e.calendarId,
                description = e.description,
                title       = e.title,
                end         = e.end,
                start       = e.start,
                Id          = e.Id,
                locationId  = e.selectedLocation
            };

            this._db.Update(entry);
            return(PartialView("EditEventForm", e));
        }
        public ActionResult EditEventForm(int id = 0)
        {
            List <EventLocation> locations = this._db.Query <EventLocation>("SELECT * FROM ec_locations").ToList();

            locations.Insert(0, new EventLocation()
            {
                LocationName = "No Location", Id = 0
            });

            //Get the Event from Database
            CalendarEntry entry = this._db.SingleOrDefault <CalendarEntry>(id);
            //Create SelectList with selected location
            SelectList list = new SelectList(locations, "Id", "LocationName", entry.locationId);
            //Create Model for the View
            EditEventModel eem = new EditEventModel()
            {
                Id          = entry.Id,
                title       = entry.title,
                start       = (DateTime)entry.start,
                description = entry.description,
                calendarId  = entry.calendarId,
                allday      = entry.allDay,
                locations   = list
            };

            if (null != entry.end)
            {
                eem.end = (DateTime)entry.end;
            }


            return(PartialView("EditEventForm", eem));
        }
        public async Task ShouldThrowValidationExceptionOnModifyWhenCalendarEntryIsNullAndLogItAsync()
        {
            //given
            CalendarEntry invalidCalendarEntry       = null;
            var           nullCalendarEntryException = new NullCalendarEntryException();

            var expectedCalendarEntryValidationException =
                new CalendarEntryValidationException(nullCalendarEntryException);

            //when
            ValueTask <CalendarEntry> modifyCalendarEntryTask =
                this.calendarEntryService.ModifyCalendarEntryAsync(invalidCalendarEntry);

            //then
            await Assert.ThrowsAsync <CalendarEntryValidationException>(() =>
                                                                        modifyCalendarEntryTask.AsTask());

            this.loggingBrokerMock.Verify(broker =>
                                          broker.LogError(It.Is(SameExceptionAs(
                                                                    expectedCalendarEntryValidationException))),
                                          Times.Once);

            this.loggingBrokerMock.VerifyNoOtherCalls();
            this.storageBrokerMock.VerifyNoOtherCalls();
            this.dateTimeBrokerMock.VerifyNoOtherCalls();
        }
示例#20
0
        public async Task <List <CalendarEntry> > GetCalendarEntries(string DateFrom, string DateTo)
        {
            HttpClient client         = new HttpClient();
            var        requestContent = new XElement("request",
                                                     new XElement("token", Token.Token),
                                                     new XElement("dateFrom", DateFrom),
                                                     new XElement("dateTo", DateTo));
            var response = await client.PostAsync("https://api.timewax.com/calendar/entries/list/", new StringContent(requestContent.ToString()));

            var responseContent = await response.Content.ReadAsStringAsync();

            XElement root = XElement.Parse(responseContent);

            if (root.Element("valid").Value == "yes")
            {
                var xmlEntries = root.Element("entries").Elements();

                XmlSerializer serializer = new XmlSerializer(typeof(CalendarEntry));

                List <CalendarEntry> calendarEntries = new List <CalendarEntry>();

                foreach (var xmlEntry in xmlEntries)
                {
                    CalendarEntry calendarEntry = serializer.Deserialize(new StringReader(xmlEntry.ToString())) as CalendarEntry;
                    calendarEntries.Add(calendarEntry);
                }
                return(calendarEntries);
            }
            else
            {
                string error = logApiError(requestContent, root);
                throw new Exception(error);
            }
        }
示例#21
0
        public void OAuth3LeggedAuthenticationTest()
        {
            Tracing.TraceMsg("Entering OAuth3LeggedAuthenticationTest");

            CalendarService service = new CalendarService("OAuthTestcode");

            OAuthParameters parameters = new OAuthParameters()
            {
                ConsumerKey     = this.oAuthConsumerKey,
                ConsumerSecret  = this.oAuthConsumerSecret,
                Token           = this.oAuthToken,
                TokenSecret     = this.oAuthTokenSecret,
                Scope           = this.oAuthScope,
                SignatureMethod = this.oAuthSignatureMethod
            };

            GOAuthRequestFactory requestFactory = new GOAuthRequestFactory("cl", "OAuthTestcode", parameters);

            service.RequestFactory = requestFactory;

            CalendarEntry calendar = new CalendarEntry();

            calendar.Title.Text = "Test OAuth";

            Uri           postUri         = new Uri("https://www.google.com/calendar/feeds/default/owncalendars/full");
            CalendarEntry createdCalendar = (CalendarEntry)service.Insert(postUri, calendar);

            // delete the new entry
            createdCalendar.Delete();
        }
        public async Task ShouldGetAllCalendarEntriesAsync()
        {
            //given
            var randomCalendarEntries = new List <CalendarEntry>();

            for (var j = 0; j <= GetRandomNumber(); j++)
            {
                randomCalendarEntries.Add(await PostRandomCalendarEntryAsync());
            }

            List <CalendarEntry> inputedCalendarEntries  = randomCalendarEntries;
            List <CalendarEntry> expectedCalendarEntries = inputedCalendarEntries;

            //When
            List <CalendarEntry> actualcalendarEntries =
                await this.otripleSApiBroker.GetAllCalendarEntriesAsync();

            //then
            foreach (CalendarEntry expectedCalendarEntry in expectedCalendarEntries)
            {
                CalendarEntry actualCalendarEntry =
                    actualcalendarEntries.Single(calendarEntry =>
                                                 calendarEntry.Id == expectedCalendarEntry.Id);

                actualCalendarEntry.Should().BeEquivalentTo(expectedCalendarEntry);
                await DeleteCalendarEntryAsync(actualCalendarEntry);
            }
        }
示例#23
0
        protected void btnSave_ServerClick(object sender, System.EventArgs e)
        {
            SwitchValidators();

            Page.Validate();
            if (!Page.IsValid)
            {
                return;
            }

            if (EventId != 0)
            {
                int iEndAfter = 0;
                if (rbEndAfter.Checked)
                {
                    iEndAfter = int.Parse(tbEndAfter.Text);
                }
                // TODO: вместо Security.CurrentUser.TimeOffset использовать значение, выбранное из списка!
                CalendarEntry.AddRecurrence(EventId, TimeStart, TimeEnd, Pattern,
                                            SubPattern, Frequency, Weekdays, MonthDay,
                                            WeekNumber, MonthNumber, iEndAfter, dtcDateStart.SelectedDate,
                                            dtcDateEnd.SelectedDate, int.Parse(lstTimeZone.SelectedItem.Value));
                String slink = String.Empty;
                if (SharedID > 0)
                {
                    slink = "&SharedId=" + SharedID;
                }

                Response.Redirect("../Events/EventView.aspx?EventId=" + EventId + slink);
            }
        }
示例#24
0
        protected void lbEventDeleteAll_Click(object sender, System.EventArgs e)
        {
            int EventId = int.Parse(hdnEventId.Value);

            CalendarEntry.Delete(EventId);
            BindDGEvent();
        }
示例#25
0
 public bool CreateEvent(CalendarEntry events)
 {
     using (SqlConnection connection = new SqlConnection(ConnectionString))
     {
         if (events.Hearse == null)
         {
             SqlCommand command = new SqlCommand();
             command.CommandText = "EXEC dbo.insert_event2 @START_AT, @END_AT, @AT_ADDRESS, @COMMENT";
             command.Parameters.AddWithValue("@START_AT", events.Start);
             command.Parameters.AddWithValue("@END_AT", events.End);
             command.Parameters.AddWithValue("@AT_ADDRESS", events.Address);
             command.Parameters.AddWithValue("@COMMENT", events.Comment);
             command.Connection = connection;
             connection.Open();
             command.ExecuteNonQuery();
         }
         else
         {
             SqlCommand command = new SqlCommand();
             command.CommandText = "EXEC dbo.insert_event @START_AT, @END_AT, @VEHICLE, @AT_ADDRESS, @COMMENT";
             command.Parameters.AddWithValue("@START_AT", events.Start);
             command.Parameters.AddWithValue("@END_AT", events.End);
             command.Parameters.AddWithValue("@VEHICLE", events.Hearse.Key);
             command.Parameters.AddWithValue("@AT_ADDRESS", events.Address);
             command.Parameters.AddWithValue("@COMMENT", events.Comment);
             command.Connection = connection;
             connection.Open();
             command.ExecuteNonQuery();
         }
     }
     return(true);
 }
    public CalendarEntry SetEntry(TimeManager.MonthNames pMonth, int pDay)
    {
        Entries = Resources.LoadAll <CalendarEntry>("CalendarEntries/" + pMonth.ToString());

        foreach (CalendarEntry entry in Entries)
        {
            if (entry.Month == pMonth && entry.Day == pDay)
            {
                CurrentEntry = entry;
                CurrentEvent = CurrentEntry.Event;
                if (CurrentEvent != null)
                {
                    if (CurrentEvent.Competition != null)
                    {
                        Game.NPCs.Blossoms.BlossomCompetitionManager.Instance.SelectCompetition(CurrentEvent.Competition.Name, CurrentEvent.Presenter.transform);
                    }
                }
                if (CurrentEvent != null)
                {
                    foreach (FestivalProp obj in CurrentEvent.Props)
                    {
                        if (GameManager.Instance.LevelName == obj.Level)
                        {
                            Instantiate(obj.Prop, obj.Position, transform.rotation);
                        }
                    }
                }
                return(entry);
            }
        }
        CurrentEntry = null;
        CurrentEvent = null;

        return(null);
    }
示例#27
0
        public ValueTask <CalendarEntry> AddCalendarEntryAsync(CalendarEntry calendarEntry) =>
        TryCatch(async() =>
        {
            ValidateCalendarEntryOnCreate(calendarEntry);

            return(await this.storageBroker.InsertCalendarEntryAsync(calendarEntry));
        });
示例#28
0
 public override void ChangeSelectedCalendarEntry(CalendarEntry selectedCalendarEntry)
 {
     foreach (var dayEntryViewModel in Days)
     {
         dayEntryViewModel.ChangeSelectedCalendarEntry(selectedCalendarEntry);
     }
 }
 private void ValidateCalendarEntryOnModify(CalendarEntry calendarEntry)
 {
     ValidateCalendarEntryIsNotNull(calendarEntry);
     ValidateCalendarEntryId(calendarEntry.Id);
     ValidateCalendarEntryRequiredFields(calendarEntry);
     ValidateCalendarEntryAuditFieldsOnModify(calendarEntry);
 }
示例#30
0
        public async void ShouldThrowValidationExceptionOnAddWhenCalendarEntryIsNullAndLogItAsync()
        {
            // given
            CalendarEntry randomCalendarEntry = null;
            CalendarEntry nullCalendarEntry   = randomCalendarEntry;

            var nullCalendarEntryException = new NullCalendarEntryException();

            var expectedCalendarEntryValidationException =
                new CalendarEntryValidationException(nullCalendarEntryException);

            // when
            ValueTask <CalendarEntry> registerCalendarEntryTask =
                this.calendarEntryService.AddCalendarEntryAsync(nullCalendarEntry);

            // then
            await Assert.ThrowsAsync <CalendarEntryValidationException>(() =>
                                                                        registerCalendarEntryTask.AsTask());

            this.loggingBrokerMock.Verify(broker =>
                                          broker.LogError(It.Is(SameExceptionAs(expectedCalendarEntryValidationException))),
                                          Times.Once);

            this.storageBrokerMock.Verify(broker =>
                                          broker.InsertCalendarEntryAsync(It.IsAny <CalendarEntry>()),
                                          Times.Never);

            this.dateTimeBrokerMock.VerifyNoOtherCalls();
            this.loggingBrokerMock.VerifyNoOtherCalls();
            this.storageBrokerMock.VerifyNoOtherCalls();
        }
示例#31
0
        public AddToCalendarForm(Framework.Interfaces.ICore core, List<Framework.Data.Geocache> gcList)
            : this()
        {
            if (Properties.Settings.Default.UpgradeNeeded)
            {
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.UpgradeNeeded = false;
                Properties.Settings.Default.Save();
            }

            _core = core;

            checkBoxGoogleAgenda.Checked = Properties.Settings.Default.AddToGoogleCalendar;
            checkBoxOutlook.Checked = Properties.Settings.Default.AddToOutlook;
            checkBoxOpenGoogleCalendar.Checked = Properties.Settings.Default.OpenGoogleCalendar;

            this.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_TITLE);
            this.buttonAddToCalendar.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_ADDTOCAL);
            this.buttonAddNextToCalendar.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_ADDONETOCAL);
            this.buttonSave.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_SAVE);
            this.label13.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_ADDTO);
            this.label12.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_EVENT);
            this.label1.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_START);
            this.label2.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_END);
            this.label6.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_LOCATION);
            this.label8.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_SUMMARY);
            this.label10.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_DESCRIPTIONB);

            _calendarEntries = new List<CalendarEntry>();
            foreach (var gc in gcList)
            {
                CalendarEntry ce = new CalendarEntry();
                ce.gc = gc;
                ce.Enabled = true;
                ce.StartTime = new DateTime(gc.PublishedTime.Year, gc.PublishedTime.Month, gc.PublishedTime.Day, 9, 0, 0);
                ce.EndTime = new DateTime(gc.PublishedTime.Year, gc.PublishedTime.Month, gc.PublishedTime.Day, 17, 0, 0);
                ce.Summary = string.Format("{0}: {1} {2} {3}", Utils.LanguageSupport.Instance.GetTranslation(STR_GEOCACHEEVENT), gc.Name == null ? "" : gc.Name.Replace('"', ' '), Utils.LanguageSupport.Instance.GetTranslation(STR_BY), gc.PlacedBy == null ? "" : gc.PlacedBy.Replace('"', ' '));
                ce.Location = Utils.Conversion.GetCoordinatesPresentation(gc.Lat, gc.Lon);
                ce.Description = string.Format("{0} {1}", Utils.LanguageSupport.Instance.GetTranslation(STR_GEOCACHEEVENT), gc.Url ?? "");
                _calendarEntries.Add(ce);

                checkedListBox1.SetItemChecked(checkedListBox1.Items.Add(ce), true);                
            }
            buttonAddToCalendar.Enabled = _calendarEntries.Count > 0;
            buttonAddNextToCalendar.Enabled = _calendarEntries.Count > 0;
            checkedListBox1_SelectedIndexChanged(this, EventArgs.Empty);

            labelGoogleExpl.Visible = false;
            labelICSFilename.Visible = false;
            labelGoogleExpl.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_GOOGLEXPL);
        }
示例#32
0
文件: Gsm.cs 项目: nofuture-git/31g
 /// <summary>
 /// Asserts that a <see cref="CalendarEntry"/> is equal by <see cref="Description"/>, <see cref="EntryDateTime"/> and <see cref="Duration"/>
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public bool Equals(CalendarEntry obj)
 {
     var compare = obj;
     if (compare == null)
         return false;
     return (this.Description == compare.Description && this.EntryDateTime == compare.EntryDateTime && this.Duration == compare.Duration);
 }