public ActionResult BookCar(string programId) { var prdId = Request.Form["productId"]; var sessionId = Request.Form["sessionId"]; var carPrograms = (SearchCarInfo)Session["SessionCarPrograms"]; var carProgram = new CarProgram(); if (carPrograms != null) { carProgram = carPrograms.RouteOptions.First().ProgramList.CarProgram.First(p => p.id == programId); } var bookCarRequest = new BookCarRequest { SelectedProgram = programId, recordLocatorId = 0, DriverInfo = new Driver() { age = 30, firstName = "FName", lastName = "LName" }, PaymentType = "Obligo", RequestedPrice = (decimal)carProgram.price, DeltaPrice = (decimal)(carProgram.price * 10 / 100), Currency = carProgram.currency }; var resultsInfo = new ResultsInfo(); CarServiceClient carSvc = new CarServiceClient(); var bookRespone = carSvc.BookCar(new LoginHeader { UserName = "******", Password = "******", Culture = "en-US", Version = "1" }, bookCarRequest, out resultsInfo); string fileLoc = @"C:\Temp\BookingHistory.txt"; System.IO.File.AppendAllText(fileLoc, (bookRespone.rgid + "," + bookRespone.Reservation.pickUpDate + "," + bookRespone.Reservation.toDate + "," + bookRespone.Reservation.status + ";")); return View(bookRespone); }
private void DeserializeResultsInfo(SerializationInfo info) { ResultsInfo resultsInfo = (ResultsInfo)info.GetValue("ResultsInfo", typeof(ResultsInfo)); // Output CopyOutput(resultsInfo.Output); // Error CopyError(resultsInfo.Error); // Warning CopyWarning(resultsInfo.Warning); // Verbose CopyVerbose(resultsInfo.Verbose); // Progress CopyProgress(resultsInfo.Progress); // Debug CopyDebug(resultsInfo.Debug); // Information CopyInformation(resultsInfo.Information); }
//[MultipleButton(Name = "action", Argument = "Tourico")] public ActionResult GetCarDetails(string productId) { var prdId = Request.Form["productId"]; var sessionId = Request.Form["sessionId"]; var searchCarDetailInfo = new SearchCarInfo(); if (Session[sessionId] != null) { var cars = (SearchCarInfo[])Session[sessionId]; searchCarDetailInfo = cars.Select(x => x).First(p => p.productId == productId); } Session["SessionCarPrograms"] = searchCarDetailInfo; var resultInfo = new ResultsInfo(); CarServiceClient carSvc = new CarServiceClient(); var companyRules = carSvc.GetRulesAndRestrictions( new LoginHeader { UserName = "******", Password = "******", Culture = "en-US", Version = "1" }, searchCarDetailInfo.carCompanyId, out resultInfo); CarSearchModel carSearchModel = new CarSearchModel(); carSearchModel.searchCarInfo = searchCarDetailInfo; carSearchModel.companyrules = companyRules; return(View(carSearchModel)); }
public string GetCallbackResult() { JavaScriptSerializer js = new JavaScriptSerializer(); if (resOut == null) { resOut = new ResultsInfo(); } return(js.Serialize(resOut)); }
public ActionResult CancelCar(string reservationId) { var resultsInfo = new ResultsInfo(); CarServiceClient carSvc = new CarServiceClient(); var resultInfo = new ResultsInfo(); var cancelResponse = carSvc.CancelCar(new LoginHeader { UserName = "******", Password = "******", Culture = "en-US", Version = "1" }, Convert.ToInt64(reservationId), out resultInfo); CarCancelModel carCancelModel = new CarCancelModel(); carCancelModel.CancellationStatus = cancelResponse; return View(carCancelModel); }
public ActionResult CancelCar(string reservationId) { var resultsInfo = new ResultsInfo(); CarServiceClient carSvc = new CarServiceClient(); var resultInfo = new ResultsInfo(); var cancelResponse = carSvc.CancelCar(new LoginHeader { UserName = "******", Password = "******", Culture = "en-US", Version = "1" }, Convert.ToInt64(reservationId), out resultInfo); CarCancelModel carCancelModel = new CarCancelModel(); carCancelModel.CancellationStatus = cancelResponse; return(View(carCancelModel)); }
private static ResultsInfo EvaluateResults(int[] results, bool scale) { ResultsInfo ri = EvaluateResults(results); if (!scale) { return(ri); } float range = ri.Max - ri.Min; for (int x = 0; x < results.Length; x++) { results[x] = Math.Max((int)((results[x] - ri.Min) / range * 100F), 1); } return(EvaluateResults(results)); }
protected void ExecuteTestRunner() { var runner = new TestRunProcess(new RunnerFeedback()); runner .WrapTestProcessWith(ProfilerWrapper) .ProcessTestRuns(GetRunOptions()); var reader = new BinaryReader(_stream); reader.BaseStream.Position = 0; while (reader.BaseStream.Position < reader.BaseStream.Length) { var key = reader.ReadByte(); switch (key) { case 1: reader.ReadUInt32(); reader.ReadDouble(); reader.ReadInt32(); reader.ReadUInt64(); var info = new ResultsInfo(); info.RuntimeData = Encoding.Unicode.GetString(reader.ReadBytes(reader.ReadInt32() * 2)); info.MetaData = Encoding.Unicode.GetString(reader.ReadBytes(reader.ReadInt32() * 2)); ResultsInfos.Add(info); break; case 2: reader.ReadUInt32(); reader.ReadDouble(); reader.ReadInt32(); reader.ReadUInt64(); break; case 3: reader.ReadUInt32(); reader.ReadDouble(); reader.ReadInt32(); reader.ReadUInt64(); break; default: Assert.Fail("Validation failed {0} {1}", key, reader.BaseStream.Position); return; } } }
public ActionResult GetCars(FormCollection collection) { sessionPick = collection["pickUpLocation"].Substring(0, 3); sessionDrop = collection["dropLocation"].Substring(0, 3); string sessionName = "SearchResult" + sessionPick + sessionDrop + collection["pickUpDate"]; var searchCarInfo = new SearchCarInfo[] { }; if (Session[sessionName] == null) { SearchCarsRequest request = new SearchCarsRequest(); Route route = new Route(); route.PickUp = collection["pickUpLocation"].Substring(0, 3); route.DropOff = collection["dropLocation"].Substring(0, 3); //request.Route.PickUp = "MCO"; //request.Route.DropOff = "MCO"; request.Route = route; request.PickUpDate = Convert.ToDateTime(collection["pickUpDate"]); request.DropOffDate = Convert.ToDateTime(collection["dropDate"]); request.PickUpHour = Convert.ToInt32(collection["ddlPickUpHour"]); request.DropOffHour = Convert.ToInt32(collection["ddlDropHour"]); request.VehicleType = Convert.ToInt32(collection["ddlVehicleType"]); request.CarCompany = Convert.ToInt32(collection["ddlCarCompany"]); request.TotalPax = Convert.ToInt32(collection["ddlTotalPax"]); var resultsInfo = new ResultsInfo(); CarServiceClient carSvc = new CarServiceClient(); var result = carSvc.SearchCarsByAirportCode( new LoginHeader { UserName = "******", Password = "******", Culture = "en-US", Version = "1" }, request, out searchCarInfo, out resultsInfo); Session[sessionName] = searchCarInfo; } else { searchCarInfo = (SearchCarInfo[])Session[sessionName]; } ViewBag.SessionId = sessionName; return(View(searchCarInfo)); }
public void RaiseCallbackEvent(String eventArgument) { try { //Validate that an appropriate control caused the callback for security reasons Page.ClientScript.ValidateEvent(this.UniqueID); //Create a serializer to handle the client side info JavaScriptSerializer js = new JavaScriptSerializer(); //Serialize out the info from the callback so we can work with it CallbackActionRequest car = js.Deserialize <CallbackActionRequest>(eventArgument); Boolean byPassDistances = car.LastResult; if (car.ToDo == "ChangeSort") { byPassDistances = false; } //Perform the intended action car.Act(); //Setup the distances we'll want to reprort back using Google if (!byPassDistances) { car.GetDistances(); } //Sort the results including the buffer ontop of what the database already sort as we now have google distance data if (!byPassDistances) { car.SortResults(); } else { car.SortFullResults(); } //Set the resOut object to an instance of ResultsInfo for serialization resOut = car.RetrieveResultsInfo(); } catch (Exception ex) { } }
public ActionResult GetBookingDetail(string rgId) { CarServiceClient carSvc = new CarServiceClient(); var getRGInfoRequest = new GetRGInfoRequest() { nRGID = Convert.ToInt32(rgId), Notifications = new Notifications(), SendDrivingDirections = true }; var resultsInfo = new ResultsInfo(); var rgInfoResponse = carSvc.GetRGInfo( new LoginHeader { UserName = "******", Password = "******", Culture = "en-US", Version = "1" }, getRGInfoRequest, out resultsInfo); return(View(rgInfoResponse)); }
//[MultipleButton(Name = "action", Argument = "Tourico")] public ActionResult BookCar(string programId) { var prdId = Request.Form["productId"]; var sessionId = Request.Form["sessionId"]; var carPrograms = (SearchCarInfo)Session["SessionCarPrograms"]; var carProgram = new CarProgram(); if (carPrograms != null) { carProgram = carPrograms.RouteOptions.First().ProgramList.CarProgram.First(p => p.id == programId); } var bookCarRequest = new BookCarRequest { SelectedProgram = programId, recordLocatorId = 0, DriverInfo = new Driver() { age = 30, firstName = "FName", lastName = "LName" }, PaymentType = "Obligo", RequestedPrice = (decimal)carProgram.price, DeltaPrice = (decimal)(carProgram.price * 10 / 100), Currency = carProgram.currency }; var resultsInfo = new ResultsInfo(); CarServiceClient carSvc = new CarServiceClient(); var bookRespone = carSvc.BookCar(new LoginHeader { UserName = "******", Password = "******", Culture = "en-US", Version = "1" }, bookCarRequest, out resultsInfo); string fileLoc = @"C:\Temp\BookingHistory.txt"; System.IO.File.AppendAllText(fileLoc, (bookRespone.rgid + "," + bookRespone.Reservation.pickUpDate + "," + bookRespone.Reservation.toDate + "," + bookRespone.Reservation.status + ";")); return(View(bookRespone)); }
//---------------------------------------------------------------------------------------// private string ConvertToXml(ResultsInfo[] resultsInfoArray) { const string STRLOG_MethodName = "ConvertToXml"; Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName); // // Catch all exceptions thrown and return an empty string if an error occurred // XmlDocument xmlDocument = null; string xmlExperimentResults = string.Empty; try { // // Check that the experiment info array exists // if (resultsInfoArray == null) { throw new ArgumentNullException(STRERR_ResultsInfoArrayIsNull); } // // Take the experiment info and put into the XML document // for (int i = 0; i < resultsInfoArray.GetLength(0); i++) { ResultsInfo resultsInfo = resultsInfoArray[i]; // Load experiment results XML template string XmlDocument xmlTemplateDocument = XmlUtilities.GetXmlDocument(STRXMLDOC_XmlTemplate); // // Fill in the XML template with values from the experiment results information // XmlNode xmlRootNode = XmlUtilities.GetXmlRootNode(xmlTemplateDocument, STRXML_experimentResults); XmlNode xmlNode = XmlUtilities.GetXmlNode(xmlRootNode, STRXML_experimentResult); XmlUtilities.SetXmlValue(xmlNode, Consts.STRXML_experimentID, resultsInfo.experimentId); XmlUtilities.SetXmlValue(xmlNode, Consts.STRXML_sbName, resultsInfo.sbName, false); XmlUtilities.SetXmlValue(xmlNode, STRXML_userGroup, resultsInfo.userGroup, false); XmlUtilities.SetXmlValue(xmlNode, STRXML_priorityHint, resultsInfo.priorityHint); XmlUtilities.SetXmlValue(xmlNode, STRXML_statusCode, resultsInfo.statusCode); XmlUtilities.SetXmlValue(xmlNode, STRXML_xmlExperimentResult, resultsInfo.xmlExperimentResult, true); XmlUtilities.SetXmlValue(xmlNode, STRXML_xmlResultExtension, resultsInfo.xmlResultExtension, true); XmlUtilities.SetXmlValue(xmlNode, STRXML_xmlBlobExtension, resultsInfo.xmlBlobExtension, true); XmlNode xmlNodeTemp = XmlUtilities.GetXmlNode(xmlNode, STRXML_warningMessages); XmlUtilities.SetXmlValues(xmlNodeTemp, STRXML_warningMessage, resultsInfo.warningMessages, true); XmlUtilities.SetXmlValue(xmlNode, STRXML_errorMessage, resultsInfo.errorMessage, true); if (xmlDocument == null) { xmlDocument = xmlTemplateDocument; } else { // // Create an XML fragment from the XML template and append to the document // XmlDocumentFragment xmlFragment = xmlDocument.CreateDocumentFragment(); xmlFragment.InnerXml = xmlNode.OuterXml; xmlDocument.DocumentElement.AppendChild(xmlFragment); } } // // Check if there were any experiment statistics // if (xmlDocument == null) { xmlDocument = XmlUtilities.GetXmlDocument(STRXMLDOC_XmlTemplate); XmlNode xmlRootNode = XmlUtilities.GetXmlRootNode(xmlDocument, STRXML_experimentResults); XmlNode xmlNode = XmlUtilities.GetXmlNode(xmlRootNode, STRXML_experimentResult); xmlRootNode.RemoveChild(xmlNode); } // // Convert the XML document to a string // StringWriter sw = new StringWriter(); XmlTextWriter xtw = new XmlTextWriter(sw); xtw.Formatting = Formatting.Indented; xmlDocument.WriteTo(xtw); xtw.Flush(); xmlExperimentResults = sw.ToString(); } catch (Exception ex) { Logfile.WriteError(ex.Message); } Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName); return(xmlExperimentResults); }
private MemoryStream PlotSparklineSmooth(int[] results) { try { int step = int.Parse(GetArg("step", "2")); int height = int.Parse(GetArg("height", "20")); Color minColor = GetColor(GetArg("min-color", "#0000FF")); Color maxColor = GetColor(GetArg("max-color", "#00FF00")); Color lastColor = GetColor(GetArg("last-color", "#FF0000")); Color rangeColor = GetColor(GetArg("range-color", "#CCCCCC")); bool hasMin = bool.Parse(GetArg("min-m", "false")); bool hasMax = bool.Parse(GetArg("max-m", "false")); bool hasLast = bool.Parse(GetArg("last-m", "false")); int rangeLower = int.Parse(GetArg("range-lower", "0")); int rangeUpper = int.Parse(GetArg("range-upper", "0")); bool transparent = bool.Parse(GetArg("transparent", "false")); bool scale = bool.Parse(GetArg("scale", "false")); ResultsInfo resultsInfo = EvaluateResults(results, scale); if (rangeLower < 0 || rangeLower > 100) { return(PlotError()); } if (rangeUpper < 0 || rangeUpper > 100) { return(PlotError()); } using (Bitmap bitmap = new Bitmap((results.Length - 1) * step + 4, height, PixelFormat.Format32bppArgb)) { using (Graphics g = Graphics.FromImage(bitmap)) { using (SolidBrush br = new SolidBrush(Color.White)) { g.FillRectangle(br, 0, 0, bitmap.Width, height); } if (!(0 == rangeLower && 0 == rangeUpper) && rangeLower <= rangeUpper) { using (SolidBrush br = new SolidBrush(rangeColor)) { int y = height - 3 - (int)Math.Ceiling(rangeUpper / (101F / (height - 4))); int h = height - 3 - (int)Math.Ceiling(rangeLower / (101F / (height - 4))) - y + 1; g.FillRectangle(br, 1, y, bitmap.Width - 2, h); } } Point[] coords = new Point[results.Length]; for (int x = 0; x < results.Length; x++) { int r = results[x]; int y = height - 3 - (int)Math.Ceiling(r / (101F / (height - 4))); coords[x] = new Point(x * step + 1, y); } using (Pen p = new Pen(GetColor("#999999"))) { g.DrawLines(p, coords); } if (hasMin) { DrawTick(g, minColor, coords[resultsInfo.MinIndex]); } if (hasMax) { DrawTick(g, maxColor, coords[resultsInfo.MaxIndex]); } if (hasLast) { DrawTick(g, lastColor, coords[results.Length - 1]); } MemoryStream m = new MemoryStream(); bitmap.Save(m, ImageFormat.Gif); return(transparent ? MakeTransparent(m) : m); } } } catch { return(PlotError()); } }
public ActionResult GetCarDetails(string productId) { var prdId = Request.Form["productId"]; var sessionId = Request.Form["sessionId"]; var searchCarDetailInfo = new SearchCarInfo(); if (Session[sessionId] != null) { var cars = (SearchCarInfo[])Session[sessionId]; searchCarDetailInfo = cars.Select(x => x).First(p => p.productId == productId); } Session["SessionCarPrograms"] = searchCarDetailInfo; var resultInfo = new ResultsInfo(); CarServiceClient carSvc = new CarServiceClient(); var companyRules = carSvc.GetRulesAndRestrictions( new LoginHeader { UserName = "******", Password = "******", Culture = "en-US", Version = "1" }, searchCarDetailInfo.carCompanyId, out resultInfo); CarSearchModel carSearchModel = new CarSearchModel(); carSearchModel.searchCarInfo = searchCarDetailInfo; carSearchModel.companyrules = companyRules; return View(carSearchModel); }
private void SerializeResultsInfo(SerializationInfo info) { // All other job information is in the child jobs. Collection <PSObject> output = new Collection <PSObject>(); Collection <ErrorRecord> error = new Collection <ErrorRecord>(); Collection <WarningRecord> warning = new Collection <WarningRecord>(); Collection <VerboseRecord> verbose = new Collection <VerboseRecord>(); Collection <ProgressRecord> progress = new Collection <ProgressRecord>(); Collection <DebugRecord> debug = new Collection <DebugRecord>(); Collection <InformationRecord> information = new Collection <InformationRecord>(); if (_job != null) { // Collect data from "live" job. if (JobStateInfo.Reason != null) { error.Add(new ErrorRecord(JobStateInfo.Reason, "ScheduledJobFailedState", ErrorCategory.InvalidResult, null)); } foreach (var item in _job.Error) { error.Add(item); } foreach (Job childJob in ChildJobs) { if (childJob.JobStateInfo.Reason != null) { error.Add(new ErrorRecord(childJob.JobStateInfo.Reason, "ScheduledJobFailedState", ErrorCategory.InvalidResult, null)); } foreach (var item in childJob.Output) { output.Add(item); } foreach (var item in childJob.Error) { error.Add(item); } foreach (var item in childJob.Warning) { warning.Add(item); } foreach (var item in childJob.Verbose) { verbose.Add(item); } foreach (var item in childJob.Progress) { progress.Add(item); } foreach (var item in childJob.Debug) { debug.Add(item); } foreach (var item in childJob.Information) { information.Add(item); } } } else { // Collect data from object collections. foreach (var item in Output) { // Wrap the base object in a new PSObject. This is necessary because the // source deserialized PSObject doesn't serialize again correctly and breaks // PS F&O. Not sure if this is a PSObject serialization bug or not. output.Add(new PSObject(item.BaseObject)); } foreach (var item in Error) { error.Add(item); } foreach (var item in Warning) { warning.Add(item); } foreach (var item in Verbose) { verbose.Add(item); } foreach (var item in Progress) { progress.Add(item); } foreach (var item in Debug) { debug.Add(item); } foreach (var item in Information) { information.Add(item); } } ResultsInfo resultsInfo = new ResultsInfo( output, error, warning, verbose, progress, debug, information); info.AddValue("ResultsInfo", resultsInfo); }
public ActionResult GetCars(FormCollection collection) { sessionPick = collection["pickUpLocation"].Substring(0, 3); sessionDrop = collection["dropLocation"].Substring(0, 3); string sessionName = "SearchResult" + sessionPick + sessionDrop + collection["pickUpDate"]; var searchCarInfo = new SearchCarInfo[] { }; if (Session[sessionName] == null) { SearchCarsRequest request = new SearchCarsRequest(); Route route = new Route(); route.PickUp = collection["pickUpLocation"].Substring(0, 3); route.DropOff = collection["dropLocation"].Substring(0, 3); //request.Route.PickUp = "MCO"; //request.Route.DropOff = "MCO"; request.Route = route; request.PickUpDate = Convert.ToDateTime(collection["pickUpDate"]); request.DropOffDate = Convert.ToDateTime(collection["dropDate"]); request.PickUpHour = Convert.ToInt32(collection["ddlPickUpHour"]); request.DropOffHour = Convert.ToInt32(collection["ddlDropHour"]); request.VehicleType = Convert.ToInt32(collection["ddlVehicleType"]); request.CarCompany = Convert.ToInt32(collection["ddlCarCompany"]); request.TotalPax = Convert.ToInt32(collection["ddlTotalPax"]); var resultsInfo = new ResultsInfo(); CarServiceClient carSvc = new CarServiceClient(); var result = carSvc.SearchCarsByAirportCode( new LoginHeader { UserName = "******", Password = "******", Culture = "en-US", Version = "1" }, request, out searchCarInfo, out resultsInfo); Session[sessionName] = searchCarInfo; } else { searchCarInfo = (SearchCarInfo[])Session[sessionName]; } ViewBag.SessionId = sessionName; return View(searchCarInfo); }
public ActionResult GetBookingDetail(string rgId) { CarServiceClient carSvc = new CarServiceClient(); var getRGInfoRequest = new GetRGInfoRequest() { nRGID = Convert.ToInt32(rgId), Notifications = new Notifications(), SendDrivingDirections = true }; var resultsInfo = new ResultsInfo(); var rgInfoResponse = carSvc.GetRGInfo( new LoginHeader { UserName = "******", Password = "******", Culture = "en-US", Version = "1" }, getRGInfoRequest, out resultsInfo); return View(rgInfoResponse); }
//---------------------------------------------------------------------------------------// private ResultsInfo[] RetrieveAll() { const string STRLOG_MethodName = "RetrieveAll"; List<ResultsInfo> resultsInfoList = new List<ResultsInfo>(); lock (this.resultsLock) { try { SqlCommand sqlCommand = new SqlCommand(STRSQLCMD_RetrieveResultsAll, this.sqlConnection); sqlCommand.CommandType = CommandType.StoredProcedure; try { this.sqlConnection.Open(); SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); while (sqlDataReader.Read() == true) { ResultsInfo resultsInfo = new ResultsInfo(); string xmlWarningMessages = string.Empty; object sdrObject = null; if ((sdrObject = sqlDataReader[STRSQL_ExperimentId]) != System.DBNull.Value) resultsInfo.experimentId = (int)sdrObject; if ((sdrObject = sqlDataReader[STRSQL_SbName]) != System.DBNull.Value) resultsInfo.sbName = (string)sdrObject; if ((sdrObject = sqlDataReader[STRSQL_UserGroup]) != System.DBNull.Value) resultsInfo.userGroup = (string)sdrObject; if ((sdrObject = sqlDataReader[STRSQL_PriorityHint]) != System.DBNull.Value) resultsInfo.priorityHint = (int)sdrObject; if ((sdrObject = sqlDataReader[STRSQL_Status]) != System.DBNull.Value) { StatusCodes status = (StatusCodes)Enum.Parse(typeof(StatusCodes), (string)sdrObject); resultsInfo.statusCode = (int)status; } if ((sdrObject = sqlDataReader[STRSQL_XmlExperimentResult]) != System.DBNull.Value) resultsInfo.xmlExperimentResult = (string)sdrObject; if ((sdrObject = sqlDataReader[STRSQL_XmlResultExtension]) != System.DBNull.Value) resultsInfo.xmlResultExtension = (string)sdrObject; if ((sdrObject = sqlDataReader[STRSQL_XmlBlobExtension]) != System.DBNull.Value) resultsInfo.xmlBlobExtension = (string)sdrObject; if ((sdrObject = sqlDataReader[STRSQL_WarningMessages]) != System.DBNull.Value) xmlWarningMessages = (string)sdrObject; if ((sdrObject = sqlDataReader[STRSQL_ErrorMessage]) != System.DBNull.Value) resultsInfo.errorMessage = (string)sdrObject; // // Convert warning messages from XML format to string array // try { XmlDocument xmlDocument = XmlUtilities.GetXmlDocument(xmlWarningMessages); XmlNode xmlRootNode = XmlUtilities.GetXmlRootNode(xmlDocument, STRXML_warningMessages); resultsInfo.warningMessages = XmlUtilities.GetXmlValues(xmlRootNode, STRXML_warningMessage, true); } catch { } // // Add the results info to the list // resultsInfoList.Add(resultsInfo); } sqlDataReader.Close(); } catch (SqlException ex) { throw new Exception(STRERR_SqlException + ex.Message); } catch (Exception ex) { throw new Exception(STRERR_Exception + ex.Message); } finally { this.sqlConnection.Close(); } } catch (Exception ex) { Logfile.WriteError(ex.Message); } } string logMessage = STRLOG_count + resultsInfoList.Count.ToString(); Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage); return resultsInfoList.ToArray(); }
public void RaiseCallbackEvent(String eventArgument) { try { //Page.ClientScript.ValidateEvent(this.pnlServices.UniqueID); JavaScriptSerializer js = new JavaScriptSerializer(); CallbackActionRequest car = js.Deserialize<CallbackActionRequest>(eventArgument); car.ResultSet = ResultsTable; //car.Act(); //car.SortResults(); resOut = car.RetrieveResultsInfo(); } catch (Exception ex) { } }
//---------------------------------------------------------------------------------------// private ResultsInfo[] RetrieveAll() { const string STRLOG_MethodName = "RetrieveAll"; List <ResultsInfo> resultsInfoList = new List <ResultsInfo>(); lock (this.resultsLock) { try { SqlCommand sqlCommand = new SqlCommand(STRSQLCMD_RetrieveResultsAll, this.sqlConnection); sqlCommand.CommandType = CommandType.StoredProcedure; try { this.sqlConnection.Open(); SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); while (sqlDataReader.Read() == true) { ResultsInfo resultsInfo = new ResultsInfo(); string xmlWarningMessages = string.Empty; object sdrObject = null; if ((sdrObject = sqlDataReader[STRSQL_ExperimentId]) != System.DBNull.Value) { resultsInfo.experimentId = (int)sdrObject; } if ((sdrObject = sqlDataReader[STRSQL_SbName]) != System.DBNull.Value) { resultsInfo.sbName = (string)sdrObject; } if ((sdrObject = sqlDataReader[STRSQL_UserGroup]) != System.DBNull.Value) { resultsInfo.userGroup = (string)sdrObject; } if ((sdrObject = sqlDataReader[STRSQL_PriorityHint]) != System.DBNull.Value) { resultsInfo.priorityHint = (int)sdrObject; } if ((sdrObject = sqlDataReader[STRSQL_Status]) != System.DBNull.Value) { StatusCodes status = (StatusCodes)Enum.Parse(typeof(StatusCodes), (string)sdrObject); resultsInfo.statusCode = (int)status; } if ((sdrObject = sqlDataReader[STRSQL_XmlExperimentResult]) != System.DBNull.Value) { resultsInfo.xmlExperimentResult = (string)sdrObject; } if ((sdrObject = sqlDataReader[STRSQL_XmlResultExtension]) != System.DBNull.Value) { resultsInfo.xmlResultExtension = (string)sdrObject; } if ((sdrObject = sqlDataReader[STRSQL_XmlBlobExtension]) != System.DBNull.Value) { resultsInfo.xmlBlobExtension = (string)sdrObject; } if ((sdrObject = sqlDataReader[STRSQL_WarningMessages]) != System.DBNull.Value) { xmlWarningMessages = (string)sdrObject; } if ((sdrObject = sqlDataReader[STRSQL_ErrorMessage]) != System.DBNull.Value) { resultsInfo.errorMessage = (string)sdrObject; } // // Convert warning messages from XML format to string array // try { XmlDocument xmlDocument = XmlUtilities.GetXmlDocument(xmlWarningMessages); XmlNode xmlRootNode = XmlUtilities.GetXmlRootNode(xmlDocument, STRXML_warningMessages); resultsInfo.warningMessages = XmlUtilities.GetXmlValues(xmlRootNode, STRXML_warningMessage, true); } catch { } // // Add the results info to the list // resultsInfoList.Add(resultsInfo); } sqlDataReader.Close(); } catch (SqlException ex) { throw new Exception(STRERR_SqlException + ex.Message); } catch (Exception ex) { throw new Exception(STRERR_Exception + ex.Message); } finally { this.sqlConnection.Close(); } } catch (Exception ex) { Logfile.WriteError(ex.Message); } } string logMessage = STRLOG_count + resultsInfoList.Count.ToString(); Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage); return(resultsInfoList.ToArray()); }
public ResultsInfo RetrieveResultsInfo() { ResultsInfo ri = new ResultsInfo(); ri.ResultCount = (tblResults == null ? 0 : tblResults.Rows.Count); List <Result> lResult = new List <Result>(); if (ri.ResultCount > 0) { if (!IsMultiLab) { ri.LearnMore = new String[1]; if (learnMoreTable.Rows.Count > 0 && learnMoreTable.Rows[0][0].ToString().Trim() != String.Empty) { ri.LearnMore[0] = learnMoreTable.Rows[0][0].ToString().Trim(); } else { ri.LearnMore[0] = "Additional information about this service could not be retrieved at this time."; } } else { ri.LearnMore = new String[(learnMoreTable.Rows.Count)]; if (learnMoreTable.Rows.Count > 0) { for (int i = 0; i < learnMoreTable.Rows.Count; i++) { if (learnMoreTable.Rows[i]["Description"].ToString().Trim() != String.Empty && learnMoreTable.Rows[i]["Description"].ToString() != "NULL") { ri.LearnMore[i] = learnMoreTable.Rows[i]["Description"].ToString().Trim(); } else { ri.LearnMore[i] = "Additional information about this service could not be retrieved at this time."; } } } } Result r = null; DataRow dr = null; for (Int32 i = 1; i <= ri.ResultCount; i++) { dr = tblResults.Rows[i - 1]; r = new Result(int.Parse(resCount) + i, this.sYC); r.Name = dr["PracticeName"].ToString(); r.City = (tblResults.Columns.Contains("LocationCity") ? dr["LocationCity"].ToString() : dr["City"].ToString()); r.Distance = dr["Distance"].ToString(); r.RangeMin = dr["RangeMin"].ToString(); r.RangeMax = dr["RangeMax"].ToString(); r.YourCostMin = dr["YourCostMin"].ToString(); r.YourCostMax = dr["YourCostMax"].ToString(); r.LocID = dr["OrganizationLocationID"].ToString(); Int32 iFP = 0; if (Int32.TryParse(dr["FairPrice"].ToString(), out iFP)) { r.isFairPrice = Convert.ToBoolean(iFP); } else { r.isFairPrice = Boolean.Parse((dr["FairPrice"].ToString().Trim() == String.Empty ? "False" : dr["FairPrice"].ToString().Trim())); } if (dr["HGRecognized"].ToString().Trim() == "") { r.isHGRecognized = false; } else { r.isHGRecognized = Boolean.Parse((dr["HGRecognized"].ToString().Trim() == String.Empty ? "False" : dr["HGRecognized"].ToString().Trim())); } r.Lat = dr["Latitude"].ToString(); r.Lng = dr["Longitude"].ToString(); //Encrypt the Navigation Elements to prevent potential security risk(s) FormsAuthenticationTicket tk = new FormsAuthenticationTicket(String.Format("{0}|{1}|{2}|{3}", r.Name, (ThisSession.ChosenLabs == null ? dr["NPI"].ToString() : dr["OrganizationID"].ToString()), r.Distance, r.LocID), false, 5); r.Nav = FormsAuthentication.Encrypt(tk); r.HGRecognizedDocCount = dr["HGRecognizedDocCount"].ToString(); r.HGDocCount = dr["HGDocCount"].ToString(); lResult.Add(r); } ri.EndOfResults = this.lastResult; } else { lResult.Add(new EmptyResult()); ri.EndOfResults = true; } ri.Results = lResult.ToArray <Result>(); return(ri); }
public void RaiseCallbackEvent(String eventArgument) { try { //Validate that an appropriate control caused the callback for security reasons Page.ClientScript.ValidateEvent(this.UniqueID); //Create a serializer to handle the client side info JavaScriptSerializer js = new JavaScriptSerializer(); //Serialize out the info from the callback so we can work with it CallbackActionRequest car = js.Deserialize<CallbackActionRequest>(eventArgument); Boolean byPassDistances = car.LastResult; if (car.ToDo == "ChangeSort") { byPassDistances = false; } //Perform the intended action car.Act(); //Setup the distances we'll want to reprort back using Google if (!byPassDistances) car.GetDistances(); //Sort the results including the buffer ontop of what the database already sort as we now have google distance data if (!byPassDistances) car.SortResults(); else car.SortFullResults(); //Set the resOut object to an instance of ResultsInfo for serialization resOut = car.RetrieveResultsInfo(); } catch (Exception ex) { } }
public ResultsInfo RetrieveResultsInfo() { string[] pracCols = { "PracticeName", "Latitude", "Longitude", "LocationAddress1", "LocationCity", "LocationState", "LocationZip", "Distance" }; string[] provCols = { "ProviderName", "NPI", "RangeMin", "RangeMax", "FairPrice", "HGRecognized", "HGOverallRating", "HGPatientCount", "PracticeName" }; ResultsInfo ri = new ResultsInfo(); ri.ResultCount = this._results.Rows.Count; ri.EndOfResults = true; //We aren't buffering these results so for now just load the whole set and don't try again. List<Result> lResult = new List<Result>(); using (DataView dv = new DataView(this._results)) { string[] UniquePractCol = { "PracticeName" }; using (DataTable uniquePractices = dv.ToTable("ByPractice", true, UniquePractCol)) { foreach (DataRow dr in uniquePractices.Rows) { Result r = new Result(lResult.Count + 1); using (DataView byPractice = new DataView(dv.ToTable("PracticeInfo", true, pracCols))) { byPractice.RowFilter = "PracticeName = '" + dr[0].ToString().Replace("'", "''") + "'"; Practice pr = new Practice(); pr.Name = byPractice[0].Row[pracCols[0].ToString()].ToString(); pr.Lat = byPractice[0].Row[pracCols[1].ToString()].ToString(); pr.Lng = byPractice[0].Row[pracCols[2].ToString()].ToString(); pr.Address1 = byPractice[0].Row[pracCols[3].ToString()].ToString(); pr.City = byPractice[0].Row[pracCols[4].ToString()].ToString(); pr.State = byPractice[0].Row[pracCols[5].ToString()].ToString(); pr.Zip = byPractice[0].Row[pracCols[6].ToString()].ToString(); pr.Distance = byPractice[0].Row[pracCols[7].ToString()].ToString(); FormsAuthenticationTicket tk = new FormsAuthenticationTicket(string.Format("{0}|{1}|{2}|{3}" , pr.Name , "" , "" , pr.Distance) , false, 5); pr.Nav = FormsAuthentication.Encrypt(tk); r.Practice = pr; } List<Provider> provsAtPrac = new List<Provider>(); using (DataView byProvider = new DataView(dv.ToTable("ProviderInfo", false, provCols))) { byProvider.RowFilter = "PracticeName = '" + dr[0].ToString().Replace("'", "''") + "'"; for (int i = 0; i < byProvider.Count; i++) { Provider pr = new Provider(lResult.Count + 1); pr.Name = byProvider[i].Row[provCols[0].ToString()].ToString(); pr.NPI = byProvider[i].Row[provCols[1].ToString()].ToString(); pr.RangeMin = byProvider[i].Row[provCols[2].ToString()].ToString(); pr.RangeMax = byProvider[i].Row[provCols[3].ToString()].ToString(); pr.IsFairPrice = Boolean.Parse(byProvider[i].Row[provCols[4].ToString()].ToString()); pr.IsHGRecognized = Boolean.Parse(byProvider[i].Row[provCols[5].ToString()].ToString()); pr.HGRating = byProvider[i].Row[provCols[6].ToString()].ToString(); pr.HGRatingCount = byProvider[i].Row[provCols[7].ToString()].ToString(); FormsAuthenticationTicket tk = new FormsAuthenticationTicket(string.Format("{0}|{1}|{2}|{3}" , r.Practice.Name , pr.Name , pr.NPI , r.Practice.Distance) , false, 5); pr.Nav = FormsAuthentication.Encrypt(tk); provsAtPrac.Add(pr); } } r.Providers = provsAtPrac.ToArray<Provider>(); lResult.Add(r); } } } ri.Results = lResult.ToArray<Result>(); return ri; }
public string GetCallbackResult() { JavaScriptSerializer js = new JavaScriptSerializer(); if (resOut == null) { resOut = new ResultsInfo(); } return js.Serialize(resOut); }
//---------------------------------------------------------------------------------------// private string ConvertToXml(ResultsInfo[] resultsInfoArray) { const string STRLOG_MethodName = "ConvertToXml"; Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName); // // Catch all exceptions thrown and return an empty string if an error occurred // XmlDocument xmlDocument = null; string xmlExperimentResults = string.Empty; try { // // Check that the experiment info array exists // if (resultsInfoArray == null) { throw new ArgumentNullException(STRERR_ResultsInfoArrayIsNull); } // // Take the experiment info and put into the XML document // for (int i = 0; i < resultsInfoArray.GetLength(0); i++) { ResultsInfo resultsInfo = resultsInfoArray[i]; // Load experiment results XML template string XmlDocument xmlTemplateDocument = XmlUtilities.GetXmlDocument(STRXMLDOC_XmlTemplate); // // Fill in the XML template with values from the experiment results information // XmlNode xmlRootNode = XmlUtilities.GetXmlRootNode(xmlTemplateDocument, STRXML_experimentResults); XmlNode xmlNode = XmlUtilities.GetXmlNode(xmlRootNode, STRXML_experimentResult); XmlUtilities.SetXmlValue(xmlNode, Consts.STRXML_experimentID, resultsInfo.experimentId); XmlUtilities.SetXmlValue(xmlNode, Consts.STRXML_sbName, resultsInfo.sbName, false); XmlUtilities.SetXmlValue(xmlNode, STRXML_userGroup, resultsInfo.userGroup, false); XmlUtilities.SetXmlValue(xmlNode, STRXML_priorityHint, resultsInfo.priorityHint); XmlUtilities.SetXmlValue(xmlNode, STRXML_statusCode, resultsInfo.statusCode); XmlUtilities.SetXmlValue(xmlNode, STRXML_xmlExperimentResult, resultsInfo.xmlExperimentResult, true); XmlUtilities.SetXmlValue(xmlNode, STRXML_xmlResultExtension, resultsInfo.xmlResultExtension, true); XmlUtilities.SetXmlValue(xmlNode, STRXML_xmlBlobExtension, resultsInfo.xmlBlobExtension, true); XmlNode xmlNodeTemp = XmlUtilities.GetXmlNode(xmlNode, STRXML_warningMessages); XmlUtilities.SetXmlValues(xmlNodeTemp, STRXML_warningMessage, resultsInfo.warningMessages, true); XmlUtilities.SetXmlValue(xmlNode, STRXML_errorMessage, resultsInfo.errorMessage, true); if (xmlDocument == null) { xmlDocument = xmlTemplateDocument; } else { // // Create an XML fragment from the XML template and append to the document // XmlDocumentFragment xmlFragment = xmlDocument.CreateDocumentFragment(); xmlFragment.InnerXml = xmlNode.OuterXml; xmlDocument.DocumentElement.AppendChild(xmlFragment); } } // // Check if there were any experiment statistics // if (xmlDocument == null) { xmlDocument = XmlUtilities.GetXmlDocument(STRXMLDOC_XmlTemplate); XmlNode xmlRootNode = XmlUtilities.GetXmlRootNode(xmlDocument, STRXML_experimentResults); XmlNode xmlNode = XmlUtilities.GetXmlNode(xmlRootNode, STRXML_experimentResult); xmlRootNode.RemoveChild(xmlNode); } // // Convert the XML document to a string // StringWriter sw = new StringWriter(); XmlTextWriter xtw = new XmlTextWriter(sw); xtw.Formatting = Formatting.Indented; xmlDocument.WriteTo(xtw); xtw.Flush(); xmlExperimentResults = sw.ToString(); } catch (Exception ex) { Logfile.WriteError(ex.Message); } Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName); return xmlExperimentResults; }
public ResultsInfo RetrieveResultsInfo() { ResultsInfo ri = new ResultsInfo(); ri.ResultCount = (tblResults == null ? 0 : tblResults.Rows.Count); List<Result> lResult = new List<Result>(); if (ri.ResultCount > 0) { if (!IsMultiLab) { ri.LearnMore = new String[1]; if (learnMoreTable.Rows.Count > 0 && learnMoreTable.Rows[0][0].ToString().Trim() != String.Empty) ri.LearnMore[0] = learnMoreTable.Rows[0][0].ToString().Trim(); else ri.LearnMore[0] = "Additional information about this service could not be retrieved at this time."; } else { ri.LearnMore = new String[(learnMoreTable.Rows.Count)]; if (learnMoreTable.Rows.Count > 0) for (int i = 0; i < learnMoreTable.Rows.Count; i++) if (learnMoreTable.Rows[i]["Description"].ToString().Trim() != String.Empty && learnMoreTable.Rows[i]["Description"].ToString() != "NULL") ri.LearnMore[i] = learnMoreTable.Rows[i]["Description"].ToString().Trim(); else ri.LearnMore[i] = "Additional information about this service could not be retrieved at this time."; } Result r = null; DataRow dr = null; for (Int32 i = 1; i <= ri.ResultCount; i++) { dr = tblResults.Rows[i - 1]; r = new Result(int.Parse(resCount) + i, this.sYC); r.Name = dr["PracticeName"].ToString(); r.City = (tblResults.Columns.Contains("LocationCity") ? dr["LocationCity"].ToString() : dr["City"].ToString()); r.Distance = dr["Distance"].ToString(); r.RangeMin = dr["RangeMin"].ToString(); r.RangeMax = dr["RangeMax"].ToString(); r.YourCostMin = dr["YourCostMin"].ToString(); r.YourCostMax = dr["YourCostMax"].ToString(); r.LocID = dr["OrganizationLocationID"].ToString(); Int32 iFP = 0; if (Int32.TryParse(dr["FairPrice"].ToString(), out iFP)) r.isFairPrice = Convert.ToBoolean(iFP); else r.isFairPrice = Boolean.Parse((dr["FairPrice"].ToString().Trim() == String.Empty ? "False" : dr["FairPrice"].ToString().Trim())); if (dr["HGRecognized"].ToString().Trim() == "") r.isHGRecognized = false; else r.isHGRecognized = Boolean.Parse((dr["HGRecognized"].ToString().Trim() == String.Empty ? "False" : dr["HGRecognized"].ToString().Trim())); r.Lat = dr["Latitude"].ToString(); r.Lng = dr["Longitude"].ToString(); //Encrypt the Navigation Elements to prevent potential security risk(s) FormsAuthenticationTicket tk = new FormsAuthenticationTicket(String.Format("{0}|{1}|{2}|{3}", r.Name, (ThisSession.ChosenLabs == null ? dr["NPI"].ToString() : dr["OrganizationID"].ToString()), r.Distance, r.LocID), false, 5); r.Nav = FormsAuthentication.Encrypt(tk); r.HGRecognizedDocCount = dr["HGRecognizedDocCount"].ToString(); r.HGDocCount = dr["HGDocCount"].ToString(); lResult.Add(r); } ri.EndOfResults = this.lastResult; } else { lResult.Add(new EmptyResult()); ri.EndOfResults = true; } ri.Results = lResult.ToArray<Result>(); return ri; }
public ActionResult GetCars(FormCollection collection) { //Based on lat and long get the airport code string url = string.Format("http://iatageo.com/getCode/{0}/{1}", collection["lati"], collection["long"]); var getRequest = WebRequest.Create(url); getRequest.ContentType = "application/json; charset=utf-8"; string text; var response = (HttpWebResponse)getRequest.GetResponse(); // ReSharper disable once AssignNullToNotNullAttribute using (var sr = new StreamReader(response.GetResponseStream())) { text = sr.ReadToEnd(); } dynamic jsonResp = JsonConvert.DeserializeObject(text); //Assumption for test - pick and drop location same. sessionPick = jsonResp["IATA"]; sessionDrop = jsonResp["IATA"]; string sessionName = "SearchResult" + sessionPick + sessionDrop + collection["pickUpDate"]; var searchCarInfo = new SearchCarInfo[] { }; if (Session[sessionName] == null) { SearchCarsRequest request = new SearchCarsRequest(); Route route = new Route(); route.PickUp = sessionPick; route.DropOff = sessionPick; //request.Route.PickUp = "MCO"; //request.Route.DropOff = "MCO"; request.Route = route; request.PickUpDate = Convert.ToDateTime(collection["pickUpDate"]); request.DropOffDate = Convert.ToDateTime(collection["dropDate"]); request.PickUpHour = Convert.ToInt32(collection["ddlPickUpHour"]); request.DropOffHour = Convert.ToInt32(collection["ddlDropHour"]); request.VehicleType = Convert.ToInt32(collection["ddlVehicleType"]); request.CarCompany = Convert.ToInt32(collection["ddlCarCompany"]); request.TotalPax = Convert.ToInt32(collection["ddlTotalPax"]); var resultsInfo = new ResultsInfo(); CarServiceClient carSvc = new CarServiceClient(); var result = carSvc.SearchCarsByAirportCode( new LoginHeader { UserName = "******", Password = "******", Culture = "en-US", Version = "1" }, request, out searchCarInfo, out resultsInfo); Session[sessionName] = searchCarInfo; } else { searchCarInfo = (SearchCarInfo[])Session[sessionName]; } ViewBag.SessionId = sessionName; return(View(searchCarInfo)); }