Example #1
0
        public async Task <IEnumerable <ServiceEntity> > GetServiceData(ServiceInput input)
        {
            const string STORE_PROCEDURE_NAME = "dbo.spu_ServiceSchedule";

            try
            {
                using (IDbConnection db = GetConnection())
                {
                    var values = new { BaseID = input.BaseId, RptDate = input.Today, SvcDay = GetSvcDayForStoreProcedure(input.GetSvcDay()) };
                    await db.QueryAsync(STORE_PROCEDURE_NAME, values, commandType : CommandType.StoredProcedure);

                    return(await db.QueryAsync <ServiceEntity>(GetServiceQuery(input.ShortBase)));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #2
0
        private async Task UpdateServiceData(List <ServiceEntity> serviceData, ServiceInput input)
        {
            foreach (ServiceEntity serviceDataItem in serviceData)
            {
                if (double.TryParse(serviceDataItem.Lat, out double latitude) && double.TryParse(serviceDataItem.Lon, out double longitude))
                {
                    serviceDataItem.MGRS = ConvertToMGRS(latitude, longitude);
                }

                SetGeographicCoordinates(serviceDataItem);
                string weekDay = input.GetSvcDay();
                serviceDataItem.MonRN = GetValueOf(weekDay, "RN", serviceDataItem);
                serviceDataItem.MonRO = GetValueOf(weekDay, "RO", serviceDataItem);
                if (Convert.ToBoolean(serviceDataItem.Pickup))
                {
                    serviceDataItem.MonRN = 1000; //Do not service
                    continue;
                }
                else
                {
                    if (serviceDataItem.PUDate != null)
                    {
                        if (serviceDataItem.PUDate.Date > new DateTime(1900, 12, 30).Date&& serviceDataItem.PUDate.Date <= input.Today.Date)
                        {
                            serviceDataItem.MonRN = 1000; //Do not service
                            continue;
                        }
                    }
                    if (serviceDataItem.DelDate != null)
                    {
                        if (serviceDataItem.DelDate.Date > new DateTime(1900, 12, 30).Date&& serviceDataItem.DelDate.Date >= input.Today.Date)
                        {
                            serviceDataItem.MonRN = 1000; //Do not service
                            continue;
                        }
                    }
                    if (serviceDataItem.SvcFreq != null)
                    {
                        switch (serviceDataItem.SvcFreq)
                        {
                        case ServiceFrequency.EveryOtherDay:
                            if (await SetUpMonRNorSvcFreq(serviceDataItem, input, ServiceFrequency.EveryOtherDay))
                            {
                                continue;
                            }
                            break;

                        case ServiceFrequency.BiWeekly:
                            if (await SetUpMonRNorSvcFreq(serviceDataItem, input, ServiceFrequency.BiWeekly))
                            {
                                continue;
                            }
                            break;

                        case ServiceFrequency.Monthly:
                            if (await SetUpMonRNorSvcFreq(serviceDataItem, input, ServiceFrequency.Monthly))
                            {
                                continue;
                            }
                            break;

                        default:
                            break;
                        }
                    }
                    if (serviceDataItem.MonRN == 0)
                    {
                        serviceDataItem.MonRN = 99;
                    }
                    UpdateOrderNumberBasedOnShortBaseAndReqNumberValue(input, serviceDataItem);
                }
            }
        }