/// <summary> /// Creates a batch for exporting the items. /// <para>Podio API Reference: https://developers.podio.com/doc/items/export-items-4235696 </para> /// </summary> /// <param name="appId"></param> /// <param name="exporter">Valid exporters are currently "xls" and "xlsx"</param> /// <param name="filter">The list of filters to apply</param> /// <returns>The id of the batch created for this export</returns> public async Task <int> ExportItems(int appId, string exporter, ExportFilter filter) { string url = string.Format("/item/app/{0}/export/{1}", appId, exporter); dynamic response = await _podio.Post <dynamic>(url, filter); return((int)response["batch_id"]); }
async public Task <ExportResult> ExportObjectsFromFinExe(ServerSetupModel serverSetup, ExportFilterModel exportFilter) { var result = await Task.Factory.StartNew(() => { ExportFinexeHandling fileHandeling = new ExportFinexeHandling() { FinsqlPath = serverSetup.FinExePath, ServerName = serverSetup.Server, Database = serverSetup.Database, NTAuthentication = serverSetup.UseNTAuthentication }; fileHandeling.OnExportError += FileHandeling_OnExportError; if (!serverSetup.UseNTAuthentication) { fileHandeling.Username = serverSetup.UserName; fileHandeling.Password = serverSetup.Password; } fileHandeling.Filter = ExportFilter.CreateFilterString(exportFilter); if (!fileHandeling.ExportObjects(out string exportedObjectsPath, out string message)) { return(new ExportResult { Success = false, ExportedObjectsPath = exportedObjectsPath, Message = message }); } return(new ExportResult { Success = true, ExportedObjectsPath = exportedObjectsPath, Message = message }); }); return(result); }
/// <summary> /// Copy a table into a new delimited text file <br /> /// Nearly equivalent to: /// <code> /// exportWriter(db, name, new BufferedWriter(f), /// header, delim, quote, filter); /// </code> /// </summary> /// <param name="db">Database the table to export belongs to</param> /// <param name="tableName">Name of the table to export</param> /// <param name="f">New file to create</param> /// <param name="header">If <code>true</code> the first line contains the column names /// </param> /// <param name="delim">The column delimiter, <code>null</code> for default (comma)</param> /// <param name="quote">The quote character</param> /// <param name="filter">valid export filter</param> /// <seealso cref="ExportWriter(Database, string, System.IO.BufferedWriter, bool, string, char, ExportFilter) /// ">ExportWriter(Database, string, System.IO.BufferedWriter, bool, string, char, ExportFilter) /// </seealso> /// <exception cref="System.IO.IOException"></exception> public static void ExportFile(Database db, string tableName, FilePath f, bool header , string delim, char quote, ExportFilter filter) { BufferedWriter @out = null; try { @out = new BufferedWriter(new FileWriter(f)); ExportWriter(db, tableName, @out, header, delim, quote, filter); @out.Close(); } finally { if (@out != null) { try { @out.Close(); } catch (Exception ex) { System.Console.Error.WriteLine("Could not close file " + f.GetAbsolutePath()); Sharpen.Runtime.PrintStackTrace(ex, System.Console.Error); } } } }
private async Task ShowPreview(ExportFilter ef) { if (!cbOpenDocument.IsChecked.Value) { MessageDialog md = new MessageDialog(GetExportResultDesc(ef), Strings.ExportComplete); await md.ShowAsync(); return; } try { if (ef.StorageFolder == null) { if (!await Launcher.LaunchFileAsync(ef.PreviewFile)) { throw new Exception("Launcher.LaunchFileAsync() returns false."); } } else { if (!await Launcher.LaunchFolderAsync(ef.StorageFolder)) { throw new Exception("Launcher.LaunchFolderAsync() returns false."); } } } catch (Exception ex) { MessageDialog md = new MessageDialog(GetExportResultDesc(ef) + string.Format(Strings.PreviewErrorFmt, ex.Message), Strings.ExportComplete); await md.ShowAsync(); } }
public async Task <Tuple <List <ExportDto>, int> > FilteredListAsync(ExportFilter filter) { FilterValidation(filter); var query = _repository.GetAll(); var numberOfModels = query.Count(); if (filter.From.HasValue) { query = query.Where(e => e.Date.CompareTo(filter.From.Value) >= 0); } if (filter.To.HasValue) { query = query.Where(e => e.Date.CompareTo(filter.To.Value) <= 0); } if (filter.LocalId.HasValue) { query = query.Where(e => e.LocalId == filter.LocalId.Value); } query = query.OrderBy(e => e.Date); query = PaginateQuery(query, filter); var exportModelList = await query.ToListAsync(); var dtoList = await ConvertModelListToDtoList(exportModelList); return(new Tuple <List <ExportDto>, int>(dtoList, numberOfModels)); }
private void btnExport_Click(object sender, RoutedEventArgs e) { if (_report.IsBusy) { return; } string selectedReport = cbReport.SelectedItem as string; if (string.IsNullOrEmpty(selectedReport)) { return; } if (cbExportFilter.SelectedIndex < 0 || cbExportFilter.SelectedIndex >= _report.SupportedExportProviders.Length) { return; } // load report try { // load from resource stream Assembly asm = Assembly.GetExecutingAssembly(); using (Stream stream = asm.GetManifestResourceStream("FlexReportSamples.Resources.FlexCommonTasks_XML.flxr")) _report.Load(stream, selectedReport); } catch (Exception ex) { MessageBox.Show(string.Format("Failed to load report [{0}], exception:\r\n{1}", selectedReport, ex.Message), "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } // prepare ExportFilter object ExportProvider ep = _report.SupportedExportProviders[cbExportFilter.SelectedIndex]; SaveFileDialog sfd = new SaveFileDialog(); sfd.FileName = string.Format("{0}.{1}", selectedReport, ep.DefaultExtension); sfd.Filter = string.Format("{0} Files (*.{1})|*.{1}", ep.FormatName, ep.DefaultExtension); sfd.CheckPathExists = true; if (!sfd.ShowDialog().Value) { return; } ExportFilter ef = ep.NewExporter() as ExportFilter; ef.FileName = sfd.FileName; ef.Preview = cbOpenDocument.IsChecked.Value; // try { _report.RenderToFilter(ef); } catch (Exception ex) { MessageBox.Show(string.Format("Failed to export report [{0}], exception:\r\n{1}", selectedReport, ex.Message), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// Copy all tables into new delimited text files <br /> /// Equivalent to: /// <code> /// exportFile(db, name, f, false, null, '"', /// SimpleExportFilter.INSTANCE); /// </code> /// </summary> /// <param name="db">Database the table to export belongs to</param> /// <param name="dir">The directory where the new files will be created</param> /// <param name="ext">The file extension of the new files</param> /// <param name="header">If <code>true</code> the first line contains the column names /// </param> /// <param name="delim">The column delimiter, <code>null</code> for default (comma)</param> /// <param name="quote">The quote character</param> /// <param name="filter">valid export filter</param> /// <seealso cref="ExportFile(Database, string, Sharpen.FilePath, bool, string, char, ExportFilter) /// ">ExportFile(Database, string, Sharpen.FilePath, bool, string, char, ExportFilter) /// </seealso> /// <exception cref="System.IO.IOException"></exception> public static void ExportAll(Database db, FilePath dir, string ext, bool header, string delim, char quote, ExportFilter filter) { foreach (string tableName in db.GetTableNames()) { ExportFile(db, tableName, new FilePath(dir, tableName + "." + ext), header, delim , quote, filter); } }
private void FilterValidation(ExportFilter filter) { if (filter.From.HasValue && filter.To.HasValue) { if (DateTime.Compare(filter.From.Value, filter.To.Value) > 0) { throw new WrongParemetrsException("Date 'from' cannot be later than Date 'to'"); } } }
private void CreateFilter() { CustomFilter = ExportFilter.CreateFilterString( Modified, DateFrom, DateTo, VersionList, UseCustomFilter, CustomFilter); }
/// <summary> /// Creates a batch for exporting the items. /// </summary> /// <param name="appId"></param> /// <param name="exporter">Valid exporters are currently "xls" and "xlsx"</param> /// <param name="limit">The maximum number of items to export, if any</param> /// <param name="offset">The offset into the list of items to export</param> /// <param name="viewId">The id of the view to use, 0 means last used view, blank means no view</param> /// <param name="filters">The list of filters to apply</param> /// <param name="sortBy">The sorting order if not using predefined filter</param> /// <param name="sortDesc">True if sorting should be descending, false otherwise</param> /// <returns>The id of the batch created for this export</returns> public Task <int> ExportItems(int appId, string exporter, int?limit = null, int?offset = null, int?viewId = null, Object filters = null, string sortBy = null, bool?sortDesc = null) { var requestData = new ExportFilter() { Limit = limit, Offset = offset, ViewId = viewId, SortBy = sortBy, SortDesc = sortDesc, Filters = filters }; return(ExportItems(appId, exporter, requestData)); }
private string GetExportResultDesc(ExportFilter ef) { if (ef.StorageFolder != null) { StringBuilder files = new StringBuilder(); foreach (var file in ef.OutputFiles) { files.AppendLine(Path.GetFileName(file)); } return(string.Format(Strings.ExportToFolderFmt, ef.StorageFolder.Path, ef.OutputFiles.Count, files.ToString())); } else { return(string.Format(Strings.ExportToFileFmt, ef.PreviewFile.Path) + "\r\n"); } }
private async Task ShowPreview(ExportFilter ef) { try { if (ef.StorageFolder == null) { await Launcher.LaunchFileAsync(ef.PreviewFile); } else { await Launcher.LaunchFolderAsync(ef.StorageFolder); } } catch { } }
private string FilterToString(ExportFilter filter) { switch (filter) { case ExportFilter.Word97: return("MS Word 97"); case ExportFilter.WriterPDF: return("writer_pdf_Export"); case ExportFilter.CalcPDF: return("calc_pdf_Export"); case ExportFilter.DrawPDF: return("draw_pdf_Export"); case ExportFilter.ImpressPDF: return("impress_pdf_Export"); case ExportFilter.MathPDF: return("math_pdf_Export"); } return(""); }
public async Task <ActionResult> Index(ExportFilter filter) { var tuple = await RunTupleResultAsync(() => _exportService.FilteredListAsync(filter)); var localList = await RunListActionResultAsync <LocalDto>(() => _localService.GetAllListAsync()); var vm = new ExportViewModel { Exports = tuple.Item1, NumberOfModels = tuple.Item2, Models = localList.Select(l => new SelectListItem { Value = l.ID.ToString(), Text = l.Name }).ToList() }; //var vm return(View(vm)); }
public void CreateExportTest() { ExportFilter filter = new ExportFilter { filterRule = FilterRuleType.member, membershipUri = "/contact/list/1", }; Dictionary <string, string> fields = new Dictionary <string, string> { { "C_EmailAddress", "{{Contact.Field(C_EmailAddress)}}" }, { "C_FirstName", "{{Contact.Field(C_FirstName)}}" }, }; const string destinationUri = "/contact/list/2"; // not used string exportUri = _contactExportHelper.CreateExport(fields, destinationUri, filter); Assert.IsNotNullOrEmpty(exportUri); }
public virtual ExportProfile InsertExportProfile( string providerSystemName, string name, string fileExtension, ExportFeatures features, bool isSystemProfile = false, string profileSystemName = null, int cloneFromProfileId = 0) { Guard.ArgumentNotEmpty(() => providerSystemName); var profileCount = _exportProfileRepository.Table.Count(x => x.ProviderSystemName == providerSystemName); if (name.IsEmpty()) { name = providerSystemName; } if (!isSystemProfile) { name = string.Concat(_localizationService.GetResource("Common.My"), " ", name); } name = string.Concat(name, " ", profileCount + 1); var cloneProfile = GetExportProfileById(cloneFromProfileId); ScheduleTask task = null; ExportProfile profile = null; if (cloneProfile == null) { task = new ScheduleTask { CronExpression = "0 */6 * * *", // every six hours Type = typeof(DataExportTask).AssemblyQualifiedNameWithoutVersion(), Enabled = false, StopOnError = false, IsHidden = true }; } else { task = cloneProfile.ScheduleTask.Clone(); task.LastEndUtc = task.LastStartUtc = task.LastSuccessUtc = null; } task.Name = string.Concat(name, " Task"); _scheduleTaskService.InsertTask(task); if (cloneProfile == null) { profile = new ExportProfile { FileNamePattern = _defaultFileNamePattern }; if (isSystemProfile) { profile.Enabled = true; profile.PerStore = false; profile.CreateZipArchive = false; profile.Cleanup = false; } else { // what we do here is to preset typical settings for feed creation // but on the other hand they may be untypical for generic data export\exchange var projection = new ExportProjection { RemoveCriticalCharacters = true, CriticalCharacters = "¼,½,¾", PriceType = PriceDisplayType.PreSelectedPrice, NoGroupedProducts = (features.HasFlag(ExportFeatures.CanOmitGroupedProducts) ? true : false), DescriptionMerging = ExportDescriptionMerging.Description }; var filter = new ExportFilter { IsPublished = true }; profile.Projection = XmlHelper.Serialize <ExportProjection>(projection); profile.Filtering = XmlHelper.Serialize <ExportFilter>(filter); } } else { profile = cloneProfile.Clone(); } profile.IsSystemProfile = isSystemProfile; profile.Name = name; profile.ProviderSystemName = providerSystemName; profile.SchedulingTaskId = task.Id; var cleanedSystemName = providerSystemName .Replace("Exports.", "") .Replace("Feeds.", "") .Replace("/", "") .Replace("-", ""); var folderName = SeoHelper.GetSeName(cleanedSystemName, true, false) .ToValidPath() .Truncate(_dataExchangeSettings.MaxFileNameLength); profile.FolderName = "~/App_Data/ExportProfiles/" + FileSystemHelper.CreateNonExistingDirectoryName(CommonHelper.MapPath("~/App_Data/ExportProfiles"), folderName); if (profileSystemName.IsEmpty() && isSystemProfile) { profile.SystemName = cleanedSystemName; } else { profile.SystemName = profileSystemName; } _exportProfileRepository.Insert(profile); task.Alias = profile.Id.ToString(); _scheduleTaskService.UpdateTask(task); if (fileExtension.HasValue() && !isSystemProfile) { if (cloneProfile == null) { if (features.HasFlag(ExportFeatures.CreatesInitialPublicDeployment)) { var subFolder = FileSystemHelper.CreateNonExistingDirectoryName(CommonHelper.MapPath("~/" + DataExporter.PublicFolder), folderName); profile.Deployments.Add(new ExportDeployment { ProfileId = profile.Id, Enabled = true, DeploymentType = ExportDeploymentType.PublicFolder, Name = profile.Name, SubFolder = subFolder }); UpdateExportProfile(profile); } } else { foreach (var deployment in cloneProfile.Deployments) { profile.Deployments.Add(deployment.Clone()); } UpdateExportProfile(profile); } } _eventPublisher.EntityInserted(profile); return(profile); }
public bool Save(string filename, ExportFilter filter) { return(Save(filename, FilterToString(filter))); }
/// <summary>Copy a table in this database into a new delimited text file.</summary> /// <remarks> /// Copy a table in this database into a new delimited text file. <br /> /// Equivalent to: /// <code>exportWriter(Cursor.createCursor(db.getTable(tableName)), out, header, delim, quote, filter); /// </code> /// </remarks> /// <param name="db">Database the table to export belongs to</param> /// <param name="tableName">Name of the table to export</param> /// <param name="out">Writer to export to</param> /// <param name="header">If <code>true</code> the first line contains the column names /// </param> /// <param name="delim">The column delimiter, <code>null</code> for default (comma)</param> /// <param name="quote">The quote character</param> /// <param name="filter">valid export filter</param> /// <seealso cref="ExportWriter(Cursor, System.IO.BufferedWriter, bool, string, char, ExportFilter) /// ">ExportWriter(Cursor, System.IO.BufferedWriter, bool, string, char, ExportFilter) /// </seealso> /// <exception cref="System.IO.IOException"></exception> public static void ExportWriter(Database db, string tableName, BufferedWriter @out , bool header, string delim, char quote, ExportFilter filter) { ExportWriter(Cursor.CreateCursor(db.GetTable(tableName)), @out, header, delim, quote , filter); }
private async Task DoExport(bool pickDestination) { if (_report.IsBusy) { return; } string selectedReport = cbReport.SelectedItem as string; if (string.IsNullOrEmpty(selectedReport)) { return; } if (cbExportFilter.SelectedIndex < 0 || cbExportFilter.SelectedIndex >= _report.SupportedExportProviders.Length) { return; } ReportItem ri = tbReportFile.SelectedItem as ReportItem; if (ri == null || (ri.File == null && ri.Caption == c_Browse)) { return; } // load report try { if (ri.File == null && ri.Caption == c_Builtin) { // load from resource stream Assembly asm = typeof(ExportPage).GetTypeInfo().Assembly; using (Stream stream = asm.GetManifestResourceStream("FlexReportSamples.Resources.FlexCommonTasks_UWP.flxr")) _report.Load(stream, selectedReport); } else { await _report.LoadAsync(ri.File, selectedReport); } } catch (Exception ex) { MessageDialog md = new MessageDialog(string.Format(Strings.FailedToLoadFmt, selectedReport, ex.Message), "Error"); await md.ShowAsync(); return; } // prepare ExportFilter object ExportProvider ep = _report.SupportedExportProviders[cbExportFilter.SelectedIndex]; ExportFilter ef = ep.NewExporter() as ExportFilter; ef.UseZipForMultipleFiles = cbUseZipForMultipleFiles.IsChecked.Value; // if ((ef is BmpFilter || ef is JpegFilter || ef is PngFilter || ef is GifFilter)) { // these export filters produce more than one file during export // ask for directory in this case string defFileName = selectedReport + "." + ep.DefaultExtension + ".zip"; if (cbUseZipForMultipleFiles.IsChecked == true) { if (pickDestination) { // ask for zip file FileSavePicker fsp = new FileSavePicker(); fsp.DefaultFileExtension = ".zip"; fsp.FileTypeChoices.Add(Strings.ZipFiles, new string[] { ".zip" }); fsp.SuggestedFileName = defFileName; ef.StorageFile = await fsp.PickSaveFileAsync(); if (ef.StorageFile == null) { return; } } else { // use file in temp folder ef.StorageFile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(defFileName, CreationCollisionOption.ReplaceExisting); } } else { if (pickDestination) { FolderPicker fp = new FolderPicker(); fp.FileTypeFilter.Add("." + ep.DefaultExtension); fp.FileTypeFilter.Add(".zip"); ef.StorageFolder = await fp.PickSingleFolderAsync(); if (ef.StorageFolder == null) { // user cancels an export return; } } else { ef.StorageFolder = await ApplicationData.Current.TemporaryFolder.CreateFolderAsync(selectedReport, CreationCollisionOption.OpenIfExists); } } } else { string defFileName = selectedReport + "." + ep.DefaultExtension; if (pickDestination) { // ask for file FileSavePicker fsp = new FileSavePicker(); fsp.DefaultFileExtension = "." + ep.DefaultExtension; fsp.FileTypeChoices.Add(ep.FormatName + " (." + ep.DefaultExtension + ")", new string[] { "." + ep.DefaultExtension }); fsp.FileTypeChoices.Add(Strings.ZipFiles, new string[] { ".zip" }); fsp.SuggestedFileName = defFileName; ef.StorageFile = await fsp.PickSaveFileAsync(); if (ef.StorageFile == null) { return; } } else { // use file in temp folder ef.StorageFile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(defFileName, CreationCollisionOption.ReplaceExisting); } } try { await _report.RenderToFilterAsync(ef); //_report.RenderToFilter(ef); await ShowPreview(ef); } catch (Exception ex) { MessageDialog md = new MessageDialog(string.Format(Strings.FailedToExportFmt, selectedReport, ex.Message), "Error"); await md.ShowAsync(); return; } }
/// <summary>Copy a table in this database into a new delimited text file.</summary> /// <remarks>Copy a table in this database into a new delimited text file.</remarks> /// <param name="cursor">Cursor to export</param> /// <param name="out">Writer to export to</param> /// <param name="header">If <code>true</code> the first line contains the column names /// </param> /// <param name="delim">The column delimiter, <code>null</code> for default (comma)</param> /// <param name="quote">The quote character</param> /// <param name="filter">valid export filter</param> /// <exception cref="System.IO.IOException"></exception> public static void ExportWriter(Cursor cursor, BufferedWriter @out, bool header, string delim, char quote, ExportFilter filter) { string delimiter = (delim == null) ? DEFAULT_DELIMITER : delim; // create pattern which will indicate whether or not a value needs to be // quoted or not (contains delimiter, separator, or newline) Sharpen.Pattern needsQuotePattern = Sharpen.Pattern.Compile("(?:" + Sharpen.Pattern .Quote(delimiter) + ")|(?:" + Sharpen.Pattern.Quote(string.Empty + quote) + ")|(?:[\n\r])" ); IList <Column> origCols = cursor.GetTable().GetColumns(); IList <Column> columns = new AList <Column>(origCols); columns = filter.FilterColumns(columns); ICollection <string> columnNames = null; if (!origCols.Equals(columns)) { // columns have been filtered columnNames = new HashSet <string>(); foreach (Column c in columns) { columnNames.AddItem(c.GetName()); } } // print the header row (if desired) if (header) { for (Iterator <Column> iter = columns.Iterator(); iter.HasNext();) { WriteValue(@out, iter.Next().GetName(), quote, needsQuotePattern); if (iter.HasNext()) { @out.Write(delimiter); } } @out.NewLine(); } // print the data rows IDictionary <string, object> row; object[] unfilteredRowData = new object[columns.Count]; while ((row = cursor.GetNextRow(columnNames)) != null) { // fill raw row data in array for (int i = 0; i < columns.Count; i++) { unfilteredRowData[i] = row.Get(columns[i].GetName()); } // apply filter object[] rowData = filter.FilterRow(unfilteredRowData); // print row for (int i_1 = 0; i_1 < columns.Count; i_1++) { object obj = rowData[i_1]; if (obj != null) { string value = null; if (obj is byte[]) { value = ByteUtil.ToHexString((byte[])obj); } else { value = rowData[i_1].ToString(); } WriteValue(@out, value, quote, needsQuotePattern); } if (i_1 < columns.Count - 1) { @out.Write(delimiter); } } @out.NewLine(); } @out.Flush(); }
/// <summary> /// Create an Export /// </summary> /// <param name="fields"></param> /// <param name="destinationUri"></param> /// <param name="filter"> </param> /// <returns>The URI for the export</returns> public string CreateExport(Dictionary <string, string> fields, string destinationUri, ExportFilter filter) { Export export = new Export { name = "sample export", fields = fields, filter = filter, secondsToAutoDelete = 3600, secondsToRetainData = 3600, syncActions = new List <SyncAction> { new SyncAction { action = SyncActionType.add, destinationUri = destinationUri } } }; RestRequest request = new RestRequest(Method.POST) { Resource = "/contact/export", RequestFormat = DataFormat.Json, RootElement = "export" }; request.AddBody(export); IRestResponse <Export> response = _client.Execute <Export>(request); Export returnedExport = response.Data; return(returnedExport.uri); }
private void button1_Click(object sender, EventArgs e) { if (application.ActiveDocument.Selection().Shapes.Count == 0) { MessageBox.Show("请选择一个对象"); return; } if (application.ActiveDocument.Selection().Shapes.Count > 1) { MessageBox.Show("只能选择一个对象"); return; } if (application.ActiveShape.Type != cdrShapeType.cdrBitmapShape) { MessageBox.Show("请选择一个位图"); return; } String PSPath = Settings.Default.PSPath; if (PSPath == "") { PSPath = getRegPSPath(); } if (PSPath == "") { MessageBox.Show("未找到PS主程序photoshop.exe,请手动设置"); frmSetPSPath f = new frmSetPSPath(); f.Show(this); return; } StartEvent(true); BitmapA = application.ActiveSelectionRange; application.ActiveShape.GetMatrix(out d11, out d12, out d21, out d22, out tx, out ty); application.ActiveShape.ClearTransformations(); Bitmap b = application.ActiveShape.Bitmap; CPtemp = application.CorelScriptTools().GetTempFolder() + "tisn2015.psd"; try { ExportFilter expflt = application.ActiveDocument.ExportBitmap(CPtemp, cdrFilter.cdrPSD, cdrExportRange.cdrSelection, b.Mode, b.SizeWidth, b.SizeHeight, b.ResolutionX, b.ResolutionY, b.Mode == cdrImageType.cdr16ColorsImage ? cdrAntiAliasingType.cdrNoAntiAliasing : cdrAntiAliasingType.cdrNormalAntiAliasing, false, b.Mode == cdrImageType.cdr16ColorsImage ? false : true, true, false, cdrCompressionType.cdrCompressionNone); expflt.Finish(); } catch (Exception ex) { MessageBox.Show("图片不在页面范围,请放入页面范围后重试!") ; } application.ActiveShape.SetMatrix(d11, d12, d21, d22, tx, ty); dtB = File.GetLastWriteTime(CPtemp); Process.Start(PSPath, CPtemp); if (MessageBox.Show("编辑完成单击确认,放弃编辑单击取消", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.OK) { dtA = File.GetLastWriteTime(CPtemp); if (dtA > dtB) { EditEnd(); } } EndEvent(); SetForegroundWindow(new IntPtr(application.AppWindow.Handle)); //application.AppWindow.WindowState = cdrWindowState.cdrWindowRestore; //timer1.Start(); }
private async void btnExport_Click(object sender, RoutedEventArgs e) { string fileName = null; while (true) { try { _pdfDocSource.UseSystemRendering = cbxUseSystemRendering.IsChecked.Value; if (_pdfFile == null) { using (Stream stream = this.GetType().GetTypeInfo().Assembly.GetManifestResourceStream("PdfDocumentSourceSamples.Resources.DefaultDocument.pdf")) await _pdfDocSource.LoadFromStreamAsync(stream.AsRandomAccessStream()); fileName = "DefaultDocument.pdf"; } else { await _pdfDocSource.LoadFromFileAsync(_pdfFile); fileName = Path.GetFileName(_pdfFile.Name); } break; } catch (PdfPasswordException) { fileNameBlock.Text = fileName; passwordBox.Password = string.Empty; if (await passwordDialog.ShowAsync() != ContentDialogResult.Primary) { return; } _pdfDocSource.Credential = new System.Net.NetworkCredential(null, passwordBox.Password); } catch (Exception ex) { MessageDialog md = new MessageDialog(string.Format(Strings.PdfErrorFormat, fileName, ex.Message), Strings.ErrorTitle); await md.ShowAsync(); return; } } // prepare ExportFilter object ExportProvider ep = _pdfDocSource.SupportedExportProviders[cbExportProvider.SelectedIndex]; ExportFilter ef = ep.NewExporter() as ExportFilter; ef.UseZipForMultipleFiles = cbxUseSystemRendering.IsChecked.Value; // if ((ef is BmpFilter || ef is JpegFilter || ef is PngFilter || ef is GifFilter)) { // these export filters produce more than one file during export // ask for directory in this case if (cbxUseZipForMultipleFiles.IsChecked == true) { // ask for zip file FileSavePicker fsp = new FileSavePicker(); fsp.DefaultFileExtension = ".zip"; fsp.FileTypeChoices.Add(Strings.ZipFiles, new string[] { ".zip" }); fsp.SuggestedFileName = Path.GetFileNameWithoutExtension(fileName) + ".zip"; ef.StorageFile = await fsp.PickSaveFileAsync(); if (ef.StorageFile == null) { return; } } else { FolderPicker fp = new FolderPicker(); fp.FileTypeFilter.Add("." + ep.DefaultExtension); fp.FileTypeFilter.Add(".zip"); ef.StorageFolder = await fp.PickSingleFolderAsync(); if (ef.StorageFolder == null) { // user cancels an export return; } } } else { // ask for file FileSavePicker fsp = new FileSavePicker(); fsp.DefaultFileExtension = "." + ep.DefaultExtension; fsp.FileTypeChoices.Add(ep.FormatName + " (." + ep.DefaultExtension + ")", new string[] { "." + ep.DefaultExtension }); fsp.FileTypeChoices.Add(Strings.ZipFiles, new string[] { ".zip" }); fsp.SuggestedFileName = Path.GetFileNameWithoutExtension(fileName) + "." + ep.DefaultExtension; ef.StorageFile = await fsp.PickSaveFileAsync(); if (ef.StorageFile == null) { return; } } btnExport.IsEnabled = false; try { await _pdfDocSource.ExportAsync(ef); await ShowPreview(ef); } catch (Exception ex) { MessageDialog md = new MessageDialog(string.Format(Strings.FailedToExportFmt, ex.Message), Strings.ErrorTitle); await md.ShowAsync(); } finally { btnExport.IsEnabled = true; } }
public virtual ExportProfile InsertExportProfile( string providerSystemName, string name, string fileExtension, ExportFeatures features, bool isSystemProfile = false, string profileSystemName = null, int cloneFromProfileId = 0) { Guard.ArgumentNotEmpty(() => providerSystemName); var profileCount = _exportProfileRepository.Table.Count(x => x.ProviderSystemName == providerSystemName); if (name.IsEmpty()) name = providerSystemName; if (!isSystemProfile) name = string.Concat(_localizationService.GetResource("Common.My"), " ", name); name = string.Concat(name, " ", profileCount + 1); var cloneProfile = GetExportProfileById(cloneFromProfileId); ScheduleTask task = null; ExportProfile profile = null; if (cloneProfile == null) { task = new ScheduleTask { CronExpression = "0 */6 * * *", // every six hours Type = typeof(DataExportTask).AssemblyQualifiedNameWithoutVersion(), Enabled = false, StopOnError = false, IsHidden = true }; } else { task = cloneProfile.ScheduleTask.Clone(); task.LastEndUtc = task.LastStartUtc = task.LastSuccessUtc = null; } task.Name = string.Concat(name, " Task"); _scheduleTaskService.InsertTask(task); if (cloneProfile == null) { profile = new ExportProfile { FileNamePattern = _defaultFileNamePattern }; if (isSystemProfile) { profile.Enabled = true; profile.PerStore = false; profile.CreateZipArchive = false; profile.Cleanup = false; } else { // what we do here is to preset typical settings for feed creation // but on the other hand they may be untypical for generic data export\exchange var projection = new ExportProjection { RemoveCriticalCharacters = true, CriticalCharacters = "¼,½,¾", PriceType = PriceDisplayType.PreSelectedPrice, NoGroupedProducts = (features.HasFlag(ExportFeatures.CanOmitGroupedProducts) ? true : false), DescriptionMerging = ExportDescriptionMerging.Description }; var filter = new ExportFilter { IsPublished = true }; profile.Projection = XmlHelper.Serialize<ExportProjection>(projection); profile.Filtering = XmlHelper.Serialize<ExportFilter>(filter); } } else { profile = cloneProfile.Clone(); } profile.IsSystemProfile = isSystemProfile; profile.Name = name; profile.ProviderSystemName = providerSystemName; profile.SchedulingTaskId = task.Id; var cleanedSystemName = providerSystemName .Replace("Exports.", "") .Replace("Feeds.", "") .Replace("/", "") .Replace("-", ""); var folderName = SeoHelper.GetSeName(cleanedSystemName, true, false) .ToValidPath() .Truncate(_dataExchangeSettings.MaxFileNameLength); profile.FolderName = "~/App_Data/ExportProfiles/" + FileSystemHelper.CreateNonExistingDirectoryName(CommonHelper.MapPath("~/App_Data/ExportProfiles"), folderName); if (profileSystemName.IsEmpty() && isSystemProfile) profile.SystemName = cleanedSystemName; else profile.SystemName = profileSystemName; _exportProfileRepository.Insert(profile); task.Alias = profile.Id.ToString(); _scheduleTaskService.UpdateTask(task); if (fileExtension.HasValue() && !isSystemProfile) { if (cloneProfile == null) { if (features.HasFlag(ExportFeatures.CreatesInitialPublicDeployment)) { var subFolder = FileSystemHelper.CreateNonExistingDirectoryName(CommonHelper.MapPath("~/" + DataExporter.PublicFolder), folderName); profile.Deployments.Add(new ExportDeployment { ProfileId = profile.Id, Enabled = true, DeploymentType = ExportDeploymentType.PublicFolder, Name = profile.Name, SubFolder = subFolder }); UpdateExportProfile(profile); } } else { foreach (var deployment in cloneProfile.Deployments) { profile.Deployments.Add(deployment.Clone()); } UpdateExportProfile(profile); } } _eventPublisher.EntityInserted(profile); return profile; }
public virtual async Task <ExportProfile> InsertExportProfileAsync( string providerSystemName, string name, string fileExtension, ExportFeatures features, bool isSystemProfile = false, string profileSystemName = null, int cloneFromProfileId = 0) { Guard.NotEmpty(providerSystemName, nameof(providerSystemName)); if (name.IsEmpty()) { name = providerSystemName; } if (!isSystemProfile) { var profileCount = await _db.ExportProfiles.CountAsync(x => x.ProviderSystemName == providerSystemName); name = $"{T("Common.My").Value} {name} {profileCount + 1}"; } TaskDescriptor task = null; ExportProfile cloneProfile = null; ExportProfile profile = null; if (cloneFromProfileId != 0) { cloneProfile = await _db.ExportProfiles .Include(x => x.Task) .Include(x => x.Deployments) .FindByIdAsync(cloneFromProfileId); } if (cloneProfile == null) { task = new TaskDescriptor { CronExpression = "0 */6 * * *", // Every six hours. Type = nameof(DataExportTask), Enabled = false, StopOnError = false, IsHidden = true }; } else { task = cloneProfile.Task.Clone(); } task.Name = name + " Task"; _db.TaskDescriptors.Add(task); // Get the task ID. await _db.SaveChangesAsync(); if (cloneProfile == null) { profile = new ExportProfile { FileNamePattern = _defaultFileNamePattern }; if (isSystemProfile) { profile.Enabled = true; profile.PerStore = false; profile.CreateZipArchive = false; profile.Cleanup = false; } else { // What we do here is to preset typical settings for feed creation // but on the other hand they may be untypical for generic data export\exchange. var projection = new ExportProjection { RemoveCriticalCharacters = true, CriticalCharacters = "¼,½,¾", PriceType = PriceDisplayType.PreSelectedPrice, NoGroupedProducts = features.HasFlag(ExportFeatures.CanOmitGroupedProducts), OnlyIndividuallyVisibleAssociated = true, DescriptionMerging = ExportDescriptionMerging.Description }; var filter = new ExportFilter { IsPublished = true, ShoppingCartTypeId = (int)ShoppingCartType.ShoppingCart }; using var writer1 = new StringWriter(); new XmlSerializer(typeof(ExportProjection)).Serialize(writer1, projection); profile.Projection = writer1.ToString(); using var writer2 = new StringWriter(); new XmlSerializer(typeof(ExportFilter)).Serialize(writer2, projection); profile.Filtering = writer2.ToString(); } } else { profile = cloneProfile.Clone(); } profile.IsSystemProfile = isSystemProfile; profile.Name = name; profile.ProviderSystemName = providerSystemName; profile.TaskId = task.Id; var cleanedSystemName = providerSystemName .Replace("Exports.", string.Empty) .Replace("Feeds.", string.Empty) .Replace("/", string.Empty) .Replace("-", string.Empty); var directoryName = SeoHelper.BuildSlug(cleanedSystemName, true, false, false) .ToValidPath() .Truncate(_dataExchangeSettings.MaxFileNameLength); // TODO: (mg) (core) find out how to correctly build new app relative paths for ExportProfile.FolderName like x '~/App_Data/Tenants/Default/ExportProfiles/bmecatproductxml-1-2' // ExportProfile.FolderName must fulfil PathHelper.IsSafeAppRootPath! See also below. var tenantRoot = DataSettings.Instance.TenantRoot; var profileDirectory = tenantRoot.GetDirectory("ExportProfiles"); // TODO: (mg) (core) TenantRoot is rooted to the tenant dir and DOES NOT CONTAIN "App_Data/Tenants/{TenantName}" anymore. // The result will be "ExportProfiles/{UniqueDirName}, which conflicts with how we saved the path in the past ("~/App_Data/..."). You must // "upgrade" legacy pathes to new root whenever an entity is loaded and processed. profile.FolderName = tenantRoot.PathCombine(profileDirectory.SubPath, tenantRoot.CreateUniqueDirectoryName(profileDirectory.SubPath, directoryName)); profile.SystemName = profileSystemName.IsEmpty() && isSystemProfile ? cleanedSystemName : profileSystemName; _db.ExportProfiles.Add(profile); // Get the export profile ID. await _db.SaveChangesAsync(); task.Alias = profile.Id.ToString(); if (fileExtension.HasValue() && !isSystemProfile) { if (cloneProfile == null) { if (features.HasFlag(ExportFeatures.CreatesInitialPublicDeployment)) { var subFolder = tenantRoot.CreateUniqueDirectoryName(DataExporter.PublicFolder, directoryName); profile.Deployments.Add(new ExportDeployment { ProfileId = profile.Id, Enabled = true, DeploymentType = ExportDeploymentType.PublicFolder, Name = profile.Name, SubFolder = subFolder }); } } else { cloneProfile.Deployments.Each(x => profile.Deployments.Add(x.Clone())); } } // Finally update task and export profile. await _db.SaveChangesAsync(); return(profile); }