private void dataGridView1_RowHeaderMouseDoubleClick_1(object sender, DataGridViewCellMouseEventArgs e) { if (!_mdiForm.Jarvis.CurrentUser.UserHasPermissionForAction("Appointment", "Edit")) { return; } int index = e.RowIndex; int apId = (int)dgAppointment.Rows[e.RowIndex].Cells[0].Value; AppointmentBase ap = _appointmentSearchClassBase.GetAppointment(apId); if (ap != null) { //if (Application.OpenForms["StudentAddEdit"] as StudentAddEdit != null) //{ // StudentAddEdit frm1 = (StudentAddEdit)Application.OpenForms["StudentAddEdit"]; // frm1.Close(); //} AddEditAppointment frm = new AddEditAppointment(ap); //frm.MdiParent = _mdiForm; //frm.Dock = DockStyle.Fill; //frm.FormBorderStyle = FormBorderStyle.None; frm.ShowDialog(); LoadAppointments(); } }
public async Task UpdateAppointmentMongo(AppointmentBase appointmentToBeUpdated, AppointmentBase appointment) { appointmentToBeUpdated.Status = appointment.Status; appointmentToBeUpdated.DateTime = appointment.DateTime; await _mongounitOfWork.Appointments.Update(appointmentToBeUpdated.Id, appointment); }
public void AddAppointment(AppointmentBase appointment) { try { GoogleAppointment.Insert(appointment: appointment, service: service, calendarId: calendarId); } catch (Exception ex) { Log.Error(ex); } }
public async Task <Appointment> AddAppointment(AppointmentBase appointment) { var response = await _httpClient.PostAsJsonAsync(_apiBaseUrl, appointment); if (response.IsSuccessStatusCode) { return(await response.Content.ReadFromJsonAsync <Appointment>()); } return(null); }
private static void Copy(AppointmentBase from, Event to) { to.Start = new EventDateTime { DateTime = from.StartDate }; to.End = new EventDateTime { DateTime = from.EndDate }; to.Description = from.Body; to.Summary = from.Title; to.Location = from.Location; }
public static void Insert(AppointmentBase appointment, CalendarService service, string calendarId) { var newEvent = new Event { }; Copy(from: appointment, to: newEvent); try { var request = service.Events.Insert(newEvent, calendarId); request.Execute(); } catch (Exception ex) { Log.Error(ex); } }
private void btnAddAppontment_Click(object sender, EventArgs e) { if (InputValidated()) { try { AppointmentBase newAp = GetAppointmentToUpdate(); newAp.Save(); this.DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void deleteAppintmentToolStripMenuItem_Click(object sender, EventArgs e) { int index = dgAppointment.CurrentCell.RowIndex; if (index != -1) { int appointmentId = (int)dgAppointment.Rows[index].Cells[0].Value; AppointmentBase ap = _allAppointments.Find(x => x.AppointmentId == appointmentId); if (MessageBox.Show("Are you sure you want to delete appointment '" + ap.Purpose + "' ?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ap.Delete(); LoadAppointments(); //SetDataSource(); } } }
public void Put(Guid rowGuid, [FromBody] AppointmentBase value) { if (value == null) { throw new ArgumentNullException(nameof(value), $"Argument value cannot be null"); } AG_B_APPOINTMENT Item = DBContext.AG_B_APPOINTMENT.SingleOrDefault(E => E.ROWGUID == rowGuid); if (Item == null) { throw new NotFoundException($"No appointment found with RowGuid:{rowGuid}"); } OperationResult <bool> check = CheckCanBookAppointment(value.CustomerCode, value.AppointmentShopCode, value.ServiceCode, value.AppointmentDate, rowGuid); if (!check.Result) { throw new InvalidOperationException(check.Message); } EntityMapper.UpdateEntity(value, Item, Item.AG_B_APPOINTMENT_EXT_AUS); value.SaveData <AG_B_APPOINTMENT>(DBContext, Item); if (string.IsNullOrEmpty(Item.SHOP_CODE)) { Item.SHOP_CODE = Item.AG_B_APPOINTMENT_EXT_AUS.SHOP_CODE = Item.LAPTOP_CODE = Item.AG_B_APPOINTMENT_EXT_AUS.LAPTOP_CODE = Item.APPOINTMENT_SHOP_CODE; } CM_B_SHOP shop = DBContext.CM_B_SHOP.FirstOrDefault(E => E.SHOP_CODE == Item.SHOP_CODE); value.SaveData <AG_B_APPOINTMENT>(DBContext, Item); using (IDbContextTransaction scope = DBContext.Database.BeginTransaction()) { CheckAppointmentOverlap(Item); //Complete the scope here to commit, otherwise it will rollback //The table lock will be released after we exit the TransactionScope block DBContext.SaveChanges(); scope.Commit(); } }
public async void NotifyAt(AppointmentBase appointment, Action action, CancellationToken cancellationToken) { try { await Task.Factory.StartNew(() => { var targetDateTime = appointment.AppointmentDate; // Fast forward on past occurrences. while (targetDateTime < DateTime.Now) { targetDateTime = targetDateTime.CalculateNextOccurrence(appointment.RepetitionType, appointment.RepetitionValue, appointment.ExpirationDate); } while (targetDateTime != DateTime.MaxValue) { // Waiting for next occurrence. while (DateTime.Now < targetDateTime && !cancellationToken.IsCancellationRequested) { Thread.Sleep(100); } if (cancellationToken.IsCancellationRequested) { targetDateTime = DateTime.MaxValue; break; } else { action(); // Get next occurrence. while (targetDateTime < DateTime.Now) { targetDateTime = targetDateTime.CalculateNextOccurrence(appointment.RepetitionType, appointment.RepetitionValue, appointment.ExpirationDate); } } } }, cancellationToken); } catch (TaskCanceledException ex) { logger.Warning(ex); } }
public void cmbAppointmentType_SelectedIndexChanged(object sender, EventArgs e) { AppointmentBase ap; if (cmbAppointmentType.SelectedIndex == 0) { ap = new DoctorAppointment(); _appointmentClassBase = new NewDoctorAppointmentClass(this); } else { ap = new SpecialistAppointment(); _appointmentBase.ProfessionalServiceProviderTypeId = (int)cmbAppointmentType.SelectedValue; _appointmentClassBase = new NewSpecialistAppointmentClass(this); } CommonFunctions.TransferPropertyValues(_appointmentBase, ap); _appointmentBase = ap; //_appointmentBase.ProfessionalServiceProviderTypeId = (int)cmbAppointmentType.SelectedValue; }
private static void Copy(Event from, AppointmentBase to) { if (from.Start != null && from.Start.DateTime.HasValue) { to.StartDate = from.Start.DateTime.Value; } if (from.End != null && from.End.DateTime.HasValue) { to.EndDate = from.End.DateTime.Value; } to.Body = from.Description ?? ""; to.Title = from.Summary ?? ""; to.Location = from.Location ?? ""; to.UID = from.ICalUID; if (from.Start != null) { to.IsAllDayEvent = !string.IsNullOrWhiteSpace(from.Start.Date); } }
private void MenuItemClick(object sender, RoutedEventArgs e) { RadMenuItem item = e.OriginalSource as RadMenuItem; AppointmentBase app = this.EditedAppointment as AppointmentBase; if (item != null && app != null) { Category category = item.Header as Category; if (this.Category == category) { category.IsChecked = false; app.Category = this.Category = null; } else { if (this.Category != null) { this.Category.IsChecked = false; } category.IsChecked = true; app.Category = this.Category = category; } } }
public AddEditAppointment(AppointmentBase appointmentBase) { InitializeComponent(); _appointmentBase = appointmentBase; }
public ActionResult <AppointmentListItem> Post([FromBody] AppointmentBase value, string campaignCode = null, string mediaTypeCode = null, string callID = null) { return(DoPost(value, campaignCode, mediaTypeCode, callID)); }
private AppointmentListItem DoPost(AppointmentBase value, string campaignCode = null, string mediaTypeCode = null, string callID = null, Guid?rescheduledAppointmentRowGuid = null) { if (value == null) { throw new ArgumentNullException(nameof(value), "Argument 'value' cannot be null"); } OperationResult <bool> check = CheckCanBookAppointment(value.CustomerCode, value.AppointmentShopCode, value.ServiceCode, value.AppointmentDate, rescheduledAppointmentRowGuid.GetValueOrDefault(Guid.Empty)); if (!check.Result) { throw new InvalidOperationException(check.Message); } AG_B_APPOINTMENT Item = EntityMapper.CreateEntity <AG_B_APPOINTMENT>(); AG_B_APPOINTMENT_EXT_AUS ItemExt = EntityMapper.CreateEntity <AG_B_APPOINTMENT_EXT_AUS>(); CU_B_ACTIVITY activity = EntityMapper.CreateEntity <CU_B_ACTIVITY>(); CU_B_ACTIVITY_EXT_AUS activityExt = EntityMapper.CreateEntity <CU_B_ACTIVITY_EXT_AUS>(); AG_B_APPOINTMENT_STATUS_HISTORY history = EntityMapper.CreateEntity <AG_B_APPOINTMENT_STATUS_HISTORY>(); if ((string.IsNullOrWhiteSpace(value.StatusCode) || value.StatusCode == appointmentStatus.Open) && value.AppointmentDate >= DateTime.Today && value.AppointmentDate < DateTime.Today.AddDays(2)) { value.StatusCode = appointmentStatus.Confirmed; } EntityMapper.UpdateEntity(value, Item, ItemExt); //Add default or other values Item.APPOINTMENT_ID = ItemExt.APPOINTMENT_ID = string.Format("{0}00{1}", Item.APPOINTMENT_SHOP_CODE, FoxDataService.GetNewCounter("AG_B_APPOINTMENT", "APPOINTMENT_ID", "*", Item.USERINSERT).FORMATTEDVALUE); if (string.IsNullOrEmpty(Item.SHOP_CODE)) { Item.SHOP_CODE = ItemExt.SHOP_CODE = Item.LAPTOP_CODE = ItemExt.LAPTOP_CODE = Item.APPOINTMENT_SHOP_CODE; } string[] specialAvailabilityServiceCodes = FoxDataService.GetSpecialAvailabilityServiceCodes(Item.SHOP_CODE); CM_B_SHOP shop = DBContext.CM_B_SHOP.FirstOrDefault(E => E.SHOP_CODE == Item.SHOP_CODE); activity.ACTIVITY_TYPE_CODE = "PR"; activity.ACTIVITY_DATE = DateTime.Today; activity.CUSTOMER_CODE = activityExt.CUSTOMER_CODE = Item.CUSTOMER_CODE; activity.EMPLOYEE_CODE = Item.EMPLOYEE_CODE; Item.LOCATION_CODE = activity.LOCATION_CODE = shop?.OBJ_CODE; Item.LOCATION_TYPE_CODE = activity.LOCATION_TYPE_CODE = Item.SHOP_CODE == "000" ? "03" : "01"; Item.STATUS_CODE = Item.STATUS_CODE ?? appointmentStatus.Open; activity.REFERENCE_DATE = Item.DT_APPOINTMENT; activity.REFERENCE_NUMBER = Item.APPOINTMENT_ID; history.APPOINTMENT_ID = activity.APPOINTMENT_ID = Item.APPOINTMENT_ID; history.SHOP_CODE = history.LAPTOP_CODE = activity.SHOP_CODE = activity.LAPTOP_CODE = activityExt.SHOP_CODE = activityExt.LAPTOP_CODE = Item.SHOP_CODE; activity.ACTIVITY_ID = activityExt.ACTIVITY_ID = FoxDataService.GetNewCounter("CU_B_ACTIVITY", "ACTIVITY_ID", Item.SHOP_CODE, Item.USERINSERT).VALUE.GetValueOrDefault(); history.CONFIRMATION_STATUS = Item.STATUS_CODE; history.REASON_CODE = Item.REASON_CODE; history.ROWGUID = Item.ROWGUID; /* Disabled FK check * //Check for valid campaign * if (!string.IsNullOrWhiteSpace(campaignCode)) * { * CM_S_CAMPAIGN campaign = DBContext.CM_S_CAMPAIGN.FirstOrDefault(E => E.CAMPAIGN_CODE == campaignCode); * ItemExt.CAMPAIGN_CODE = activity.CAMPAIGN_CODE = campaign?.CAMPAIGN_CODE; * } * //Check for valid mediatype * if (!string.IsNullOrWhiteSpace(mediaTypeCode)) * { * CM_S_MEDIATYPE mediaType = DBContext.CM_S_MEDIATYPE.FirstOrDefault(E => E.MEDIATYPE_CODE == mediaTypeCode); * ItemExt.MEDIATYPE_CODE = activity.MEDIATYPE_CODE = mediaType?.MEDIATYPE_CODE; * } */ ItemExt.CAMPAIGN_CODE = activity.CAMPAIGN_CODE = campaignCode; ItemExt.MEDIATYPE_CODE = activity.MEDIATYPE_CODE = mediaTypeCode; ItemExt.SOURCE_TRACKING_ID = callID; EntityMapper.CheckEntityRowId(activity, activityExt, Guid.NewGuid()); value.SaveData <AG_B_APPOINTMENT>(DBContext, Item); value.SaveData <CU_B_ACTIVITY>(DBContext, activity); // Set proper customer shop code if needed CU_B_ADDRESS_BOOK customer = DBContext.CU_B_ADDRESS_BOOK.FirstOrDefault(E => E.CUSTOMER_CODE == Item.CUSTOMER_CODE && E.CU_B_ADDRESS_BOOK_EXT_AUS.SHOP_CODE == "000"); if (customer != null) { customer.CU_B_ADDRESS_BOOK_EXT_AUS.SHOP_CODE = Item.APPOINTMENT_SHOP_CODE; } DBContext.AG_B_APPOINTMENT.Add(Item); DBContext.AG_B_APPOINTMENT_EXT_AUS.Add(ItemExt); DBContext.CU_B_ACTIVITY.Add(activity); DBContext.CU_B_ACTIVITY_EXT_AUS.Add(activityExt); DBContext.AG_B_APPOINTMENT_STATUS_HISTORY.Add(history); IDbContextTransaction scope = DBContext.Database.CurrentTransaction; bool ownTransaction = (scope == null); if (scope == null) { scope = DBContext.Database.BeginTransaction(); } try { //Lock the table during this transaction DBContext.AG_B_APPOINTMENT.FromSql("SELECT TOP 1 * FROM AG_B_APPOINTMENT WITH (TABLOCKX, HOLDLOCK)"); //Check for overlap DateTime appointmentStart = Item.DT_APPOINTMENT; DateTime appointmentEnd = Item.DT_APPOINTMENT.AddMinutes(Item.DURATION.GetValueOrDefault()); int overlappedAppointmentCount = DBContext.AG_B_APPOINTMENT.Where(E => AllowedAppointmentStatus.Contains(E.STATUS_CODE) && (E.ROOM_CODE == Item.ROOM_CODE || E.EMPLOYEE_CODE == Item.EMPLOYEE_CODE) && !specialAvailabilityServiceCodes.Contains(E.AG_S_SERVICE.SERVICE_TYPE_CODE) && ((E.DT_APPOINTMENT >= appointmentStart && E.DT_APPOINTMENT < appointmentEnd) || (E.DT_APPOINTMENT.AddMinutes(E.DURATION.GetValueOrDefault()) > appointmentStart && E.DT_APPOINTMENT.AddMinutes(E.DURATION.GetValueOrDefault()) < appointmentEnd) || (E.DT_APPOINTMENT <= appointmentStart && E.DT_APPOINTMENT.AddMinutes(E.DURATION.GetValueOrDefault()) > appointmentEnd))).Count(); if (overlappedAppointmentCount > 0) { throw new Exception("There is already an appointment for the given time slot"); } //Complete the scope here to commit, otherwise it will rollback //The table lock will be released after we exit the TransactionScope block DBContext.SaveChanges(); if (ownTransaction) { scope.Commit(); } } catch (Exception E) { if (ownTransaction) { scope.Rollback(); } throw E; } return(Get(Item.ROWGUID).Value); }
public async Task DeleteAppointmentMongo(AppointmentBase appointment) { await _mongounitOfWork.Appointments.Delete(appointment.Id); }
public async Task <AppointmentBase> CreateAppointmentMongo(AppointmentBase newAppointment) { await _mongounitOfWork.Appointments.Create(newAppointment); return(newAppointment); }
public ActionResult <AppointmentListItem> Reschedule(Guid rescheduledAppointmentRowGuid, [FromBody] AppointmentBase value) { if (value == null) { throw new ArgumentNullException(nameof(value), $"Argument value cannot be null"); } AG_B_APPOINTMENT oldAppointment = DBContext.AG_B_APPOINTMENT.SingleOrDefault(E => E.ROWGUID == rescheduledAppointmentRowGuid); if (oldAppointment == null) { throw new NotFoundException($"No appointment found with RowGuid:{rescheduledAppointmentRowGuid}"); } if (oldAppointment.AG_B_APPOINTMENT_EXT_AUS.RESCHEDULED_NUMBER.GetValueOrDefault(0) >= 3) { throw new InvalidOperationException("Appointment reschedule max number exceeded"); } oldAppointment.AG_B_APPOINTMENT_EXT_AUS.RESCHEDULED_NUMBER = oldAppointment.AG_B_APPOINTMENT_EXT_AUS.RESCHEDULED_NUMBER.GetValueOrDefault(0) + 1; using (IDbContextTransaction scope = DBContext.Database.BeginTransaction()) { UpdateAppointmentStatus(oldAppointment.ROWGUID, appointmentStatus.Rescheduled); AppointmentListItem Result = DoPost(value, rescheduledAppointmentRowGuid: rescheduledAppointmentRowGuid); CU_B_ACTIVITY activity = EntityMapper.CreateEntity <CU_B_ACTIVITY>(); CU_B_ACTIVITY_EXT_AUS activityExt = EntityMapper.CreateEntity <CU_B_ACTIVITY_EXT_AUS>(); activity.ACTIVITY_TYPE_CODE = "DY"; activity.ACTIVITY_DATE = DateTime.Today; activity.CUSTOMER_CODE = activityExt.CUSTOMER_CODE = Result.CustomerCode; activity.EMPLOYEE_CODE = Result.EmployeeCode; activity.REFERENCE_DATE = oldAppointment.DT_APPOINTMENT; activity.REFERENCE_NUMBER = oldAppointment.APPOINTMENT_ID; activity.APPOINTMENT_ID = Result.AppointmentID; activityExt.DT_APPOINTEMENT_FROM = oldAppointment.DT_APPOINTMENT; activityExt.DT_APPOINTEMENT_TO = Result.AppointmentDate; activity.ACTIVITY_ID = activityExt.ACTIVITY_ID = FoxDataService.GetNewCounter("CU_B_ACTIVITY", "ACTIVITY_ID", Result.StatusCode, activity.USERINSERT).VALUE.GetValueOrDefault(); activity.SHOP_CODE = activity.LAPTOP_CODE = activityExt.SHOP_CODE = activityExt.LAPTOP_CODE = Result.ShopCode; DBContext.CU_B_ACTIVITY.Add(activity); DBContext.CU_B_ACTIVITY_EXT_AUS.Add(activityExt); DBContext.SaveChanges(); scope.Commit(); return(Result); } }