/// <summary> /// Get the Name for the Enum Value /// </summary> /// <returns></returns> public string GetSerializedDisposition() { Type t = Disposition.GetType(); FieldInfo fi = t.GetField(Disposition.ToString()); return(EnumSerilizedNameAttribute.GetValue(fi)); }
/// <summary> /// Produces a report of this job for the console. /// </summary> public override string ToString() { var report = new StringBuilder(); report.AppendLine(ConsoleFormat.DoubleLine); report.AppendLine($"JOB {Disposition.ToString().ToUpper()}"); report.AppendLine(ConsoleFormat.DoubleLine); report.AppendLine(); report.AppendLine($"{Items.Count()} item{ConsoleFormat.AsPlural(Items.Count())} {(TotalItemCount.HasValue ? "of " + TotalItemCount + " processed" : "processed")}"); report.AppendLine(); report.AppendLine(ConsoleFormat.AsColumns(20, nameof(InitializeAsync), InitializeAsync.IsSuccessful ? "Successful" : "Unsuccessful")); report.AppendLine(ConsoleFormat.AsColumns(20, nameof(GetItemsAsync), GetItemsAsync.IsSuccessful ? "Successful" : "Unsuccessful")); if (!Count?.IsSuccessful ?? false) { report.AppendLine(ConsoleFormat.AsColumns(20, nameof(Count), Count.IsSuccessful ? "Successful" : "Unsuccessful")); } if (!GetEnumerator?.IsSuccessful ?? false) { report.AppendLine(ConsoleFormat.AsColumns(20, nameof(GetEnumerator), GetEnumerator.IsSuccessful ? "Successful" : "Unsuccessful")); } report.AppendLine(ConsoleFormat.AsColumns(20, "ProcessAsync", FailedItemCount == 0 ? "Successful" : "Unsuccessful")); report.AppendLine(ConsoleFormat.AsColumns(20, nameof(FinalizeAsync), FinalizeAsync.IsSuccessful ? "Successful" : "Unsuccessful")); report.AppendLine(); foreach (var summary in Categories) { report.AppendLine(ConsoleFormat.AsColumns(20, $"{summary.Count} item{ConsoleFormat.AsPlural(Items.Count())}", summary.IsSuccessful ? "Successful" : "Unsuccessful", summary.Category)); } report.AppendLine(); if (FailedItemsThatThrewExceptions.Count() > 0 || Methods.Values.Any(m => !m.IsSuccessful)) { report.AppendLine(ConsoleFormat.DoubleLine); report.AppendLine("UNHANDLED EXCEPTIONS"); report.AppendLine(ConsoleFormat.DoubleLine); report.AppendLine(); foreach (var method in Methods.Values.Where(m => !m.IsSuccessful)) { report.AppendLine(ConsoleFormat.SingleLine); report.AppendLine(method.Method.ToString()); report.AppendLine(ConsoleFormat.SingleLine); report.AppendLine(method.Exception.ToString()); report.AppendLine(); } foreach (var failure in FailedItemsThatThrewExceptions.Take(10)) { report.AppendLine(ConsoleFormat.SingleLine); report.AppendLine(failure.Id ?? "Unknown"); report.AppendLine(ConsoleFormat.SingleLine); report.AppendLine((failure.ProcessAsync.Exception ?? failure.EnumeratorCurrent.Exception ?? failure.EnumeratorMoveNext.Exception).ToString()); report.AppendLine(); } } return(report.ToString()); }
static void AddResponse(Disposition disposition, string response) { _cannedResponses.Add( new OracleResponse { Disposition = disposition.ToString().ToLowerInvariant(), Response = response } ); }
public void TestDisposition() { Disposition disposition = new Disposition(MDNStandard.NotificationType.Processed); Assert.True(disposition.ToString() == "automatic-action/MDN-sent-automatically;processed"); disposition = new Disposition(MDNStandard.NotificationType.Processed, true); Assert.True(disposition.ToString() == "automatic-action/MDN-sent-automatically;processed/error"); disposition = new Disposition(MDNStandard.TriggerType.Automatic, MDNStandard.SendType.UserMediated, MDNStandard.NotificationType.Displayed, true); Assert.True(disposition.ToString() == "automatic-action/MDN-sent-manually;displayed/error"); disposition = new Disposition(MDNStandard.TriggerType.UserInitiated, MDNStandard.SendType.UserMediated, MDNStandard.NotificationType.Displayed, true); Assert.True(disposition.ToString() == "manual-action/MDN-sent-manually;displayed/error"); }
internal MultipartFormDataContent ToFormData(string boundary) { var form = new MultipartFormDataContent(boundary); form.Headers.Remove("Content-Type"); form.Headers.Add("Content-Type", "multipart/form-data;boundary=" + boundary); var s = ToJson(); var stringContent = new StringContent(s); stringContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "message" }; form.Add(stringContent, "message"); var disp = new StringContent(Disposition.ToString()); disp.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "disposition" }; form.Add(disp, "disposition"); foreach (var attachment in Attachments) { var ba = new ByteArrayContent(attachment.FileContent); ba.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "attachments[]", FileName = Path.GetFileName(attachment.Filename) }; ba.Headers.ContentType = new MediaTypeHeaderValue(attachment.MimeType); form.Add(ba, "attachments[]", Path.GetFileName(attachment.Filename)); } // form.ReadAsStringAsync().Result; return(form); }
Task IContent.WritePage(object response) { HttpResponse resp = response.Convert <HttpResponse>(); resp.Clear(); resp.ContentType = fContent.ContentType; if (fUseCache) { resp.GetTypedHeaders().CacheControl = new CacheControlHeaderValue { Public = true, MaxAge = TimeSpan.FromDays(1) }; } if (fContent.IsWriteFileName) { string title = "filename="; var agentSvc = WebGlobalVariable.Context.RequestServices.GetService( typeof(IUserAgentService)).Convert <IUserAgentService>(); //HttpBrowserCapabilities browser = WebGlobalVariable.Request.Browser; string browserName = agentSvc.Agent.Browser.Name.ToLower(ObjectUtil.SysCulture); if (browserName == "firefox" || browserName == "opera") { title = "filename*=UTF-8''"; } string fileName = HttpUtility.UrlEncode(fContent.FileName, Encoding.UTF8); resp.Headers.Add("content-disposition", $"{Disposition.ToString().ToLower(ObjectUtil.SysCulture)}; {title}{fileName}"); } IFileInfo fileInfo = new WebFileInfo(fContent); return(resp.SendFileAsync(fileInfo)); }
public override string ToString() { return($"GrossPay: {GrossPay}, Deductions:{Deductions}, NetPay: {NetPay}, Disposition: {Disposition.ToString()}"); }
public void AddHeader(string name, Disposition disposition) { this.headers.Add(name, disposition.ToString()); }
/// <summary> /// Produces a report of this job for the console. /// </summary> public override string ToString() { var report = new StringBuilder(); report.AppendLine(ConsoleFormat.DoubleLine); report.AppendLine($"JOB {Disposition.ToString().ToUpper()}"); report.AppendLine(ConsoleFormat.DoubleLine); report.AppendLine(); report.AppendLine($"{Items.Count()} item{ConsoleFormat.AsPlural(Items.Count())} {(TotalItemCount.HasValue ? "of " + TotalItemCount + " processed" : "processed")}"); report.AppendLine(); report.AppendLine(ConsoleFormat.AsColumns(20, nameof(InitializeAsync), InitializeAsync.IsSuccessful ? "Successful" : "Unsuccessful")); report.AppendLine(ConsoleFormat.AsColumns(20, nameof(GetItemsAsync), GetItemsAsync.IsSuccessful ? "Successful" : "Unsuccessful")); report.AppendLine(ConsoleFormat.AsColumns(20, nameof(GetEnumerator), GetEnumerator.IsSuccessful ? "Successful" : "Unsuccessful")); report.AppendLine(ConsoleFormat.AsColumns(20, nameof(FinalizeAsync), FinalizeAsync.IsSuccessful ? "Successful" : "Unsuccessful")); report.AppendLine(); foreach (var summary in Categories) { report.AppendLine(ConsoleFormat.AsColumns(20, $"{summary.Count} item{ConsoleFormat.AsPlural(Items.Count())}", summary.IsSuccessful ? "Successful" : "Unsuccessful", summary.Category)); } report.AppendLine(); report.AppendLine(ConsoleFormat.DoubleLine); report.AppendLine("RESULTS"); report.AppendLine(ConsoleFormat.DoubleLine); report.AppendLine(); foreach (var summary in Categories) { report.AppendLine(ConsoleFormat.SingleLine); report.AppendLine($"{summary.Category}"); report.AppendLine(ConsoleFormat.SingleLine); foreach (var item in Items.Where(i => i.Category == summary.Category).OrderBy(i => i.Id).Take(100)) { report.AppendLine(item.Id); } report.AppendLine(); } report.AppendLine(ConsoleFormat.DoubleLine); report.AppendLine("OUTPUT"); report.AppendLine(ConsoleFormat.DoubleLine); report.AppendLine(); report.AppendLine(Output != null ? JsonConvert.SerializeObject(Output) : "-- No Output --"); report.AppendLine(); if (FailedItemsThatThrewExceptions.Count() > 0) { report.AppendLine(ConsoleFormat.DoubleLine); report.AppendLine("UNHANDLED EXCEPTIONS"); report.AppendLine(ConsoleFormat.DoubleLine); report.AppendLine(); foreach (var failure in FailedItemsThatThrewExceptions.Take(10)) { report.AppendLine(ConsoleFormat.SingleLine); report.AppendLine(failure.Id ?? "Unknown"); report.AppendLine(ConsoleFormat.SingleLine); report.AppendLine((failure.ProcessAsync.Exception ?? failure.EnumeratorCurrent.Exception ?? failure.EnumeratorMoveNext.Exception).ToString()); report.AppendLine(); } } return(report.ToString()); }