コード例 #1
0
ファイル: Service1.cs プロジェクト: goa-csk/NordCarAPI
            public RegistrationsToSOS()
            {
                basic = new NordCar.Carla.Data.Entities.BasicStructure()
                {
                    BookTypes = "SOS"
                };

                ecr = new NordCar.Carla.Data.Implementation.ECAPIManagerRepository(Properties.Settings.Default.Ip7913, Properties.Settings.Default.Port7913, LoggerFile());
            }
コード例 #2
0
ファイル: Service1.cs プロジェクト: goa-csk/NordCarAPI
 private void DeleteMessage(NordCar.Carla.Data.Entities.BasicStructure basic, NordCar.Carla.Data.Entities.EC.QueueInfo item, string message)
 {
     try
     {
         //basic.FunctionId = NordCar.Carla.Data.Entities.FunctionList.ReservationStatusQueueMessageProcessed;
         var result = ecr.ReservationStatusQueueMessageProcessed(basic, item.MessageId, message);
         Log.Info(string.Format("Deleted {0}", result.Item2));
     }
     catch (Exception ex)
     {
         Log.Error(string.Format("Exception {0}", ex.ToString()));
     }
 }
コード例 #3
0
ファイル: SOSService.cs プロジェクト: goa-csk/NordCarAPI
        /// <summary>
        /// Get a list of SOS avaiable stations in the Carla system
        /// </summary>
        /// <returns></returns>
        public IEnumerable <Location> GetStations()
        {
            try
            {
                var bs = new NordCar.Carla.Data.Entities.BasicStructure()
                {
                    BookTypes = "SOS", CustomerId = customerNo.ToString()
                };

                var data = ecAPIManager.GetLocations(bs, "", "");

                if (!data.Item1.Succes)
                {
                    throw new FaultException <ECConfigurationFault>(new ECConfigurationFault("GetStations"), data.Item1.ErrorMessage);
                }


                return(Mapper.Map <List <NordCar.Carla.Data.Entities.EC.Location>, List <Location> >(data.Item2));
            }
            catch (FaultException <ConfigurationFault> ex)
            {
                log.Warn(ex.Reason);
                throw new FaultException <ECConfigurationFault>(new ECConfigurationFault("GetStations"), ex.Reason);
            }
            catch (FaultException ex)
            {
                if (!(ex is FaultException <ECValidationFault>))
                {
                    log.Warn(ex.Reason);
                }
                throw ex;
            }
            catch (System.Exception ex)
            {
                log.Error(ex.Message, ex);
                throw new FaultException(ex.Message);
            }
        }
コード例 #4
0
ファイル: SOSService.cs プロジェクト: goa-csk/NordCarAPI
        /// <summary>
        /// Get station details
        /// </summary>
        /// <param name="stationNo">Station number</param>
        /// <returns></returns>
        public LocationDetail GetStationDetails(int stationNo)
        {
            try
            {
                var bs = new NordCar.Carla.Data.Entities.BasicStructure()
                {
                    BookTypes = "SOS", CustomerId = customerNo.ToString()
                };

                var data = ecAPIManager.GetLocationDetails(bs, stationNo.ToString(), DateTime.Now, 120);

                if (!data.Item1.Succes)
                {
                    throw new FaultException <ECConfigurationFault>(new ECConfigurationFault("GetStationDetails"), data.Item1.ErrorMessage);
                }

                return(Mapper.Map <NordCar.Carla.Data.Entities.EC.LocationDetail, LocationDetail>(data.Item2));
            }
            catch (FaultException <ConfigurationFault> ex)
            {
                log.Warn(ex.Reason);
                throw new FaultException <ECConfigurationFault>(new ECConfigurationFault("GetStationDetails"), ex.Reason);
            }
            catch (FaultException ex)
            {
                if (!(ex is FaultException <ECValidationFault>))
                {
                    log.Warn(ex.Reason);
                }
                throw ex;
            }
            catch (System.Exception ex)
            {
                log.Error(ex.Message, ex);
                throw new FaultException(ex.Message);
            }
        }
コード例 #5
0
ファイル: SOSService.cs プロジェクト: goa-csk/NordCarAPI
        /// <summary>
        /// Make a reservation in the Carla system
        /// </summary>
        /// <param name="reservation"></param>
        public string MakeReservation(Reservation reservation)
        {
            //Input in UTC
            //Station in same as out
            try
            {
                log.Info("Object Received:" + Serialize.SerializeObject(reservation));
                //Make date time string
                var dt_str_in  = string.Format("{0} {1}", reservation.rental.DateIn, reservation.rental.TimeIn);
                var dt_str_out = string.Format("{0} {1}", reservation.rental.DateOut, reservation.rental.TimeOut);

                var carlatid_in  = Helpers.FromUTCToLocalCarlaTime(dt_str_in);
                var carlatid_out = Helpers.FromUTCToLocalCarlaTime(dt_str_out);

                var bs = new NordCar.Carla.Data.Entities.BasicStructure()
                {
                    BookTypes = "SOS", CustomerId = customerNo.ToString()
                };


                //New Reservation
                var newRes = new NordCar.Carla.Data.Entities.EC.Reservation()
                {
                    Gender                  = "",
                    FirstName               = reservation.driver.Name,
                    LastName                = reservation.driver.LastName,
                    Address                 = reservation.driver.address.Street,
                    City                    = reservation.driver.address.City,
                    PostCode                = reservation.driver.address.ZipCode,
                    Country                 = reservation.driver.address.Country,
                    PhoneNumber             = reservation.driver.Phone,
                    Remarks                 = SetRemarks(reservation.rental),
                    CustomerRefefenceNumber = reservation.CustomerReferenceNumber,
                    Address2                = "",
                    Address3                = "",
                    BirthDay                = "",
                    Email                   = "",
                    FlightNo                = "",
                    paymentType             = "0",
                    BookStatus              = 0,
                    ProductId               = reservation.AgreementId.ToString(),
                    Title                   = "",
                    PickDropInfo            = new NordCar.Carla.Data.Entities.EC.PickDropInfo()
                    {
                        PickUp = new NordCar.Carla.Data.Entities.EC.Trip()
                        {
                            LocationId = reservation.rental.StationOutId.ToString(), Date = carlatid_out.DateString, Time = carlatid_out.TimeString
                        },
                        DropOff = new NordCar.Carla.Data.Entities.EC.Trip()
                        {
                            LocationId = reservation.rental.StationOutId.ToString(), Date = carlatid_in.DateString, Time = carlatid_in.TimeString
                        },
                        CarGroupId = "",
                        CarTypeId  = "",
                        CountryId  = ""
                    },
                    Extra = null//new NordCar.Carla.Data.Entities.EC.SelectedExtras() { Insurance = null, Mileage = null, RecommendedExtras = null}
                };

                if (reservation.ECReservationNumer.Trim() != "")
                {
                    bs.OrgBookNr = reservation.ECReservationNumer;
                }

                var data = ecAPIManager.MakeReservation(bs, newRes);

                if (!data.Item1.Succes)
                {
                    throw new FaultException <ECConfigurationFault>(new ECConfigurationFault("MakeReservation"), data.Item1.ErrorMessage);
                }

                log.Info(string.Format("Reservationsnumber: {0}", data.Item2.ReservationNo));

                return(data.Item2.ReservationNo);
            }
            catch (FaultException <ConfigurationFault> ex)
            {
                log.Warn(ex.Reason);
                throw new FaultException <ECConfigurationFault>(new ECConfigurationFault("Make_Reservation"), ex.Reason);
            }
            catch (FaultException ex)
            {
                if (!(ex is FaultException <ECValidationFault>))
                {
                    log.Warn(ex.Reason);
                }
                throw ex;
            }
            catch (System.Exception ex)
            {
                log.Error(ex.Message, ex);
                throw new FaultException(ex.Message);
            }
        }