/// <summary> /// Mains the specified arguments. /// </summary> /// <param name="args">The arguments.</param> static void Main(string[] args) { var options = new ProcessOption(); if (CommandLine.Parser.Default.ParseArguments(args, options)) { var container = new ServiceLocatorFluent().CreateContainer().Build(); var application = container.Resolve <IProcessManager>(); application.ExecuteProcess(container, options); } }
public ImageProcess(ImageIO sourceImage, int targetWidth, int targetHeight, Interpolation interpolation, double bicubicFactor = -0.5) { _imageParameter = new ImageParameter(sourceImage, null, sourceImage.Path, null); sourceImage.LockBits(); _processOption = new ProcessOption(Transform.None, interpolation); _distortionParameter = null; _warpParameter = null; _faceTransformation = null; _interpolationParameter = new InterpolationParameter(targetWidth, targetHeight, bicubicFactor); _processResult = new ProcessResult(this.InterpolationFunction(), null, null); sourceImage.UnlockBits(); }
public ImageProcess(ImageIO sourceImage, ImageIO faceImage, int targetWidth, int targetHeight, Interpolation interpolation, double bicubicFactor = -0.5) { _imageParameter = new ImageParameter(sourceImage, faceImage, sourceImage.Path, faceImage.Path); sourceImage.LockBits(); faceImage.LockBits(); _processOption = new ProcessOption(Transform.TPS, interpolation); _distortionParameter = null; _warpParameter = null; _faceTransformation = new FaceTransformation(this.ImageParameter.SourcePath, this.ImageParameter.FacePath); _interpolationParameter = new InterpolationParameter(targetWidth, targetHeight, bicubicFactor); _processResult = new ProcessResult(this.InterpolationFunction(), this.FaceTransformation.Source_marked, this.FaceTransformation.Face_marked); sourceImage.UnlockBits(); faceImage.UnlockBits(); }
public ImageProcess(ImageIO sourceImage, double warpFactor, int warpCenter_x, int warpCenter_y, int targetWidth, int targetHeight, Interpolation interpolation, double bicubicFactor = -0.5) { _stretch = false; _imageParameter = new ImageParameter(sourceImage, null, sourceImage.Path, null); sourceImage.LockBits(); _processOption = new ProcessOption(Transform.Warp, interpolation); _distortionParameter = null; _warpParameter = new WarpParameter(sourceImage.Width * sourceImage.Height, warpFactor, warpCenter_x, warpCenter_y); _faceTransformation = null; _interpolationParameter = new InterpolationParameter(targetWidth, targetHeight, bicubicFactor); _processResult = new ProcessResult(this.InterpolationFunction(), null, null); sourceImage.UnlockBits(); }
/// <summary> /// Executes the process. /// </summary> /// <param name="processOption">The process option.</param> /// public void ExecuteProcess(ServiceLocatorFluent container, ProcessOption processOption) { var stopWatch = new Stopwatch(); stopWatch.Start(); var previousColor = Console.ForegroundColor; try { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("The process is preparing to execute"); var processes = container.Resolve <IEnumerable <IProcessBase> >(); var process = processes.FirstOrDefault(p => string.Compare(p.ExecutionKey(), processOption.Batch, StringComparison.OrdinalIgnoreCase) == 0); if (process != null) { if (process.HasUniqueExecution()) { process.Execute(0); } else { for (var i = 0; i < processOption.Days; i++) { if (i % processOption.DeliveryResume == 0) { Console.WriteLine($"Executing process #{i} of {processOption.Days}"); } process.Execute(i); } } } else { Console.WriteLine("The process does not exists"); } Console.WriteLine("The execution was succesfully"); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"An error was ocurre: {ex.Message}"); } Console.ForegroundColor = previousColor; stopWatch.Stop(); Console.WriteLine($"Time Elapsed: {stopWatch.ElapsedMilliseconds / 1000} seconds"); }
/// <summary> /// 填充参数 /// </summary> /// <param name="args">The args.</param> /// <returns></returns> public virtual Dictionary <string, string> FillArgs(Dictionary <string, string> args) { if (args == null) { args = new Dictionary <string, string>(); } args["entity_name"] = EntityName; var op = ProcessOption?.ToString(); if (string.IsNullOrWhiteSpace(op) == false) { args["process_option"] = op; } args["coord_type_output"] = CoordTypeOutput.ToString(); return(args); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if ( System.Diagnostics.Process.GetProcessesByName( System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)) .Count() > 1) { System.Diagnostics.Process.GetCurrentProcess().Kill(); } // Show the system tray icon. using (ProcessOption pi = new ProcessOption()) { pi.Display(); // Make sure the application runs! Application.Run(); } }
/// <summary> /// Initializes a new instance of the <see cref="ProcessOptionChangedEvent"/> class. /// </summary> /// <param name="processOption">The process option.</param> public ProcessOptionChangedEvent(ProcessOption processOption) { ProcessOption = processOption; }
/// <summary> /// Try to process one command line option. /// The ref input "i" may be incremented if the option was matched. The ref input "error" is set if the option /// was matched but could not be fully processed. /// </summary> /// <returns><c>true</c>, if the option matches and was processed successfully, <c>false</c> otherwise.</returns> /// <param name="args">command line argument array</param> /// <param name="shortForm">short form of the option</param> /// <param name="longForm">long form of the option</param> /// <param name="action">method to process the option</param> /// <param name="i">index into args</param> /// <param name="error">flag an error in processing a matched option</param> static bool ProcessArgument(string[] args, string shortForm, string longForm, ProcessOption action, ref int i, ref bool error) { if (error) { return(false); } if (args[i] == shortForm || longForm.StartsWith(args[i])) { var okay = action(args, ref i); if (okay) { return(true); } error = true; } return(false); }
/// <summary> /// 获取服务,根据设置自动判断。 /// </summary> /// <returns></returns> public override IEphemerisService GetService() { //检查当前,避免重复加载 if (IsCurrentEphemerisServiceAvailable()) { log.Info("返回已有星历服务 " + CurrentService); return(CurrentService); } if (ProcessOption.IsUseUniqueEphemerisFile) { this.CurrentService = EphemerisDataSourceFactory.Create(ProcessOption.EphemerisFilePath); log.Info("成功载入选项指定星历文件: " + ProcessOption.EphemerisFilePath); return(CurrentService); } if (ProcessOption.IsIndicatedEphemerisPathes) //优先指定的星历文件 { var ephePathes = ProcessOption.GetIndicatedEphemerisPathes(); this.CurrentService = new IndicatedEphemerisService(ephePathes, ProcessOption, DataSourceOption.GetIgsProductSourceOption(CurrentSession)); //EphemerisDataSourceFactory.Create(ProcessOption.EphemerisFilePath); StringBuilder sb = new StringBuilder(); foreach (var item in ephePathes) { sb.AppendLine(item.Key + ":" + item.Value); } log.Info("成功载入选项指定星历文件:\r\n " + sb.ToString()); return(CurrentService); } //如果不需要精密星历,且数据文件夹中有导航文件,则加载之 if (ObservationDataSources != null && !this.ProcessOption.IsPreciseEphemerisFileRequired) { ObservationDataSources.TryLoadEphemerisServices(); if (ObservationDataSources.EphemerisServices.Count > 0) { this.CurrentService = ObservationDataSources.EphemerisServices.First; var msg = "设置没有指定星历,也不需要精密星历,发现了导航星历,因此采用此一个导航星历。" + this.CurrentService; log.Info(msg); return(CurrentService); } } //自动匹配精密星历 if (DataSourceOption.EnableAutoFindingFile) { // new IgsEphemerisServiceAutoProvider(DataSourceOption.GetIgsProductSourceOption(CurrentSession)).GetEphemerisService(); GlobalIgsEphemerisService.Instance.IgsEphAutoProvider.IsConnectIgsProduct = this.ProcessOption.IsConnectIgsDailyProduct; //尝试获取一个,如果失败则表示不可用 if (CurrentSession.SatelliteTypes.Count == 0) { log.Error("请指定GNSS系统类型"); } else if (GlobalIgsEphemerisService.Instance.IsAvailable(this.CurrentSession.TimePeriod.Start, this.CurrentSession.SatelliteTypes[0])) { this.CurrentService = GlobalIgsEphemerisService.Instance; if (this.CurrentService == null || CurrentService.SatCount == 0) { log.Info("没有匹配上星历文件 " + CurrentService); } else { //设置拟合阶次,放在此处不是很合理,2019.05.15,czs GlobalIgsEphemerisService.Instance.IgsEphAutoProvider.InerpolateOrder = this.ProcessOption.EphemerisInterpolationOrder; log.Info("成功自动匹配星历文件 " + CurrentService); return(CurrentService); } } } //自动匹配精密星历 //if (DataSourceOption.EnableAutoFindingFile) //{ // this.EphemerisService = new IgsEphemerisServiceAutoProvider(DataSourceOption.GetIgsProductSourceOption(CurrentSession)).GetEphemerisService(); // if (this.EphemerisService == null || EphemerisService.SatCount == 0) { log.Info("没有匹配上星历文件 " + EphemerisService); } // else // { // log.Info("成功自动匹配星历文件 " + EphemerisService); // return EphemerisService; // } //} //NGA星历匹配 if (ProcessOption.IsEnableNgaEphemerisSource && DataSourceOption.EnableAutoFindingFile && Setting.EnableNet) { Time obsTime = CurrentSession.TimePeriod.Start; Time time = Time.UtcNow; var span = (time - obsTime); //与当前的时间差 var isWithTwoDays = span < 48 * 3600; //IGS快速星历服务 //NGA只有预报星历,取消之。应急采用。 TryAddNgaEphemeris(obsTime, isWithTwoDays); if (this.CurrentService == null || CurrentService.SatCount == 0) { log.Info("没有匹配上星历文件 " + CurrentService); } else { log.Info("成功自动匹配 NGA 星历文件 " + CurrentService); return(CurrentService); } } //还没有匹配上,寻找导航文件 if ((CurrentService == null || CurrentService.SatCount == 0)) { ObservationDataSources.TryLoadEphemerisServices(); if (ObservationDataSources.EphemerisServices.Count > 0) { this.CurrentService = ObservationDataSources.EphemerisServices.First; var msg = "最后时刻,采用了一个导航星历。" + this.CurrentService; log.Info(msg); } } if ((CurrentService == null || CurrentService.SatCount == 0)) { this.CurrentService = GlobalIgsEphemerisService.Instance; var msg = "星历服务匹配失败!!!,仍然尝试用全局星历!"; log.Error(msg); // throw new ArgumentException(msg); } return(this.CurrentService); }