} = 3000; // 3 sec public DICOMSCU(Entity ae) : base(ae) { #if NETCOREAPP System.Text.EncodingProvider provider = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(provider); #endif }
private void download() { System.Text.EncodingProvider provider = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(provider); var siteGot = @"http://ktg.hg.pl/komisja-tg/got/got.html"; var siteDownloader = new SiteDownloader { Url = siteGot }; siteDownloader.Download(); Regex rx = new Regex(@"<a href=""([a-zA-Z0-9_/-]+[.]html)"">"); // MatchCollection mc = rx.Matches(siteDownloader.Content); // mc. foreach (Match m in rx.Matches(siteDownloader.Content)) { var site = "http://ktg.hg.pl/komisja-tg/got/" + m.Groups[1]; Console.WriteLine(site); var subSiteDownloader = new SiteDownloader { Url = site }; subSiteDownloader.Download(); File.WriteAllText(m.Groups[1].Value.Replace(@"/", "_"), subSiteDownloader.Content); } }
static async Task Main(string[] args) { System.Text.EncodingProvider provider = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(provider); Log.Logger = new LoggerConfiguration() .WriteTo.Console() .CreateLogger(); Log.Logger.Information("starting up!"); var client = new MongoClient("mongodb://localhost:27017/?maxPoolSize=200"); var database = client.GetDatabase("cli-feed-crawler"); await new RssCrawler(null, database, new FeedCrawler.Models.Rss { Url = "http://daddynkidsmakers.blogspot.com/feeds/posts/default", Name = "강태욱" }).RunAsync(); await new RssCrawler(null, database, new FeedCrawler.Models.Rss { Url = "https://elky84.github.io/feed.xml", Name = "Elky Essay" }).RunAsync(); await new RssCrawler(null, database, new FeedCrawler.Models.Rss { Url = "https://developer.amazon.com/blogs/home/feed/entries/atom", Name = "Amazon Developer Blogs" }).RunAsync(); }
//Send GET request and return data Stream (Fetching available currencies) public Stream MakeRequestCurrency() { var handler = new HttpClientHandler(); handler.UseCookies = false; WebResponse response; handler.AutomaticDecompression = ~DecompressionMethods.None; using (var httpClient = new HttpClient(handler)) { var request = WebRequest.Create(_URL); request.Method = "GET"; request.ContentType = "application/x-www-form-urlencoded"; System.Text.EncodingProvider provider = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(provider); response = request.GetResponse(); Stream dataStream = response.GetResponseStream(); return(dataStream); } }
static void Main(string[] args) { System.Text.EncodingProvider provider = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(provider); Console.WriteLine("1 requête 1er démarrage"); Init(); Console.WriteLine(); Console.WriteLine("10 itérations"); //Appels multiple, 100 itérations , 1 enregistrement MultipleIteration(10); Console.WriteLine(); Console.WriteLine("100 itérations"); //Appels multiple, 100 itérations , 1 enregistrement MultipleIteration(100); Console.WriteLine(); Console.WriteLine("1000 itérations"); //Appels multiple, 100 itérations , 1 enregistrement MultipleIteration(1000); Console.WriteLine(); Console.WriteLine("1 itération ramenant 500 enregistrements"); //Appel unique, 500 enregistrements SingleCall(); Console.ReadLine(); }
//Constructor for inherited classes protected DICOMBinaryReader() { #if NETCOREAPP System.Text.EncodingProvider provider = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(provider); #endif }
public DICOMSCP(Entity ae) : base(ae) { _server = new TcpListener(IPAddress.Parse(ApplicationEntity.IpAddress), ApplicationEntity.Port); #if NETCOREAPP System.Text.EncodingProvider provider = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(provider); #endif }
private string removeSymbols(string name) { System.Text.EncodingProvider provider = System.Text.CodePagesEncodingProvider.Instance; // enable coding in .net core framework for env Encoding.RegisterProvider(provider); byte[] bytes = System.Text.Encoding.GetEncoding("Cyrillic").GetBytes(name); // remove polish symbols return(Regex.Replace(System.Text.Encoding.ASCII.GetString(bytes), "[^a-zA-Z0-9 ]+", "", RegexOptions.Compiled).ToLower()); // remove special characters "[^a-zA-Z0-9_.]+" }
public Startup(IConfiguration configuration) { System.Text.EncodingProvider provider = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(provider); Log.Logger = new LoggerConfiguration() .MinimumLevel.Error() .WriteTo.Console() .CreateLogger(); Configuration = configuration; }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { UnhandledException += OnUnhandledException; TaskScheduler.UnobservedTaskException += OnUnobservedException; var services = new Type[] { typeof(Crashes), typeof(Analytics) }; AppCenter.Start(null, services); System.Text.EncodingProvider provider = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(provider); InitializeComponent(); Suspending += OnSuspending; }
//Send POST request and return data Stream (Fetching data for a currency at page=page) public Stream MakeRequestData(String currency, int page) { var handler = new HttpClientHandler(); handler.UseCookies = false; WebResponse response; handler.AutomaticDecompression = ~DecompressionMethods.None; using (var httpClient = new HttpClient(handler)) { var request = WebRequest.Create(_URL); request.Method = "POST"; String headers; //If page == 0 we do not include it to headers if (page == 0) { headers = String.Format( "erectDate={0}¬hing={1}&pjname={2}", _startDate.ToString(_dtFormat), _endDate.ToString(_dtFormat), currency); } else { headers = String.Format( "erectDate={0}¬hing={1}&pjname={2}&page={3}", _startDate.ToString(_dtFormat), _endDate.ToString(_dtFormat), currency, page.ToString()); } byte[] byteArray = Encoding.UTF8.GetBytes(headers); request.ContentType = "application/x-www-form-urlencoded"; System.Text.EncodingProvider provider = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(provider); Stream dataStream = request.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); response = request.GetResponse(); dataStream = response.GetResponseStream(); return(dataStream); } }
public void Control() { System.Text.EncodingProvider provider = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(provider); while (true) { switch (Console.ReadKey().Key) { case ConsoleKey.W: case ConsoleKey.UpArrow: if (Direction != "down") { setDir = "up"; } break; case ConsoleKey.A: case ConsoleKey.LeftArrow: if (Direction != "right") { setDir = "left"; } break; case ConsoleKey.D: case ConsoleKey.RightArrow: if (Direction != "left") { setDir = "right"; } break; case ConsoleKey.S: case ConsoleKey.DownArrow: if (Direction != "up") { setDir = "down"; } break; } } }
public static void Main(string[] args) { // 注册Encoding System.Text.EncodingProvider provider = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(provider); // Log Config Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .MinimumLevel.Override("Microsoft", LogEventLevel.Information) .Enrich.FromLogContext() .WriteTo.Console() .WriteTo.File( @"log\log.txt", fileSizeLimitBytes: 1_000_000, rollOnFileSizeLimit: true, shared: true, flushToDiskInterval: TimeSpan.FromSeconds(1)) .CreateLogger(); CreateWebHostBuilder(args).Build().Run(); }
internal static void AddProvider(EncodingProvider provider) { if (provider == null) throw new ArgumentNullException("provider"); lock (s_InternalSyncObject) { if (s_providers == null) { s_providers = new EncodingProvider[1] { provider }; return; } if (Array.IndexOf(s_providers, provider) >= 0) { return; } EncodingProvider[] providers = new EncodingProvider[s_providers.Length + 1]; Array.Copy(s_providers, providers, s_providers.Length); providers[providers.Length - 1] = provider; s_providers = providers; } }
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { #region Metrics监控配置 string isOpen = Configuration.GetSection("InfluxDB")["IsOpen"].ToLower(); if (isOpen == "true") { string database = Configuration.GetSection("InfluxDB")["DataBaseName"]; string influxDbConStr = Configuration.GetSection("InfluxDB")["ConnectionString"]; string app = Configuration.GetSection("InfluxDB")["app"]; string env = Configuration.GetSection("InfluxDB")["env"]; string username = Configuration.GetSection("InfluxDB")["username"]; string password = Configuration.GetSection("InfluxDB")["password"]; var uri = new Uri(influxDbConStr); var metrics = AppMetrics.CreateDefaultBuilder() .Configuration.Configure( options => { options.AddAppTag(app); options.AddEnvTag(env); }) .Report.ToInfluxDb( options => { options.InfluxDb.BaseUri = uri; options.InfluxDb.Database = database; options.InfluxDb.UserName = username; options.InfluxDb.Password = password; options.HttpPolicy.BackoffPeriod = TimeSpan.FromSeconds(30); options.HttpPolicy.FailuresBeforeBackoff = 5; options.HttpPolicy.Timeout = TimeSpan.FromSeconds(10); options.FlushInterval = TimeSpan.FromSeconds(5); }) .Build(); services.AddMetrics(metrics); services.AddMetricsReportScheduler(); services.AddMetricsTrackingMiddleware(); services.AddMetricsEndpoints(); } #endregion services.AddSingleton(HtmlEncoder.Create(UnicodeRanges.All)); System.Text.EncodingProvider provider = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(provider); // 读取配置文件转换为强类型对象 services.Configure <MyOption>(Configuration.GetSection("MyOption")); services.Configure <MyOption>("codeConfig", x => { x.Name = "djlCoder"; x.Age = 22; }); //services.PostConfigure<MyOption>(x => //{ // x.Name = "new"; // x.Age = 18; //}); //services.PostConfigureAll<MyOption>(x => //{ // x.Name = "all"; // x.Age = 22; //}); services.AddMvc().AddControllersAsServices(); //IServiceContainer container = new ServiceContainer(); //container.AddType<ICustomService, CustomService>(); //container.AddType<IContactService, ContactService>(); services.AddScoped <IContactService, ContactService>(); services.AddTransient <ICustomService, CustomService>(); services.AddTransient <ITestCheckInput, TestCheckInput>(); //services.AddDynamicProxy(); #region AspectAPM // 1、代码配置 //services.AddAspectCoreAPM(component => //{ // component.AddApplicationProfiler(); //注册ApplicationProfiler收集GC和ThreadPool数据 // component.AddHttpProfiler(); //注册HttpProfiler收集Http请求数据 // component.AddLineProtocolCollector(options => //注册LineProtocolCollector将数据发送到InfluxDb // { // options.Server = "http://192.168.1.134:8086"; //你自己的InfluxDB Http地址 // options.Database = "aspnetcore"; //你自己创建的Database // }); //}); // 2、config配置 services.AddAspectCoreAPM(component => { component.AddLineProtocolCollector(options => Configuration.GetLineProtocolSection().Bind(options)) .AddHttpProfiler() .AddApplicationProfiler() .AddRedisProfiler(options => Configuration.GetRedisProfilerSection().Bind(options)); component.AddMethodProfiler(); }); // 与微软自己的DI集成AOP //return services.BuildAspectCoreServiceProvider(); //返回AspectCore AOP的ServiceProvider,这句代码一定要有 // 与AspectCore.Inject 集成 //services.AddAspectCoreContainer(); //var container = services.ToServiceContainer(); ////container.Configure(x => x.Interceptors.AddTyped<TestIntercptorAttribute>()); //return container.Build(); var container = services.ToServiceContainer(); //container.AddType<ICustomService, CustomService>(); //container.AddType<IContactService, ContactService>(); container.AddDataAnnotations(); return(container.Build()); #endregion }
static StringUtilities() { // Need to make sure we have ISO-8859-8 encoding available for RemoveDiacriticals System.Text.EncodingProvider provider = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(provider); }
static async Task Main(string[] args) { System.Text.EncodingProvider provider = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(provider); Log.Logger = new LoggerConfiguration() .MinimumLevel.Information() .WriteTo.Console() .CreateLogger(); Log.Logger.Information("starting up!"); var client = new MongoClient("mongodb://localhost:27017/?maxPoolSize=200"); var database = client.GetDatabase("cli-web-crawler"); await new ItcmCrawler(null, database, new WebCrawler.Models.Source { Type = CrawlingType.Itcm, BoardId = "game_news", Name = "핫딜" }).RunAsync(); await new ClienCrawler(null, database, new WebCrawler.Models.Source { Type = CrawlingType.Clien, BoardId = "jirum", Name = "지름" }).RunAsync(); await new FmkoreaCrawler(null, database, new WebCrawler.Models.Source { Type = CrawlingType.FmKorea, BoardId = "hotdeal", Name = "펨코핫딜" }).RunAsync(); await new FmkoreaCrawler(null, database, new WebCrawler.Models.Source { Type = CrawlingType.FmKorea, BoardId = "best", Name = "포텐터짐" }).RunAsync(); await new HumorUnivCrawler(null, database, new WebCrawler.Models.Source { Type = CrawlingType.HumorUniv, BoardId = "pick", Name = "인기자료" }).RunAsync(); await new InvenNewsCrawler(null, database, new WebCrawler.Models.Source { Type = CrawlingType.InvenNews, BoardId = "site=lol", Name = "인벤 LOL 뉴스" }).RunAsync(); await new PpomppuCrawler(null, database, new WebCrawler.Models.Source { Type = CrawlingType.Ppomppu, BoardId = "freeboard", Name = "자유게시판" }).RunAsync(); await new TodayhumorCrawler(null, database, new WebCrawler.Models.Source { Type = CrawlingType.TodayHumor, BoardId = "bestofbest", Name = "베오베" }).RunAsync(); await new SlrclubCrawler(null, database, new WebCrawler.Models.Source { Type = CrawlingType.SlrClub, BoardId = "free", Name = "자유게시판" }).RunAsync(); await new FmkoreaCrawler(null, database, new WebCrawler.Models.Source { Type = CrawlingType.FmKorea, BoardId = "football_news", Name = "축구 뉴스" }).RunAsync(); await new ClienCrawler(null, database, new WebCrawler.Models.Source { Type = CrawlingType.Clien, BoardId = "sold", Name = "회원중고장터" }).RunAsync(); await new RuliwebCrawler(null, database, new WebCrawler.Models.Source { Type = CrawlingType.Ruliweb, BoardId = "market/board/1020", Name = "핫딜게시판" }).RunAsync(); await new RuliwebCrawler(null, database, new WebCrawler.Models.Source { Type = CrawlingType.Ruliweb, BoardId = "market/board/1003", Name = "콘솔뉴스" }).RunAsync(); await new RuliwebCrawler(null, database, new WebCrawler.Models.Source { Type = CrawlingType.Ruliweb, BoardId = "best/selection", Name = "베스트" }).RunAsync(); await new RuliwebCrawler(null, database, new WebCrawler.Models.Source { Type = CrawlingType.Ruliweb, BoardId = "best", Name = "유머베스트" }).RunAsync(); }
public override void createPdf() { string file = "Models/Vehicle_Contract.json"; using var reader = new StreamReader(file, Encoding.Default); try { dynamic groupsJSON = JsonConvert.DeserializeObject(reader.ReadToEnd()); int pageNumber = 1; Document doc = new Document(iTextSharp.text.PageSize.A4, 10, 10, 10, 10); PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream("vehicleContract.pdf", FileMode.Create)); doc.Open(); System.Text.EncodingProvider ppp = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(ppp); FontFactory.Register("c:/Windows/Fonts/times.ttf", "Times New Roman"); Font titleFont = FontFactory.GetFont("Times New Roman", 13, Font.BOLD); Font regularFont = FontFactory.GetFont("Times New Roman", 13); Paragraph title; string text = groupsJSON.title; title = new Paragraph(text, titleFont); title.Alignment = Element.ALIGN_CENTER; doc.Add(title); text = groupsJSON.rightsTitle; doc.Add(new Paragraph(text, regularFont)); text = groupsJSON.nextLine; doc.Add(new Paragraph(text, regularFont)); text = groupsJSON.buyerName; text = text.Replace("[$buyerName]", personA.LastName + " " + personA.FirstName); doc.Add(new Paragraph(text, regularFont)); text = groupsJSON.buyerBirthplace; text = text.Replace("[$buyerBirthplace]", personA.BirthPlace); doc.Add(new Paragraph(text, regularFont)); text = groupsJSON.buyerMother; text = text.Replace("[$buyerMother]", personA.MotherName); doc.Add(new Paragraph(text, regularFont)); text = groupsJSON.buyerNationality; text = text.Replace("[$buyerNationality]", personA.Nationality); doc.Add(new Paragraph(text, regularFont)); text = groupsJSON.buyerAddress; text = text.Replace("[$buyerAddress]", personA.PostCode + ", " + personA.City + " " + personA.Street + " " + personA.HouseNumber); doc.Add(new Paragraph(text, regularFont)); text = groupsJSON.buyerID; text = text.Replace("[$buyerID]", personA.PersonalID.ToString()); doc.Add(new Paragraph(text, regularFont)); text = groupsJSON.buyerIDType; doc.Add(new Paragraph(text, regularFont)); text = groupsJSON.buyerNumber; doc.Add(new Paragraph(text + dotLine(40), regularFont)); text = groupsJSON.buyerOrganisation; doc.Add(new Paragraph(text + dotLine(70), regularFont)); text = groupsJSON.buyerSiteAddress; doc.Add(new Paragraph(text, regularFont)); text = groupsJSON.buyerRegistrationNumber; doc.Add(new Paragraph(text + dotLine(60), regularFont)); text = groupsJSON.buyerRepresenter; doc.Add(new Paragraph(text + dotLine(50), regularFont)); text = groupsJSON.sellTitle; doc.Add(new Paragraph(text, regularFont)); text = groupsJSON.sellerName; text = text.Replace("[$sellerName]", personB.LastName + " " + personB.FirstName); doc.Add(new Paragraph(text, regularFont)); text = groupsJSON.sellerBirthPlace; text = text.Replace("[$sellerBirthPlace]", personB.BirthPlace); doc.Add(new Paragraph(text, regularFont)); text = groupsJSON.sellerMother; text = text.Replace("[$sellerMother]", personB.MotherName); doc.Add(new Paragraph(text, regularFont)); text = groupsJSON.sellerNationality; text = text.Replace("[$sellerNationality]", personB.Nationality); doc.Add(new Paragraph(text, regularFont)); text = groupsJSON.sellerAddress; text = text.Replace("[$sellerAddress]", personB.PostCode + ", " + personB.City + " " + personB.Street + " " + personB.HouseNumber); doc.Add(new Paragraph(text, regularFont)); text = groupsJSON.sellerID; text = text.Replace("[$sellerID]", personB.PersonalID.ToString()); doc.Add(new Paragraph(text, regularFont)); text = groupsJSON.sellerIDType; doc.Add(new Paragraph(text, regularFont)); text = groupsJSON.sellerNumber; doc.Add(new Paragraph(text, regularFont)); text = groupsJSON.sellerOrganisation; doc.Add(new Paragraph(text + dotLine(40), regularFont)); text = groupsJSON.sellerOrganisationSiteAddress; doc.Add(new Paragraph(text + dotLine(40), regularFont)); text = groupsJSON.sellerOrganisationRegistrationNumber; doc.Add(new Paragraph(text + dotLine(40), regularFont)); text = groupsJSON.sellerOrganisationRepresenterName; doc.Add(new Paragraph(text + dotLine(40), regularFont)); doc.NewPage(); doc.Add(new Paragraph(encodedText("a továbbiakban mint Vevő"), regularFont)); doc.Add(new Paragraph(encodedText("(együttesen a továbbiakban: Felek) között az alulírott helyen és időben az alábbi feltételek szerint:"), regularFont)); List list = new List(List.ORDERED); for (int i = 1; i < groupsJSON.Conditions.Count; i++) { text = groupsJSON.Conditions[i].text; list.Add(new ListItem(text, regularFont)); } doc.Add(list); text = groupsJSON.twoCopies; doc.Add(new Paragraph(text, regularFont)); System.DateTime moment = DateTime.Today; text = text.Replace("[$City]", personB.City).Replace("[$year]", moment.Year.ToString()).Replace("[$month]", moment.Month.ToString()).Replace("[$day]", moment.Day.ToString()); doc.Add(new Paragraph(text, regularFont)); doc.Add(new Paragraph(dotLine(30) + " " + dotLine(30) + encodedText("\n Eladó Vevő"), regularFont)); doc.Add(new Paragraph(encodedText("Előttünk mint tanúk előtt:"), regularFont)); doc.Add(new Paragraph(encodedText("1.Családi és utónév:") + dotLine(25), regularFont)); doc.Add(new Paragraph(encodedText("lakcím:") + dotLine(25), regularFont)); doc.Add(new Paragraph(encodedText("2.Családi és utónév:") + dotLine(25), regularFont)); doc.Add(new Paragraph(encodedText("lakcím:") + dotLine(25), regularFont)); doc.Close(); } catch (Exception e) { } }
static void Main(string[] args) { Console.Title = "Kurs Walut"; poczatek: Console.WriteLine("Kurs Walut"); Console.WriteLine("----------"); Console.WriteLine(); Console.Beep(); //pobieranie i porządkowanie danych System.Text.EncodingProvider provider = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(provider); XDocument xDocument = XDocument.Load(XmlReader.Create("http://www.nbp.pl/kursy/xml/lasta.xml")); int i = 0; int j = 0; string[,] tablicaPozycja = new string[35, 4]; foreach (XElement hashElement in xDocument.Descendants("nazwa_waluty")) { string nazwaWaluty = (string)hashElement; //Console.WriteLine(hashValue); tablicaPozycja[i, 0] = nazwaWaluty; i++; } i = 0; foreach (XElement hashElement2 in xDocument.Descendants("przelicznik")) { string przelicznik = (string)hashElement2; tablicaPozycja[i, 1] = przelicznik; i++; } i = 0; foreach (XElement hashElement3 in xDocument.Descendants("kod_waluty")) { string kodWaluty = (string)hashElement3; tablicaPozycja[i, 2] = kodWaluty; i++; } i = 0; foreach (XElement hashElement4 in xDocument.Descendants("kurs_sredni")) { string kursSredni = (string)hashElement4; tablicaPozycja[i, 3] = kursSredni; i++; } //wyświetlanie wszyskich nazw walut for (int q = 0; q < 35; q++) { Console.WriteLine(q + 1 + " - " + tablicaPozycja[q, 0]); } //menu wyboru waluty wyborWaluty: Console.Write("\nWybierz walutę: "); string wybors = Console.ReadLine(); int cleanWybor = 0; while (!int.TryParse(wybors, out cleanWybor)) { Console.WriteLine("To jest błędna warość. Proszę wprowadzić poprawną!"); goto wyborWaluty; } int wybor = int.Parse(wybors); if (wybor > 35 || wybor < 1) { Console.WriteLine("To jest błędna warość. Proszę wprowadzić poprawną!"); goto wyborWaluty; } Console.Clear(); Console.WriteLine("> " + tablicaPozycja[wybor - 1, 0] + " <"); string nazwa = tablicaPozycja[wybor - 1, 0]; for (int t = 0; t < nazwa.Length + 4; t++) { Console.Write("-"); } Console.WriteLine("\n"); wyborKwoty: Console.Write("Wprowadź kwotę: "); string kwotas = Console.ReadLine(); decimal cleanKwota = 0; while (!decimal.TryParse(kwotas, out cleanKwota)) { Console.WriteLine("To jest błędna warość. Proszę wprowadzić poprawną!"); goto wyborKwoty; } decimal kwota = decimal.Parse(kwotas); if (kwota < 0 || kwota == 0) { Console.WriteLine("To jest błędna warość. Proszę wprowadzić poprawną!"); goto wyborKwoty; } decimal kwotaDec = decimal.Parse(tablicaPozycja[wybor - 1, 3]); decimal przelicznikDec = decimal.Parse(tablicaPozycja[wybor - 1, 1]); Console.WriteLine("\n" + kwota + " " + tablicaPozycja[wybor - 1, 2] + " ====> " + kwotaDec * kwota / przelicznikDec + " PLN"); Console.WriteLine("\nNaciśnij 'n' i Enter by zamknąć aplikację, lub dowolny inny klawisz i Enter by kontynuować:"); if (Console.ReadLine() == "n") { return; } else { Console.Clear(); goto poczatek; } }
static void Main(string[] args) { try { // Registering encoding provider for .net core solution System.Text.EncodingProvider encodingProvider = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(encodingProvider); // Parse MessageContents using MsgReader Library // MsgReader library can be obtained from: https://github.com/Sicos1977/MSGReader using (var msg = new MsgReader.Outlook.Storage.Message("HtmlSampleEmailWithAttachment.msg")) { // Get Sender information var from = msg.GetEmailSender(false, false); // Message sent datetime var sentOn = msg.SentOn; // Recipient To information var recipientsTo = msg.GetEmailRecipients(MsgReader.Outlook.RecipientType.To, false, false); // Recipient CC information var recipientsCc = msg.GetEmailRecipients(MsgReader.Outlook.RecipientType.Cc, false, false); // Message subject var subject = msg.Subject; // Get Message Body var msgBody = msg.BodyHtml; // Prepare PDF docuemnt using (Document outputDocument = new Document()) { // Add registration keys outputDocument.RegistrationName = "demo"; outputDocument.RegistrationKey = "demo"; // Add page Page page = new Page(PaperFormat.A4); outputDocument.Pages.Add(page); // Add sample content Font font = new Font(StandardFonts.Times, 12); Brush brush = new SolidBrush(); // Add Email contents int topMargin = 20; page.Canvas.DrawString($"File Name: {msg.FileName}", font, brush, 20, (topMargin += 20)); page.Canvas.DrawString($"From: {from}", font, brush, 20, (topMargin += 20)); page.Canvas.DrawString($"Sent On: {(sentOn.HasValue ? sentOn.Value.ToString("MM/dd/yyyy HH:mm") : "")}", font, brush, 20, (topMargin += 20)); page.Canvas.DrawString($"To: {recipientsTo}", font, brush, 20, (topMargin += 20)); if (!string.IsNullOrEmpty(recipientsCc)) { page.Canvas.DrawString($"CC: {recipientsCc}", font, brush, 20, (topMargin += 20)); } page.Canvas.DrawString($"Subject: {subject}", font, brush, 20, (topMargin += 20)); page.Canvas.DrawString("Message body and attachments in next page.", font, brush, 20, (topMargin += 20)); // Convert Html body to PDF in order to retain all formatting. using (HtmlToPdfConverter converter = new HtmlToPdfConverter()) { converter.PageSize = PaperKind.A4; converter.Orientation = Bytescout.PDF.Converters.PaperOrientation.Portrait; // Convert input HTML to stream byte[] byteArrayBody = Encoding.UTF8.GetBytes(msgBody); MemoryStream inputStream = new MemoryStream(byteArrayBody); // Create output stream to store generated PDF file MemoryStream outputStream = new MemoryStream(); // Convert HTML to PDF converter.ConvertHtmlToPdf(inputStream, outputStream); // Create new document from generated output stream Document docContent = new Document(outputStream); // Append all pages to main PDF foreach (Page item in docContent.Pages) { outputDocument.Pages.Add(item); } // Get attachments from message (if any, and append to document) if (msg.Attachments.Count > 0) { foreach (MsgReader.Outlook.Storage.Attachment itmAttachment in msg.Attachments) { // Get Memory Stream MemoryStream attachmentMemoryStream = new MemoryStream(itmAttachment.Data); // Append Attachment Document docAttachment = new Document(attachmentMemoryStream); // Append all pages to main PDF foreach (Page item in docAttachment.Pages) { outputDocument.Pages.Add(item); } } } // Save output file outputDocument.Save("result.pdf"); } // Open result document in default associated application (for demo purpose) ProcessStartInfo processStartInfo = new ProcessStartInfo("result.pdf"); processStartInfo.UseShellExecute = true; Process.Start(processStartInfo); } } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine("Press enter key to exit..."); Console.ReadLine(); } }
public static void RegisterProvider(EncodingProvider provider) { // Parameters validated inside EncodingProvider EncodingProvider.AddProvider(provider); }
/// <summary> /// Construct an <see cref="EncodingInfo"/> object. /// </summary> /// <param name="provider">The <see cref="EncodingProvider"/> object which created this <see cref="EncodingInfo"/> object</param> /// <param name="codePage">The encoding codepage</param> /// <param name="name">The encoding name</param> /// <param name="displayName">The encoding display name</param> /// <returns></returns> public EncodingInfo(EncodingProvider provider !!, int codePage, string name !!, string displayName !!) : this(codePage, name, displayName)