static void SimpleOCRCalculator(string filePath)
{
RasterCodecs codecs = new RasterCodecs();
RasterImage image = codecs.Load(filePath);
string[] calculations;
using (IOcrEngine engine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false))
{
engine.Startup(null, null, null, null);
IOcrPage page = engine.CreatePage(image, OcrImageSharingMode.None);
page.AutoZone(null);
page.Recognize(null);
calculations = new string[page.Zones.Count];
for (int i = 0; i < page.Zones.Count; i++)
{
calculations[i] = page.GetText(i);
}
engine.Shutdown();
}
Dictionary<string, Action<double, double>> operands = new Dictionary<string, Action<double, double>>();
operands.Add("+", new Action<double, double>(delegate(double a, double b) { double ans = a + b; Console.WriteLine("{0} + {1} = {2}", a, b, ans); }));
operands.Add("-", new Action<double, double>(delegate(double a, double b) { double ans = a - b; Console.WriteLine("{0} - {1} = {2}", a, b, ans); }));
operands.Add("x", new Action<double, double>(delegate(double a, double b) { double ans = a * b; Console.WriteLine("{0} * {1} = {2}", a, b, ans); }));
operands.Add("/", new Action<double, double>(delegate(double a, double b) { double ans = a / b; Console.WriteLine("{0} / {1} = {2}", a, b, ans); }));
for (int i = 0; i < calculations.Length; i++)
{
string equation = Regex.Replace(calculations[i], @"\n|\r| ", "");
string[] ops = new string[] { "+", "-", "x", "/" };
for (int j = 0; j < ops.Length; j++)
{
int index = equation.IndexOf(ops[j]);
if (index > 0 && index < equation.Length)
{
string op1 = equation.Substring(0, index);
string op2 = equation.Substring(index + 1);
double arg1 = double.Parse(op1);
double arg2 = double.Parse(op2);
operands[ops[j]](arg1, arg2);
break;
}
}
}
codecs.Dispose();
image.Dispose();
}
C#: MailBee.SmtpMail.Smtp.QuickSend("from@me.com", "to@you.com", "Subject", "Message Body"); |
VB.NET: MailBee.SmtpMail.Smtp.QuickSend("from@me.com", "to@you.com", "Subject", "Message Body") |
C#: MailBee.SmtpMail.Smtp.QuickSend("From Me (Company Info)", "To you ", "Subject", "Plain text body", "HTML-formatted body", null, @"C:\My Documents\report.doc"); |
VB.NET: MailBee.SmtpMail.Smtp.QuickSend("From Me (Company Info)", _ "To you ", _ "Subject", "Plain text body", _ "«html»HTML-formatted body«/html»", _ Nothing, "C:\My Documents\report.doc") |
C#: Smtp oMailer = new Smtp(); |
VB.NET: Dim oMailer As New Smtp() |
C#: oMailer.SmtpServers.Add("smtp.domain.com"); |
VB.NET: oMailer.SmtpServers.Add("smtp.domain.com") |
C#: oMailer.SmtpServers.Add("127.0.0.1"); |
VB.NET: oMailer.SmtpServers.Add("127.0.0.1") |
C#: oMailer.SmtpServers.Add("smtp.domain.com","login","password"); |
VB.NET: oMailer.SmtpServers.Add("smtp.domain.com","login","password") |
C#: oMailer.SmtpServers.Add("127.0.0.1","login","password"); |
VB.NET: oMailer.SmtpServers.Add("127.0.0.1","login","password") |
C#: oMailer.From.AsString = "Dan Brown (Company Info)"; |
VB.NET: oMailer.From.AsString = "Dan Brown (Company Info)" |
C#: oMailer.From.AsString = "Dan Brown "; |
VB.NET: oMailer.From.AsString = "Dan Brown " |
C#: oMailer.From.AsString = "dan@domain.com"; |
VB.NET: oMailer.From.AsString = "dan@domain.com" |
C#: oMailer.To.AsString = "Bill Smith (Remarks), Kathy@mail.com "; oMailer.Cc.AsString = "Joe Black , Joseph "; oMailer.Bcc.AsString = "t.jay@domain.com, s.connor@domain.com"; oMailer.ReplyTo.AsString = "john@domain.com, Barbara Jones "; |
VB.NET: oMailer.To.AsString = "Bill Smith (Remarks), Kathy@mail.com " oMailer.Cc.AsString = "Joe Black , Joseph " oMailer.Bcc.AsString = "t.jay@domain.com, s.connor@domain.com" oMailer.ReplyTo.AsString = "john@domain.com, Barbara Jones " |
C#: oMailer.Subject = "Test message"; |
VB.NET: oMailer.Subject = "Test message" |
C#: oMailer.BodyPlainText = "This is a test e-mail message."; |
VB.NET: oMailer.BodyPlainText = "This is a test e-mail message." |
C#: oMailer.BodyHtmlText = @" Test HTML message.
www.afterlogic.com"; |
VB.NET: oMailer.BodyHtmlText = " Test HTML message. " & vbCrLf & _ "" & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ "www.afterlogic.com" |
C#: oMailer.AddAttachment(@"C:\annual_reoprt.xls"); oMailer.AddAttachment(@"C:\deposits.doc"); |
VB.NET: oMailer.AddAttachment("C:\annual_reoprt.xls") oMailer.AddAttachment("C:\deposits.doc") |
C#: try { oMailer.Send(); Console.WriteLine("The message has been successfully sent."); } catch (MailBeeSmtpRefusedRecipientException e) { Console.WriteLine("The following recipient was refused by SMTP server: " + e.RefusedRecipientEmail); } |
VB.NET: Try oMailer.Send() Console.WriteLine("The message has been successfully sent.") Catch e As MailBeeSmtpRefusedRecipientException Console.WriteLine("The following recipient was refused by SMTP server: " + e.RefusedRecipientEmail) End Try |
C#: using System; using MailBee; using MailBee.SmtpMail; namespace EmailApp { class Class1 { [STAThread] static void Main(string[] args) { Smtp oMailer = new Smtp(); oMailer.From.AsString = "John Doe (Company Info)"; oMailer.To.AsString = "Bill Smith , Kathy Ritchie (Company Info)"; oMailer.Subject = "Test e-mail"; oMailer.BodyPlainText = "This is a test e-mail message."; oMailer.BodyHtmlText = @" Test HTML message.
www.afterlogic.com"; oMailer.AddAttachment(@"C:\annual_reoprt.xls"); oMailer.SmtpServers.Add("127.0.0.1", "login", "password"); oMailer.SmtpServers[0].AllowRefusedRecipients = false; try { oMailer.Send(); Console.WriteLine("The message has been successfully sent."); } catch (MailBeeSmtpRefusedRecipientException e) { Console.WriteLine("The following recipient was refused by SMTP server: "+ e.RefusedRecipientEmail); } } } } |
VB.NET: Imports System Imports MailBee Imports MailBee.SmtpMail Namespace EmailApp Class Class1 _ Shared Sub Main(ByVal args() As String) Dim oMailer As New Smtp() oMailer.From.AsString = "John Doe (Company Info)" oMailer.To.AsString = "Bill Smith , Kathy Ritchie (Company Info)" oMailer.Subject = "Test e-mail" oMailer.BodyPlainText = "This is a test e-mail message." oMailer.BodyHtmlText = " Test HTML message. " & vbCrLf & _ "" & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ "www.afterlogic.com" oMailer.AddAttachment("C:\annual_reoprt.xls") oMailer.SmtpServers.Add("127.0.0.1", "login", "password") oMailer.SmtpServers(0).AllowRefusedRecipients = False Try oMailer.Send() Console.WriteLine("The message has been successfully sent.") Catch e As MailBeeSmtpRefusedRecipientException Console.WriteLine("The following recipient was refused by SMTP server: "+ e.RefusedRecipientEmail) End Try End Sub End Class End Namespace |
很多企业都选择使用开源软件(OSS)构建更加灵活的产品,但其中也存在潜在的风险,软件供应商和IoT制造商都有必要去了解一下隐藏在软件供应链中的风险。
例如,犯罪分子就完全可以利用Apache Struts CVE-2017-5638漏洞来获取Equifax客户的个人资料。众所周知,Apache Struts是一种广泛使用的开源组件 – Web服务器的框架,它可以用于接收和提供公司内部系统中的商业数据。归根到底,还是因为这个开源组件所存在的漏洞以致于使其成为网络攻击的主要目标。
根据Flexera的一份最新报告显示,在商业和IoT软件产品中所发现的代码有百分之五十都是与开源软件有关的。但调查显示只有37%的受访者表示曾获取并使用开源软件。而63%的公司说,他们并没有获取或使用开源软件,或者说他们根本就不知道有这种情况的存在。
并且据了解,目前基本没有人对开源软件的安全性负责:39%的受访者表示,在他们公司内部没有人会对开源软件的安全性负责,或者可以说他们压根就不知道应该是由谁来负责。
除此之外,开源软件的贡献者也不是遵循最佳实践:33%的受访者表示自己的公司曾为开源项目做出了贡献。但是,又有63%的受访者表示他们的公司压根并没有开源采购或使用政策,当然也有43%的受访者表示自己本身对开源项目也有做出贡献。
不管怎样,我们都不能忽视开源确实是一个明显的捷径。 Flexera产品管理副总裁Jeff Luszcz表示:“完全开源可获取的代码可以快速获得产品,这对于软件开发的快速节奏来说非常重要。” “然而,大多数软件工程师并没有在私下里去跟踪开源的使用情况,而且有绝大部分的软件高管都没有意识到其安全/合规风险方面存在一定差距。”
事实上,对于开源软件使用过程中的安全合规、许可等流程可能远比简单的拿来用要方便的多,但这些流程毫无疑问是必不可少的。
“开源软件的安全合规流程能够很好的保护产品和品牌声誉。但大多数软件和IoT厂商都没有意识到存在的问题,所以他们并没有保护自己和户,”Luszcz说,“对于暴露产品合规性和漏洞风险的供应商,还有那些压根就不知道他们运行开放源代码和其他第三方软件的客户,甚至可能是包含软件漏洞的客户 ,这些都是会危及到整个软件供应链。”
2017慧都十四周年狂欢搞事情!砸金蛋100%抽现金红包、满额豪送iPhone X、iPhone 8、DevExpress汉化免费送、团队升级培训套包劲省10万元......更多惊喜等您来探索!

以独立软件包提供的原因在于:(一)不少API是仅出于兼容性的考虑而提供的。在新代码中,不应依赖于这些API;(二)不少API仅用于Windows平台。我们不希望将用户引上一条更难以跨平台迁移应用的道路。
你可以使用与弃用API相同的抑制选项,但是也可以选择对特定平台给出抑制警告。如果你仅规划在一组特定的平台上支持你的代码,例如只支持Windows和Linux但不支持macOS,这一工具十分有用。为此,你只需编辑项目文件,添加一个PlatformCompatIgnore属性,并在该属性中列出所有要忽略的平台。
