public void Convert(IMapGraphic mapGraphic, string outputFilename) { var inkscapeExe = GetInkscapePath(); if (inkscapeExe == null) { throw new ApplicationException("Inkscape is required to convert."); } using (var tfh = new TemporalFileHelper()) { var xmlDocument = mapGraphic.GetSvgXmlDocument(); xmlDocument.Save(tfh.TemporalFileName); var arguments = string.Format("--file {0} {1} {2}", tfh.TemporalFileName, ConvertOption, outputFilename); Process p = Process.Start(inkscapeExe, arguments); p.WaitForExit(); } }
public void Convert(IMapGraphic mapGraphic, string outputFilename) { using (var tfh = new TemporalFileHelper()) { var xmlDocument = mapGraphic.GetSvgXmlDocument(); xmlDocument.Save(tfh.TemporalFileName); using (WebClient client = new WebClient()) { client.Headers["Content-Type"] = "binary/octet-stream"; StringBuilder sb = new StringBuilder(); var result = client.UploadFile( "https://api.cloudconvert.com/convert?" + "apikey=" + _apikey + "&input=upload" + "&inputformat=svg" + "&outputformat=" + OutputFormat, tfh.TemporalFileName); File.WriteAllBytes(outputFilename, result); } } }
public ISpreadsheet ParseSpreadsheet(string spreadsheetFileName) { // Ugly patch to allow to read opened XLSX files, FileShare.Read is not enough using (var tfh = new TemporalFileHelper()) { ISpreadsheet spreadsheet; try { File.Copy(spreadsheetFileName, tfh.TemporalFileName, true); spreadsheet = _spreadsheetParser.ParseFromFile(tfh.TemporalFileName); } catch { throw new ApplicationException(string.Format("Error reading the file {0}", spreadsheetFileName)); } try { spreadsheet = spreadsheet.CreateNewParsingHeaders(); } catch { throw new ApplicationException(string.Format("Error parsing the file {0}.\nA valid Excel Workbook file (.xlsx) is expected.", spreadsheetFileName)); } var requiredColumns = new[] { ID_COLUMN }.Union(Products.AllProducts.ProductNames).ToArray(); if (!spreadsheet.HasAllColumns(requiredColumns)) { var requiredColumnsAsText = string.Join(", ", requiredColumns.Select(x => string.Format("\"{0}\""))); throw new ApplicationException(string.Format("Excel file format is not valid.\nIt requires the columns {0}.", requiredColumnsAsText)); } return(spreadsheet); } }