Ejemplo n.º 1
0
        /// <summary>
        /// This method get a list of available slots of the calendar, we will pass the calendar Id
        /// </summary>
        /// <param name="calendarId"></param>
        /// <returns></returns>
        public static int CancelAppoinment(int processId, string fromDate, string toDate, string comment)
        {
            int result = 0;

            WebAppoinmentsClientLibrary.Appoinments appoinment = new WebAppoinmentsClientLibrary.Appoinments();
            int      cancelReasonId           = 0;
            int      parentCaseId             = 0;
            int      cancelationType          = 0;
            bool     removeWaitingListRequest = false;
            int      customerTretmentPlaneId  = 0;
            int      treatmentPlantype        = 0;
            DateTime fromDateString           =
                DateTime.Parse(fromDate, System.Globalization.CultureInfo.InvariantCulture);
            DateTime toDatestring =
                DateTime.Parse(toDate, System.Globalization.CultureInfo.InvariantCulture);

            try
            {
                appoinment.CancelAppoinment(
                    processId,
                    cancelReasonId,
                    parentCaseId,
                    cancelationType,
                    comment,
                    removeWaitingListRequest,
                    customerTretmentPlaneId,
                    treatmentPlantype
                    );
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Geth a list of services
        /// </summary>
        /// <param name="unitId"></param>
        /// <returns></returns>
        public static List <Service> GetListServices(int unitId)
        {
            List <Service> listServices     = new List <Service>();
            List <string>  listServicesName = new List <string>();

            WebAppoinmentsClientLibrary.Appoinments appoinment = new WebAppoinmentsClientLibrary.Appoinments();
            listServices = appoinment.GetServices(unitId);
            return(listServices);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This method returns a list of availables appoinments (Example)
        /// </summary>
        /// <returns></returns>
        public static async Task <List <string> > GetServices()
        {
            List <Service> listServices     = new List <Service>();
            List <string>  listServicesName = new List <string>();

            WebAppoinmentsClientLibrary.Appoinments appoinment = new WebAppoinmentsClientLibrary.Appoinments();
            listServices = appoinment.GetServices(1);
            foreach (Service service in listServices)
            {
                listServicesName.Add(service.Name);
            }
            return(listServicesName);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// This method get an appoinment by id
        /// </summary>
        /// <returns></returns>
        public static AppointmentGetResults GetAppointmentById(int appointmentId)
        {
            AppointmentGetResults appoinment = new AppointmentGetResults();

            try
            {
                WebAppoinmentsClientLibrary.Appoinments _appoinmentLibray = new WebAppoinmentsClientLibrary.Appoinments();
                appoinment = _appoinmentLibray.GetAppoinment(appointmentId).AppointmentInformation;
            }
            catch (Exception)
            {
                throw;
            }
            return(appoinment);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// This method reschedule an appoinment
        /// </summary>
        /// <param name="slotToShowInformation"></param>
        /// <param name="dateInput"></param>
        /// <param name="serviceId"></param>
        /// <returns></returns>
        public static int RescheduleAppoinment(int originalProcessId, string dateAndTimeString, int serviceId)
        {
            int result = 0;

            WebAppoinmentsClientLibrary.Appoinments appoinment = new WebAppoinmentsClientLibrary.Appoinments();
            int      cancelReasonId    = 0;
            int      appoinmentTypeId  = 0;
            int      treatmentPlantype = 0;
            DateTime dateAndTime;

            try
            {
                dateAndTime =
                    DateTime.Parse(dateAndTimeString, System.Globalization.CultureInfo.InvariantCulture);
            }
            catch (Exception ex)
            {
                string message = ex.Message.ToString();
                throw;
            }
            try
            {
                ResultObjectBase resultObjectBase = appoinment.RescheduleAppoinment(
                    originalProcessId,
                    cancelReasonId,
                    serviceId,
                    dateAndTime,
                    appoinmentTypeId,
                    treatmentPlantype
                    );
                result = resultObjectBase.Id;
                if (resultObjectBase.ReturnCode > 0)
                {
                    throw new Exception(resultObjectBase.ReturnMessage);
                }

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// This method can set or book a new appointment
        /// </summary>
        /// <param name="parentCaseId"></param>
        /// <param name="serviceId"></param>
        /// <param name="customerId"></param>
        /// <param name="slotOrdinalNumber"></param>
        /// <param name="calendarId"></param>
        /// <returns></returns>
        public static ResultObjectBase SetAppoinment(int parentCaseId,
                                                     int serviceId,
                                                     int customerId,
                                                     int slotOrdinalNumber,
                                                     int calendarId)
        //int duration,)
        {
            ResultObjectBase resultObjectBase = new ResultObjectBase();

            WebAppoinmentsClientLibrary.Appoinments appoinment = new WebAppoinmentsClientLibrary.Appoinments();
            DateTime dateandTime                = DateTime.Today;
            int      appoimentTypeId            = 0;
            int      treatmentPlantype          = 0;
            string   subject                    = "";
            string   notes                      = "sd";
            string   extRef                     = "asd";
            bool     preventAutoQueue           = false;
            string   languageCode               = "en";
            bool     isWalkIn                   = false;
            bool     forceSimultaneousAppoiment = true;
            bool     forceWastedDuration        = false;
            bool     autoFreeUp                 = false;
            int      treatmentPlanId            = 0;
            int      customerTreatmentPlan      = 0;
            int      duration                   = 0;
            int      basedonAppoimentRequestId  = 0;
            bool     simulationOnly             = false;
            bool     forceNoDynamicVacancy      = false;
            int      userId                     = 0;
            string   typeSerializer             = "XML";

            try
            {
                resultObjectBase = appoinment.SetAppoinment(parentCaseId, calendarId, serviceId, dateandTime, customerId, appoimentTypeId, treatmentPlanId, subject, notes, extRef, preventAutoQueue, languageCode, isWalkIn, forceSimultaneousAppoiment, forceWastedDuration, autoFreeUp, treatmentPlanId, customerTreatmentPlan, slotOrdinalNumber, calendarId, duration, basedonAppoimentRequestId, simulationOnly, forceWastedDuration, userId, typeSerializer
                                                            );
                return(resultObjectBase);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// This method create an Iform (form flow) for reschedule an appointement
        /// </summary>
        /// <returns></returns>
        public static IForm <ReservationReschedule> BuildForm()
        {
            //Instance of library for manage appoinments
            WebAppoinmentsClientLibrary.Appoinments appointmentLibrary = new WebAppoinmentsClientLibrary.Appoinments();
            #region On complete, process Order
            OnCompletionAsyncDelegate <ReservationReschedule> processOrder = async(context, state) =>
            {
                try
                {
                    Char     delimiter        = '.';
                    string[] arrayInformation = state.processIdServiceId.Split(delimiter);
                    int      processId        = Convert.ToInt32(arrayInformation[0]);
                    int      serviceId        = Convert.ToInt32(arrayInformation[1]);

                    string[] dateInformation = state.Date.Split(delimiter);
                    string   stringDate      = dateInformation[1];
                    //stringDate = stringDate.Replace("-", " ");
                    stringDate = Utilities.Util.GetDateWithOutTime(stringDate);
                    //Here I create the new date
                    string newDate = stringDate + " " + state.Hour;
                    string newDat2 = Utilities.Util.GetDateWithCorrectPositionOfTheMonth(newDate);
                    int    result  = 0;
                    try
                    {
                        result = AppoinmentService.RescheduleAppoinment(processId, newDat2, serviceId);
                    }
                    catch (Exception)
                    {
                        result = AppoinmentService.RescheduleAppoinment(processId, newDate, serviceId);
                    }
                    AppointmentGetResults _appointment = AppoinmentService.GetAppointmentById(result);
                    await context.PostAsync($"The appointment was rescheduled, Ticket: " + _appointment.QCode + _appointment.QNumber);
                }
                catch (Exception ex)
                {
                    await context.PostAsync(ex.Message.ToString());
                }
            };
            #endregion
            #region set language and create a container for form builder
            CultureInfo ci = new CultureInfo("en");
            Thread.CurrentThread.CurrentCulture   = ci;
            Thread.CurrentThread.CurrentUICulture = ci;
            var culture  = Thread.CurrentThread.CurrentUICulture;
            var form     = new FormBuilder <ReservationReschedule>();
            var yesTerms = form.Configuration.Yes.ToList();
            var noTerms  = form.Configuration.No.ToList();
            yesTerms.Add("Yes");
            noTerms.Add("No");
            form.Configuration.Yes = yesTerms.ToArray();
            return(form
                   #endregion
                   #region process and service ids
                   .Field(new FieldReflector <ReservationReschedule>(nameof(ReservationReschedule.processIdServiceId))
                          .SetType(null)
                          .SetDefine(async(state, field) =>
            {
                //Get the actual user state of the customer
                ACFCustomer customerState = new ACFCustomer();
                int customerIdState = 0;
                customerIdState = state._customerId;
                string personalIdState = string.Empty;
                //Instance of library for manage customers
                WebAppoinmentsClientLibrary.Customers customerLibrary = new WebAppoinmentsClientLibrary.Customers();
                //Instance of library for manage cases
                WebAppoinmentsClientLibrary.Cases caseLibrary = new WebAppoinmentsClientLibrary.Cases();
                //Here we will to find the customer by customer id or personal id
                Customer customer = null;
                if (!string.IsNullOrEmpty(customerIdState.ToString()))
                {
                    //Get the object ObjectCustomer and inside of this the object Customer
                    try
                    {
                        customer = customerLibrary.GetCustomer(customerIdState).Customer;
                    }
                    catch (Exception)
                    {
                        // throw; here we not send the exception beacuse we need to do the next method below
                    }
                }
                //If not found by customer id , we will try to find by personal id
                else
                {
                    int idType = 0;
                    //Get the object ObjectCustomer and inside of this the object Customer
                    try
                    {
                        customer = customerLibrary.GetCustomerByPersonalId(personalIdState, idType).Customer;
                    }
                    catch (Exception)
                    {
                        //throw;
                    }
                }
                if (customer == null)
                {
                    throw new Exception("No records found");
                }
                else
                {
                    //Declaration of Calendar Get Slots Results object
                    CalendarGetSlotsResults slotToShowInformation = new CalendarGetSlotsResults();
                    //Set the parameters for get the expected appoinments
                    int customerTypeId = 0;
                    string customerTypeName = "";
                    int customerId = customer.Id;
                    DateTime startDate = DateTime.Today;
                    //here we add ten days to the startdate
                    DateTime endDate = startDate.AddDays(10);
                    string fromDate = startDate.ToString();
                    string toDate = endDate.ToString();
                    string typeSeriaizer = "XML";
                    //Declaration of the ocject to save the result of the GetExpectedAppoinment
                    ObjectCustomerGetExpectedAppointmentsResults objectCustomerGetExpectedAppointmentsResults = new ObjectCustomerGetExpectedAppointmentsResults();
                    objectCustomerGetExpectedAppointmentsResults = customerLibrary.GetExpectedAppoinment(customerTypeId, customerTypeName, customerId, startDate, endDate, typeSeriaizer);
                    if (objectCustomerGetExpectedAppointmentsResults.ListCustomerGetExpectedAppointmentsResults.Count > 0)
                    {
                        foreach (CustomerGetExpectedAppointmentsResults listCustomer in objectCustomerGetExpectedAppointmentsResults.ListCustomerGetExpectedAppointmentsResults)
                        {
                            //At first I need to find the appoinment by appoiment id, for saw the actual status
                            Appointment appointment = appointmentLibrary.GetAppoinment(listCustomer.AppointmentId).AppointmentInformation;
                            string data = appointment.AppointmentDate.ToString();
                            string processIdAndServiceId = appointment.ProcessId + "." + appointment.ServiceId + "." + Utilities.Util.GetDateWithOutTime(data);
                            field
                            .AddDescription(processIdAndServiceId, data + " | " + listCustomer.ServiceName)              //here we put the process id and the date of the appointment of this process
                            .AddTerms(processIdAndServiceId, data + " | " + listCustomer.ServiceName);
                        }
                        return await Task.FromResult(true);
                    }
                    else
                    {
                        throw new Exception("No records found");
                    }
                }
            }))
                   #endregion
                   #region Date
                   .Field(new FieldReflector <ReservationReschedule>(nameof(ReservationReschedule.Date))
                          .SetType(null)
                          .SetDefine(async(state, field) =>
            {
                List <OTempus.Library.Class.Calendar> listCalendars;
                StringBuilder response = new StringBuilder();
                List <CalendarGetSlotsResults> listGetAvailablesSlots = new List <CalendarGetSlotsResults>();
                if (!String.IsNullOrEmpty(state.processIdServiceId))
                {
                    Char delimiter = '.';
                    string[] arrayInformation = state.processIdServiceId.Split(delimiter);
                    int processId = Convert.ToInt32(arrayInformation[0]);
                    int serviceId = Convert.ToInt32(arrayInformation[1]);
                    string currentAppoinmentDate = arrayInformation[2];
                    DateTime dateFromString = DateTime.Parse(currentAppoinmentDate, System.Globalization.CultureInfo.CurrentCulture);
                    try
                    {
                        listCalendars = new List <OTempus.Library.Class.Calendar>();

                        listCalendars = GetCalendar(serviceId.ToString(), dateFromString);

                        if (listCalendars.Count == 0)
                        {
                            throw new Exception("No records found");
                        }
                        else
                        {
                            foreach (var calendar in listCalendars)
                            {
                                string data = calendar.Id + "." + calendar.CalendarDate.ToString();
                                string data1 = Utilities.Util.GetDateWithOutTime(calendar.CalendarDate.ToString());//we see this in form flow
                                field
                                .AddDescription(data, data1)
                                .AddTerms(data, data1);
                            }
                            return await Task.FromResult(true);
                        } //End else
                    }     //End try
                    catch (Exception e) { }
                }
                return await Task.FromResult(true);
            }))
                   #endregion
                   #region Period day
                   .Field(nameof(ReservationReschedule.dayPeriod))
                   #endregion
                   #region hour
                   .Field(new FieldReflector <ReservationReschedule>(nameof(ReservationReschedule.Hour))
                          .SetType(null)
                          .SetDefine(async(state, value) =>
            {
                string date;
                List <OTempus.Library.Class.Calendar> listCalendars;
                List <CalendarSlot> listGetAvailablesSlots;
                if (!String.IsNullOrEmpty(state.Date) && !String.IsNullOrEmpty(state.dayPeriod.ToString()) && !String.IsNullOrEmpty(state.processIdServiceId))
                {
                    Char delimiter = '.';
                    string[] arrayInformation = state.processIdServiceId.Split(delimiter);
                    int processId = Convert.ToInt32(arrayInformation[0]);
                    int serviceId = Convert.ToInt32(arrayInformation[1]);
                    string currentAppoinmentDate = arrayInformation[2];
                    DateTime dateFromString = DateTime.Parse(currentAppoinmentDate, System.Globalization.CultureInfo.CurrentCulture);


                    int periodDay = Convert.ToInt32(Utilities.Util.GetIntPeriodDay(state.dayPeriod.ToString()));
                    string calendarId = Utilities.Util.GetCalendarIdFromBotOption(state.Date);
                    try
                    {
                        listCalendars = new List <OTempus.Library.Class.Calendar>();
                        date = state.Date;
                        listCalendars = GetCalendar(serviceId.ToString(), dateFromString);
                        listGetAvailablesSlots = new List <CalendarSlot>();

                        StringBuilder response = new StringBuilder();
                        response.Append("Not exists slots").ToString();
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Here are the error: " + ex.Message);
                    }
                    date = state.Date.ToString();
                    if (listCalendars.Count > 0)
                    {
                        listGetAvailablesSlots = AppoinmentService.GetSlotsByPeriod(Convert.ToInt32(calendarId), periodDay.ToString(), 0.ToString());
                        if (listGetAvailablesSlots.Count > 0)
                        {
                            int cont = 0;
                            foreach (OTempus.Library.Class.CalendarSlot calendarSlots in listGetAvailablesSlots)
                            {
                                if (calendarSlots.Status.ToString() == "Vacant")
                                {
                                    string data = calendarSlots.StartTime.ToString();
                                    DateTime date1 = DateTime.Today;
                                    date1 = date1.AddMinutes(calendarSlots.StartTime);
                                    string data1 = date1.ToShortTimeString();
                                    //string data1 = string.Format("{0:hh:mm-tt}", date1);
                                    //assign the calendar id
                                    value
                                    .AddDescription(data1, data1)
                                    .AddTerms(data1, data1);
                                    cont++;
                                }
                            }
                            return await Task.FromResult(true);
                        }
                        else
                        {
                            throw new Exception("No records found");
                        }
                    }
                    else
                    {
                        throw new Exception("No records found");
                    }
                }
                return await Task.FromResult(false);
            }))
                   .Field(new FieldReflector <ReservationReschedule>(nameof(ReservationReschedule._customerId)).SetActive(InactiveField))

                   #endregion
                   .OnCompletion(processOrder)
                   .Build());
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creation of the IForm(Form flow for cancel an appointment)
        /// </summary>
        /// <returns></returns>
        public static IForm <CancelForm> BuildForm()
        {
            OnCompletionAsyncDelegate <CancelForm> processOrder = async(context, state) =>
            {
                //Get the actual user state of the customer
                ACFCustomer customerState = new ACFCustomer();
                try
                {
                    if (!context.UserData.TryGetValue <ACFCustomer>("customerState", out customerState))
                    {
                        customerState = new ACFCustomer();
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Not exists a user session");
                }
                int customerIdState = 0;
                customerIdState = customerState.CustomerId;
                string personalIdState = string.Empty;
                personalIdState = customerState.PersonaId;

                //Instance of library for manage customers
                WebAppoinmentsClientLibrary.Customers customerLibrary = new WebAppoinmentsClientLibrary.Customers();
                //Instance of library for manage appoinments
                WebAppoinmentsClientLibrary.Appoinments appointmentLibrary = new WebAppoinmentsClientLibrary.Appoinments();
                //Instance of library for manage cases
                WebAppoinmentsClientLibrary.Cases caseLibrary = new WebAppoinmentsClientLibrary.Cases();
                //Here we will to find the customer by customer id or personal id
                Customer customer = null;
                if (!String.IsNullOrEmpty(customerIdState.ToString()))
                {
                    //Get the object ObjectCustomer and inside of this the object Customer
                    try
                    {
                        customer = customerLibrary.GetCustomer(customerIdState).Customer;
                    }
                    catch (Exception)
                    {
                        // throw; here we not send the exception beacuse we need to do the next method below
                    }
                }
                //If not found by customer id , we will try to find by personal id
                else
                {
                    int idType = 0;
                    //GEt the object ObjectCustomer and inside of this the object Customer
                    try
                    {
                        customer = customerLibrary.GetCustomerByPersonalId(personalIdState, idType).Customer;
                    }
                    catch (Exception)
                    {
                        //throw;
                    }
                }

                if (customer == null)
                {
                    await context.PostAsync($"The user is not valid");
                }
                else
                {
                    //Declaration of Calendar Get Slots Results oobject
                    CalendarGetSlotsResults slotToShowInformation = new CalendarGetSlotsResults();
                    //Set the parameters for get the expected appoinments
                    int    customerTypeId   = 0;
                    string customerTypeName = "";
                    int    customerId       = customer.Id;
                    //This variables are in hard code because...
                    string fromDate = "09/21/2017 ";
                    string toDate   = "10/21/2018 ";

                    //DateTime fromDate = DateTime.Today;
                    //DateTime toDate = DateTime.Today.AddDays(5);
                    string typeSeriaizer = "XML";
                    //get the appoinment id fore filter in the below results
                    int appoinmentId = state.appoinmentId;

                    //At first I need to find the appoinment by appoiment id, for saw the actual status
                    Appointment appoinment = appointmentLibrary.GetAppoinment(appoinmentId).AppointmentInformation;

                    //Get the case for get the status of the appoinment (check for more information QFlow documentation)
                    // Case cases= caseLibrary.GetCase(customerId).CaseList;
                    //cases.
                    //Declare the object for keept the value of the appoinment find it
                    CustomerGetExpectedAppointmentsResults customerGetExpectedAppointmentsResults = new CustomerGetExpectedAppointmentsResults();
                    //Declaration of the ocject to save the result of the GetExpectedAppoinment
                    ObjectCustomerGetExpectedAppointmentsResults objectCustomerGetExpectedAppointmentsResults = new ObjectCustomerGetExpectedAppointmentsResults();
                    objectCustomerGetExpectedAppointmentsResults = customerLibrary.GetExpectedAppoinment(customerTypeId, customerTypeName, customerId, fromDate, toDate, typeSeriaizer);
                    foreach (CustomerGetExpectedAppointmentsResults listCustomer in objectCustomerGetExpectedAppointmentsResults.ListCustomerGetExpectedAppointmentsResults)
                    {
                        if (listCustomer.AppointmentId.Equals(appoinmentId))
                        {
                            customerGetExpectedAppointmentsResults.CaseId              = listCustomer.CaseId;
                            customerGetExpectedAppointmentsResults.ProcessId           = listCustomer.ProcessId;
                            customerGetExpectedAppointmentsResults.ServiceId           = listCustomer.ServiceId;
                            customerGetExpectedAppointmentsResults.AppointmentTypeId   = listCustomer.AppointmentTypeId;
                            customerGetExpectedAppointmentsResults.AppointmentTypeName = listCustomer.AppointmentTypeName;
                        }
                        //Maybe we not found the appoiment that we want, because when pass a short time, a job of sql is in charge to change the status of the appoinments
                        //it means , by default the state is in expected but when pass determinate time, it can change to absent for example
                        //So the recomendation is find the appointment by id and administrate the error
                    }

                    //Then when we have our object , we can cancel the appoinment because we have his process id

                    if (customerGetExpectedAppointmentsResults.ProcessId > 0)
                    {
                        appointmentLibrary.CancelAppoinment(customerGetExpectedAppointmentsResults.ProcessId,
                                                            0, 0, 0, "notes", false, 0, 0
                                                            );
                    }
                    // in other hand we can't find the record, so we will send the appropiate message
                    else
                    {
                        await context.PostAsync($"I don't found a record with appoinment Id: \n*" + state.appoinmentId);
                    }
                }
            };
            CultureInfo ci = new CultureInfo("en");

            Thread.CurrentThread.CurrentCulture   = ci;
            Thread.CurrentThread.CurrentUICulture = ci;
            var culture  = Thread.CurrentThread.CurrentUICulture;
            var form     = new FormBuilder <CancelForm>();
            var yesTerms = form.Configuration.Yes.ToList();
            var noTerms  = form.Configuration.No.ToList();

            yesTerms.Add("Yes");
            noTerms.Add("No");
            form.Configuration.Yes = yesTerms.ToArray();

            return(form.Message("Fill the information for cancel the appoinment, please")
                   .Field(nameof(appoinmentId))
                   .Confirm("Are you selected:  " +
                            "\n* appoinmentId: {appoinmentId}: ? \n" +
                            "(yes/no)")
                   .AddRemainingFields()
                   .Message("The process for cancel the appoinment has been started!")
                   .OnCompletion(processOrder)
                   .Build());
        }
Ejemplo n.º 9
0
        public static IForm <ReservationStatus> BuildForm()
        {
            //Instance of library for manage appoinments
            WebAppoinmentsClientLibrary.Appoinments       appointmentLibrary = new WebAppoinmentsClientLibrary.Appoinments();
            OnCompletionAsyncDelegate <ReservationStatus> processOrder       = async(context, state) =>
            {
                //Get the appoinment by appoinment id
                AppointmentGetResults _appointment = AppoinmentService.GetAppointmentById(Convert.ToInt32(state.appointmentId));

                if (_appointment != null)
                {
                    await context.PostAsync($"Appointment Details:" +
                                            " \n* Ticket: " + _appointment.QCode + _appointment.QNumber +
                                            " \n* Service name: " + _appointment.ServiceName +
                                            " \n* Appointment date: " + _appointment.AppointmentDate

                                            );
                }
                // in other hand we can't find the record, so we will send the appropiate message
                else
                {
                    await context.PostAsync($"I don't found record with the appointment id: \n* " + state.appointmentId);
                }
            };
            CultureInfo ci = new CultureInfo("en");

            Thread.CurrentThread.CurrentCulture   = ci;
            Thread.CurrentThread.CurrentUICulture = ci;
            var culture  = Thread.CurrentThread.CurrentUICulture;
            var form     = new FormBuilder <ReservationStatus>();
            var yesTerms = form.Configuration.Yes.ToList();
            var noTerms  = form.Configuration.No.ToList();

            yesTerms.Add("Yes");
            noTerms.Add("No");
            form.Configuration.Yes = yesTerms.ToArray();
            return(form
                   .Field(new FieldReflector <ReservationStatus>(nameof(ReservationStatus.appointmentId))
                          .SetType(null)
                          .SetDefine(async(state, field) =>
            {
                //Get the actual user state of the customer
                ACFCustomer customerState = new ACFCustomer();

                int customerIdState = 0;
                //customerIdState = customerState.CustomerId;
                customerIdState = state._customerId;

                string personalIdState = string.Empty;
                //Instance of library for manage customers
                WebAppoinmentsClientLibrary.Customers customerLibrary = new WebAppoinmentsClientLibrary.Customers();

                //Instance of library for manage cases
                WebAppoinmentsClientLibrary.Cases caseLibrary = new WebAppoinmentsClientLibrary.Cases();
                //Here we will to find the customer by customer id or personal id
                Customer customer = null;
                if (!string.IsNullOrEmpty(customerIdState.ToString()))
                {
                    //Get the object ObjectCustomer and inside of this the object Customer
                    try
                    {
                        customer = customerLibrary.GetCustomer(customerIdState).Customer;
                    }
                    catch (Exception)
                    {
                        // throw; here we not send the exception beacuse we need to do the next method below
                    }
                }
                //If not found by customer id , we will try to find by personal id
                else
                {
                    int idType = 0;
                    //Get the object ObjectCustomer and inside of this the object Customer
                    try
                    {
                        customer = customerLibrary.GetCustomerByPersonalId(personalIdState, idType).Customer;
                    }
                    catch (Exception)
                    {
                        //throw;
                    }
                }

                if (customer == null)
                {
                    throw new Exception("No records found");
                }
                else
                {
                    //Declaration of Calendar Get Slots Results object
                    CalendarGetSlotsResults slotToShowInformation = new CalendarGetSlotsResults();
                    //Set the parameters for get the expected appoinments
                    int customerTypeId = 0;
                    string customerTypeName = "";
                    int customerId = customer.Id;
                    DateTime startDate = DateTime.Today;
                    //here we add ten days to the startdate
                    DateTime endDate = startDate.AddDays(10);
                    string fromDate = startDate.ToString();
                    string toDate = endDate.ToString();
                    string typeSeriaizer = "XML";

                    //Declaration of the ocject to save the result of the GetExpectedAppoinment
                    ObjectCustomerGetExpectedAppointmentsResults objectCustomerGetExpectedAppointmentsResults = new ObjectCustomerGetExpectedAppointmentsResults();
                    objectCustomerGetExpectedAppointmentsResults = customerLibrary.GetExpectedAppoinment(customerTypeId, customerTypeName, customerId, startDate, endDate, typeSeriaizer);
                    if (objectCustomerGetExpectedAppointmentsResults.ListCustomerGetExpectedAppointmentsResults.Count > 0)
                    {
                        foreach (CustomerGetExpectedAppointmentsResults listCustomer in objectCustomerGetExpectedAppointmentsResults.ListCustomerGetExpectedAppointmentsResults)
                        {
                            //At first I need to find the appoinment by appoiment id, for saw the actual status
                            Appointment appointment = appointmentLibrary.GetAppoinment(listCustomer.AppointmentId).AppointmentInformation;
                            //string data = appointment.AppointmentDate.ToString();
                            string data = string.Format("{0:dd/MM/yyyy-hh:mmtt}", appointment.AppointmentDate);

                            field
                            .AddDescription(listCustomer.AppointmentId.ToString(), data + "|" + listCustomer.ServiceName)                  //here we put the process id and the date of the appointment of this process
                            .AddTerms(listCustomer.AppointmentId.ToString(), data + "|" + listCustomer.ServiceName);
                        }
                        return await Task.FromResult(true);
                    }
                    else
                    {
                        await ReservationCancel.context.PostAsync($"No records found");
                        throw new Exception("No records found");
                    }
                }
            }))
                   .Field(new FieldReflector <ReservationStatus>(nameof(ReservationStatus._customerId)).SetActive(InactiveField))
                   .AddRemainingFields()
                   .OnCompletion(processOrder)
                   .Build());
        }
Ejemplo n.º 10
0
        public static IForm <StatusFormApp> BuildForm()
        {
            OnCompletionAsyncDelegate <StatusFormApp> processOrder = async(context, state) =>
            {
                //Get the actual user state of the customer
                ACFCustomer customerState = new ACFCustomer();
                try
                {
                    if (!context.UserData.TryGetValue <ACFCustomer>("customerState", out customerState))
                    {
                        customerState = new ACFCustomer();
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Not exists a user session");
                }
                //Instance of library for manage customers
                WebAppoinmentsClientLibrary.Customers customerLibrary = new WebAppoinmentsClientLibrary.Customers();
                //Instance of library for manage appoinments
                WebAppoinmentsClientLibrary.Appoinments appointmentLibrary = new WebAppoinmentsClientLibrary.Appoinments();
                //Instance of library for manage cases
                WebAppoinmentsClientLibrary.Cases caseLibrary = new WebAppoinmentsClientLibrary.Cases();
                //Here we will to find the customer by customer id or personal id
                Customer customer = null;
                if (!String.IsNullOrEmpty(customerState.CustomerId.ToString()))
                {
                    //Get the object ObjectCustomer and inside of this the object Customer
                    try
                    {
                        customer = customerLibrary.GetCustomer(customerState.CustomerId).Customer;
                    }
                    catch (Exception)
                    {
                        // throw; here we not send the exception beacuse we need to do the next method below
                    }
                }
                //If not found by customer id , we will try to find by personal id
                if (customer.Id <= 0)
                {
                    int idType = 0;
                    //GEt the object ObjectCustomer and inside of this the object Customer
                    try
                    {
                        customer = customerLibrary.GetCustomerByPersonalId(customerState.PersonaId, idType).Customer;
                    }
                    catch (Exception)
                    {
                        //throw;
                    }
                }

                if (customer == null)
                {
                    await context.PostAsync($"The user is not valid");
                }
                else
                {
                    int customerId = customer.Id;

                    //get the appoinment id for filter in the below results
                    int appoinmentId = state.appoinmentId;


                    //Get a list of cases by customer id (no trae resultados)
                    List <Case>        listCases = caseLibrary.GetCase(customerId).CaseList;
                    CaseCustomerResult cd        = new CaseCustomerResult();

                    //Get the appoinment by appoinment id
                    AppointmentGetResults _appoinment = AppoinmentService.GetAppointmentById(appoinmentId);

                    //Declare a case for save the specific case that we search
                    Case caseForSaveResult = new Case();

                    string test = caseForSaveResult.OTUnitName;

                    if (_appoinment.ProcessId > 0)
                    {
                        await context.PostAsync($"The appointment have the next information " +
                                                " \n* Process Id: " + _appoinment.ProcessId +
                                                " \n* Appointment date: " + _appoinment.AppointmentDate +
                                                " \n* Q-Code: " + _appoinment.QCode +
                                                " \n* Q-Number: " + _appoinment.QNumber +
                                                //" \n* Arrival date: " + _appoinment.ArrivalDate +
                                                " \n* Customer Id: " + _appoinment.CustomerId +
                                                // " \n* Date called: " + _appoinment.DateCalled +
                                                // " \n* Name: " + _appoinment.Name +
                                                " \n* Case Id: " + _appoinment.CaseId +
                                                //  " \n* Is Walkin: " + _appoinment.IsWalkIn +
                                                " \n* Is Active: " + _appoinment.IsActive +
                                                " \n* Service Name: " + _appoinment.ServiceName
                                                // " \n* Cancelreason name: " + _appoinment.CancelationReasonName
                                                );
                    }
                    // in other hand we can't find the record, so we will send the appropiate message
                    else
                    {
                        await context.PostAsync($"I don't found record with the appointment id: \n*" + state.appoinmentId);
                    }
                }
            };
            CultureInfo ci = new CultureInfo("en");

            Thread.CurrentThread.CurrentCulture   = ci;
            Thread.CurrentThread.CurrentUICulture = ci;
            var culture  = Thread.CurrentThread.CurrentUICulture;
            var form     = new FormBuilder <StatusFormApp>();
            var yesTerms = form.Configuration.Yes.ToList();
            var noTerms  = form.Configuration.No.ToList();

            yesTerms.Add("Yes");
            noTerms.Add("No");
            form.Configuration.Yes = yesTerms.ToArray();
            return(form.Message("Fill the information for search the appointment, please")
                   .Field(nameof(appoinmentId))
                   .Confirm("Are you selected the appointment id: {appoinmentId}: ? (yes/no)")
                   .AddRemainingFields()
                   .OnCompletion(processOrder)
                   .Build());
        }