public NotifyCancelledBooking() { InitializeComponent(); IsolatedStorageFile storageFile = IsolatedStorageFile.GetUserStoreForApplication(); if (storageFile.FileExists("BookingCancellation.txt")) { try { StreamReader Reader = new StreamReader(new IsolatedStorageFileStream("BookingCancellation.txt", FileMode.Open, storageFile)); BookingID = Convert.ToInt32(Reader.ReadLine()); CabID = Convert.ToInt32(Reader.ReadLine()); Reader.Close(); // Getting Booking Details From DB ServiceReference1.ServiceClient clientForTesting = new ServiceReference1.ServiceClient(); clientForTesting.DetailsForCancelledBookingCompleted += new EventHandler<ServiceReference1.DetailsForCancelledBookingCompletedEventArgs>(CallBackFunction); clientForTesting.DetailsForCancelledBookingAsync(BookingID); } catch { MessageBox.Show("Unable to read booking cancellation file"); } } else { MessageBox.Show("BookingCancellation.txt not found"); } }
public async Task <string> ProbarAsync() { ServiceReference1.ServiceClient clientechido = new ServiceReference1.ServiceClient(); string s = await clientechido.ObtenerCatalogosPagoTarjetaAsync(); return(s.ToString()); }
//protected override void OnStart(string[] args) public void OnStart() { StopSync = false; server = WCF.GetWCF(); syncReceiptTimeFile = Path.Combine(basePath, syncReceiptFileName); syncDeliveryTimeFile = Path.Combine(basePath, syncDeliveryFileName); syncBaseTimeFile = Path.Combine(basePath, syncBaseFileName); syncQualityStatuceTimeFile = Path.Combine(basePath, synQualityStatuceFileName); int FirstSyncTime = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["FirstSyncTime"]); //同步时间文件不存在,自动创建 createSyncTimeFile(syncReceiptTimeFile, FirstSyncTime); createSyncTimeFile(syncDeliveryTimeFile, FirstSyncTime); createSyncTimeFile(syncBaseTimeFile, FirstSyncTime); createSyncTimeFile(syncQualityStatuceTimeFile, FirstSyncTime); LogNet.LogInfo("Server Start:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //DocumentSyncReceipt = new Thread(new ThreadStart(SyncReceipt)); //DocumentSyncReceipt.Start(); //DocumentSyncDelivery = new Thread(new ThreadStart(SyncDelivery)); //DocumentSyncDelivery.Start(); DocumentSyncBase = new Thread(new ThreadStart(SyncBase)); DocumentSyncBase.Start(); //QualitySyncStatus = new Thread(new ThreadStart(QualityStatus)); //QualitySyncStatus.Start(); }
protected void Button1_Click1(object sender, EventArgs e) { ServiceReference1.ServiceClient obj = new ServiceReference1.ServiceClient(); // Proxy Class String[] weatherForecast = new String[5]; weatherForecast = obj.weatherservice(TextBox2.Text); // Forecast results being stored. Label6.Text = ""; try { TextBox3.Text = weatherForecast[0]; TextBox4.Text = weatherForecast[1]; TextBox5.Text = weatherForecast[2]; TextBox6.Text = weatherForecast[3]; TextBox7.Text = weatherForecast[4]; Label6.Visible = false; } catch { TextBox3.Text = ""; TextBox4.Text = ""; TextBox5.Text = ""; TextBox6.Text = ""; TextBox7.Text = ""; Label6.Visible = true; Label6.Text = "Invalid Zipcode"; } }
protected void LogInButton_Click(object sender, EventArgs e) { using (var serv = new ServiceReference1.ServiceClient()) { string email = EmailTextBox.Text; string password = PasswordTextBox.Text; try { Controller.LogIn(email, password); Response.Redirect("Form.aspx"); } catch (NotLoggedOutException) { Response.Redirect("LogInForm.aspx"); // Shouldn't happen, as the page logs the user out when it loads, but if it does, reload page. } catch (NoSuchUserException) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorAlert", "alert('No user exists with that email.');", true); } catch (IncorrectPasswordException) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorAlert", "alert('The password does not match the email.');", true); } } }
/* * Generate card * Add card number to list of cards and funds, starting with no funds * Return the new card */ public static Int32 registerCreditCard() { ServiceReference1.ServiceClient serviceClient = new ServiceReference1.ServiceClient(); Random rnd = new Random(); bool valid; Int32 newCard; string encryptedCard = ""; do { valid = true; newCard = rnd.Next(5000, 10000); for (int i = 0; i < cardList.Count && valid; i++) { if (newCard == Int32.Parse(serviceClient.Decrypt(cardList[i]))) { valid = false; } } } while (!valid); encryptedCard = serviceClient.Encrypt(newCard.ToString()); cardList.Add(encryptedCard); fundsList.Add(0); return(newCard); }
private void Button_Click(object sender, RoutedEventArgs e) { string CabNo=""; // Getting Cab Registration Number from Isolated Storage File // Reading logged in customer details IsolatedStorageFile loginFile = IsolatedStorageFile.GetUserStoreForApplication(); StreamReader Reader = null; String Buffer = ""; try { Reader = new StreamReader(new IsolatedStorageFileStream("LoginDetails.txt", FileMode.Open, loginFile)); Buffer = Reader.ReadLine(); if (Buffer.Equals("Customer Logged In")) { // Reading logged in customer's ID Buffer = Reader.ReadLine(); String[] Token = Buffer.Split(new char[] { ':' }); Buffer = Token[1]; } Reader.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (IsolatedStorageFile.GetUserStoreForApplication().FileExists("BookingDetails" + Buffer + ".txt")) // Reading Booking Details from isolated storage file { IsolatedStorageFile fileStorage = IsolatedStorageFile.GetUserStoreForApplication(); try { Reader = new StreamReader(new IsolatedStorageFileStream("BookingDetails" + Buffer + ".txt", FileMode.Open, fileStorage)); Reader.ReadLine(); Reader.ReadLine(); CabNo = Reader.ReadLine(); Reader.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { } ServiceReference1.ServiceClient clientForTesting = new ServiceReference1.ServiceClient(); clientForTesting.RateDriverCompleted += new EventHandler<ServiceReference1.RateDriverCompletedEventArgs>(TestCallback); clientForTesting.RateDriverAsync(CabNo,Convert.ToInt32(DriverRating.Value)); }
static void Main(string[] args) { ServiceReference1.ServiceClient client = new ServiceReference1.ServiceClient(); Console.WriteLine(client.DoWork()); Console.ReadKey(); }
static void Main(string[] args) { var proxy = new ServiceReference1.ServiceClient(); string data = proxy.GetData(42); Console.WriteLine(data); Console.ReadLine(); }
protected void Page_Load(object sender, EventArgs e) { strMenu += "<a href ='UserGrant.aspx' class='list-group-item list-group-item-action list-group-item-success'>Phân quyền</a>"; strMenu += "<a href ='QuanLyTaiKhoan.aspx' class='list-group-item list-group-item-action'>Quản lý tài khoản</a>"; ServiceReference1.ServiceClient ws = new ServiceReference1.ServiceClient(); ws.CreateTree(); DataList1.DataSource = ws.getTableTree(); DataList1.DataBind(); }
protected void Button1_Click1(object sender, EventArgs e) { decimal latitude = Convert.ToDecimal(TextBox1.Text); decimal longitude = Convert.ToDecimal(TextBox2.Text); ServiceReference1.ServiceClient serviceref = new ServiceReference1.ServiceClient(); TextArea1.InnerText = serviceref.getSolarIntensity(latitude, longitude); String str="latitude: "+latitude.ToString()+"\n"+"longitude:"+longitude.ToString()+"\n"+serviceref.getSolarIntensity(latitude, longitude); Cache.Insert("CacheItem",str,null,DateTime.Now.AddMinutes(10), TimeSpan.Zero); }
public string[] topTen(string website) { proxy = new ServiceReference1.ServiceClient(); string websiteString = proxy.GetWebContent(website); List<string> words = new List<string>(); List<int> wordCount = new List<int>(); string[] websiteStringParsed = websiteString.Split(new Char[] {' ', ',', '.', '\n', '\t', '>', '<', '&', '+', ';', '='}); bool wordExists; int loopCount = 0; foreach (string value in websiteStringParsed) { if (value.All(Char.IsLetter) && value.Length > 1) { wordExists = words.Exists(word => word.Equals(value)); if (wordExists) //if the word is in the list already, then only increase //the count of it in the 2nd list { int index = words.FindIndex(word => word.Equals(value)); wordCount[index] = wordCount[index] + 1; } else//else add the word to the word list and make count 1 { words.Add(value); wordCount.Add(1); } } //loopCount++; } //get top ten words in the word count list string[] topTen = new string[10]; int[] maxCounts = {0,0,0,0,0,0,0,0,0,0}; loopCount = 0; foreach (string word in words) { int maxCountLoop = 0; bool alreadyEntered = false; foreach(int max in maxCounts){ if (wordCount[loopCount] > max && alreadyEntered == false) { maxCounts[maxCountLoop] = loopCount; alreadyEntered = true; } maxCountLoop++; } loopCount++; } for (int i = 0; i < 10; ++i) { topTen[i] = words[maxCounts[i]]; } return topTen; }
public ApplyRepository(IConfiguration configuration) { Configuration = configuration; connectionString = Configuration["ConnectionStrings:DefaultConnection"]; //WCF SERVICE wcf = new ServiceReference1.ServiceClient(); //WEB API api = new DAL.ServiceConnector.ApiClient(); }
protected void Button1_Click(object sender, EventArgs e) { using (var derp = new ServiceReference1.ServiceClient()) { ServiceReference1.User myUser = derp.GetUserByEmail(TextBox1.Text); string type = myUser.Type.ToString(); string pw = myUser.Password; string email = myUser.Email; GetUserTextBox.Text = "Type: " + type + "\nPassword: "******"\nEmail: " + email; } }
public Cancel_Booking() { InitializeComponent(); // Getting the time customer made the booking ServiceReference1.ServiceClient clientfortesting = new ServiceReference1.ServiceClient(); clientfortesting.GetBookingTimeCompleted += new EventHandler<ServiceReference1.GetBookingTimeCompletedEventArgs>(ReturnFunction); clientfortesting.GetBookingTimeAsync(ForGlobalVariables.CutomerBookingDetails.BookingID); }
private void Button_Click(object sender, RoutedEventArgs e) { if ((UserNametxt.Text == "") || (UserNametxt.Text == "") || (PasswordTxt.Password == "") || (adresstxt.Text == "") || (phnetxt.Text == "") || (emailtxt.Text == "") || (Nictxt.Text == "")) { MessageBox.Show("Enter Complete Information"); } else { Customer cus = new Customer(UserNametxt.Text, PasswordTxt.Password, adresstxt.Text, phnetxt.Text, emailtxt.Text, Nictxt.Text, Gender.SelectedItem.ToString(), AgeTxt.Text); ServiceReference1.ServiceClient clientfortesting = new ServiceReference1.ServiceClient(); clientfortesting.CustomerRegistrationRequestCompleted += new EventHandler<ServiceReference1.CustomerRegistrationRequestCompletedEventArgs>(CustomerRegistrationRequestReturnFunction); clientfortesting.CustomerRegistrationRequestAsync(cus.username,cus.password,cus.email,cus.PhoneNumber,cus.NIC,cus.address,cus.Gender,cus.age); } }
protected void btnSave_Click(object sender, EventArgs e) { ServiceReference1.ServiceClient obj = new ServiceReference1.ServiceClient(); string status = obj.SerializeCarParts(txtPartNo.Text); if (status == "Success") { lblStatus.Text = "PartDetails_" + txtPartNo.Text + ".xml Created!"; } else { lblStatus.Text = status; } }
public Form1() { InitializeComponent(); try { ServiceReference1.ServiceClient client = new ServiceReference1.ServiceClient(); bool querySql = true; client.querySql(out querySql); client.Close(); } catch (Exception ex) { throw; } }
static void Main(string[] args) { try { // Binding Configurations WSHttpBinding communicationBinding = new WSHttpBinding(); communicationBinding.Security.Mode = SecurityMode.Transport; communicationBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate; CryptographyHelper cryptographyHelper = new CryptographyHelper(); X509Certificate2 serviceCertificate = cryptographyHelper.GetX509CertificateBySerialNumber(_ServiceCertSerial, StoreName.My, StoreLocation.LocalMachine); X509Certificate2 clientCertificate = cryptographyHelper.GetX509CertificateBySerialNumber(_ClientCertSerial);//from configiration // Create the endpoint address. EndpointAddress endpointAddress = new EndpointAddress(new Uri(_EndpointURL), EndpointIdentity.CreateX509CertificateIdentity(serviceCertificate)); // Call the client service // Client service class can generated from the WSDL file ServiceReference1.ServiceClient ws = new ServiceReference1.ServiceClient(communicationBinding, endpointAddress); // Specify a certificate to use for authenticating the client. ws.ClientCredentials.ClientCertificate.SetCertificate( StoreLocation.LocalMachine, StoreName.My, X509FindType.FindBySerialNumber, clientCertificate.SerialNumber); // Specify a default certificate for the service. ws.ClientCredentials.ServiceCertificate.SetDefaultCertificate( StoreLocation.LocalMachine, StoreName.My, X509FindType.FindBySerialNumber, serviceCertificate.SerialNumber); // Call the service ws.DoWork(); } catch(Exception ex) { Console.Write(ex.Message); } }
private async void appBar_OnChk(object sender, EventArgs e) { try { getCoordinatesFromLocation geocoding = new getCoordinatesFromLocation(); string location = ""; location = addressLocationtxt.Text + "+" + cityLocationtxt.Text + "+" + "Pakistan"; /////////////////////////////////////// ServiceReference1.ServiceClient clientfortesting = new ServiceReference1.ServiceClient(); clientfortesting.AddresstoCoordinatesCompleted += new EventHandler<ServiceReference1.AddresstoCoordinatesCompletedEventArgs>(AddresstoCoordinatesReturnFunction); clientfortesting.AddresstoCoordinatesAsync(location); /////////////////////////////// } catch (Exception ed) { MessageBox.Show(ed.ToString()); } }
protected void btnShow_Click(object sender, EventArgs e) { ServiceReference1.ServiceClient obj = new ServiceReference1.ServiceClient(); DataSet dsObj = obj.QueryCarPart(txtPartNo.Text); if (dsObj.Tables[0].Rows.Count == 0) { btnSave.Visible = false; lblStatus.Text = ""; } else { GridView1.DataSource = dsObj.Tables[0]; btnSave.Visible = true; lblStatus.Text = ""; } GridView1.DataBind(); }
private void CallBackFunction(object sender, ServiceReference1.DetailsForCancelledBookingCompletedEventArgs e) { if(!e.Result.Contains("No Booking")) { string[] token = e.Result.Split(new char[] { '+' }); CustomerLocationText.Text = token[0]; DestinationTextBox.Text = token[1]; DateTextBox.Text = token[2]; } else { MessageBox.Show(e.Result); } ServiceReference1.ServiceClient clientForTesting = new ServiceReference1.ServiceClient(); clientForTesting.UpdateBookingAndCabStatusCompleted += new EventHandler<ServiceReference1.UpdateBookingAndCabStatusCompletedEventArgs>(CallBackFunction2); clientForTesting.UpdateBookingAndCabStatusAsync(BookingID, CabID); }
public ActionResult ResultadoBusca(string obj) { var cliente = new ServiceReference1.ServiceClient(); ServiceReference1.sroxml xml = new ServiceReference1.sroxml(); xml = cliente.buscaEventos("ECT", "SRO", "L", "T", "101", "OJ012070825BR"); Objeto objeto = new Objeto(); Evento e = new Evento(); foreach (var item in xml.objeto) { objeto.nome = item.nome; objeto.categoria = item.categoria; objeto.numero = item.numero; objeto.sigla = item.sigla; foreach (var item1 in item.evento) { e.cidade = item1.cidade; e.codigo = item1.codigo; e.Data = item1.data; e.Descricao = item1.descricao; e.Hora = item1.hora; e.local = item1.local; e.Status = item1.status; e.Tipo = item1.tipo; e.uf = item1.uf; objeto.eventos.Add(e); } } ViewBag.Rastreio = e; ViewBag.teste = 1; return(View(objeto)); }
/*Validate orders by checking that the credit card has been registered and that it has sufficient funds*/ public static string validate(Int32 creditCardNumber, double amount) { ServiceReference1.ServiceClient serviceClient = new ServiceReference1.ServiceClient(); int index = -1; for (int i = 0; i < cardList.Count && index == -1; i++) { if (creditCardNumber == Int32.Parse(serviceClient.Decrypt(cardList[i]))) { index = i; } } if (index != -1 && fundsList[index] > amount) { fundsList[index] -= amount; return("valid"); } else { return("not valid"); } }
/* * Adds funds and returns true if the creditCard is found, otherwise returns false */ public static bool deposit(Int32 creditCardNumber, double amount) { ServiceReference1.ServiceClient serviceClient = new ServiceReference1.ServiceClient(); int index = -1; for (int i = 0; i < cardList.Count && index == -1; i++) { if (creditCardNumber == Int32.Parse(serviceClient.Decrypt(cardList[i]))) { index = i; } } if (index != -1) { fundsList[index] += amount; return(true); } else { return(false); } }
static async Task Main(string[] args) { var file = @"..\..\..\..\SampleFile.bin"; if (!File.Exists(file)) { Random rnd = new Random(); var buffer = new byte[62 * 1024 * 1024]; rnd.NextBytes(buffer); File.WriteAllBytes(file, buffer); } var f = File.ReadAllBytes(file); var watch = Stopwatch.StartNew(); for (int i = 0; i < 10; i++) { watch.Restart(); var service = new ServiceReference1.ServiceClient(); var result = await service.GetDataAsync(f); Console.WriteLine($"{result}: {watch.ElapsedMilliseconds}ms"); } }
private void cancel_Booking_Button(object sender, RoutedEventArgs e) { IsolatedStorageFile fileStorage = IsolatedStorageFile.GetUserStoreForApplication(); String LoggedInCustomerID = ""; if(fileStorage.FileExists("LoginDetails.txt")) { String Buffer; try { StreamReader Reader = new StreamReader(new IsolatedStorageFileStream("LoginDetails.txt", FileMode.Open, fileStorage)); Buffer = Reader.ReadLine(); if(Buffer.Equals("Customer Logged In")) { Buffer = Reader.ReadLine(); String[] Token = Buffer.Split(new char[] { ':' }); LoggedInCustomerID = Token[1]; } Reader.Close(); // Checking if the logged in customer has made any bookings ServiceReference1.ServiceClient clientfortesting = new ServiceReference1.ServiceClient(); clientfortesting.CheckCustomerBookingsCompleted += new EventHandler<ServiceReference1.CheckCustomerBookingsCompletedEventArgs>(ReturnFunction); clientfortesting.CheckCustomerBookingsAsync(Convert.ToInt32(LoggedInCustomerID)); } catch(Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("Login file does not exist"); } }
private void CancelBookingButton_Click(object sender, RoutedEventArgs e) { String Fare; String[] token = ApproximateFare.Split(new char[] { ' ' }); String[] token2 = token[2].Split(new char[] { '/' }); Fare = token2[0]; // Getting the time customer made the booking ServiceReference1.ServiceClient clientfortesting = new ServiceReference1.ServiceClient(); clientfortesting.CancelBookingCompleted += new EventHandler<ServiceReference1.CancelBookingCompletedEventArgs>(CancellationReturnFunction); clientfortesting.CancelBookingAsync(ForGlobalVariables.CutomerBookingDetails.BookingID,TimeElapsed.ToString(),BookingStatusTextBox.Text,Convert.ToInt32(Fare)); }
public Add_Book(string mode, ServiceReference1.ServiceClient client) { InitializeComponent(); this.client = client; this.mode = mode; }
private void AuthenticateDriverReturnFunction(object sender, ServiceReference1.AuthenticateDriverCompletedEventArgs e) { if (e.Result != -1) { try { // Setting the global attributes sharable between mobile app and background agent //Global_Library.Class1.DriverID = e.Result; ForGlobalVariables.LoginDetails.DriverLoggedIn = true; int DriverID = Convert.ToInt32(e.Result); ForGlobalVariables.LoginDetails.DriverID = e.Result; //Calling service function to return the cab ID for this logged in Driver ServiceReference1.ServiceClient clientfortesting = new ServiceReference1.ServiceClient(); clientfortesting.CabIDforDriverCompleted += new EventHandler<ServiceReference1.CabIDforDriverCompletedEventArgs>(CabIDForDriverReturnFunction); clientfortesting.CabIDforDriverAsync(ForGlobalVariables.LoginDetails.DriverID); //NavigationService.Navigate(new Uri("/DriverMainPage.xaml", UriKind.Relative)); //Launching the background task //ScheduledActionService.Add(periodicTask); //ScheduledActionService.LaunchForTest("DriverTask", TimeSpan.FromSeconds(60)); authenticated = true; } catch(Exception ex) { MessageBox.Show("Exception in authenticate driver completed.\nException message: " + ex.Message); } } else { MessageBox.Show("ERROR! Invalid username or password."); } }
private void appBar_OnSave(object sender, EventArgs e) { authenticated = false; var periodicTask = new PeriodicTask("PeriodicTaskDemo") { Description = "Are presenting a periodic task" }; //MessageBox.Show(listPicker.SelectedItem.ToString()); if (usertxt.Text == "" || Password1.Password == "") { MessageBox.Show("Username or Password Missing"); return; } if (user.SelectedItem.ToString() == "Customer") { try { ServiceReference1.ServiceClient clientfortesting = new ServiceReference1.ServiceClient(); clientfortesting.AuthenticateCustomerCompleted += new EventHandler<ServiceReference1.AuthenticateCustomerCompletedEventArgs>(AuthenticateReturnFunction); clientfortesting.AuthenticateCustomerAsync(usertxt.Text.ToString(), Password1.Password.ToString()); // Scheduled Agent ScheduledActionService.Add(periodicTask); ScheduledActionService.LaunchForTest("PeriodicTaskDemo", TimeSpan.FromSeconds(3)); //MessageBox.Show("Background agent started"); ScheduledActionService.LaunchForTest("PeriodicTaskDemo", TimeSpan.FromSeconds(60)); } catch (Exception ex) { //MessageBox.Show(ex.Message.ToString()); } //NavigationService.Navigate(new Uri("/MainMenu.xaml", UriKind.Relative)); } else if (user.SelectedItem.ToString() == "Driver") { try { ServiceReference1.ServiceClient clientfortesting = new ServiceReference1.ServiceClient(); clientfortesting.AuthenticateDriverCompleted += new EventHandler<ServiceReference1.AuthenticateDriverCompletedEventArgs>(AuthenticateDriverReturnFunction); clientfortesting.AuthenticateDriverAsync(usertxt.Text.ToString(), Password1.Password.ToString()); // Scheduled Agent ScheduledActionService.Add(periodicTask); ScheduledActionService.LaunchForTest("PeriodicTaskDemo", TimeSpan.FromSeconds(3)); //MessageBox.Show("Background agent started"); ScheduledActionService.LaunchForTest("PeriodicTaskDemo", TimeSpan.FromSeconds(60)); } catch (Exception ex) { //MessageBox.Show(ex.Message.ToString()); } } }
public HomeController() { serviceRef = new ServiceReference1.ServiceClient(); ServicePointManager.ServerCertificateValidationCallback += (o, c, ch, er) => true; }
//bool updateTime = true; protected void Page_Load(object sender, EventArgs e) { // Here is a good place to add which packages should be able to be seen to the dropdown. if (!IsPostBack) { using (var serv = new ServiceReference1.ServiceClient()) { ServiceReference1.Package[] l = Controller.kewinhalp(); foreach (ServiceReference1.Package p in l) { DropDownList1.Items.Add(p.Id.ToString()); } fixSource(); //DropDownList1.Items.Add(""); //DropDownList1.Items.Add(""); } /* { Somebody get a list of all packages the user is supposed to see, and make it into a list, so my foreach works :) List<ServiceReference1.Package> l = new List<ServiceReference1.Package>(YOUR LIST); */ InteractivePanelFiles.CssClass = "rightCol"; InteractivePanelOther.CssClass ="rightCol"; } //} }
protected override void OnInvoke(ScheduledTask task) { bool driverLoggedIn = false; ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(60)); // Read manually updated driver location from file. string DriverLocation = ReadLocationFromFile(); //getGpsLocation(); //Getting GPS location from GPS sensor //GPSWait.WaitOne(); /* Reading isolated storage files for login details in main mobile application * if the logged in user is driver then update location using GPS */ IsolatedStorageFile fileStorage = IsolatedStorageFile.GetUserStoreForApplication(); StreamReader Reader = null; string ReadText = ""; try { Reader = new StreamReader(new IsolatedStorageFileStream("LoginDetails.txt", FileMode.Open, fileStorage)); ReadText = Reader.ReadLine(); if (ReadText.Equals("Customer Logged In")) { driverLoggedIn = false; } else if (ReadText.Equals("Driver Logged In")) { driverLoggedIn = true; // Storing Driver ID ReadText = Reader.ReadLine(); string[] token = ReadText.Split(new char[] { ':' }); DriverID = Convert.ToInt32(token[1]); // Storing Cab ID ReadText = Reader.ReadLine(); token = ReadText.Split(new char[] { ':' }); CabID = Convert.ToInt32(token[1]); } Reader.Close(); } catch { MessageBox.Show("File it not created"); } if (driverLoggedIn && DriverID != -1) { ServiceReference1.ServiceClient clientForTesting = new ServiceReference1.ServiceClient(); if (DriverLocation != "LocationNotUpdatedManually" && DriverLocation != "Exception") { // Calling web service function to update Cab Location clientForTesting.UpdateLocationCompleted += new EventHandler<ServiceReference1.UpdateLocationCompletedEventArgs>(TestCallback); clientForTesting.UpdateLocationAsync(CabLatitude, CabLongitude, CabID); // lock the thread until web call is completed ServiceWait.WaitOne(); } ServiceWait = new AutoResetEvent(false); // Calling web service to check if there are any notifications regarding order clientForTesting.CheckForDriverBookingCompleted += new EventHandler<ServiceReference1.CheckForDriverBookingCompletedEventArgs>(CheckForDriverBookingCompletedReturnFunction); clientForTesting.CheckForDriverBookingAsync(CabID); ServiceWait.WaitOne(); // Calling web service to check if there are any notifications regard booking cancellation clientForTesting.CheckForDriverCancelledBookingsCompleted += new EventHandler<ServiceReference1.CheckForDriverCancelledBookingsCompletedEventArgs>(CheckForCancelledBookingsReturnFunction); clientForTesting.CheckForDriverCancelledBookingsAsync(CabID); ServiceWati2.WaitOne(); } //var toast = new ShellToast { Title = DateTime.Now.ToShortTimeString(), Content = "Background Agent Launched" }; //toast.Show(); NotifyComplete(); }
protected void finalUpload_Click(object sender, EventArgs e) { using (var serv = new ServiceReference1.ServiceClient()) { //make new file from the file coming from this bytearray! if (FileUpload1.FileName != "") { byte[] filebytes = FileUpload1.FileBytes; string desc = Description.Value; string filename = FileUpload1.FileName; string origin = Origin.Value; ServiceReference1.FileTransfer filetrans = new ServiceReference1.FileTransfer(); filetrans.Data = filebytes; ServiceReference1.FileInfo fileinf = new ServiceReference1.FileInfo(); fileinf.Date = DateTime.Now; fileinf.Description = desc; fileinf.Name = FileUpload1.FileName; fileinf.Origin = origin; filetrans.Info = fileinf; try { Controller.UploadFile(filetrans); } catch (NotLoggedInException) { // #Kewin } catch (InadequateObjectException) { // Tell the user he has to selece a file from file system # Kewin } //Check if everything is fine, and upload the file. } } }
public HomeController() { client = new ServiceReference1.ServiceClient(); }
private void appBar_OnSave(object sender, EventArgs e) { try { if (DestinationLocationtxt.Text == "" && currentLocationtxt.Text == "") { MessageBox.Show("Select Destination and Current Location."); return; } else if (DestinationLocationtxt.Text == "") { MessageBox.Show("Enter Destination Location"); return; } else if (currentLocationtxt.Text == "") { MessageBox.Show("Acquire Current Location"); return; } string Type = cab_type.SelectedItem.ToString(); DateTime objDate = Convert.ToDateTime(datePicker.Value); string Date = objDate.ToString("dd-MM-yyyy"); DateTime objTime = Convert.ToDateTime(timePicker.Value); string Time = objTime.ToString("hh:mm tt"); DateTime BookingDateTime = new DateTime(objDate.Year, objDate.Month, objDate.Day, objTime.Hour, objTime.Minute, objTime.Second); //DateTime current = DateTime.Now; //MessageBox.Show(BookingDateTime.ToString("dd-MMM-yyy hh:mm:ss tt")); //MessageBox.Show(current.ToString()); MainPage.bookingData.SetPreferences(Date, Time, Type); Booking bookingInstance = new Booking(currentLocationtxt.Text, DestinationLocationtxt.Text, BookingDateTime, Type); MessageBoxButton button = MessageBoxButton.OKCancel; // ("Are you sure?"); MessageBoxResult result = MessageBox.Show("Are you sure?", "", button); if (result == MessageBoxResult.OK) { // ------------------------------- Remote call to web service (for booking) ---------------------------------- ServiceReference1.ServiceClient clientForTesting = new ServiceReference1.ServiceClient(); clientForTesting.CabBookingCompleted += new EventHandler<ServiceReference1.CabBookingCompletedEventArgs>(TestCallback); clientForTesting.CabBookingAsync(bookingInstance.BookingStatus, bookingInstance.BookingDateTime, bookingInstance.BookingOrigin, bookingInstance.BookingDestination, bookingInstance.BookingCabType, Booking.SourceLat, Booking.SourceLong, Booking.DestinationLat, Booking.DestinationLong,ForGlobalVariables.LoginDetails.CustomerID.ToString()); //MessageBox.Show("Cab Booking Request Sent!" + "\n" + "Current Location: " + currentLocationtxt.Text + "\n" + "Destination: " + DestinationLocationtxt.Text + "\n" + "Cab Type: " + cab_type.SelectedItem.ToString()); } } catch(Exception ex) { MessageBox.Show(ex.Message); } }