本文整理汇总了C#中Report.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Report.ToString方法的具体用法?C# Report.ToString怎么用?C# Report.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Report
的用法示例。
在下文中一共展示了Report.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendReport
public void SendReport(Report report , Contact[] contacts , Report.ExportFormat Format, DateTime getCachedFrom, out bool isFromCache)
{
isFromCache=false;
if(report.IsProxy)
throw new Exception("Report cannot be Proxy");
if(contacts.Length==0)
return;
string fileNamePattern=report.GetType().Name + "_" + report.ID.ToString() + "_";
string fileName=fileNamePattern + DateTime.Now.ToString("yyyyMMddHHmmss") + "." + Format.ToString();
string cacheLookupFileName=fileNamePattern + getCachedFrom.ToString("yyyyMMddHHmmss") + "." + Format.ToString();
string filePath=null;
string reportString=null;
// lookup cached report
string[] lookupPaths=Directory.GetFiles(FI.Common.AppConfig.TempDir, fileNamePattern + "*." + Format.ToString());
if(lookupPaths!=null)
{
foreach(string path in lookupPaths)
{
string file=Path.GetFileName(path);
if(file.Length==cacheLookupFileName.Length && file.CompareTo(cacheLookupFileName)>0)
{
filePath=FI.Common.AppConfig.TempDir+ @"\" + file;
isFromCache=true;
break;
}
}
}
if(filePath==null)
{
filePath=FI.Common.AppConfig.TempDir+ @"\" + fileName;
report.Export(filePath, Format);
}
foreach(Contact cnt in contacts)
{
if(Format==Report.ExportFormat.HTML && reportString==null)
{
if(cnt.DistributionFormat==Contact.DistributionFormatEnum.MessageBody || cnt.DistributionFormat==Contact.DistributionFormatEnum.Body_And_Attachment)
{
StreamReader sr=new StreamReader(filePath, System.Text.Encoding.Unicode, true);
if(sr!=null)
{
reportString=sr.ReadToEnd();
sr.Close();
}
}
}
//send via email
try
{
if(cnt.IsProxy)
cnt.Fetch();
// message object
OpenSmtp.Mail.MailMessage msg=new OpenSmtp.Mail.MailMessage();
msg.From=new OpenSmtp.Mail.EmailAddress(FI.Common.AppConfig.SmtpSender);
msg.To.Add(new OpenSmtp.Mail.EmailAddress(cnt.EMail));
msg.Subject=report.Name + " (" + report.Description + ")";
// attachment if ordered or report is not html
if(cnt.DistributionFormat==Contact.DistributionFormatEnum.Attachment ||
cnt.DistributionFormat==Contact.DistributionFormatEnum.Body_And_Attachment ||
Format!=Report.ExportFormat.HTML)
{
OpenSmtp.Mail.Attachment att=new OpenSmtp.Mail.Attachment(filePath);
//att.Encoding=System.Web.Mail.MailEncoding.UUEncode;
msg.Attachments.Add(att);
}
// message body (if retport is html)
if(Format==Report.ExportFormat.HTML &&
(cnt.DistributionFormat==Contact.DistributionFormatEnum.MessageBody ||
cnt.DistributionFormat==Contact.DistributionFormatEnum.Body_And_Attachment))
{
msg.HtmlBody=reportString;
}
// msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "0"); //This is crucial. put 0 there
// msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 90);
OpenSmtp.Mail.SmtpConfig.LogToText=false;
OpenSmtp.Mail.Smtp smtp=new OpenSmtp.Mail.Smtp();
smtp.SendTimeout=600;
smtp.Host=FI.Common.AppConfig.SmtpServer;
if(FI.Common.AppConfig.SmtpUserName!=null && FI.Common.AppConfig.SmtpUserName!="")
{
smtp.Username=FI.Common.AppConfig.SmtpUserName;
smtp.Password=FI.Common.AppConfig.SmtpPassword;
}
smtp.SendMail(msg);
// System.Web.Mail.SmtpMail.SmtpServer=FI.Common.AppConfig.SmtpServer;
// System.Web.Mail.SmtpMail.Send(msg);
}
catch(Exception exc)
//.........这里部分代码省略.........
示例2: GenerateSolution
public static StringBuilder GenerateSolution()
{
Solution solutionReport = m_Context.Solve(m_CSPDirective);
_Report = solutionReport.GetReport();
foreach (Shift shift in Management.Shifts)
{
shift.EmployeesInShift.Clear();
}
int[,] solution = convertDecicionsToIntegers();
StringBuilder shiftsStringBuildr = new StringBuilder();
string reportString = _Report.ToString();
for (int i = 0; i < solution.GetLength(0); i++)
{
for (int j = 0; j < solution.GetLength(1); j++)
{
if (solution[i, j] == 1)
{
Management.Shifts[j].EmployeesInShift.Add(Management.Employees[i]);
}
}
shiftsStringBuildr.AppendLine();
}
System.IO.File.WriteAllText(@"C:\\Temp\REPORT.txt", reportString);
return shiftsStringBuildr;
}