public static void LogHotelBookResp(HotelBookResponse HotelBookResp, string SearchId) { string path = MainPath + @"\TBOLogs\" + DateTime.UtcNow.Date.ToString("dd_MM_yyyy") + @"\" + SearchId + @"\HotelBookResp\"; Directory.CreateDirectory(path); path = path + "HotelBookResp.txt"; try { XmlSerializer xmlSerializer = new XmlSerializer(HotelBookResp.GetType()); using (StreamWriter streamwriter = new StreamWriter(path, append: false)) { xmlSerializer.Serialize(streamwriter, HotelBookResp); streamwriter.Close(); } } catch (FileNotFoundException Ex) { throw new LoggerException(LoggerErrorCodes.LoggerFileNotFound, LoggerErrorCodes.LoggerFileNotFound + " -This path (" + path + ") doesn't exist with file name " + Ex.FileName + " .", Ex.Message); } catch (IOException Ex) { throw new LoggerException(LoggerErrorCodes.LoggerFileINProcess, LoggerErrorCodes.LoggerFileINProcess + " -This Logger File (" + path + ") in another process you can not access it right now.", Ex.Message); } catch (Exception Ex) { throw new LoggerException(LoggerErrorCodes.FailedLogIntoLogger, LoggerErrorCodes.FailedLogIntoLogger + " -Failed Log Into Logger with path (" + path + ").", Ex.Message); } }
public static HotelBookResponse Booking(HotelBookRequest req, string SID) { var UName = ConfigurationSettings.AppSettings["TBOUserName"]; var UPass = ConfigurationSettings.AppSettings["TBOPassword"]; IHotelService proxy = TBOCredentials.CreateProxy(); req.Credentials = new AuthenticationData() { UserName = UName, Password = UPass }; req.RestrictDuplicateBooking = true; ProviderLogger.LogHotelBookReq(req, SID); HotelBookResponse resp = new HotelBookResponse(); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); resp = proxy.HotelBook(req); stopwatch.Stop(); TimeSpan ts1 = stopwatch.Elapsed; TimeSpan baseInterval = new TimeSpan(0, 0, 60); if (ts1 > baseInterval) { BookDetail.DetailService(req.ClientReferenceNumber); } ProviderLogger.LogHotelBookResp(resp, SID); return(resp); }