コード例 #1
0
 public void Export(string fileName, IEnumerable <object> data)
 {
     try
     {
         string ext = System.IO.Path.GetExtension(fileName).ToLowerInvariant();
         if (ext == ".xml")
         {
             XmlWriterSettings s = new XmlWriterSettings();
             s.Indent = true;
             using (XmlWriter writer = XmlWriter.Create(fileName))
             {
                 writer.WriteStartElement("root");
                 ExportToXml(writer, data);
                 writer.WriteEndElement();
             }
             InternetExplorer.EditTransform(IntPtr.Zero, fileName);
         }
         else if (ext == ".csv")
         {
             using (StreamWriter sw = new System.IO.StreamWriter(fileName, false, Encoding.UTF8))
             {
                 ExportToCsv(sw, data);
             }
             InternetExplorer.OpenUrl(IntPtr.Zero, fileName);
         }
         else
         {
             throw new Exception("Expecting either .xml or .csv file extension");
         }
     }
     catch (Exception e)
     {
         MessageBoxEx.Show("Error exporting rows\n" + e.Message, "Export Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
コード例 #2
0
ファイル: Reports.cs プロジェクト: youscam/MyMoney.Net
        protected void ExportReportAsCsv()
        {
            SaveFileDialog fd = new SaveFileDialog();

            fd.CheckPathExists = true;
            fd.AddExtension    = true;
            fd.Filter          = "CSV File (.csv)|*.csv";
            fd.FileName        = this.GetType().Name;

            if (fd.ShowDialog(App.Current.MainWindow) == true)
            {
                try
                {
                    string filename = fd.FileName;
                    this.Export(filename);
                    if (System.IO.File.Exists(filename))
                    {
                        InternetExplorer.OpenUrl(IntPtr.Zero, filename);
                    }
                }
                catch (Exception ex)
                {
                    MessageBoxEx.Show(ex.Message, "Error Exporting .txf", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
コード例 #3
0
        void OnShowLogFile(object sender, RoutedEventArgs e)
        {
            Hyperlink link = (Hyperlink)sender;
            Uri       uri  = link.NavigateUri;

            InternetExplorer.OpenUrl(IntPtr.Zero, uri.AbsoluteUri);
        }
コード例 #4
0
 private void OnBrowse(object sender, RoutedEventArgs e)
 {
     if (this.ComboServiceName.SelectedItem is string s && Uri.TryCreate(s, UriKind.Absolute, out Uri uri))
     {
         InternetExplorer.OpenUrl(IntPtr.Zero, uri);
     }
 }
コード例 #5
0
        private void OnDetailsClick(object sender, RoutedEventArgs e)
        {
            Hyperlink       link    = (Hyperlink)sender;
            OfxDownloadData ofxData = link.DataContext as OfxDownloadData;

            if (ofxData != null)
            {
                switch (ofxData.OfxError)
                {
                case OfxErrorCode.AUTHTOKENRequired:
                case OfxErrorCode.AUTHTOKENInvalid:
                    ofxData.LinkCaption = "";
                    ofxData.Message     = "Getting authorization token...";
                    GetAuthenticationToken(ofxData, ofxData.OfxError);
                    return;

                case OfxErrorCode.MFAChallengeAuthenticationRequired:
                    ofxData.LinkCaption = "";
                    ofxData.Message     = "Getting MFA challenge questions...";
                    GetMFAChallenge(ofxData);
                    return;

                case OfxErrorCode.MustChangeUSERPASS:
                    ofxData.LinkCaption = "";
                    ofxData.Message     = "Getting new password...";
                    GetNewPassword(ofxData);
                    return;

                case OfxErrorCode.SignonInvalid:
                    ofxData.LinkCaption = "";
                    ofxData.Message     = "Logging in ...";
                    GetLogin(ofxData);
                    return;
                }

                if (ofxData.LinkCaption == tryAgainCaption)
                {
                    SyncOneAccount(ofxData.OnlineAccount);
                    return;
                }


                string template = ProcessHelper.GetEmbeddedResource("Walkabout.Ofx.OfxErrorTemplate.htm");
                // css uses curly brackets, so it must be substituted.
                string css = @"body, th, td { font-family: Verdana; font-size:10pt; }
h2 { font-size: 12pt; }";

                string response = null;
                string headers  = null;
                string message  = ofxData.Message;

                Exception error = ofxData.Error;
                if (error != null)
                {
                    HtmlResponseException htmlError = error as HtmlResponseException;
                    if (htmlError != null)
                    {
                        message  = htmlError.Message;
                        response = htmlError.Html;
                        headers  = "";
                    }
                    else
                    {
                        OfxException ofxerror = error as OfxException;
                        if (ofxerror != null)
                        {
                            message  = ofxerror.Message;
                            response = ofxerror.Response;
                            headers  = ofxerror.HttpHeaders;
                        }
                        else
                        {
                            message  = error.GetType().FullName + ": " + error.Message;
                            response = error.StackTrace;
                        }
                    }
                }
                OnlineAccount account = ofxData.OnlineAccount;
                string        result  = string.Format(template,
                                                      css,
                                                      account != null ? account.Ofx : "",
                                                      account != null ? account.Institution : "",
                                                      message,
                                                      response,
                                                      headers);

                string tempPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "DownloadError.htm");
                using (System.IO.StreamWriter sw = new System.IO.StreamWriter(tempPath))
                {
                    sw.WriteLine(result);
                }

                InternetExplorer.OpenUrl(IntPtr.Zero, tempPath);
            }
        }
コード例 #6
0
ファイル: HelpService.cs プロジェクト: clovett/MyMoney.Net
 public static void OpenHelpPage(string name)
 {
     InternetExplorer.OpenUrl(IntPtr.Zero, WebPath + name);
 }