public void ExportManagerAllExportersTest() { // Arrange var context = new ExportImportContext(); context.SetupAutocompletes(1); context.SetupRelatedQueries(2); var exporters = new List<IExporter> { context.AutocompleteExporter, context.RelatedQueryExporter }; var exportManager = new ExportManager(exporters, context.SiteIdentityLoaderMock.Object, context.Settings); MemoryStream stream = new MemoryStream(); // Act exportManager.ExportToStream(new List<string> { context.AutocompleteExporter.EntityKey, context.RelatedQueryExporter.EntityKey }, Helpers.AllSitesId, Helpers.AllLanguages, stream); // Assert var outputStream = new MemoryStream(stream.ToArray()); var streamReader = new StreamReader(outputStream); var exportedData = streamReader.ReadToEnd(); Assert.NotNull(exportedData); Assert.Equal("[{\"$type\":\"Vro.FindExportImport.Models.EntitySet`1[[Vro.FindExportImport.Models.IOptimizationEntity, Vro.FindExportImport]], Vro.FindExportImport\"," + "\"Key\":\"AutocompleteEntity\",\"Entities\":[" + "{\"$type\":\"Vro.FindExportImport.Models.AutocompleteEntity, Vro.FindExportImport\",\"priority\":0,\"query\":\"testAQuery0\",\"id\":\"testAId0\",\"tags\":[\"siteid:84bfaf5c52a349a0bc61a9ffb6983a66\",\"language:7d2da0a9fc754533b091fa6886a51c0d\"]}]}," + "{\"$type\":\"Vro.FindExportImport.Models.EntitySet`1[[Vro.FindExportImport.Models.IOptimizationEntity, Vro.FindExportImport]], Vro.FindExportImport\"," + "\"Key\":\"RelatedQueryEntity\",\"Entities\":[" + "{\"$type\":\"Vro.FindExportImport.Models.RelatedQueryEntity, Vro.FindExportImport\",\"priority\":0,\"query\":\"testRQQuery0\",\"suggestion\":\"testRQSuggestion0\",\"id\":\"testRQId0\",\"tags\":[\"siteid:84bfaf5c52a349a0bc61a9ffb6983a66\",\"language:7d2da0a9fc754533b091fa6886a51c0d\"]}," + "{\"$type\":\"Vro.FindExportImport.Models.RelatedQueryEntity, Vro.FindExportImport\",\"priority\":1,\"query\":\"testRQQuery1\",\"suggestion\":\"testRQSuggestion1\",\"id\":\"testRQId1\",\"tags\":[\"siteid:84bfaf5c52a349a0bc61a9ffb6983a66\",\"language:7d2da0a9fc754533b091fa6886a51c0d\"]}" + "]}]", exportedData); }
public List<OptimizationCount> GetCounts(string siteId, string language) { var exportManager = new ExportManager(); return exportManager.Exporters.Select(e => new OptimizationCount { EntityKey = e.EntityKey, Count = e.GetTotalCount(siteId, language) }).ToList(); }
public void ExportImportTest() { // Arrange var exportContext = new ExportImportContext(); var autocompletesCount = 25; var relatedQueriesCount = 49; exportContext.SetupAutocompletes(autocompletesCount); exportContext.SetupRelatedQueries(relatedQueriesCount); var exporters = new List<IExporter> { exportContext.AutocompleteExporter, exportContext.RelatedQueryExporter }; var exportManager = new ExportManager(exporters, exportContext.SiteIdentityLoaderMock.Object, exportContext.Settings); var importContext = new ExportImportContext(); importContext.SetupAutocompletes(0); importContext.SetupRelatedQueries(0); var importers = new List<IImporter> { importContext.AutocompleteImporter, importContext.RelatedQueryImporter }; var importManager = new ImportManager(importers); // Act MemoryStream exportStream = new MemoryStream(); exportManager.ExportToStream(new List<string> { exportContext.AutocompleteExporter.EntityKey, exportContext.RelatedQueryExporter.EntityKey }, Helpers.AllSitesId, Helpers.AllLanguages, exportStream); var importStream = new MemoryStream(exportStream.ToArray()); importManager.ImportFromStream("MySite", importStream); // Assert Assert.Equal(autocompletesCount, importContext.Autocompletes.Count); Assert.Equal(relatedQueriesCount, importContext.RelatedQueries.Count); for (int i = 0; i < autocompletesCount; i++) { Assert.Equal(exportContext.Autocompletes[i].Id, importContext.Autocompletes[i].Id); Assert.Equal(exportContext.Autocompletes[i].Query, importContext.Autocompletes[i].Query); Assert.Equal(exportContext.Autocompletes[i].Priority, importContext.Autocompletes[i].Priority); Assert.NotEqual(exportContext.Autocompletes[i].Tags, importContext.Autocompletes[i].Tags); Assert.Equal("siteid:MySite", importContext.Autocompletes[i].Tags.First()); } for (int i = 0; i < relatedQueriesCount; i++) { Assert.Equal(exportContext.RelatedQueries[i].Id, importContext.RelatedQueries[i].Id); Assert.Equal(exportContext.RelatedQueries[i].Query, importContext.RelatedQueries[i].Query); Assert.Equal(exportContext.RelatedQueries[i].Priority, importContext.RelatedQueries[i].Priority); Assert.Equal(exportContext.RelatedQueries[i].Suggestion, importContext.RelatedQueries[i].Suggestion); Assert.NotEqual(exportContext.RelatedQueries[i].Tags, importContext.RelatedQueries[i].Tags); Assert.Equal("siteid:MySite", importContext.RelatedQueries[i].Tags.First()); } }
private void 导出ToolStripMenuItem_Click(object sender, EventArgs e) { ExportManager.ExportDataGridViewToExcel(gvInfo, "收件单号查询"); }
public void TestInitialize() { _serviceProviderMock = new Mock <IServiceProvider>(); _pictureServiceMock = new Mock <IPictureService>(); _exportManager = new ExportManager(_pictureServiceMock.Object, _serviceProviderMock.Object); }
public ExportServices(string pTestDB) { _exportManager = new ExportManager(pTestDB); }
private void LayoutRoot_KeyDown(object sender, KeyRoutedEventArgs e) { if (e.Key == VirtualKey.F11) { Utils.ToggleFullScreenMode(); } var ctrlState = CoreWindow.GetForCurrentThread().GetKeyState(VirtualKey.Control); if ((ctrlState & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down) { // Check to see if any basic modals are open first if ((SettingsView != null && SettingsView.IsOpen) || (PrintPresenter != null && PrintPresenter.Child != null)) { return; } switch (e.Key) { case VirtualKey.C: FontMap.TryCopy(); break; case VirtualKey.S: if (FontMap.ViewModel.SelectedVariant is FontVariant v) { ExportManager.RequestExportFontFile(v); } break; case VirtualKey.N: if (ViewModel.SelectedFont is InstalledFont fnt) { _ = FontMapView.CreateNewViewForFontAsync(fnt); } break; case VirtualKey.P: Messenger.Send(new PrintRequestedMessage()); break; case VirtualKey.Delete: if (ViewModel.SelectedFont is InstalledFont font && font.HasImportedFiles) { FlyoutHelper.RequestDelete(font); } break; case VirtualKey.Add: case (VirtualKey)187: FontMap.ViewModel.IncreaseCharacterSize(); break; case VirtualKey.Subtract: case (VirtualKey)189: FontMap.ViewModel.DecreaseCharacterSize(); break; case VirtualKey.L: TogglePane_Click(null, null); break; case VirtualKey.R: ViewModel.Settings.EnablePreviewPane = !ViewModel.Settings.EnablePreviewPane; break; case VirtualKey.B: ViewModel.Settings.EnableCopyPane = !ViewModel.Settings.EnableCopyPane; break; case VirtualKey.T: FontMap.ViewModel.ChangeDisplayMode(); break; case VirtualKey.Q: _ = QuickCompareView.CreateNewWindowAsync(); break; } } }
private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); WindowRestoreMessage = NativeMethods.RegisterWindowMessage("TweetDuckRestore"); if (!WindowsUtils.CheckFolderWritePermission(StoragePath)) { MessageBox.Show(BrandName + " does not have write permissions to the storage folder: " + StoragePath, "Permission Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Reporter = new Reporter(ErrorLogFilePath); Reporter.SetupUnhandledExceptionHandler(BrandName + " Has Failed :("); if (Arguments.HasFlag(Arguments.ArgRestart)) { for (int attempt = 0; attempt < 21; attempt++) { LockManager.Result lockResult = LockManager.Lock(); if (lockResult == LockManager.Result.Success) { break; } else if (lockResult == LockManager.Result.Fail) { MessageBox.Show("An unknown error occurred accessing the data folder. Please, make sure " + BrandName + " is not already running. If the problem persists, try restarting your system.", BrandName + " Has Failed :(", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (attempt == 20) { using (FormMessage form = new FormMessage(BrandName + " Cannot Restart", BrandName + " is taking too long to close.", MessageBoxIcon.Warning)){ form.CancelButton = form.AddButton("Exit"); form.ActiveControl = form.AddButton("Retry", DialogResult.Retry); if (form.ShowDialog() == DialogResult.Retry) { attempt /= 2; continue; } return; } } else { Thread.Sleep(500); } } } else { LockManager.Result lockResult = LockManager.Lock(); if (lockResult == LockManager.Result.HasProcess) { if (LockManager.LockingProcess.MainWindowHandle == IntPtr.Zero) // restore if the original process is in tray { NativeMethods.SendMessage(NativeMethods.HWND_BROADCAST, WindowRestoreMessage, LockManager.LockingProcess.Id, IntPtr.Zero); if (WindowsUtils.TrySleepUntil(() => { LockManager.LockingProcess.Refresh(); return(LockManager.LockingProcess.HasExited || (LockManager.LockingProcess.MainWindowHandle != IntPtr.Zero && LockManager.LockingProcess.Responding)); }, 2000, 250)) { return; // should trigger on first attempt if succeeded, but wait just in case } } if (MessageBox.Show("Another instance of " + BrandName + " is already running.\r\nDo you want to close it?", BrandName + " is Already Running", MessageBoxButtons.YesNo, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { if (!LockManager.CloseLockingProcess(10000, 5000)) { MessageBox.Show("Could not close the other process.", BrandName + " Has Failed :(", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } LockManager.Lock(); } else { return; } } else if (lockResult != LockManager.Result.Success) { MessageBox.Show("An unknown error occurred accessing the data folder. Please, make sure " + BrandName + " is not already running. If the problem persists, try restarting your system.", BrandName + " Has Failed :(", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } ReloadConfig(); if (Arguments.HasFlag(Arguments.ArgImportCookies)) { ExportManager.ImportCookies(); } if (Arguments.HasFlag(Arguments.ArgUpdated)) { WindowsUtils.TryDeleteFolderWhenAble(InstallerPath, 8000); } CefSharpSettings.WcfEnabled = false; CefSettings settings = new CefSettings { AcceptLanguageList = BrowserUtils.HeaderAcceptLanguage, UserAgent = BrowserUtils.HeaderUserAgent, Locale = Arguments.GetValue(Arguments.ArgLocale, string.Empty), BrowserSubprocessPath = BrandName + ".Browser.exe", CachePath = StoragePath, LogFile = ConsoleLogFilePath, #if !DEBUG LogSeverity = Arguments.HasFlag(Arguments.ArgLogging) ? LogSeverity.Info : LogSeverity.Disable #endif }; CommandLineArgsParser.ReadCefArguments(UserConfig.CustomCefArgs).ToDictionary(settings.CefCommandLineArgs); if (!HardwareAcceleration.IsEnabled) { settings.CefCommandLineArgs["disable-gpu"] = "1"; settings.CefCommandLineArgs["disable-gpu-vsync"] = "1"; } settings.CefCommandLineArgs["disable-extensions"] = "1"; settings.CefCommandLineArgs["disable-plugins-discovery"] = "1"; settings.CefCommandLineArgs["enable-system-flash"] = "0"; Cef.Initialize(settings, false, new BrowserProcessHandler()); Application.ApplicationExit += (sender, args) => ExitCleanup(); PluginManager plugins = new PluginManager(PluginPath, PluginConfigFilePath); plugins.Reloaded += plugins_Reloaded; plugins.Executed += plugins_Executed; plugins.Reload(); FormBrowser mainForm = new FormBrowser(plugins, new UpdaterSettings { AllowPreReleases = Arguments.HasFlag(Arguments.ArgDebugUpdates), DismissedUpdate = UserConfig.DismissedUpdate, InstallerDownloadFolder = InstallerPath }); Application.Run(mainForm); if (mainForm.UpdateInstallerPath != null) { ExitCleanup(); // ProgramPath has a trailing backslash string updaterArgs = "/SP- /SILENT /CLOSEAPPLICATIONS /UPDATEPATH=\"" + ProgramPath + "\" /RUNARGS=\"" + Arguments.GetCurrentForInstallerCmd() + "\"" + (IsPortable ? " /PORTABLE=1" : ""); bool runElevated = !IsPortable || !WindowsUtils.CheckFolderWritePermission(ProgramPath); WindowsUtils.StartProcess(mainForm.UpdateInstallerPath, updaterArgs, runElevated); Application.Exit(); } }
private void btnExport_Click(object sender, EventArgs e) { ExportManager.ExportDataGridViewToExcel(gvInfo, "快件称重订单查询"); }
/// <summary> /// Sets the export manager needed to export the data /// </summary> public void SetExportManager(ExportManager exportManager) { this.exportManager = exportManager; }
private void button3_Click(object sender, EventArgs e) { ExportManager.ExportDataGridViewToExcel(gvInfo, "集包单号"); }
static void Dev_ResetToReport() { ExportManager.CreateReport(); EditorApplication.Beep(); }
private static void RunOptionsAndReturnExitCode(Options opts) { try { using (var site = new SPSite(opts.Url)) { using (var web = site.OpenWeb()) { var assembly = Assembly.GetAssembly(typeof(ExportManager)); var type = assembly.GetType("ChemAxon.JChemSharePoint.Services.Model.SP.Data.JChemAppContext"); var createContext = type.GetMethod("CreateContext", new Type[] { typeof(JChemContextInfo) }); JChemContextInfo ctxInfo = new JChemContextInfo(true, Environment.UserName, Convert.ToBase64String(web.CurrentUser.UserToken.BinaryToken), Guid.NewGuid(), site.ID, web.ID, web.Locale, web.Locale, Guid.NewGuid()); using (DataContext ctx = (DataContext)createContext.Invoke(null, new object[] { ctxInfo })) { var list = web.GetListFromUrl(opts.Url); var outputFile = string.IsNullOrWhiteSpace(opts.Output) ? list.Title : Path.GetFileNameWithoutExtension(opts.Output); var fileFormat = string.IsNullOrWhiteSpace(opts.Format) ? "mrv" : opts.Format; ExportManager exportManager = new ExportManager(ctx); var exportOptions = new ExportOptions() { FileEncoding = "UTF-8", FileName = outputFile, IncludeNoStructures = false, OutputFormat = fileFormat, ListId = list.ID, Columns = new List <ExportColumn> { new ExportColumn() { ColumnName = opts.ColumnName, IsMainStructureColumn = true, IsStructureColumn = true, IsSelectedForSaving = true } } }; using (var stream = exportManager.ExportList(exportOptions)) { using (var fs = new FileStream(string.Format("{0}.{1}", outputFile, fileFormat), FileMode.Create)) { stream.CopyTo(fs); } } } } } } catch (Exception ex) { Console.WriteLine("Error while exporting: ", ex.Message); Console.WriteLine("Stack: ", ex.StackTrace); } }
private void 导出ToolStripMenuItem1_Click(object sender, EventArgs e) { ExportManager.ExportDataGridViewToExcel(dataGridView1, "VIP反向查单汇总表"); }
protected override void OnInit(EventArgs e) { _importManager = new ImportManager(); _exportManager = new ExportManager(); _exportersCheckBoxes = CreateCheckBoxes(exportersPanel, _exportManager.Exporters.Select(exporter => new cbLinks { Id = exporter.EntityKey, Text = Helpers.GetEntityName(exporter.EntityKey), Link = exporter.UiUrl }), true); _deletersCheckBoxes = CreateCheckBoxes(deletersPanel, _exportManager.Exporters.Select(exporter => new cbLinks { Id = exporter.EntityKey, Text = Helpers.GetEntityName(exporter.EntityKey), Link = exporter.UiUrl }), false); _exportManager.GetSites().ForEach(s => exportSite.Items.Add(new ListItem(s.Name, s.Id))); _exportManager.GetSites().ForEach(s => importSite.Items.Add(new ListItem(s.Name, s.Id))); _exportManager.GetSites().ForEach(s => deleteSite.Items.Add(new ListItem(s.Name, s.Id))); _exportManager.GetLanguages().ForEach(l => exportLanguage.Items.Add(new ListItem(l.Name, l.Id))); _exportManager.GetLanguages().ForEach(l => deleteLanguage.Items.Add(new ListItem(l.Name, l.Id))); base.OnInit(e); }
public ExportServices(ExportManager pExportManager) { _exportManager = pExportManager; }
private IExtractResult HistoryDataLayoutAlgorithm(Action <int, string> progressTracker) { //1.获取到数据 List <string> list = ExportManager.GetInstance().List; //这个针对查询出来的数据出专题图 string[] inputfiles = list.ToArray(); //再加一上基于 同期统计数据的专题图,如果是冬季的,还要再计算一次 StatisticResultManager manager = StatisticResultManager.GetInstance(); List <string> list2 = manager.GetFilePathFromList(); //得到的是基于数据查询的数据又做的统计数据 if (list2.Count != 0) { inputfiles = list2.ToArray(); period = "yes"; Match m = DataReg2.Match(inputfiles[0]); if (m.Success) { Iswinter = "yes"; } } //处理后的数据存储路径 string savePath = _argumentProvider.GetArg("HistoryDataSave") as string; regioNames = _argumentProvider.GetArg("regionNames") as string; string orbitType = _argumentProvider.GetArg("OrbitType") as string; string Str = null; if (orbitType == "Ascend") { Str = "_A_"; } if (orbitType == "Descend") { Str = "_D_"; } //同期统计计算传出来的文件没有分升降轨,这里进行区分 List <string> fnamelist = new List <string>(); foreach (string file in inputfiles) { if (Path.GetFileName(file).Contains(Str)) { fnamelist.Add(file); } } inputfiles = fnamelist.ToArray(); //处理后的数据,用它来出专题图 List <string> afterProcessfiles = new List <string>(); //(插一步,通过这个原始选择的文件名时间信息把专题图名称确定) //2.确定选择区域,没有选或者中国区域不要用裁,如果是其地区首先裁切,并且放到指定文件夹下 aoiContainer = new GeoDo.RSS.Core.VectorDrawing.AOIContainerLayer(); MulRegionsClip muticlip = new MulRegionsClip(); //裁切 MWSSmoothHelp smooth = new MWSSmoothHelp(); //平滑 string regionsname = ""; #region 获得目标区域 aoiContainer = new GeoDo.RSS.Core.VectorDrawing.AOIContainerLayer(); string fieldName; string shapeFilename; int fieldIndex = -1; List <string> fieldValues = new List <string>(); using (frmStatSubRegionTemplates frm = new frmStatSubRegionTemplates()) { frm.listView1.MultiSelect = true; if (frm.ShowDialog() == DialogResult.OK) { Feature[] fets = frm.GetSelectedFeatures(); fets = frm.GetStatFeatures(out fieldName, out shapeFilename, out fieldIndex); if (fets == null) { aoiContainer = null; regionsname = "全国"; } else { string chinafieldValue = fets[0].GetFieldValue(fieldIndex); if (chinafieldValue == "中国") { aoiContainer = null; regionsname = "全国"; } else { foreach (Feature fet in fets) { fieldValues.Add(fet.GetFieldValue(fieldIndex)); //获得选择区域名称 aoiContainer.AddAOI(fet); } foreach (string region in fieldValues) { regionsname += region; } if (regionsname.Contains("西藏") && regionsname.Contains("青海")) { regionsname = "青藏地区"; } if (!string.IsNullOrEmpty(regioNames)) { regionsname = regioNames.Trim(); } } } } else //没有点击确定,返回空 { return(null); } } #endregion if (aoiContainer == null) { //不用裁切,只做中值滤波的平滑处理。 regionsname = "全国"; foreach (string infile in inputfiles) { //创建专题图路径 gxdsave = savePath + "\\" + regionsname + "\\" + "专题图"; if (!System.IO.Directory.Exists(gxdsave))//如果不存在这个路径 { System.IO.Directory.CreateDirectory(gxdsave); } //创建平滑路径 string smoothsave = savePath + "\\" + regionsname + "\\" + "平滑"; if (!System.IO.Directory.Exists(smoothsave)) { System.IO.Directory.CreateDirectory(smoothsave); } //创建平滑\\中值 string filtersave = smoothsave + "\\" + "中值"; if (!System.IO.Directory.Exists(filtersave)) { System.IO.Directory.CreateDirectory(filtersave); } string filterfile = smooth.ComputerMid(infile, 5, filtersave); string hdrfile = Path.GetDirectoryName(filterfile) + "\\" + Path.GetFileNameWithoutExtension(filterfile) + ".hdr"; afterProcessfiles.Add(filterfile); } } else { //创建裁切路径 string clipsave = savePath + "\\" + regionsname + "\\" + "裁切"; if (!System.IO.Directory.Exists(clipsave))//如果不存在这个路径 { System.IO.Directory.CreateDirectory(clipsave); } //创建专题图路径 gxdsave = savePath + "\\" + regionsname + "\\" + "专题图"; if (!System.IO.Directory.Exists(gxdsave))//如果不存在这个路径 { System.IO.Directory.CreateDirectory(gxdsave); } //创建平滑路径 string smoothsave = savePath + "\\" + regionsname + "\\" + "平滑"; if (!System.IO.Directory.Exists(smoothsave)) { System.IO.Directory.CreateDirectory(smoothsave); } //创建平滑\\中值 string filtersave = smoothsave + "\\" + "中值"; if (!System.IO.Directory.Exists(filtersave)) { System.IO.Directory.CreateDirectory(filtersave); } //创建平滑\\插值 string bilisave = smoothsave + "\\" + "插值"; if (!System.IO.Directory.Exists(bilisave)) { System.IO.Directory.CreateDirectory(bilisave); } foreach (string infile in inputfiles) { //加一个条件判断要处理的数据是否已经存在,如果存就不用再做 string newclipfile = Path.Combine(clipsave, Path.GetFileName(infile).Replace("China", regionsname)); if (!File.Exists(newclipfile)) { string clipfile = muticlip.MutiRegionsClip(infile, aoiContainer, clipsave); string hdrfile = Path.GetDirectoryName(clipfile) + "\\" + Path.GetFileNameWithoutExtension(clipfile) + ".hdr"; //重命名 string newhdrfile = Path.Combine(Path.GetDirectoryName(clipfile), Path.GetFileNameWithoutExtension(infile).Replace("China", regionsname) + ".hdr"); FileInfo fi = new FileInfo(clipfile); fi.MoveTo(newclipfile); FileInfo fihdr = new FileInfo(hdrfile); fihdr.MoveTo(newhdrfile); } //裁切后要对数据中值、插值 string filterfile = smooth.ComputerMid(newclipfile, 5, filtersave); string bilifile = smooth.Bilinear(filterfile, 10, bilisave); afterProcessfiles.Add(bilifile); } } //把处理后的afterProcessfiles.ToArray()数组文件名标识变为“HFSD”或“HFWE”。 foreach (string file in afterProcessfiles.ToArray()) { string hdrfile = Path.GetDirectoryName(file) + "\\" + Path.GetFileNameWithoutExtension(file) + ".hdr"; string newfile = ""; string newhdr = ""; if (file.Contains("MWSD")) { newfile = file.Replace("MWSD", "HFSD"); newhdr = hdrfile.Replace("MWSD", "HFSD"); } if (file.Contains("MSWE")) { newfile = file.Replace("MSWE", "HFWE"); newhdr = hdrfile.Replace("MSWE", "HFWE"); } FileInfo fi = new FileInfo(file); if (!File.Exists(newfile)) { fi.MoveTo(newfile); } FileInfo fihdr = new FileInfo(hdrfile); if (!File.Exists(newhdr)) { fihdr.MoveTo(newhdr); } imgfiles.Add(newfile); } IExtractResultArray results = new ExtractResultArray(""); foreach (string arguments in imgfiles.ToArray()) { string product = ""; if (arguments.Contains("HFSD")) { _argumentProvider.SetArg("OutFileIdentify", "HSDI"); product = "雪深"; } if (arguments.Contains("HFWE")) { _argumentProvider.SetArg("OutFileIdentify", "HSWI"); product = "雪水当量"; } //解析文件名确定专题图名称 string filename = Path.GetFileNameWithoutExtension(arguments); if (period == "yes") //同期统计的 { if (Iswinter == "yes") { Match m = DataReg2.Match(filename); string year = ""; if (m.Success) { year = m.Value; } imgname = year.Substring(0, 4) + "年" + "冬季" + regionsname + product + "分布图"; } else { Regex DataReg1 = new Regex(@"(?<year>\d{4})_(?<year>\d{4})", RegexOptions.Compiled); Match m = DataReg1.Match(filename); string year = ""; if (m.Success) { year = m.Value; } //提取年至avg之间的字符 string filetime = filename.Substring(filename.IndexOf(year), filename.Length - 3 - filename.IndexOf(year)); string[] mxchars = filetime.Split(new char[] { '_' }); string mx = "";//月+旬 if (filename.Contains("Xun")) { if (mxchars[3] == "1") { mx = mxchars[2] + "月" + "上旬"; } if (mxchars[3] == "2") { mx = mxchars[2] + "月" + "中旬"; } if (mxchars[3] == "3") { mx = mxchars[2] + "月" + "下旬"; } } if (filename.Contains("Month")) { mx = mxchars[2] + "月"; } imgname = year + "年" + mx + regionsname + product + "分布图"; } } else { Regex DataReg = new Regex(@"(?<year>\d{4})", RegexOptions.Compiled); Match m = DataReg.Match(filename); string year = ""; if (m.Success) { year = m.Value; } //提取年至avg之间的字符 string filetime = filename.Substring(filename.IndexOf(year), filename.Length - 3 - filename.IndexOf(year)); string[] mxchars = filetime.Split(new char[] { '_' }); string mx = "";//月+旬 if (filename.Contains("Xun")) { if (mxchars[2] == "1") { mx = mxchars[1] + "月" + "上旬"; } if (mxchars[2] == "2") { mx = mxchars[1] + "月" + "中旬"; } if (mxchars[2] == "3") { mx = mxchars[1] + "月" + "下旬"; } } if (filename.Contains("Month")) { mx = mxchars[1] + "月"; } if (filetime.Contains("Season")) { mx = mxchars[1] + "季度"; } imgname = year + "年" + mx + regionsname + product + "分布图"; } _argumentProvider.SetArg("SelectedPrimaryFiles", arguments); _argumentProvider.SetArg("fileOpenArgs", arguments); FileExtractResult result = ThemeGraphyResult(null) as FileExtractResult; //增加矢量 string autopath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"SystemData\ProductArgs\MWS\shppath.txt"); string shpFile = ""; if (File.Exists(autopath)) { FileStream fauto = new FileStream(autopath, FileMode.Open, FileAccess.Read); StreamReader rauto = new StreamReader(fauto, Encoding.GetEncoding("gb2312")); shpFile = rauto.ReadLine(); rauto.Close(); fauto.Close(); } else { shpFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"数据引用\基础矢量\行政区划\线\中国边界_线.shp"); } CreateMcd(shpFile); _shpFile = shpFile; _gxdFile = (result as FileExtractResult).FileName; AddShpToGxd(); FileInfo fi = new FileInfo(result.FileName); string newresultfile = Path.Combine(gxdsave, Path.GetFileNameWithoutExtension(arguments) + ".gxd"); if (!File.Exists(newresultfile)) { fi.MoveTo(newresultfile); } else { FileInfo fi1 = new FileInfo(newresultfile); fi1.Delete(); } IFileExtractResult res = new FileExtractResult(_subProductDef.Identify, newresultfile, false); results.Add(res); } return(results); }
private void 导出ToolStripMenuItem2_Click(object sender, EventArgs e) { ExportManager.ExportDataGridViewToExcel(dataGridView2, "待处理重量的单号"); }
static void Main(string[] args) { try { List <string> results = new List <string>(); string chartConfig = @"[{ ""type"": ""column2d"", ""renderAt"": ""chart-container"", ""width"": ""600"", ""height"": ""400"", ""dataFormat"": ""json"", ""dataSource"": { ""chart"": { ""caption"": ""Number of visitors last week"", ""subCaption"": ""Bakersfield Central vs Los Angeles Topanga"" }, ""data"": [{ ""label"": ""Mon"", ""value"": ""15123"" },{ ""label"": ""Tue"", ""value"": ""14233"" },{ ""label"": ""Wed"", ""value"": ""25507"" } ] } }, { ""type"": ""column2d"", ""renderAt"": ""chart-container"", ""width"": ""600"", ""height"": ""400"", ""dataFormat"": ""json"", ""dataSource"": { ""chart"": { ""caption"": ""Number of visitors last week"", ""subCaption"": ""Bakersfield Central vs Los Angeles Topanga"" }, ""data"": [{ ""label"": ""Mon"", ""value"": ""15123"" },{ ""label"": ""Tue"", ""value"": ""14233"" },{ ""label"": ""Wed"", ""value"": ""25507"" } ] } }]"; ExportConfig exportConfig = new ExportConfig(); using (ExportManager em = new ExportManager()) { exportConfig.Set("chartConfig", chartConfig); exportConfig.Set("type", "xlsx"); results.AddRange(em.Export(exportConfig)); } foreach (string path in results) { Console.WriteLine(path); Console.WriteLine("adasd"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.Read(); }
public ProductQuickView(string inFile) { _SourceFile = inFile; _OutFile = inFile.Substring(0, inFile.LastIndexOf(".")) + ".jpg"; _ExportMan = new ExportManager(); }
public ExportResultPack Export(OutputFormat format, IEnumerable <ISearchResult> result, ServiceKind serviceKind) { ExportResultPack pack = new ExportResultPack(); if (format.HasFlag(OutputFormat.Json)) { string folder = SettingManager.ExportOptionSetting.JsonFolderLocation; string fileName = SettingManager.ExportOptionSetting.JsonFileName; if (fileName.IsNullOrEmpty()) { AddLog("파일을 Json 형식으로 내보내기 실패했습니다. [파일명 입력란이 비어있습니다.]", TaskLogType.Failed); Dispatcher.Invoke(() => pack.JsonExportResult = JsonExportResult.Fail_FileNameNull); } else { if (Directory.Exists(folder)) { try { string fullPath = Path.Combine(folder, $"{fileName}{GetServiceString(serviceKind)}.json"); if (ExportManager.JsonExport(fullPath, result, SettingManager.ExportOptionSetting.JsonSort)) { AddLog($"Json으로 성공적으로 내보냈습니다. 저장 위치 : {fullPath}", TaskLogType.Complete); pack.JsonExportResult = JsonExportResult.Success; } else { AddLog($"Json으로 내보낼 파일 위치에 접근 실패했습니다. 위치 : {fullPath}", TaskLogType.Failed); pack.JsonExportResult = JsonExportResult.Fail_FileAccessDenied; } } catch (Exception ex) { AddLog($"Json으로 내보내던 중 알 수 없는 오류가 발생했습니다.{Environment.NewLine}{Environment.NewLine}{ex.ToString()}", TaskLogType.System); pack.JsonExportResult = JsonExportResult.Unknown; } } else { if (folder.IsNullOrEmpty()) { AddLog("파일을 Json 형식으로 내보내기 실패했습니다. [폴더 입력란이 비어있습니다.]", TaskLogType.Failed); pack.JsonExportResult = JsonExportResult.Fail_FileDirectoryNull; } else if (!Directory.Exists(folder)) { AddLog("파일을 Json 형식으로 내보내기 실패했습니다. [해당하는 경로가 없습니다.]", TaskLogType.Failed); pack.JsonExportResult = JsonExportResult.Fail_FileDirectoryNotExists; } } } } if (format.HasFlag(OutputFormat.CSV)) { string folder = SettingManager.ExportOptionSetting.CSVFolderLocation; string fileName = SettingManager.ExportOptionSetting.CSVFileName; if (fileName.IsNullOrEmpty()) { AddLog("파일을 CSV 형식으로 내보내기 실패했습니다. [파일명 입력란이 비어있습니다.]", TaskLogType.Failed); pack.CSVExportResult = CSVExportResult.Fail_FileNameNull; } else { if (Directory.Exists(folder)) { try { string fullPath = Path.Combine(folder, $"{fileName}{GetServiceString(serviceKind)}.csv"); if (ExportManager.CSVExport(fullPath, result)) { AddLog($"CSV로 성공적으로 내보냈습니다. 저장 위치 : {fullPath}", TaskLogType.Complete); pack.CSVExportResult = CSVExportResult.Success; } else { AddLog($"CSV로 내보낼 파일 위치에 접근 실패했습니다. 위치 : {fullPath}", TaskLogType.Failed); pack.CSVExportResult = CSVExportResult.Fail_FileAccessDenied; } } catch (Exception ex) { AddLog($"CSV로 내보내던 중 알 수 없는 오류가 발생했습니다.{Environment.NewLine}{Environment.NewLine}{ex.ToString()}", TaskLogType.System); pack.CSVExportResult = CSVExportResult.Unknown; } } else { if (folder.IsNullOrEmpty()) { AddLog("파일을 CSV 형식으로 내보내기 실패했습니다. [폴더 입력란이 비어있습니다.]", TaskLogType.Failed); pack.CSVExportResult = CSVExportResult.Fail_FileDirectoryNull; } else if (!Directory.Exists(folder)) { AddLog("파일을 CSV 형식으로 내보내기 실패했습니다. [해당하는 경로가 없습니다.]", TaskLogType.Failed); pack.CSVExportResult = CSVExportResult.Fail_FileDirectoryNotExists; } } } } if (format.HasFlag(OutputFormat.MySQL)) { pack.MySQLExportResult = MySQLExportResult.NotSet; MySQLFormat <ISearchResult> mySQLFormat = null; try { if (SettingManager.ExportOptionSetting.MySQLManualInput) { if (SettingManager.ExportOptionSetting.MySQLConnString.IsNullOrEmpty()) { AddLog("파일을 MySQL로 내보내기 실패했습니다. [데이터베이스 연결문이 입력되지 않았습니다.]", TaskLogType.Failed); pack.MySQLExportResult = MySQLExportResult.Fail_NotEnoughConnectData; } if (pack.MySQLExportResult == MySQLExportResult.NotSet) { mySQLFormat = new MySQLFormat <ISearchResult>(SettingManager.ExportOptionSetting.MySQLConnString); } } else { if (SettingManager.ExportOptionSetting.MySQLConnAddr.IsNullOrEmpty()) { AddLog("파일을 MySQL로 내보내기 실패했습니다. [연결 주소가 입력되지 않았습니다.]", TaskLogType.Failed); pack.MySQLExportResult = MySQLExportResult.Fail_NotEnoughConnectData; } else if (SettingManager.ExportOptionSetting.MySQLDatabaseName.IsNullOrEmpty()) { AddLog("파일을 MySQL로 내보내기 실패했습니다. [데이터베이스 이름이 입력되지 않았습니다.]", TaskLogType.Failed); pack.MySQLExportResult = MySQLExportResult.Fail_NotEnoughConnectData; } else if (SettingManager.ExportOptionSetting.MySQLUserID.IsNullOrEmpty()) { AddLog("파일을 MySQL로 내보내기 실패했습니다. [데이터베이스 사용자 이름이 입력되지 않았습니다.]", TaskLogType.Failed); pack.MySQLExportResult = MySQLExportResult.Fail_NotEnoughConnectData; } else if (SettingManager.ExportOptionSetting.MySQLUserPassword.IsNullOrEmpty()) { AddLog("파일을 MySQL로 내보내기 실패했습니다. [데이터베이스 사용자 비밀번호가 입력되지 않았습니다.]", TaskLogType.Failed); pack.MySQLExportResult = MySQLExportResult.Fail_NotEnoughConnectData; } if (pack.MySQLExportResult == MySQLExportResult.NotSet) { mySQLFormat = new MySQLFormat <ISearchResult>(SettingManager.ExportOptionSetting.MySQLConnAddr, SettingManager.ExportOptionSetting.MySQLUserID, SettingManager.ExportOptionSetting.MySQLUserPassword, SettingManager.ExportOptionSetting.MySQLDatabaseName); } } } catch (Exception) { } if (mySQLFormat == null) { AddLog("파일을 MySQL로 내보내기 실패했습니다. [데이터베이스 연결 정보중 하나가 잘못되었습니다.]", TaskLogType.Failed); } else { try { ExportManager.MySQLExport(result, mySQLFormat); AddLog("MySQL로 성공적으로 내보냈습니다.", TaskLogType.Complete); pack.MySQLExportResult = MySQLExportResult.Success; } catch (Exception ex) { AddLog("파일을 MySQL로 내보내기 실패했습니다. [알 수 없는 오류가 발생했습니다.]", TaskLogType.Failed); AddLog(ex.ToString(), TaskLogType.Failed); pack.MySQLExportResult = MySQLExportResult.Fail_UnkownError; } } } if (format.HasFlag(OutputFormat.AccessDB)) { string folder = SettingManager.ExportOptionSetting.AccessFolderLocation; string fileName = SettingManager.ExportOptionSetting.AccessFileName; if (fileName.IsNullOrEmpty()) { AddLog("파일을 Access DB 형식으로 내보내기 실패했습니다. [파일명 입력란이 비어있습니다.]", TaskLogType.Failed); pack.AccessExportResult = AccessExportResult.Fail_FileNameNull; } else { if (Directory.Exists(folder)) { try { string fullPath = Path.Combine(folder, $"{fileName}.accdb"); if (ExportManager.AccessDBExport(fullPath, result)) { AddLog($"Access DB로 성공적으로 내보냈습니다. 저장 위치 : {fullPath}", TaskLogType.Complete); pack.AccessExportResult = AccessExportResult.Success; } else { AddLog($"Access DB로 내보낼 파일 위치에 접근 실패했습니다. 위치 : {fullPath}", TaskLogType.Failed); pack.AccessExportResult = AccessExportResult.Fail_FileAccessDenied; } } catch (Exception ex) { AddLog($"파일을 Access DB로 내보내기 실패했습니다. [알 수 없는 오류가 발생했습니다.]", TaskLogType.Failed); AddLog(ex.ToString(), TaskLogType.Failed); pack.AccessExportResult = AccessExportResult.Unknown; } } else { if (folder.IsNullOrEmpty()) { AddLog("파일을 Access DB 형식으로 내보내기 실패했습니다. [폴더 입력란이 비어있습니다.]", TaskLogType.Failed); pack.AccessExportResult = AccessExportResult.Fail_FileDirectoryNull; } else if (!Directory.Exists(folder)) { AddLog("파일을 Access DB 형식으로 내보내기 실패했습니다. [해당하는 경로가 없습니다.]", TaskLogType.Failed); pack.AccessExportResult = AccessExportResult.Fail_FileDirectoryNotExists; } } } } return(pack); }
// Evernote has a bunch of junk in it's xml tomboy doesn't care about, and tomboy // also requires some specific tags. So strip out evernote's and add tomboys // TODO - Really, Really need to convert the html-like tags, not just strip them // TODO - so that we can keep things like bulleted lists, font sizes, etc public string CreateTomboyNoteContent(Evernote.EDAM.Type.Note note) { string evernoteContent; try { evernoteContent = _noteStore.getNoteContent(_authToken, note.Guid); } catch (Exception e) { evernoteContent = "Could not retrieve Evernote Content"; } ExportManager exportManager = new ExportManager(EvernoteToTomboyXSLTResourceName); string tomboyContent; try { tomboyContent = exportManager.ApplyXSL(evernoteContent, note.Title, null, ValidationType.DTD); } catch (Exception e) { tomboyContent = "Evernote Export failed." + " Please report a bug at http://bugzilla.gnome.org with the following: (strip out confidential information)" + e + "\n" + note; } string content = TomboyHeader + "\n" + "<title>" + note.Title + "</title>" + "<text xml:space=\"preserve\"><note-content version=\"0.1\">" + "\n"; content += tomboyContent; content += "</note-content></text>\n"; DateTime date; if (note.Updated > DateTime.MinValue.Ticks && note.Updated < DateTime.MaxValue.Ticks) { date = Epoch.Add(TimeSpan.FromTicks(note.Updated*10000)); } else { date = DateTime.Now; } content += "<last-change-date>" + date + "</last-change-date>\n"; content += "<last-metadata-change-date>" + date + "</last-metadata-change-date>\n"; if (note.Created > DateTime.MinValue.Ticks && note.Created < DateTime.MaxValue.Ticks) { date = Epoch.Add(TimeSpan.FromTicks(note.Created * 10000)); } content += "<create-date>" + date + "</create-date>\n"; content += "</note>"; return content; }
private IExtractResult JPAnaStatAlgorithm(Action <int, string> progressTracker) { string[] inputCurrentFiles = null; //= ExportManager.GetInstance().List.ToArray();//GetStringArray("RasterCurrentFile"); 由查询那里获得 string[] inputHistoryFiles = null; List <string> list1 = ExportManager.GetInstance().List; //得到的是从数据库里查询出来的周期数据 StatisticResultManager manager = StatisticResultManager.GetInstance(); List <StatisticResult> list = manager.List; List <string> list2 = manager.GetFilePathFromList(); //得到的是基于数据查询的数据又做的统计数; #region 获得目标区域 regionNames = _argumentProvider.GetArg("regionNames") as string; aoiContainer = new GeoDo.RSS.Core.VectorDrawing.AOIContainerLayer(); string fieldName; string shapeFilename; int fieldIndex = -1; List <string> fieldValues = new List <string>(); string regionsname = ""; using (frmStatSubRegionTemplates frm = new frmStatSubRegionTemplates()) { frm.listView1.MultiSelect = true; if (frm.ShowDialog() == DialogResult.OK) { Feature[] fets = frm.GetSelectedFeatures(); fets = frm.GetStatFeatures(out fieldName, out shapeFilename, out fieldIndex); if (fets == null) { aoiContainer = null; regionsname = "全国"; } else { string chinafieldValue = fets[0].GetFieldValue(fieldIndex); if (chinafieldValue == "中国") { aoiContainer = null; regionsname = "全国"; } else { foreach (Feature fet in fets) { fieldValues.Add(fet.GetFieldValue(fieldIndex)); //获得选择区域名称 aoiContainer.AddAOI(fet); } foreach (string region in fieldValues) { regionsname += region; } if (regionsname.Contains("西藏") && regionsname.Contains("青海")) { regionsname = "青藏地区"; } if (!string.IsNullOrEmpty(regionNames)) { regionsname = regionNames.Trim(); } } } } else { return(null); } } #endregion Regex DataReg = new Regex(@"(?<year>\d{4})", RegexOptions.Compiled); //处理后的数据存储路径 string savePath = _argumentProvider.GetArg("HistoryDataSave") as string; string jpsavepath = savePath + "\\" + "距平分析"; if (!System.IO.Directory.Exists(jpsavepath))//如果不存在这个路径 { System.IO.Directory.CreateDirectory(jpsavepath); } //参数设置 List <string> paraset = _argumentProvider.GetArg("paraSet") as List <string>; string[] paras = paraset.ToArray(); //先裁切分别算每个文件的雪水当量体积后再相减 string Nostr = ""; //排除非选择的轨道数据 if (paras[0] == "Ascend") { Nostr = "_D_"; } if (paras[0] == "Descend") { Nostr = "_A_"; } if (paras[1] == "winter") // inputCurrentFiles = manager.GetFilePathFromList() 冬季的数所是统计出来的。 { // inputHistoryFiles 需要再重新计算一次 *** 这是多对一计算距平 //比如说要算2000-2013年冬季的距平,需要先分别算出每年冬季的值,用这些值算总的均值。再分别用每年冬季减去总冬季值。 List <string> files = new List <string>(); foreach (string file in list2) { if (!Path.GetFileName(file).Contains(Nostr)) { files.Add(file); } if (file.Contains("MWSE")) { prdType = "SWE"; } else { prdType = "SD"; } } inputCurrentFiles = files.ToArray(); string outHistoryFile = jpsavepath + "\\" + Path.GetFileNameWithoutExtension(inputCurrentFiles[0]).Substring(0, 14) + "_" + paras[2] + ".dat"; SNWParaStat snwStat = new SNWParaStat(); snwStat.SNWParaAvgStat(inputCurrentFiles, 0.1f, outHistoryFile); List <string> temphistory = new List <string>(); temphistory.Add(outHistoryFile); inputHistoryFiles = temphistory.ToArray(); if (inputCurrentFiles == null || inputCurrentFiles.Length < 0 || inputHistoryFiles == null || inputHistoryFiles.Length < 0) { PrintInfo("缺少分析文件"); return(null); } } else { inputCurrentFiles = list1.ToArray(); inputHistoryFiles = list2.ToArray(); if (inputCurrentFiles[0].Contains("MWSE")) { prdType = "SWE"; } else { prdType = "SD"; } if (inputCurrentFiles == null || inputCurrentFiles.Length < 0 || inputHistoryFiles == null || inputHistoryFiles.Length < 0) { PrintInfo("缺少分析文件"); return(null); } if ((inputCurrentFiles.Length) * 2 != inputHistoryFiles.Length) { MessageBox.Show("当年数据与同期数据不对应"); return(null); } } #region 裁切文件 string clipsave = jpsavepath + "\\" + regionsname + "\\" + "裁切"; if (!System.IO.Directory.Exists(clipsave))//如果不存在这个路径 { System.IO.Directory.CreateDirectory(clipsave); } //体积文件SVOL存放路径 string svolPath = jpsavepath + "\\" + regionsname + "\\" + "体积文件"; if (!System.IO.Directory.Exists(svolPath)) { System.IO.Directory.CreateDirectory(svolPath); } //统计出的各个文件夹的数据放在txt文本里 string statxt = jpsavepath + "\\" + regionsname + "\\" + regionsname + ".txt"; FileStream fauto = new FileStream(statxt, FileMode.Create, FileAccess.Write); StreamWriter rauto = new StreamWriter(fauto); if (aoiContainer == null) { //不用裁切 直接计算 resultList.Clear(); if (paras[1] == "winter") { #region 冬季 //只返回一个体积和 double pixelSumWinter; // 总冬季雪水当量的体积和,是被减数 if (prdType == "SWE") { title = regionsname + "冬季雪水当量距平" + "(" + paras[2] + "年)"; string sumsweVolFile = svolPath + "\\" + Path.GetFileName(inputHistoryFiles[0]).Replace("MSWE", "SVOL"); if (!File.Exists(sumsweVolFile)) { IFileExtractResult sweVolResult = ComputeSnowSWEVOL(inputHistoryFiles[0], sumsweVolFile); sumsweVolFile = sweVolResult.FileName; } using (IRasterDataProvider inRaster = RasterDataDriver.Open(sumsweVolFile) as IRasterDataProvider) { pixelSumWinter = CompuCurPixel(sumsweVolFile); } foreach (string infile in inputCurrentFiles) { //MWS_JPEA_MSWE_China_Month_SWE_D_2011_2013_1_avg.dat Regex DataReg2 = new Regex(@"(?<year>\d{4})_(?<month>\d{2})_(?<year>\d{4})_(?<month>\d{1})", RegexOptions.Compiled); Match m = DataReg2.Match(infile); //提取每年冬季的时间 string year = ""; if (m.Success) { year = m.Value; } string mx = ""; //横轴时间 mx = year.Substring(0, 4) + "年"; string sweVolFile = svolPath + "\\" + Path.GetFileName(infile).Replace("MSWE", "SVOL"); if (!File.Exists(sweVolFile)) { IFileExtractResult sweVolResult = ComputeSnowSWEVOL(infile, sweVolFile); sweVolFile = sweVolResult.FileName; } double pixelSum;//只返回一个体积和 using (IRasterDataProvider inRaster = RasterDataDriver.Open(sweVolFile) as IRasterDataProvider) { pixelSum = CompuCurPixel(sweVolFile); } resultList.Add(new string[] { mx, ((pixelSum - pixelSumWinter) / pixelSumWinter * 100).ToString() + "%" }); rauto.WriteLine(mx + " " + ((pixelSum - pixelSumWinter) / pixelSumWinter * 100).ToString() + "%"); } } if (prdType == "SD") { title = regionsname + "冬季雪水当量距平" + "(" + paras[2] + "年)"; using (IRasterDataProvider inRaster = RasterDataDriver.Open(inputHistoryFiles[0]) as IRasterDataProvider) { pixelSumWinter = CompuCurPixel(inputHistoryFiles[0]); } foreach (string infile in inputCurrentFiles) { //MWS_JPEA_MSWE_China_Month_SD_D_2011_2013_1_avg.dat Regex DataReg2 = new Regex(@"(?<year>\d{4})_(?<month>\d{2})_(?<year>\d{4})_(?<month>\d{1})", RegexOptions.Compiled); Match m = DataReg2.Match(infile); //提取每年冬季的时间 string year = ""; if (m.Success) { year = m.Value; } string mx = ""; //横轴时间 mx = year.Substring(0, 4) + "年"; string sweVolFile = svolPath + "\\" + Path.GetFileName(infile).Replace("MSWE", "SVOL"); //只返回一个体积和 double pixelSum; using (IRasterDataProvider inRaster = RasterDataDriver.Open(infile) as IRasterDataProvider) { pixelSum = CompuCurPixel(infile); } resultList.Add(new string[] { mx, ((pixelSum - pixelSumWinter) / pixelSumWinter * 100).ToString() + "%" }); rauto.WriteLine(mx + " " + ((pixelSum - pixelSumWinter) / pixelSumWinter * 100).ToString() + "%"); } } } #endregion else { #region dang nian旬月 resultList.Clear(); foreach (string infile in inputCurrentFiles) { //先假设选择的是旬数据 MWS_MWSD_China_Xun_0SD_A_2011_1_avg.dat // 则同期旬数据 MWS_MWSD_China_Xun_0SD_A_1989_2011_1_avg.dat string cfile = Path.GetFileNameWithoutExtension(infile); Match m = DataReg.Match(cfile); string date = ""; if (m.Success) { date = m.Value; //根据年4个数字来拆分字符串 } string bhalf = cfile.Substring(0, cfile.IndexOf(date)); string ahalf = cfile.Substring(cfile.IndexOf(date) + 4, cfile.Length - 4 - cfile.IndexOf(date)); foreach (string inputHistoryFile in inputHistoryFiles) { string aa = Path.GetFileNameWithoutExtension(inputHistoryFile); double infilepixelSum = 0; //只返回一个体积和 double hisfilepixelSum; //只返回一个体积和 if (aa.Contains(bhalf) && aa.Contains(ahalf) && aa.Contains(date) && !aa.Contains(Nostr)) { #region 当前文件体积计算,并相减 if (prdType == "SWE") { string sweVolFile = svolPath + "\\" + Path.GetFileName(infile).Replace("MSWE", "SVOL"); if (!File.Exists(sweVolFile)) { IFileExtractResult sweVolResult = ComputeSnowSWEVOL(infile, sweVolFile); sweVolFile = sweVolResult.FileName; } using (IRasterDataProvider inRaster = RasterDataDriver.Open(sweVolFile) as IRasterDataProvider) { infilepixelSum = CompuCurPixel(sweVolFile); } #region 历史文件做裁切,体积计算,并相减 string hissweVolFile = svolPath + "\\" + Path.GetFileName(inputHistoryFile).Replace("MSWE", "SVOL"); if (!File.Exists(hissweVolFile)) { IFileExtractResult sweVolResult = ComputeSnowSWEVOL(inputHistoryFile, hissweVolFile); hissweVolFile = sweVolResult.FileName; } using (IRasterDataProvider inRaster = RasterDataDriver.Open(hissweVolFile) as IRasterDataProvider) { hisfilepixelSum = CompuCurPixel(hissweVolFile); } #endregion } else { using (IRasterDataProvider inRaster = RasterDataDriver.Open(infile) as IRasterDataProvider) { infilepixelSum = CompuCurPixel(infile); } using (IRasterDataProvider inRaster = RasterDataDriver.Open(inputHistoryFile) as IRasterDataProvider) { hisfilepixelSum = CompuCurPixel(inputHistoryFile); } } #endregion //提取年至avg之间的字符 string filetime = cfile.Substring(cfile.IndexOf(date), cfile.Length - 3 - cfile.IndexOf(date)); string[] mxchars = filetime.Split(new char[] { '_' }); string mx = "";//月+旬 if (cfile.Contains("Xun")) { title = regionsname + date + "年冬季雪水当量旬距平" + "(" + paras[2] + "年)"; if (mxchars[2] == "1") { mx = mxchars[1] + "月" + "上旬"; } if (mxchars[2] == "2") { mx = mxchars[1] + "月" + "中旬"; } if (mxchars[2] == "3") { mx = mxchars[1] + "月" + "下旬"; } } else if (cfile.Contains("Month")) { title = regionsname + date + "年冬季雪水当量月距平" + "(" + paras[2] + "年)"; mx = mxchars[1] + "月"; } else { mx = filetime; } resultList.Add(new string[] { mx, ((infilepixelSum - hisfilepixelSum) / hisfilepixelSum * 100).ToString() + "%" }); rauto.WriteLine(mx + " " + ((infilepixelSum - hisfilepixelSum) / hisfilepixelSum * 100).ToString() + "%"); } } } #endregion } } else //选择了aois { MulRegionsClip muticlip = new MulRegionsClip(); //裁切 if (paras[1] == "winter") { resultList.Clear(); double pixelSumWinter = 0d; // 总冬季雪水当量的体积和,是被减数 #region title = regionsname + "冬季雪水当量距平" + "(" + paras[2] + "年)"; //先把总的冬季给裁了 string newsumWinter = Path.Combine(clipsave, Path.GetFileName(inputHistoryFiles[0]).Replace("China", regionsname)); if (!File.Exists(newsumWinter)) { string sumWinter = muticlip.MutiRegionsClip(inputHistoryFiles[0], aoiContainer, clipsave); string hdrfile = Path.GetDirectoryName(sumWinter) + "\\" + Path.GetFileNameWithoutExtension(sumWinter) + ".hdr"; //重命名 string newhdrfile = Path.Combine(Path.GetDirectoryName(sumWinter), Path.GetFileNameWithoutExtension(inputHistoryFiles[0]).Replace("China", regionsname) + ".hdr"); FileInfo fi = new FileInfo(sumWinter); fi.MoveTo(newsumWinter); FileInfo fihdr = new FileInfo(hdrfile); fihdr.MoveTo(newhdrfile); } if (prdType == "SWE") { string sumsweVolFile = svolPath + "\\" + Path.GetFileName(newsumWinter).Replace("MSWE", "SVOL"); if (!File.Exists(sumsweVolFile)) { IFileExtractResult sweVolResult = ComputeSnowSWEVOL(newsumWinter, sumsweVolFile); sumsweVolFile = sweVolResult.FileName; } using (IRasterDataProvider inRaster = RasterDataDriver.Open(sumsweVolFile) as IRasterDataProvider) { pixelSumWinter = CompuCurPixel(sumsweVolFile); } } if (prdType == "SD") { using (IRasterDataProvider inRaster = RasterDataDriver.Open(inputHistoryFiles[0]) as IRasterDataProvider) { pixelSumWinter = CompuCurPixel(inputHistoryFiles[0]); } } foreach (string infile in inputCurrentFiles) { //MWS_JPEA_MSWE_China_Month_SWE_D_2011_2013_1_avg.dat Regex DataReg2 = new Regex(@"(?<year>\d{4})_(?<month>\d{2})_(?<year>\d{4})_(?<month>\d{1})", RegexOptions.Compiled); Match m = DataReg2.Match(infile); //提取每年冬季的时间 string year = ""; if (m.Success) { year = m.Value; } string mx = ""; //横轴时间 mx = year.Substring(0, 4) + "年"; string newclipfile = Path.Combine(clipsave, Path.GetFileName(infile).Replace("China", regionsname)); if (!File.Exists(newclipfile)) { string clipfile = muticlip.MutiRegionsClip(infile, aoiContainer, clipsave); string hdrfile = Path.GetDirectoryName(clipfile) + "\\" + Path.GetFileNameWithoutExtension(clipfile) + ".hdr"; //重命名 string newhdrfile = Path.Combine(Path.GetDirectoryName(clipfile), Path.GetFileNameWithoutExtension(infile).Replace("China", regionsname) + ".hdr"); FileInfo fi = new FileInfo(clipfile); fi.MoveTo(newclipfile); FileInfo fihdr = new FileInfo(hdrfile); fihdr.MoveTo(newhdrfile); } //只返回一个体积和 double pixelSum = 0d; if (prdType == "SWE") { string sweVolFile = svolPath + "\\" + Path.GetFileName(newclipfile).Replace("MSWE", "SVOL"); if (!File.Exists(sweVolFile)) { IFileExtractResult sweVolResult = ComputeSnowSWEVOL(newclipfile, sweVolFile); sweVolFile = sweVolResult.FileName; } using (IRasterDataProvider inRaster = RasterDataDriver.Open(sweVolFile) as IRasterDataProvider) { pixelSum = CompuCurPixel(sweVolFile); } } if (prdType == "SD") { using (IRasterDataProvider inRaster = RasterDataDriver.Open(infile) as IRasterDataProvider) { pixelSum = CompuCurPixel(infile); } } resultList.Add(new string[] { mx, ((pixelSum - pixelSumWinter) / pixelSumWinter * 100).ToString() + "%" }); rauto.WriteLine(mx + " " + ((pixelSum - pixelSumWinter) / pixelSumWinter).ToString()); } } #endregion else //选择的是旬、月 { #region resultList.Clear(); foreach (string infile in inputCurrentFiles) { //先假设选择的是旬数据 MWS_MWSD_China_Xun_0SD_A_2011_1_avg.dat // 则同期旬数据 MWS_MWSD_China_Xun_0SD_A_1989_2011_1_avg.dat string cfile = Path.GetFileNameWithoutExtension(infile); Match m = DataReg.Match(cfile); string date = ""; if (m.Success) { date = m.Value; //根据年4个数字来拆分字符串 } string bhalf = cfile.Substring(0, cfile.IndexOf(date)); string ahalf = cfile.Substring(cfile.IndexOf(date) + 4, cfile.Length - 4 - cfile.IndexOf(date)); foreach (string inputHistoryFile in inputHistoryFiles) { string aa = Path.GetFileNameWithoutExtension(inputHistoryFile); if (aa.Contains(bhalf) && aa.Contains(ahalf) && aa.Contains(date) && !aa.Contains(Nostr)) { //只返回一个体积和 double infilepixelSum; //当前文件做裁切,体积计算,并相减 #region string newclipfile = Path.Combine(clipsave, Path.GetFileName(infile).Replace("China", regionsname)); if (!File.Exists(newclipfile)) { string clipfile = muticlip.MutiRegionsClip(infile, aoiContainer, clipsave); string hdrfile = Path.GetDirectoryName(clipfile) + "\\" + Path.GetFileNameWithoutExtension(clipfile) + ".hdr"; //重命名 string newhdrfile = Path.Combine(Path.GetDirectoryName(clipfile), Path.GetFileNameWithoutExtension(infile).Replace("China", regionsname) + ".hdr"); FileInfo fi = new FileInfo(clipfile); fi.MoveTo(newclipfile); FileInfo fihdr = new FileInfo(hdrfile); fihdr.MoveTo(newhdrfile); } if (prdType == "SWE") { string sweVolFile = svolPath + "\\" + Path.GetFileName(newclipfile).Replace("MSWE", "SVOL"); if (!File.Exists(sweVolFile)) { IFileExtractResult sweVolResult = ComputeSnowSWEVOL(newclipfile, sweVolFile); sweVolFile = sweVolResult.FileName; } using (IRasterDataProvider inRaster = RasterDataDriver.Open(sweVolFile) as IRasterDataProvider) { infilepixelSum = CompuCurPixel(sweVolFile); } } else { using (IRasterDataProvider inRaster = RasterDataDriver.Open(newclipfile) as IRasterDataProvider) { infilepixelSum = CompuCurPixel(newclipfile); } } #endregion //历史文件做裁切,体积计算,并相减 #region //只返回一个体积和 double hisfilepixelSum; string newhisclipfile = Path.Combine(clipsave, Path.GetFileName(inputHistoryFile).Replace("China", regionsname)); if (!File.Exists(newhisclipfile)) { string clipfile = muticlip.MutiRegionsClip(inputHistoryFile, aoiContainer, clipsave); string hdrfile = Path.GetDirectoryName(clipfile) + "\\" + Path.GetFileNameWithoutExtension(clipfile) + ".hdr"; //重命名 string newhdrfile = Path.Combine(Path.GetDirectoryName(clipfile), Path.GetFileNameWithoutExtension(inputHistoryFile).Replace("China", regionsname) + ".hdr"); FileInfo fi = new FileInfo(clipfile); fi.MoveTo(newhisclipfile); FileInfo fihdr = new FileInfo(hdrfile); fihdr.MoveTo(newhdrfile); } if (prdType == "SWE") { string hissweVolFile = svolPath + "\\" + Path.GetFileName(newhisclipfile).Replace("MSWE", "SVOL"); if (!File.Exists(hissweVolFile)) { IFileExtractResult sweVolResult = ComputeSnowSWEVOL(newhisclipfile, hissweVolFile); hissweVolFile = sweVolResult.FileName; } using (IRasterDataProvider inRaster = RasterDataDriver.Open(hissweVolFile) as IRasterDataProvider) { hisfilepixelSum = CompuCurPixel(hissweVolFile); } } else { using (IRasterDataProvider inRaster = RasterDataDriver.Open(newhisclipfile) as IRasterDataProvider) { hisfilepixelSum = CompuCurPixel(newhisclipfile); } } #endregion //提取年至avg之间的字符 string filetime = cfile.Substring(cfile.IndexOf(date), cfile.Length - 3 - cfile.IndexOf(date)); string[] mxchars = filetime.Split(new char[] { '_' }); string mx = "";//月+旬 if (cfile.Contains("Xun")) { title = regionsname + date + "年冬季雪水当量旬距平" + "(" + paras[2] + "年)"; if (mxchars[2] == "1") { mx = mxchars[1] + "月" + "上旬"; } if (mxchars[2] == "2") { mx = mxchars[1] + "月" + "中旬"; } if (mxchars[2] == "3") { mx = mxchars[1] + "月" + "下旬"; } } else if (cfile.Contains("Month")) { title = regionsname + date + "年冬季雪水当量月距平" + "(" + paras[2] + "年)"; mx = mxchars[1] + "月"; } else { mx = filetime; } resultList.Add(new string[] { mx, ((infilepixelSum - hisfilepixelSum) / hisfilepixelSum * 100).ToString() + "%" }); rauto.WriteLine(mx + " " + ((infilepixelSum - hisfilepixelSum) / hisfilepixelSum).ToString()); } } } #endregion } } rauto.Close(); fauto.Close(); string coluString = regionsname; string sentitle = "统计日期:" + DateTime.Now.ToShortDateString(); string[] columns = new string[] { coluString, "距平" }; fresult = new StatResult(sentitle, columns, resultList.ToArray()); string outputIdentify = regionsname; string fileexcel = StatResultToFile(new string[] { inputCurrentFiles[0] }, fresult, "MWS", outputIdentify, title, null, 1, true, 1); string newexcelfile = Path.Combine(svolPath, title + ".XLSX");//inputCurrentFiles[0].Substring(0,9) + "_"+ regionsname + paras[2]+ ".XLSX"); FileInfo fi1 = new FileInfo(fileexcel); fi1.MoveTo(newexcelfile); IFileExtractResult res = new FileExtractResult(_subProductDef.Identify, newexcelfile, false); return(new FileExtractResult(outputIdentify, newexcelfile)); #endregion }
private Evernote.EDAM.Type.Note FillEvernote(Note tomboynote, Evernote.EDAM.Type.Note evernote) { Logger.Debug("[Evernote] Creating new Evernote from tomboy:" + tomboynote.Id.ToString()); if (evernote.Attributes == null) { evernote.Attributes = new NoteAttributes(); } evernote.Attributes.SourceApplication = "tomboy"; //this note came from tomboy. This is read later to match guids evernote.Attributes.Source = tomboynote.Id; ExportManager exportManager = new ExportManager(TomboyToEvernoteXSLTResourceName); string mycontent = exportManager.ApplyXSL(tomboynote); string content = mycontent; evernote.Content += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml.dtd\">"; evernote.Content += content; try { ValidateXML(evernote.Content); } catch (Exception e) { Logger.Error("[Evernote] Could not validate XML: " + evernote.Content); } evernote.Title = tomboynote.Title; if (tomboynote.Tags.Count > 0) { evernote.TagNames = new List<string>(); foreach (Tag tag in tomboynote.Tags) { evernote.TagNames.Add(tag.Name); } } evernote.NotebookGuid = _tomboyNotebook.Guid; evernote.Created = (long)tomboynote.CreateDate.Subtract(Epoch).TotalMilliseconds; evernote.Updated = (long)tomboynote.ChangeDate.Subtract(Epoch).TotalMilliseconds; return evernote; }
public ExportServices(User pUser) { _user = pUser; _exportManager = new ExportManager(_user); }
private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Cef.EnableHighDPISupport(); WindowRestoreMessage = NativeMethods.RegisterWindowMessage("TweetDuckRestore"); SubProcessMessage = NativeMethods.RegisterWindowMessage("TweetDuckSubProcess"); if (!WindowsUtils.CheckFolderWritePermission(StoragePath)) { FormMessage.Warning("Permission Error", "TweetDuck does not have write permissions to the storage folder: " + StoragePath, FormMessage.OK); return; } if (Arguments.HasFlag(Arguments.ArgRestart)) { LockManager.Result lockResult = LockManager.LockWait(10000); while (lockResult != LockManager.Result.Success) { if (lockResult == LockManager.Result.Fail) { FormMessage.Error("TweetDuck Has Failed :(", "An unknown error occurred accessing the data folder. Please, make sure TweetDuck is not already running. If the problem persists, try restarting your system.", FormMessage.OK); return; } else if (!FormMessage.Warning("TweetDuck Cannot Restart", "TweetDuck is taking too long to close.", FormMessage.Retry, FormMessage.Exit)) { return; } lockResult = LockManager.LockWait(5000); } } else { LockManager.Result lockResult = LockManager.Lock(); if (lockResult == LockManager.Result.HasProcess) { if (!LockManager.RestoreLockingProcess(2000) && FormMessage.Error("TweetDuck is Already Running", "Another instance of TweetDuck is already running.\nDo you want to close it?", FormMessage.Yes, FormMessage.No)) { if (!LockManager.CloseLockingProcess(10000, 5000)) { FormMessage.Error("TweetDuck Has Failed :(", "Could not close the other process.", FormMessage.OK); return; } lockResult = LockManager.Lock(); } else { return; } } if (lockResult != LockManager.Result.Success) { FormMessage.Error("TweetDuck Has Failed :(", "An unknown error occurred accessing the data folder. Please, make sure TweetDuck is not already running. If the problem persists, try restarting your system.", FormMessage.OK); return; } } UserConfig = UserConfig.Load(UserConfigFilePath); SystemConfig = SystemConfig.Load(SystemConfigFilePath); if (Arguments.HasFlag(Arguments.ArgImportCookies)) { ExportManager.ImportCookies(); } else if (Arguments.HasFlag(Arguments.ArgDeleteCookies)) { ExportManager.DeleteCookies(); } if (Arguments.HasFlag(Arguments.ArgUpdated)) { WindowsUtils.TryDeleteFolderWhenAble(InstallerPath, 8000); } CefSharpSettings.WcfEnabled = false; CefSettings settings = new CefSettings { AcceptLanguageList = BrowserUtils.HeaderAcceptLanguage, UserAgent = BrowserUtils.HeaderUserAgent, Locale = Arguments.GetValue(Arguments.ArgLocale, string.Empty), BrowserSubprocessPath = BrandName + ".Browser.exe", CachePath = StoragePath, LogFile = ConsoleLogFilePath, #if !DEBUG LogSeverity = Arguments.HasFlag(Arguments.ArgLogging) ? LogSeverity.Info : LogSeverity.Disable #endif }; CommandLineArgs.ReadCefArguments(UserConfig.CustomCefArgs).ToDictionary(settings.CefCommandLineArgs); BrowserUtils.SetupCefArgs(settings.CefCommandLineArgs); Cef.Initialize(settings, false, new BrowserProcessHandler()); Application.ApplicationExit += (sender, args) => ExitCleanup(); UpdaterSettings updaterSettings = new UpdaterSettings { AllowPreReleases = Arguments.HasFlag(Arguments.ArgDebugUpdates), DismissedUpdate = UserConfig.DismissedUpdate, InstallerDownloadFolder = InstallerPath }; FormBrowser mainForm = new FormBrowser(updaterSettings); Application.Run(mainForm); if (mainForm.UpdateInstallerPath != null) { ExitCleanup(); // ProgramPath has a trailing backslash string updaterArgs = "/SP- /SILENT /CLOSEAPPLICATIONS /UPDATEPATH=\"" + ProgramPath + "\" /RUNARGS=\"" + Arguments.GetCurrentForInstallerCmd() + "\"" + (IsPortable ? " /PORTABLE=1" : ""); bool runElevated = !IsPortable || !WindowsUtils.CheckFolderWritePermission(ProgramPath); if (WindowsUtils.OpenAssociatedProgram(mainForm.UpdateInstallerPath, updaterArgs, runElevated)) { Application.Exit(); } else { RestartWithArgsInternal(Arguments.GetCurrentClean()); } } }
public void Export(Total total, string fpath) { ExportManager em = new ExportManager(); em.Export(total, fpath); }
public ExportDialog(ExportManager manager) { InitializeComponent(); DataContext = manager; manager.OnExit = Close; }
public ExportController(ExportManager exportManager, IWebHostEnvironment env) { _exportManager = exportManager; _env = env; }
private IExtractResult HistoryDataStatAlgorithm(Action <int, string> progressTracker) { //1、获取数据 List <string> list = ExportManager.GetInstance().List; string[] fname = list.ToArray(); //再加一上基于 同期统计数据 StatisticResultManager manager = StatisticResultManager.GetInstance(); List <string> list2 = manager.GetFilePathFromList(); //得到的是基于数据查询的数据又做的统计数据 if (list2.Count != 0) { fname = list2.ToArray(); period = "yes"; Match m = DataReg2.Match(fname[0]); if (m.Success) { Iswinter = "yes"; } } //这里要对文件进行一下裁切//处理后的数据存储路径 string savePath = _argumentProvider.GetArg("HistoryDataSave") as string; regionNames = _argumentProvider.GetArg("regionNames") as string; string orbitType = _argumentProvider.GetArg("OrbitType") as string; string Str = null; if (orbitType == "Ascend") { Str = "_A_"; } if (orbitType == "Descend") { Str = "_D_"; } //同期统计计算传出来的文件没有分升降轨,这里进行区分 List <string> fnamelist = new List <string>(); foreach (string file in fname) { if (Path.GetFileName(file).Contains(Str)) { fnamelist.Add(file); } } fname = fnamelist.ToArray(); //2.确定选择区域,没有选或者中国区域不要用裁,如果是其地区首先裁切,并且放到指定文件夹下 aoiContainer = new GeoDo.RSS.Core.VectorDrawing.AOIContainerLayer(); MulRegionsClip muticlip = new MulRegionsClip(); //裁切 string regionsname = ""; IStatResult fresult = null; using (frmStatSubRegionTemplates frm = new frmStatSubRegionTemplates()) { frm.listView1.MultiSelect = true; if (frm.ShowDialog() == DialogResult.OK) { Feature[] fets = frm.GetSelectedFeatures(); if (fets == null) { #region 没选中任何矢量 regionsname = "全国"; resultList.Clear(); //体积文件SVOL存放路径 string svolPath = savePath + "\\" + regionsname + "\\" + "体积文件"; if (!System.IO.Directory.Exists(svolPath)) { System.IO.Directory.CreateDirectory(svolPath); } //统计出的各个文件夹的数据放在txt文本里 string statxt = savePath + "\\" + regionsname + "\\" + regionsname + ".txt"; FileStream fauto = new FileStream(statxt, FileMode.Create, FileAccess.Write); StreamWriter rauto = new StreamWriter(fauto); //直接对当前中国区域数据做统计 //提取年至avg之间的字符 string filetime = ""; string startDate = ""; string endDate = ""; foreach (string infile in fname) { //解析文件名确定时间 string filename = Path.GetFileNameWithoutExtension(infile); Regex DataReg = new Regex(@"(?<year>\d{4})", RegexOptions.Compiled); Match m = DataReg.Match(filename); string year = ""; if (m.Success) { year = m.Value; } //提取年至avg之间的字符 filetime = filename.Substring(filename.IndexOf(year), filename.Length - 3 - filename.IndexOf(year)); string[] mxchars = filetime.Split(new char[] { '_' }); string mx = ""; //月+旬 if (mxchars.Length == 5 && !filename.Contains("Xun")) //手动统计叫 MWS_MWSD_China_Month_0SD_D_1987_11_1988_2_avg.dat 冬季 { mx = year; } else if (mxchars.Length == 4)// MWS_MWSD_China_Month_0SD_D_1987_1988_2_avg.dat { //mx = year + "_" + mx[0] + "年" + mx[2] + "月"; mx = mx[2] + "月"; } else if (mxchars.Length == 5 && filename.Contains("Xun"))// MWS_MWSD_China_Month_0SD_D_1987_1988_2_1_avg.dat { if (mxchars[3] == "1") { mx = mxchars[2] + "月" + "上旬"; } if (mxchars[3] == "2") { mx = mxchars[2] + "月" + "中旬"; } if (mxchars[3] == "3") { mx = mxchars[2] + "月" + "下旬"; } } else { if (filename.Contains("Xun")) { if (mxchars[2] == "1") { mx = mxchars[1] + "月" + "上旬"; } if (mxchars[2] == "2") { mx = mxchars[1] + "月" + "中旬"; } if (mxchars[2] == "3") { mx = mxchars[1] + "月" + "下旬"; } } if (filename.Contains("Month")) { mx = mxchars[1] + "月"; } } #region 获得excel文件名上时间标识 if (infile == fname[0]) { startDate = year + mx; } if (infile == fname[fname.Length - 1]) { endDate = year + mx; } #endregion string sweVolFile = svolPath + "\\" + Path.GetFileName(infile).Replace("MSWE", "SVOL"); if (!File.Exists(sweVolFile)) { IFileExtractResult sweVolResult = ComputeSnowSWEVOL(infile, sweVolFile); sweVolFile = sweVolResult.FileName; } //只返回一个体积和 double pixelSum; using (IRasterDataProvider inRaster = RasterDataDriver.Open(sweVolFile) as IRasterDataProvider) { pixelSum = CompuCurPixel(sweVolFile); } resultList.Add(new string[] { mx, (pixelSum / 100000000).ToString() }); rauto.WriteLine(mx + " " + (pixelSum / 100000000).ToString()); } rauto.Close(); fauto.Close(); string coluString = regionsname; string sentitle = "统计日期:" + DateTime.Now.ToShortDateString(); string[] columns = new string[] { coluString, "累计雪水当量体积(亿立方米)" }; fresult = new StatResult(sentitle, columns, resultList.ToArray()); string outputIdentify = regionsname;// _argumentProvider.GetArg("OutFileIdentify").ToString(); string title = coluString + "时间序列雪水当量体积统计" + startDate + "_" + endDate; string fileexcel = StatResultToFile(new string[] { fname[0] }, fresult, "MWS", outputIdentify, title, null, 1, true, 1); string newexcelfile = Path.Combine(svolPath, Path.GetFileNameWithoutExtension(fname[0]).Replace(filetime, startDate + "_" + endDate) + ".XLSX"); FileInfo fi = new FileInfo(fileexcel); fi.MoveTo(newexcelfile); IFileExtractResult res = new FileExtractResult(_subProductDef.Identify, newexcelfile, false); return(new FileExtractResult(outputIdentify, newexcelfile)); } #endregion else { string fieldName; string shapeFilename; int fieldIndex = -1; List <string> fieldValues = new List <string>(); fets = frm.GetStatFeatures(out fieldName, out shapeFilename, out fieldIndex); string chinafieldValue = fets[0].GetFieldValue(fieldIndex); //提取年至avg之间的字符 string filetime = ""; string startDate = ""; string endDate = ""; if (chinafieldValue == "中国") { #region 中中国矢量 //直接对当前中国区域数据做统计 regionsname = "全国"; resultList.Clear(); //体积文件SVOL存放路径 string svolPath = savePath + "\\" + regionsname + "\\" + "体积文件"; if (!System.IO.Directory.Exists(svolPath)) { System.IO.Directory.CreateDirectory(svolPath); } //统计出的各个文件夹的数据放在txt文本里 string statxt = savePath + "\\" + regionsname + "\\" + regionsname + ".txt"; FileStream fauto = new FileStream(statxt, FileMode.Create, FileAccess.Write); StreamWriter rauto = new StreamWriter(fauto); //直接对当前中国区域数据做统计 foreach (string infile in fname) { //解析文件名确定时间 string filename = Path.GetFileNameWithoutExtension(infile); Regex DataReg = new Regex(@"(?<year>\d{4})", RegexOptions.Compiled); Match m = DataReg.Match(filename); string year = ""; if (m.Success) { year = m.Value; } //提取年至avg之间的字符 filetime = filename.Substring(filename.IndexOf(year), filename.Length - 3 - filename.IndexOf(year)); string[] mxchars = filetime.Split(new char[] { '_' }); string mx = ""; //月+旬 if (mxchars.Length == 5 && !filename.Contains("Xun")) //手动统计叫 MWS_MWSD_China_Month_0SD_D_1987_11_1988_2_avg.dat 冬季 { mx = year; } else if (mxchars.Length == 4)// MWS_MWSD_China_Month_0SD_D_1987_1988_2_avg.dat { //mx = year + "_" + mx[0] + "年" + mx[2] + "月"; mx = mx[2] + "月"; } else if (mxchars.Length == 5 && filename.Contains("Xun"))// MWS_MWSD_China_Month_0SD_D_1987_1988_2_1_avg.dat { if (mxchars[3] == "1") { mx = mxchars[2] + "月" + "上旬"; } if (mxchars[3] == "2") { mx = mxchars[2] + "月" + "中旬"; } if (mxchars[3] == "3") { mx = mxchars[2] + "月" + "下旬"; } } else { if (filename.Contains("Xun")) { if (mxchars[2] == "1") { mx = mxchars[1] + "月" + "上旬"; } if (mxchars[2] == "2") { mx = mxchars[1] + "月" + "中旬"; } if (mxchars[2] == "3") { mx = mxchars[1] + "月" + "下旬"; } } if (filename.Contains("Month")) { mx = mxchars[1] + "月"; } } //获得excel文件名上的时间标识 #region if (infile == fname[0]) { startDate = year + mx; } if (infile == fname[fname.Length - 1]) { endDate = year + mx; } #endregion string sweVolFile = svolPath + "\\" + Path.GetFileName(infile).Replace("MSWE", "SVOL"); if (!File.Exists(sweVolFile)) { IFileExtractResult sweVolResult = ComputeSnowSWEVOL(infile, sweVolFile); sweVolFile = sweVolResult.FileName; } //只返回一个体积和 double pixelSum; using (IRasterDataProvider inRaster = RasterDataDriver.Open(sweVolFile) as IRasterDataProvider) { pixelSum = CompuCurPixel(sweVolFile); } resultList.Add(new string[] { mx, (pixelSum / 100000000).ToString() }); rauto.WriteLine(mx + " " + (pixelSum / 100000000).ToString()); } rauto.Close(); fauto.Close(); string coluString = regionsname; string sentitle = "统计日期:" + DateTime.Now.ToShortDateString(); string[] columns = new string[] { coluString, "累计雪水当量体积(亿立方米)" }; fresult = new StatResult(sentitle, columns, resultList.ToArray()); string outputIdentify = regionsname;// _argumentProvider.GetArg("OutFileIdentify").ToString(); string title = coluString + "时间序列雪水当量体积统计"; string fileexcel = StatResultToFile(new string[] { fname[0] }, fresult, "MWS", outputIdentify, title, null, 1, true, 1); string newexcelfile = Path.Combine(svolPath, Path.GetFileNameWithoutExtension(fname[0]).Replace(filetime, startDate + "_" + endDate) + ".XLSX"); FileInfo fi = new FileInfo(fileexcel); fi.MoveTo(newexcelfile); IFileExtractResult res = new FileExtractResult(_subProductDef.Identify, newexcelfile, false); return(new FileExtractResult(outputIdentify, newexcelfile)); } #endregion else { #region 中非中国矢量 resultList.Clear(); foreach (Feature fet in fets) { fieldValues.Add(fet.GetFieldValue(fieldIndex)); //获得选择区域名称 aoiContainer.AddAOI(fet); } foreach (string region in fieldValues) { regionsname += region; } if (regionsname.Contains("西藏") && regionsname.Contains("青海")) { regionsname = "青藏地区"; } if (!string.IsNullOrEmpty(regionNames)) { regionsname = regionNames.Trim(); } //创建裁切路径 string clipsave = savePath + "\\" + regionsname + "\\" + "裁切"; if (!System.IO.Directory.Exists(clipsave))//如果不存在这个路径 { System.IO.Directory.CreateDirectory(clipsave); } //体积文件SVOL存放路径 string svolPath = savePath + "\\" + regionsname + "\\" + "体积文件"; if (!System.IO.Directory.Exists(svolPath)) { System.IO.Directory.CreateDirectory(svolPath); } //统计出的各个文件夹的数据放在txt文本里 string statxt = savePath + "\\" + regionsname + "\\" + regionsname + ".txt"; FileStream fauto = new FileStream(statxt, FileMode.Create, FileAccess.Write); StreamWriter rauto = new StreamWriter(fauto); string excelYear = ""; string file1Time = ""; foreach (string infile in fname) { //解析文件名确定时间 string filename = Path.GetFileNameWithoutExtension(infile); Regex DataReg = new Regex(@"(?<year>\d{4})", RegexOptions.Compiled); Match m = DataReg.Match(filename); string year = ""; if (m.Success) { year = m.Value; } //提取年至avg之间的字符 filetime = filename.Substring(filename.IndexOf(year), filename.Length - 3 - filename.IndexOf(year)); string[] mxchars = filetime.Split(new char[] { '_' }); string mx = ""; //月+旬 if (mxchars.Length == 5 && !filename.Contains("Xun")) // MWS_MWSD_China_Month_0SD_D_1987_11_1988_2_avg.dat 冬季 { mx = year; excelYear = year + "年-" + mxchars[2] + "年冬季"; } else if (mxchars.Length == 4 && !filename.Contains("Xun"))// MWS_MWSD_China_Month_0SD_D_1987_1988_2_avg.dat { mx = mxchars[2] + "月"; excelYear = year + "年-" + mxchars[1] + "年"; } else if (mxchars.Length == 5 && filename.Contains("Xun"))// MWS_MWSD_China_Xun_0SD_D_1987_1988_2_1_avg.dat { if (mxchars[3] == "1") { mx = mxchars[2] + "月" + "上旬"; } if (mxchars[3] == "2") { mx = mxchars[2] + "月" + "中旬"; } if (mxchars[3] == "3") { mx = mxchars[2] + "月" + "下旬"; } excelYear = year + "年-" + mxchars[1] + "年"; } else { if (filename.Contains("Xun")) //旬MWS_MSWE_China_Xun_SWE_A_2011_1_1_avg.dat { if (mxchars[2] == "1") { mx = mxchars[1] + "月" + "上旬"; } if (mxchars[2] == "2") { mx = mxchars[1] + "月" + "中旬"; } if (mxchars[2] == "3") { mx = mxchars[1] + "月" + "下旬"; } excelYear = year + "年"; } if (filename.Contains("Month"))//月MWS_MSWE_China_Month_SWE_A_2011_1_avg.dat { mx = mxchars[1] + "月"; excelYear = year + "年"; } } #region 获得excel文件名上的时间标识 if (infile == fname[0]) { startDate = year; file1Time = filetime; } if (infile == fname[fname.Length - 1]) { endDate = year; } #endregion string newclipfile = Path.Combine(clipsave, Path.GetFileName(infile).Replace("China", regionsname)); if (!File.Exists(newclipfile)) { string clipfile = muticlip.MutiRegionsClip(infile, aoiContainer, clipsave); string hdrfile = Path.GetDirectoryName(clipfile) + "\\" + Path.GetFileNameWithoutExtension(clipfile) + ".hdr"; //重命名 //string newclipfile = Path.Combine(Path.GetDirectoryName(clipfile), Path.GetFileName(infile).Replace("China", regionsname)); string newhdrfile = Path.Combine(Path.GetDirectoryName(clipfile), Path.GetFileNameWithoutExtension(infile).Replace("China", regionsname) + ".hdr"); FileInfo fi = new FileInfo(clipfile); fi.MoveTo(newclipfile); FileInfo fihdr = new FileInfo(hdrfile); fihdr.MoveTo(newhdrfile); } string sweVolFile = svolPath + "\\" + Path.GetFileName(newclipfile).Replace("MSWE", "SVOL"); if (!File.Exists(sweVolFile)) { IFileExtractResult sweVolResult = ComputeSnowSWEVOL(newclipfile, sweVolFile); sweVolFile = sweVolResult.FileName; } //只返回一个体积和 double pixelSum; using (IRasterDataProvider inRaster = RasterDataDriver.Open(sweVolFile) as IRasterDataProvider) { pixelSum = CompuCurPixel(sweVolFile); } resultList.Add(new string[] { mx, (pixelSum / 100000000).ToString() }); rauto.WriteLine(mx + " " + (pixelSum / 100000000).ToString()); } rauto.Close(); fauto.Close(); string coluString = regionsname; string sentitle = "统计日期:" + DateTime.Now.ToShortDateString(); string[] columns = new string[] { coluString, "累计雪水当量体积(亿立方米)" }; fresult = new StatResult(sentitle, columns, resultList.ToArray()); string outputIdentify = regionsname;// _argumentProvider.GetArg("OutFileIdentify").ToString(); //string title = coluString + excelYear+ "雪水当量体积统计"; string title = coluString + startDate + "-" + endDate + "雪水当量体积统计"; string fileexcel = StatResultToFile(new string[] { fname[0] }, fresult, "MWS", outputIdentify, title, null, 1, true, 1); string newexcelfile = Path.Combine(svolPath, Path.GetFileNameWithoutExtension(fname[0]).Replace(file1Time, startDate + "_" + endDate) + ".XLSX"); FileInfo fi1 = new FileInfo(fileexcel); fi1.MoveTo(newexcelfile); IFileExtractResult res = new FileExtractResult(_subProductDef.Identify, newexcelfile, false); return(new FileExtractResult(outputIdentify, newexcelfile)); #endregion } } } //没有点确定 else { return(null); } } }
public void ExportManagerLanguagesTest() { // Arrange var context = new ExportImportContext(); context.Settings.Languages = new Languages(); context.Settings.Languages.Add("sv"); var exportManager = new ExportManager(new List<IExporter>(), context.SiteIdentityLoaderMock.Object, context.Settings); // Act var languages = exportManager.GetLanguages(); // Assert Assert.Equal(2, languages.Count); Assert.Equal(new Guid(Helpers.AllLanguages), new Guid(languages[0].Id)); Assert.Equal("sv", languages[1].Id); }
public void ExportManagerDeleteTest() { // Arrange var context = new ExportImportContext(); context.SetupAutocompletes(23); context.SetupRelatedQueries(12); var exporters = new List<IExporter> { context.AutocompleteExporter, context.RelatedQueryExporter }; var exportManager = new ExportManager(exporters, context.SiteIdentityLoaderMock.Object, context.Settings); // Act exportManager.Delete(new List<string> { context.AutocompleteExporter.EntityKey }, Helpers.AllSitesId, Helpers.AllLanguages); // Assert Assert.Equal(0, context.Autocompletes.Count); Assert.Equal(12, context.RelatedQueries.Count); }
public void ExportManagerSitesTest() { // Arrange var context = new ExportImportContext(); var testSiteIdentity = new SiteIdentity { Id = Guid.NewGuid(), Name = "TestSite", RootPage = "123", StartPage = "456" }; context.SiteIdentityLoaderMock.SetupGet(l => l.SiteIdentites).Returns(new List<SiteIdentity> { testSiteIdentity}); var exportManager = new ExportManager(new List<IExporter>(), context.SiteIdentityLoaderMock.Object, context.Settings); // Act var sites = exportManager.GetSites(); // Assert Assert.Equal(2, sites.Count); Assert.Equal(Helpers.AllSitesId, sites[0].Id); Assert.Equal(testSiteIdentity.Id.ToString(), sites[1].Id); }
private IExtractResult JuPingAnalysisAlgorithm(Action <int, string> progressTracker) { string[] inputCurrentFiles = null; //= ExportManager.GetInstance().List.ToArray();//GetStringArray("RasterCurrentFile"); 由查询那里获得 string[] inputHistoryFiles = null; List <string> list1 = ExportManager.GetInstance().List; //得到的是从数据库里查询出来的周期数据 StatisticResultManager manager = StatisticResultManager.GetInstance(); List <StatisticResult> list = manager.List; List <string> list2 = manager.GetFilePathFromList(); //得到的是基于数据查询的数据又做的统计数据 regionNames = _argumentProvider.GetArg("regionNames") as string; //处理后的数据,用它来出专题图 List <string> afterProcessfiles = new List <string>(); #region 获得目标区域 aoiContainer = new GeoDo.RSS.Core.VectorDrawing.AOIContainerLayer(); string fieldName; string shapeFilename; int fieldIndex = -1; List <string> fieldValues = new List <string>(); string regionsname = ""; using (frmStatSubRegionTemplates frm = new frmStatSubRegionTemplates()) { frm.listView1.MultiSelect = true; if (frm.ShowDialog() == DialogResult.OK) { Feature[] fets = frm.GetSelectedFeatures(); fets = frm.GetStatFeatures(out fieldName, out shapeFilename, out fieldIndex); if (fets == null) { aoiContainer = null; regionsname = "全国"; } else { string chinafieldValue = fets[0].GetFieldValue(fieldIndex); if (chinafieldValue == "中国") { aoiContainer = null; regionsname = "全国"; } else { foreach (Feature fet in fets) { fieldValues.Add(fet.GetFieldValue(fieldIndex)); //获得选择区域名称 aoiContainer.AddAOI(fet); } foreach (string region in fieldValues) { regionsname += region; } if (regionsname.Contains("西藏") && regionsname.Contains("青海")) { regionsname = "青藏地区"; } if (!string.IsNullOrEmpty(regionNames)) { regionsname = regionNames.Trim(); } } } } else { return(null); } } #endregion Regex DataReg = new Regex(@"(?<year>\d{4})", RegexOptions.Compiled); //处理后的数据存储路径 string savePath = _argumentProvider.GetArg("HistoryDataSave") as string; string jpsavepath = savePath + "\\" + "距平分析"; if (!System.IO.Directory.Exists(jpsavepath))//如果不存在这个路径 { System.IO.Directory.CreateDirectory(jpsavepath); } //参数设置 List <string> paraset = _argumentProvider.GetArg("paraSet") as List <string>; string[] paras = paraset.ToArray(); List <string> jpfiles = new List <string>();//存放相减的距平分析文件 string date = ""; string jupingfile = ""; IExtractResultArray array = new ExtractResultArray("距平分析"); string Nostr = ""; //排除非选择的轨道数据 if (paras[0] == "Ascend") { Nostr = "_D_"; } if (paras[0] == "Descend") { Nostr = "_A_"; } if (paras[1] == "winter") // inputCurrentFiles = manager.GetFilePathFromList() 冬季的数所是统计出来的。 { // inputHistoryFiles 需要再重新计算一次 *** 这是多对一计算距平 //比如说要算2000-2013年冬季的距平,需要先分别算出每年冬季的值,用这些值算总的均值。再分别用每年冬季减去总冬季值。 List <string> files = new List <string>(); foreach (string file in list2) { if (!Path.GetFileName(file).Contains(Nostr)) { files.Add(file); } } inputCurrentFiles = files.ToArray(); string outHistoryFile = jpsavepath + "\\" + Path.GetFileNameWithoutExtension(inputCurrentFiles[0]).Substring(0, 14) + "_" + paras[2] + ".dat"; SNWParaStat snwStat = new SNWParaStat(); snwStat.SNWParaAvgStat(inputCurrentFiles, 0.1f, outHistoryFile); List <string> temphistory = new List <string>(); temphistory.Add(outHistoryFile); inputHistoryFiles = temphistory.ToArray(); if (inputCurrentFiles == null || inputCurrentFiles.Length < 0 || inputHistoryFiles == null || inputHistoryFiles.Length < 0) { PrintInfo("缺少分析文件"); return(null); } foreach (string inputCurrentFile in inputCurrentFiles) { Regex DataReg2 = new Regex(@"(?<year>\d{4})_(?<month>\d{2})_(?<year>\d{4})_(?<month>\d{1})", RegexOptions.Compiled); Match m = DataReg2.Match(inputCurrentFile); //提取每年冬季的时间 string year = ""; if (m.Success) { year = m.Value; } jupingfile = JuPinComputer(inputCurrentFile, inputHistoryFiles[0], jpsavepath); string hdrfile = Path.GetDirectoryName(jupingfile) + "\\" + Path.GetFileNameWithoutExtension(jupingfile) + ".hdr"; FileInfo fi = new FileInfo(jupingfile); string newjpfile = Path.Combine(jpsavepath, Path.GetFileNameWithoutExtension(jupingfile) + "_" + year.Substring(0, 4) + ".dat"); string newhdrfile = Path.Combine(jpsavepath, Path.GetFileNameWithoutExtension(jupingfile) + "_" + year.Substring(0, 4) + ".hdr"); fi.MoveTo(newjpfile); FileInfo fihdr = new FileInfo(hdrfile); fihdr.MoveTo(newhdrfile); jpfiles.Add(newjpfile); } } else { //例 2013年11月上旬-2013年11月下旬分别与1987-2013年11月上中下旬 同期比较 一对一计算距平 inputCurrentFiles = list1.ToArray(); inputHistoryFiles = list2.ToArray(); if (inputCurrentFiles == null || inputCurrentFiles.Length < 0 || inputHistoryFiles == null || inputHistoryFiles.Length < 0) { PrintInfo("缺少分析文件"); return(null); } if ((inputCurrentFiles.Length) * 2 != inputHistoryFiles.Length) { MessageBox.Show("当年数据与同期数据不对应"); return(null); } foreach (string inputCurrentFile in inputCurrentFiles) { //先假设选择的是旬数据 MWS_MWSD_China_Xun_0SD_A_2011_1_avg.dat // 则同期旬数据 MWS_MWSD_China_Xun_0SD_A_1989_2011_1_avg.dat string cfile = Path.GetFileNameWithoutExtension(inputCurrentFile); Match m = DataReg.Match(cfile); if (m.Success) { date = m.Value; //根据年4个数字来拆分字符串 } string bhalf = cfile.Substring(0, cfile.IndexOf(date)); string ahalf = cfile.Substring(cfile.IndexOf(date) + 4, cfile.Length - 4 - cfile.IndexOf(date)); foreach (string inputHistoryFile in inputHistoryFiles) { string aa = Path.GetFileNameWithoutExtension(inputHistoryFile); if (aa.Contains(bhalf) && aa.Contains(ahalf) && aa.Contains(date) && !aa.Contains(Nostr)) { jupingfile = JuPinComputer(inputCurrentFile, inputHistoryFile, jpsavepath); jpfiles.Add(jupingfile); break; } } } } #region 距平的文件在jpfiles 中,下面是裁切和平滑处理 MulRegionsClip muticlip = new MulRegionsClip(); //裁切 MWSSmoothHelp smooth = new MWSSmoothHelp(); //平滑 //创建专题图路径 gxdsave = jpsavepath + "\\" + regionsname + "\\" + "专题图"; if (!System.IO.Directory.Exists(gxdsave))//如果不存在这个路径 { System.IO.Directory.CreateDirectory(gxdsave); } //创建平滑路径 string smoothsave = jpsavepath + "\\" + regionsname + "\\" + "平滑"; if (!System.IO.Directory.Exists(smoothsave)) { System.IO.Directory.CreateDirectory(smoothsave); } //创建平滑\\中值 string filtersave = smoothsave + "\\" + "中值"; if (!System.IO.Directory.Exists(filtersave)) { System.IO.Directory.CreateDirectory(filtersave); } if (aoiContainer == null) { //只做中值处理 foreach (string infile in jpfiles) { // 先判断这个文件是否存在,存在了就不做 string filterfile = filtersave + "\\" + Path.GetFileName(infile); if (!File.Exists(filterfile)) { filterfile = smooth.ComputerMid(infile, 5, filtersave); } afterProcessfiles.Add(filterfile); toBarfiles.Add(infile); } } else { // 裁切 // 中值 // 插值 string clipsave = jpsavepath + "\\" + regionsname + "\\" + "裁切"; if (!System.IO.Directory.Exists(clipsave))//如果不存在这个路径 { System.IO.Directory.CreateDirectory(clipsave); } string bilisave = smoothsave + "\\" + "插值"; if (!System.IO.Directory.Exists(bilisave)) { System.IO.Directory.CreateDirectory(bilisave); } foreach (string infile in jpfiles) { string newclipfile = clipsave + "\\" + Path.GetFileName(infile).Replace("China", regionsname); if (!File.Exists(newclipfile)) { string clipfile = muticlip.MutiRegionsClip(infile, aoiContainer, clipsave); string hdrfile = Path.GetDirectoryName(clipfile) + "\\" + Path.GetFileNameWithoutExtension(clipfile) + ".hdr"; //重命名 string newhdrfile = Path.Combine(Path.GetDirectoryName(clipfile), Path.GetFileNameWithoutExtension(infile).Replace("China", regionsname) + ".hdr"); FileInfo fi = new FileInfo(clipfile); fi.MoveTo(newclipfile); FileInfo fihdr = new FileInfo(hdrfile); fihdr.MoveTo(newhdrfile); } toBarfiles.Add(newclipfile); //加上裁切后的文件 //中值、插值 string filterfile = smooth.ComputerMid(newclipfile, 5, filtersave); string bilifile = smooth.Bilinear(filterfile, 10, bilisave); afterProcessfiles.Add(bilifile); } } #endregion //出专题图 #region IExtractResultArray results = new ExtractResultArray(""); foreach (string arguments in afterProcessfiles.ToArray()) { string product = ""; if (arguments.Contains("MWSD")) { product = "雪深"; _argumentProvider.SetArg("OutFileIdentify", "JPDI"); } if (arguments.Contains("MSWE")) { product = "雪水当量"; _argumentProvider.SetArg("OutFileIdentify", "JPEI"); } //解析文件名确定专题图名称 string filename = Path.GetFileNameWithoutExtension(arguments); if (paras[1] == "usual") { Regex DataReg1 = new Regex(@"(?<year>\d{4})_(?<year>\d{4})", RegexOptions.Compiled); Match m = DataReg1.Match(filename); string year = ""; if (m.Success) { year = m.Value; } //提取年至avg之间的字符 string filetime = filename.Substring(filename.IndexOf(year), filename.Length - 3 - filename.IndexOf(year)); string[] mxchars = filetime.Split(new char[] { '_' }); string mx = "";//月+旬 if (filename.Contains("Xun")) { if (mxchars[3] == "1") { mx = mxchars[2] + "月" + "上旬"; } if (mxchars[3] == "2") { mx = mxchars[2] + "月" + "中旬"; } if (mxchars[3] == "3") { mx = mxchars[2] + "月" + "下旬"; } } if (filename.Contains("Month")) { mx = mxchars[2] + "月"; } imgname = year.Substring(5, 4) + "年" + mx + regionsname + product + "距平分布图(" + paras[2] + "年)"; } if (paras[1] == "winter") { imgname = Path.GetFileNameWithoutExtension(arguments).Substring(Path.GetFileNameWithoutExtension(arguments).Length - 4, 4) + "年" + "冬季" + regionsname + product + "距平分布图(" + paras[2] + "年)"; } _argumentProvider.SetArg("SelectedPrimaryFiles", arguments); _argumentProvider.SetArg("fileOpenArgs", arguments); FileExtractResult result = ThemeGraphyResult(null) as FileExtractResult; //增加矢量 string autopath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"SystemData\ProductArgs\MWS\shppath.txt"); string shpFile = ""; if (File.Exists(autopath)) { FileStream fauto = new FileStream(autopath, FileMode.Open, FileAccess.Read); StreamReader rauto = new StreamReader(fauto, Encoding.GetEncoding("gb2312")); shpFile = rauto.ReadLine(); rauto.Close(); fauto.Close(); } else { shpFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"数据引用\基础矢量\行政区划\线\中国边界_线.shp"); } CreateMcd(shpFile); _shpFile = shpFile; _gxdFile = (result as FileExtractResult).FileName; AddShpToGxd(); string newresultfile = Path.Combine(gxdsave, Path.GetFileNameWithoutExtension(arguments) + ".gxd"); FileInfo fi = new FileInfo(result.FileName); if (!File.Exists(newresultfile)) { fi.MoveTo(newresultfile); } else { FileInfo fi1 = new FileInfo(newresultfile); fi1.Delete(); } IFileExtractResult res = new FileExtractResult(_subProductDef.Identify, newresultfile, false); results.Add(res); } #endregion return(results); }
private static void Export(Opts opts) { Result <ExportManager> managerResult; if (opts.Archive) { if (opts.Test) { return; } managerResult = opts.ExportRelto.HasValue ? ExportManager.CreateArchiveExportManagerAsync(opts.DekiApi, opts.ExportDocument, opts.ExportRelto.Value, opts.FilePath, new Result <ExportManager>()) : ExportManager.CreateArchiveExportManagerAsync(opts.DekiApi, opts.ExportDocument, opts.ExportReltoPath, opts.FilePath, new Result <ExportManager>()); } else { if (!Directory.Exists(opts.FilePath)) { try { Directory.CreateDirectory(opts.FilePath); } catch (Exception e) { throw new ConfigurationException(string.Format("Unable to create '{0}': {1}", opts.FilePath, e.Message), e); } } if (opts.Test) { return; } managerResult = opts.ExportRelto.HasValue ? ExportManager.CreateFileExportManagerAsync(opts.DekiApi, opts.ExportDocument, opts.ExportRelto.Value, opts.FilePath, new Result <ExportManager>()) : ExportManager.CreateFileExportManagerAsync(opts.DekiApi, opts.ExportDocument, opts.ExportReltoPath, opts.FilePath, new Result <ExportManager>()); } managerResult.Block(); if (managerResult.HasException) { throw new Exception(string.Format("Export failed: {0}", managerResult.Exception.Message), managerResult.Exception); } ExportManager manager = managerResult.Value; manager.MaxRetries = opts.Retries; Result result = manager.ExportAsync(manifest => FixupManifest(manifest, opts), new Result()); int completed = 0; Console.WriteLine("Exporting: {0}", opts.FilePath); if (manager.TotalItems == 0) { throw new Exception("nothing to export"); } while (!result.HasFinished) { Thread.Sleep(200); if (manager.CompletedItems <= completed) { continue; } if (SysUtil.IsUnix) { Console.WriteLine(" {0} of {1} files ({2:0}%)", manager.CompletedItems, manager.TotalItems, 100.0 * manager.CompletedItems / manager.TotalItems); } else { Console.Write(" {0} of {1} files ({2:0}%) \r", manager.CompletedItems, manager.TotalItems, 100.0 * manager.CompletedItems / manager.TotalItems); } completed = manager.CompletedItems; } if (!SysUtil.IsUnix) { Console.WriteLine(); } if (result.HasException) { ExportException exportException = result.Exception as ExportException; if (exportException != null) { Console.WriteLine("Export failed on Item:\r\n{0}", exportException.ManifestItem.ToPrettyString()); } throw new Exception(string.Format("Export failed: {0}", result.Exception.Message), result.Exception); } }
private void MenuExport_Click(object sender, RoutedEventArgs e) { var exportMgr = new ExportManager(); exportMgr.ToExcell(contactsDataGrid); }