private void Application_BeforeExit(object sender, HtmlEventArgs args) { // Upload the user's documents back to the database // if (!model.DocumentHolder.Document.Modified) // return null; //j MessageBoxResult messageBoxResult = MessageBox.Show( //j "Save changes you have made?", "Save changes?", MessageBoxButton.OKCancel); //j if (messageBoxResult != MessageBoxResult.OK) //j { //j //return "If you close this window you will lose any unsaved work."; //j return null; //j } //j WaitingWindow waitingWindow = new WaitingWindow(); //j waitingWindow.NoticeText = "Saving work on server. Please wait..."; //j waitingWindow.Show(); PageMethodInvoker pageMethod = new PageMethodInvoker(); pageMethod.Completed += delegate(object methodName, bool success, object result, object userContext) { ScriptObject e = args.EventObject; if (e != null) e.SetProperty("returnValue", userContext as string); }; pageMethod.Invoke("ModelShutdown", new Guid().ToString(), "Context"); }
private void OnLogoClick(object sender, RoutedEventArgs e) { PageMethodInvoker pageMethod = new PageMethodInvoker(); pageMethod.Completed += delegate(object userContext, string methodName, bool success, object result) { Helper.Trace("{0} = '{1}'", methodName, (result != null ? result.ToString() : "(null)")); string ipAddress = result as string; Uri url = new Uri(string.Format("http://ipinfodb.com/ip_query.php?ip={0}", ipAddress)); WebClient client = new WebClient(); client.DownloadStringCompleted += delegate(object sender1, DownloadStringCompletedEventArgs e1) { XDocument xml = XDocument.Parse(e1.Result); XElement response = xml.Element("Response"); string ipa = response.Element("Ip").Value; string countryCode = response.Element("CountryCode").Value; string countryName = response.Element("CountryName").Value; string regionCode = response.Element("RegionCode").Value; string regionName = response.Element("RegionName").Value; string city = response.Element("City").Value; string postalCode = response.Element("ZipPostalCode").Value; string timeZone = response.Element("Timezone").Value; string gmtOffset = response.Element("Gmtoffset").Value; string dstOffset = response.Element("Dstoffset").Value; string latitude = response.Element("Latitude").Value; string longitude = response.Element("Longitude").Value; }; client.DownloadStringAsync(url); }; pageMethod.Invoke(null, "GetRequesterIP"); PageMethodInvoker pageMethod2 = new PageMethodInvoker(); pageMethod2.Completed += delegate(object userContext, string methodName, bool success, object result) { string text = result as string; }; pageMethod2.Invoke(null, "GetRequesterProperties"); #if NOTUSED //j DEBUG XigniteServiceHelper xignite = new XigniteServiceHelper(); xignite.GetHistoricalQuote("MSFT", "6/13/2008", GetHistoricalQuoteCompleted); #endif }