修改邮件保存目录

master
Hao 3 years ago
parent 9976b0dfa7
commit 3850102ea8

7
.gitignore vendored

@ -0,0 +1,7 @@
/BcCenter/BcCenter.Common/obj
/BcCenter/BcCenter.Common/bin
/BcCenter/BcCenter.Service/obj
/BcCenter/BcCenter.Service/bin
/BcCenter/packages
/BcCenter/BcCenter.Service/BcCenter.Service.csproj.user
/BcCenter/.vs/BcCenter/v16

@ -81,11 +81,11 @@ namespace BcCenter.Service
string savePath = string.Empty;
if (!string.IsNullOrEmpty(EmlSavePath))
{
savePath = Path.Combine(EmlSavePath, $"BillCenter\\{mailDate.ToString("yyyyMMdd")}\\{account}");
savePath = Path.Combine(EmlSavePath, $"BCCenter\\{mailDate.ToString("yyyyMMdd")}\\{account}");
}
else
{
savePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"BillCenter\\{mailDate.ToString("yyyyMMdd")}\\{account}");
savePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"BCCenter\\{mailDate.ToString("yyyyMMdd")}\\{account}");
}
if (!Directory.Exists(savePath))
@ -96,11 +96,11 @@ namespace BcCenter.Service
//找最大ID
long maxId = 0;
CommonDataContext commonData = new CommonDataContext();
BcCenterDataContext billCenterData = new BcCenterDataContext();
var mc = billCenterData.Mails.Count(r => r.MailAccount == account);
BcCenterDataContext bcCenterData = new BcCenterDataContext();
var mc = bcCenterData.Mails.Count(r => r.MailAccount == account);
if (mc > 0)
{
maxId = billCenterData.Mails.Where(r => r.MailAccount == account).Max(r => r.ImapId);
maxId = bcCenterData.Mails.Where(r => r.MailAccount == account).Max(r => r.ImapId);
uids = uids.Where(u => u.Id > maxId).ToList();
}
@ -109,7 +109,7 @@ namespace BcCenter.Service
int recCount = 0;
foreach (var uid in uids)
{
var c = billCenterData.Mails.Count(r => r.MailAccount == account && r.ImapId == uid.Id);
var c = bcCenterData.Mails.Count(r => r.MailAccount == account && r.ImapId == uid.Id);
if (c > 0)
{
continue; //忽略
@ -200,10 +200,10 @@ namespace BcCenter.Service
continue;
}
var attInfo = billCenterData.Attachments.AsNoTracking().FirstOrDefault(aa => aa.AttachMD5 == att.AttachMD5);
var attInfo = bcCenterData.Attachments.AsNoTracking().FirstOrDefault(aa => aa.AttachMD5 == att.AttachMD5);
if (attInfo != null)
{
var mail = billCenterData.Mails.AsNoTracking().First(mm => mm.GID == attInfo.MailGID);
var mail = bcCenterData.Mails.AsNoTracking().First(mm => mm.GID == attInfo.MailGID);
var errMsg = " <tr>" +
$" <td style=\"border:1px solid gray;padding:5px;\">{att.AttachName}</td>" +
@ -257,10 +257,10 @@ namespace BcCenter.Service
recInfo.MailPath = string.Empty;
}
billCenterData.Mails.Add(recInfo);
billCenterData.Attachments.AddRange(listAtt);
bcCenterData.Mails.Add(recInfo);
bcCenterData.Attachments.AddRange(listAtt);
billCenterData.SaveChanges(); //立即保存
bcCenterData.SaveChanges(); //立即保存
log.Debug($"{account}已下载邮件ID{uid} 标题:{suject} 发送者:{sendUser}");
recCount++;

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" requirePermission="false" />
</configSections>
<log4net>
<root>
<!-- Value of priority may be ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF -->
<level value="DEBUG" />
<appender-ref ref="DebugAppender" />
<appender-ref ref="ErrorAppender" />
<!--<appender-ref ref="AdoNetAppender_MySql" />-->
</root>
<appender name="DebugAppender" type="log4net.Appender.RollingFileAppender">
<!-- debug log: 记录 DEBUG, INFO 级别的日志 -->
<file value="App_Data\\Logs\\debug.log" />
<appendToFile value="true" />
<rollingStyle value="Composite" />
<datePattern value="yyyyMMdd" />
<maxSizeRollBackups value="100" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout" >
<param name="ConversionPattern" value="%date [%p] [%logger] [%thread] - %message%newline" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMax value="INFO" />
</filter>
</appender>
<appender name="ErrorAppender" type="log4net.Appender.RollingFileAppender">
<!-- error log: 记录 WARN,ERROR,FATAL 级别的日志 -->
<file value="App_Data\\Logs\\error.log" />
<appendToFile value="true" />
<rollingStyle value="Composite" />
<datePattern value="yyyyMMdd" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout" >
<param name="ConversionPattern" value="%date [%p] [%logger] [%thread] - %message%newline" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="WARN" />
</filter>
</appender>
<appender name="AdoNetAppender_MySql" type="log4net.Appender.AdoNetAppender">
<bufferSize value="1"/>
<param name="ConnectionType" value="MySql.Data.MySqlClient.MySqlConnection, MySql.Data"/>
<param name="ConnectionString" value="server=101.42.137.198;port=12306;database=log_test;Uid=root;Pwd=123456;"/>
<commandText value="INSERT INTO log4net(log_datetime,log_thread,log_level,log_logger,log_message,Exception) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)"/>
<parameter>
<parameterName value="@log_date"/>
<dbType value="DateTime"/>
<layout type="log4net.Layout.RawTimeStampLayout"/>
<!--<layout type="log4net.Layout.PatternLayout" value="%date{yyyy'-'MM'-'dd HH':'mm':'ss}" />-->
</parameter>
<parameter>
<parameterName value="@thread"/>
<dbType value="String"/>
<size value="255"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%thread"/>
</layout>
</parameter>
<parameter>
<parameterName value="@log_level"/>
<dbType value="String"/>
<size value="50"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%level"/>
</layout>
</parameter>
<parameter>
<parameterName value="@logger"/>
<dbType value="String"/>
<size value="255"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%logger"/>
</layout>
</parameter>
<parameter>
<parameterName value="@message"/>
<dbType value="String"/>
<size value="4000"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message"/>
</layout>
</parameter>
<parameter>
<parameterName value="@exception"/>
<dbType value="String"/>
<size value="2000"/>
<layout type="log4net.Layout.ExceptionLayout"/>
</parameter>
</appender>
</log4net>
</configuration>
Loading…
Cancel
Save