public Report CompareFiles(Log log, CsvFile csvBase, string sReportPath, ref Options options) { int iInvalids = 0; Report rep = new Report(sReportPath); log.WriteLine("Comparing \"{0}\" to \"{1}\"", _fileName, csvBase.ToString()); rep.BaseFile = csvBase.ToString(); rep.CompareFile = _fileName; Curve reference = new Curve(); Curve compareCurve = new Curve(); TubeReport tubeReport = new TubeReport(); TubeSize size = null; Tube tube = new Tube(size); switch (options.Direction) { case ToleranceDirection.X: userchoice = 1; ///set to 1 for tolerenace in X axis break; case ToleranceDirection.Y: userchoice = 0; ///set to 0 for tolerance in Y-axis break; default: //Invalid mode Console.WriteLine(options.GetUsage()); break; } if (userchoice == 1) { IOptions tubeOptions = new Options1(_dRangeDelta, Axes.X); } else if (userchoice == 0) { IOptions tubeOptions = new Options1(_dRangeDelta, Axes.Y); } else { Console.WriteLine("opted for wrong choice"); Environment.ExitCode = 2; } foreach (KeyValuePair <string, List <double> > res in csvBase.Results) { if (!this.Results.ContainsKey(res.Key)) { log.Error("{0} not found in \"{1}\", skipping checks.", res.Key, this._fileName); rep.Chart.Add(new Chart() { Title = res.Key, Errors = 1 }); Environment.ExitCode = 1; continue; } else { compareCurve = new Curve(res.Key, this.XAxis.ToArray <double>(), this.Results[res.Key].ToArray <double>()); if (res.Value.Count == 0) { log.Error("{0} has no y-Values! Maybe error during parsing? Skipping", res.Key); continue; } reference = new Curve("Reference ", csvBase.XAxis.ToArray(), csvBase.Results[res.Key].ToArray()); if (!reference.ImportSuccessful) { log.Error("Error in the calculation of the tubes. Skipping {0}", res.Key); rep.Chart.Add(new Chart() { Title = res.Key, Errors = 1 }); continue; } if (reference.X.Length < compareCurve.X.Length) { log.WriteLine(LogLevel.Warning, "The resolution of the base x-axis is smaller than the compare x-axis. The better the base resolution is, the better the validation result will be!"); } else { log.WriteLine(LogLevel.Debug, "The resolution of the base x-axis is good."); } size = new TubeSize(reference, true); switch (options.Method) { case ExecutionMethod.Relative: if (userchoice == 1) { size.Calculate(_dRangeDelta, Axes.X, Relativity.Relative); } else { size.Calculate(_dRangeDelta, Axes.Y, Relativity.Relative); } break; case ExecutionMethod.Absolute: if (userchoice == 1) { size.Calculate(_dRangeDelta, Axes.X, Relativity.Absolute); } else { size.Calculate(_dRangeDelta, Axes.Y, Relativity.Absolute); } break; default: //Invalid mode Console.WriteLine(options.GetUsage()); break; } tube = new Tube(size); tubeReport = tube.Calculate(reference); tube.Validate(compareCurve); if (tubeReport.Valid == Validity.Valid) { log.WriteLine(res.Key + " is valid"); } else { log.WriteLine(LogLevel.Warning, "{0} is invalid! {1} errors have been found during validation.", res.Key, (null != tube.Report.Errors && null != tube.Report.Errors.X) ? tube.Report.Errors.X.Length : 0); iInvalids++; Environment.ExitCode = 1; } } if (null != tube.Report)//No charts for missing reports { PrepareCharts(reference, compareCurve, tube.Report.Errors, rep, tubeReport, res, options.UseBitmapPlots); } } rep.Tolerance = _dRangeDelta; string sResult = "na"; if (rep.TotalErrors == 0) { sResult = "passed"; } else { sResult = "failed"; } if (options.ComparisonFlag) { using (TextWriter writer = File.CreateText(string.Format("{0}{1}compare_{2}.log", Path.GetDirectoryName(_fileName), Path.DirectorySeparatorChar, sResult))) { //Content needs to be defined writer.WriteLine("CSV Compare Version {0} ({1})", Info.AssemblyVersion, Assembly.GetExecutingAssembly().GetName().ProcessorArchitecture); writer.WriteLine("Comparison result file for {0}", _fileName); writer.WriteLine(". Time: {0:o}", DateTime.Now); writer.WriteLine(". Operation: {0}", options.Mode); writer.WriteLine(". Tolerance: {0}", options.Tolerance); writer.WriteLine(". Execution Method: {0}", options.Method); writer.WriteLine(". Direction of Tolerence: {0}", options.Direction); writer.WriteLine(". Result: {0}", sResult); if (rep.TotalErrors > 0) { Chart pairMax = rep.Chart.Aggregate((l, r) => l.DeltaError > r.DeltaError ? l : r); if (pairMax.DeltaError > 0) { writer.WriteLine(". Largest error: {0}=>{1}", pairMax.Title, pairMax.DeltaError); writer.WriteLine(". Failed values:"); foreach (Chart c in (from r in rep.Chart where r.DeltaError > 0 select r).OrderByDescending(er => er.DeltaError)) { writer.WriteLine("{0}=>{1}", c.Title, c.DeltaError.ToString(CultureInfo.InvariantCulture)); } } } } } rep.WriteReport(log, (string.IsNullOrEmpty(options.ReportDir) || options.NoMetaReport) ? string.Empty : options.ReportDir, options); GC.Collect();//immediately forget big charts and data return(rep); }
/// <summary> /// 模拟委托回调处理 /// </summary> /// <param name="options1"></param> /// <returns></returns> private async Task _OnCustomOptionSet(Options1 options1) { string x = options1.UserName; await Task.CompletedTask; }
/// <summary> /// Update project details /// </summary> /// <param name="orgid">Organization identifier</param> /// <param name="projectid">Project identifier</param> /// <param name="options">Options for project create/update</param> /// <returns>Task of InlineResponse2001</returns> public async System.Threading.Tasks.Task<InlineResponse2001> UpdateProjectAsync (string orgid, string projectid, Options1 options) { ApiResponse<InlineResponse2001> response = await UpdateProjectAsyncWithHttpInfo(orgid, projectid, options); return response.Data; }
/// <summary> /// Update project details /// </summary> /// <param name="orgid">Organization identifier</param> /// <param name="projectid">Project identifier</param> /// <param name="options">Options for project create/update</param> /// <returns>Task of ApiResponse (InlineResponse2001)</returns> public async System.Threading.Tasks.Task<ApiResponse<InlineResponse2001>> UpdateProjectAsyncWithHttpInfo (string orgid, string projectid, Options1 options) { // verify the required parameter 'orgid' is set if (orgid == null) throw new ApiException(400, "Missing required parameter 'orgid' when calling UpdateProject"); // verify the required parameter 'projectid' is set if (projectid == null) throw new ApiException(400, "Missing required parameter 'projectid' when calling UpdateProject"); // verify the required parameter 'options' is set if (options == null) throw new ApiException(400, "Missing required parameter 'options' when calling UpdateProject"); var path_ = "/orgs/{orgid}/projects/{projectid}"; var pathParams = new Dictionary<String, String>(); var queryParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader); var formParams = new Dictionary<String, String>(); var fileParams = new Dictionary<String, FileParameter>(); Object postBody = null; // to determine the Content-Type header String[] httpContentTypes = new String[] { "application/json" }; String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header String[] httpHeaderAccepts = new String[] { "application/json", "text/plain", "text/html" }; String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); if (httpHeaderAccept != null) headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); if (orgid != null) pathParams.Add("orgid", Configuration.ApiClient.ParameterToString(orgid)); // path parameter if (projectid != null) pathParams.Add("projectid", Configuration.ApiClient.ParameterToString(projectid)); // path parameter postBody = Configuration.ApiClient.Serialize(options); // http body (model) parameter // authentication (apikey) required // http basic authentication required if (!String.IsNullOrEmpty(Configuration.Username) || !String.IsNullOrEmpty(Configuration.Password)) { headerParams["Authorization"] = "Basic " + Base64Encode(Configuration.Username + ":" + Configuration.Password); } // authentication (permissions) required // oauth required if (!String.IsNullOrEmpty(Configuration.AccessToken)) { headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; } // make the HTTP request IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams, httpContentType); int statusCode = (int) response.StatusCode; if (statusCode >= 400) throw new ApiException (statusCode, "Error calling UpdateProject: " + response.Content, response.Content); else if (statusCode == 0) throw new ApiException (statusCode, "Error calling UpdateProject: " + response.ErrorMessage, response.ErrorMessage); return new ApiResponse<InlineResponse2001>(statusCode, response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (InlineResponse2001) Configuration.ApiClient.Deserialize(response, typeof(InlineResponse2001))); }
/// <summary> /// Update project details /// </summary> /// <param name="orgid">Organization identifier</param> /// <param name="projectid">Project identifier</param> /// <param name="options">Options for project create/update</param> /// <returns>InlineResponse2001</returns> public InlineResponse2001 UpdateProject (string orgid, string projectid, Options1 options) { ApiResponse<InlineResponse2001> response = UpdateProjectWithHttpInfo(orgid, projectid, options); return response.Data; }