Beispiel #1
0
        internal void ConvertTimetable()
        {
            IExport exp  = (Timetable.Type == TimetableType.Linear) ? (IExport) new NetworkExport() : new LinearExport();
            string  orig = (Timetable.Type == TimetableType.Linear) ? "Linear-Fahrplan" : "Netzwerk-Fahrplan";
            string  dest = (Timetable.Type == TimetableType.Linear) ? "Netzwerk-Fahrplan" : "Linear-Fahrplan";

            if (MessageBox.Show($"Die aktuelle Datei ist ein {orig}. Es wird zu einem {dest} konvertiert.", "FPLedit", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            {
                return;
            }

            using (var sfd = new SaveFileDialog())
            {
                sfd.AddLegacyFilter(exp.Filter);
                if (sfd.ShowDialog(parent) == DialogResult.Ok)
                {
                    info.Logger.Info("Konvertiere Datei...");
                    bool ret = exp.Export(Timetable, sfd.FileName, info);
                    if (ret == false)
                    {
                        return;
                    }
                    info.Logger.Info("Konvertieren erfolgreich abgeschlossen!");
                    InternalOpen(sfd.FileName);
                }
            }
        }
Beispiel #2
0
        public static async Task Main(string[] args)
        {
            _log = _container.GetInstance <ILog>();
            _log.Info("Startup");

            FileSave    save       = _container.GetInstance <FileSave>();
            IDataSource dataSource = _container.GetInstance <IDataSource>();

            IExportFactory exportFactory = _container.GetInstance <IExportFactory>();
            IExport        export        = exportFactory.Create("csv");

            ICollection <ContactView> contacts = GetBuildedContacts(dataSource);

            _log.Info("Export contacts");
            var file = await export.Export(contacts);

            _log.Debug("Get [OutExportFileName] from config");
            var fileName = ConfigurationManager.AppSettings.Get("OutExportFileName");

            _log.Info("Save file to export/" + fileName);
            save.SetPath($"export")
            .SetFileName(fileName)
            .Save(file);

            Console.ReadKey();

            _log.Info("Close app");
        }
Beispiel #3
0
        public static void Main(string[] args)
        {
            IDataSource dataSource = _container.GetInstance <MemoryDataSource>();
            IExport     export     = _container.GetInstance <ExcelExport>();
            FileSave    save       = _container.GetInstance <FileSave>();

            ICollection <ContactView> contacts = new List <ContactView>();

            ContactViewBuilder builder = new StandartContactViewBuilder();

            foreach (var contact in dataSource.GetContacts())
            {
                builder.CreateContactView();

                builder.BuildContactView();
                builder.BuildContact(contact);

                builder.BuildFormatProp("AddressProp", "st. {0}");

                contacts.Add(builder.BuildContactView());
            }

            contacts = ContactViewSortCollection.Sort(contacts);

            var file = export.Export(contacts);

            save.SetPath($"export")
            .SetFileName("test.xlsx")
            .Save(file.Result);

            Console.ReadKey();
        }
        public ActionResult Export(string ExportType, string OneSite)
        {
            if (Request.HttpMethod == "POST")
            {
                Dictionary <string, IExport> exporters = new Dictionary <string, IExport> {
                    { "TXT", new ExportTxt(Response) },
                    { "XLS", new ExportXls(Response) },
                    { "PDF", new ExportPdf(Response) }
                };

                IExport exporter = exporters[ExportType];

                bool onlyOneSite;
                try {
                    onlyOneSite = OneSite.Equals("on");
                } catch (NullReferenceException) {
                    onlyOneSite = false;
                }

                exporter.PrepareData(onlyOneSite);

                exporter.Export();

                if (ExportType.Equals("PDF"))
                {
                    return(File((exporter as ExportPdf)._memory, exporter.ContentType, $"{exporter.GetName}.{exporter.Extension}"));
                }
            }

            PrepareViewData();

            return(RedirectToAction("Index"));
        }
        public void RunExport(List <ExamResult> results = null)
        {
            var sw = Stopwatch.StartNew();

            if (results != null)
            {
                Console.WriteLine(_exporter.Export(results));
            }
            else
            {
                Console.WriteLine("From Getter");
                Console.WriteLine(_exporter.Export(_exportDataGetter.Get()));
            }
            Console.WriteLine(_exporter.Export(results));
            Console.WriteLine("ElapsedMilliseconds: {0})",
                              sw.ElapsedMilliseconds);
        }
Beispiel #6
0
 public bool ExportTask()
 {
     return(StartTask("Running Export",
                      () =>
     {
         PropertyInfo pi = Export.GetProperty("Name");
         IExport export = PingCastleFactory.LoadExport(Export);
         string name = pi.GetValue(export, null) as string;
         DisplayAdvancement("Running export " + name);
         export.Initialize(Server, Port, Credential);
         string file = "ad_export_" + name + "_" + Server + ".txt";
         export.Export(file);
         DisplayAdvancement("Results saved to " + new FileInfo(file).FullName);
     }
                      ));
 }
Beispiel #7
0
        public static async Task Main(string[] args)
        {
            IDataSource dataSource = _container.GetInstance <IDataSource>();
            IExport     export     = _container.GetInstance <IExport>();
            FileSave    save       = _container.GetInstance <FileSave>();

            ICollection <ContactView> contacts = GetBuildedContacts(dataSource);

            var file = await export.Export(contacts);

            var fileName = GetFileName();

            save.SetPath($"export")
            .SetFileName($"{fileName}.xlsx")
            .Save(file);
        }
Beispiel #8
0
 /// <summary>
 /// This function provides a safe way to execute any exporter to write to a file directly.
 /// </summary>
 /// <param name="exp">The exporter to be used.</param>
 /// <param name="tt">A readonly copy of the current timetable.</param>
 /// <param name="filename"></param>
 /// <param name="pluginInterface">A reduced PluginInterface that provides limited core features from FPledit.</param>
 /// <param name="flags">Exporter flags.</param>
 /// <returns>If the operation was successful.</returns>
 public static bool SafeExport(this IExport exp, Timetable tt, string filename, IReducedPluginInterface pluginInterface, string[]?flags = null)
 {
     try
     {
         using (var stream = File.Open(filename, FileMode.OpenOrCreate, FileAccess.Write))
         {
             stream.SetLength(0);
             return(exp.Export(tt, stream, pluginInterface, flags));
         }
     }
     catch (Exception ex)
     {
         pluginInterface.Logger.Error(exp.GetType().Name + ": " + ex.Message);
         pluginInterface.Logger.LogException(ex);
         return(false);
     }
 }
Beispiel #9
0
        /// <summary>
        /// 根据列数组导出
        /// </summary>
        /// <param name="path"></param>
        /// <param name="exportColumns"></param>
        public void Export(string path, string[] exportColumns)
        {
            if (string.IsNullOrEmpty(path))
            {
                SaveFileDialog save = new SaveFileDialog();
                save.Filter       = "Excel文件|*.xls|Pdf文件|*.pdf|文本文件|*.txt";
                save.FileName     = this.FileName;
                save.AddExtension = true;
                if (save.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                path = save.FileName;
            }
            IExport export = ExportFactory.CreateInstance(path, this, exportColumns);

            export.Export(path);
        }
Beispiel #10
0
        private void InternalSave(string filename)
        {
            if (!filename.EndsWith(".fpl"))
            {
                filename += ".fpl";
            }

            info.Logger.Info("Speichere Datei " + filename);
            bool ret = save.Export(Timetable, filename, info);

            if (ret == false)
            {
                return;
            }
            info.Logger.Info("Speichern erfolgreich abgeschlossen!");
            FileState.Saved    = true;
            FileState.FileName = filename;
        }
Beispiel #11
0
        internal void Export()
        {
            if (exportFileDialog.ShowDialog(parent) == DialogResult.Ok)
            {
                var     exporters = info.GetRegistered <IExport>();
                IExport export    = exporters[exportFileDialog.CurrentFilterIndex];
                string  filename  = exportFileDialog.FileName;

                info.Logger.Info("Exportiere in Datei " + filename);
                bool ret = export.Export(Timetable, filename, info);
                if (ret == false)
                {
                    info.Logger.Error("Exportieren fehlgeschlagen!");
                    return;
                }
                info.Logger.Info("Exportieren erfolgreich abgeschlossen!");
                info.Settings.Set("exporter.last", exportFileDialog.CurrentFilterIndex);
            }
        }
Beispiel #12
0
        private static void Collect()
        {
            var tasks = new List <Task>();

            foreach (var searchCriteria in searchCriterias)
            {
                tasks.Add(Task.Run(() =>
                {
                    ConsolePrinter.PrintGettingEventLogData(searchCriteria.LogName.ToString());

                    List <EventLogData> eventLogs = eventCollector.GetEventLogEntries(searchCriteria).Select(entry => entry.ToEventLogData()).ToList();

                    ConsolePrinter.PrintEventLogEntries(searchCriteria.LogName.ToString(), eventLogs.Count());

                    string filePath = GetFilePath(searchCriteria.LogName.ToString());

                    exportService.Export(eventLogs, filePath);

                    ConsolePrinter.PrintExportedTo(filePath);
                }));
            }

            try
            {
                Task.WaitAll(tasks.ToArray());
            }
            catch (AggregateException ae)
            {
                ae.Handle((ex) =>
                {
                    if (ex is SystemException)
                    {
                        ConsolePrinter.PrintError(ex);
                        return(true);
                    }
                    return(false);
                });
            }
        }
        public HttpResponseMessage Download()
        {
            IList <ReferencesSchool> list = Service.GetAll();
            IList <RefsFileDto>      dtos = RefsFileDto.ToDtos(list);

            ErrMsg             msg = new ErrMsg();
            ExcelConfiguration cfg = new ExcelConfiguration();

            cfg.TemplatePath     = ConfigurationManager.AppSettings["refsDataPath"];
            cfg.TemplateRowIndex = 1;
            IExport export = ExcelFactory.Instance().GetExcelExporter(cfg, msg);

            byte[]              data = export.Export <RefsFileDto>(dtos);
            MemoryStream        ms   = new MemoryStream(data);
            HttpResponseMessage res  = new HttpResponseMessage(HttpStatusCode.OK);

            res.Content = new StreamContent(ms);
            res.Content.Headers.ContentType        = new MediaTypeHeaderValue("application/octet-stream");
            res.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
            {
                FileName = "refs_file.xlsx"
            };
            return(res);
        }
Beispiel #14
0
 /// <summary>
 /// エクスポート実行
 /// </summary>
 /// <param name="export"></param>
 public bool Export(IExport export) => export.Export(_Model);
Beispiel #15
0
 public void ReservationExportMethod(List <Reservation> reservations)
 {
     _export.Export(reservations);
 }
Beispiel #16
0
 public string RunExport(List <ExamResult> list = null)
 {
     return(_exporter.Export(list ?? _exportDataGetter.Get()));
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="converterType">specific convert type </param>
 /// <returns>return the specific converter factory </returns>
 public CurrencyManager Export(ConverterType converterType)
 {
     _exporter         = new ConverterFactory().GetConverterInstance(converterType);
     _exportableString = _exporter.Export(Data.ToList());
     return(this);
 }
Beispiel #18
0
 public void ExportData()
 {
     dataExport.Export(dataView);
 }
Beispiel #19
0
 public byte[] ExportTo(IExport export, DataTable data)
 {
     return(export.Export(data));
 }