Skip to content

Commit

Permalink
Merge pull request #14 from dmpas/develop
Browse files Browse the repository at this point in the history
1.0.5
  • Loading branch information
dmpas authored Dec 30, 2017
2 parents a1b5967 + 47ec773 commit 11e81fd
Show file tree
Hide file tree
Showing 20 changed files with 128 additions and 65 deletions.
16 changes: 16 additions & 0 deletions MailComponent/Mail/InternetMailAttachment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,28 @@ namespace OneScript.InternetMail
[ContextClass("ИнтернетПочтовоеВложение", "InternetMailAttachment")]
public class InternetMailAttachment : AutoContext<InternetMailAttachment>
{
/// <summary>
/// Пустое почтовое вложение
/// </summary>
public InternetMailAttachment()
{
EncodingMode = InternetMailAttachmentEncodingMode.Mime;
Data = ValueFactory.Create();
}

/// <summary>
/// Почтовое вложение на основании BinaryDataContext
/// </summary>
public InternetMailAttachment(BinaryDataContext binaryData, string fileName = "")
{
EncodingMode = InternetMailAttachmentEncodingMode.Mime;
Data = binaryData;
FileName = fileName;
}

/// <summary>
/// Почтовое вложение на основании файла
/// </summary>
public InternetMailAttachment(string fileName)
{
EncodingMode = InternetMailAttachmentEncodingMode.Mime;
Expand Down
3 changes: 1 addition & 2 deletions MailComponent/Mail/InternetMailAttachments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ public InternetMailAttachment Add(string filePath, string attachmentName = "")

public InternetMailAttachment Add(BinaryDataContext data, string attachmentName = "")
{
var attachment = new InternetMailAttachment();
attachment.Data = data;
var attachment = new InternetMailAttachment(data, attachmentName);
attachment.Name = attachmentName;
_data.Add(attachment);
return attachment;
Expand Down
14 changes: 13 additions & 1 deletion MailComponent/Mail/InternetMailMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,15 @@ public InternetMailMessage(MailKit.IMessageSummary headers) : this(GenerateHeade

public InternetMailMessage(MimeMessage nativeMessage, string identifier) : this(nativeMessage.Headers)
{

Uid.Add(ValueFactory.Create(identifier));
if (nativeMessage.Body is TextPart)
{
Texts.Add(new InternetMailText(nativeMessage.Body as TextPart));
}
else if (nativeMessage.Body is Multipart)
{

var body = nativeMessage.Body as Multipart;
foreach (var part in body)
{
Expand All @@ -125,6 +127,17 @@ public InternetMailMessage(MimeMessage nativeMessage, string identifier) : this(
}
}
}

foreach (var attachment in nativeMessage.Attachments)
{
var part = (MimePart)attachment;
var fileName = part.FileName;
var stream = new MemoryStream();

part.ContentObject.DecodeTo(stream);
BinaryDataContext bin = new BinaryDataContext(stream.ToArray());
Attachments.Add(bin, fileName);
}
}

/// <summary>
Expand Down Expand Up @@ -255,7 +268,6 @@ public InternetMailMessage(MimeMessage nativeMessage, string identifier) : this(

/// <summary>
/// Смещение даты отправления от универсального времени (UTC) в секундах. Для часовых поясов, отстающих от UTC, значение отрицательное.

/// Пример приведения даты отправления к дате в часовом поясе сеанса:
/// ДатаОтправленияВЗонеОтправителя = Сообщение.ДатаОтправления; 
/// <code>
Expand Down
1 change: 0 additions & 1 deletion MailComponent/Mail/InternetMailMessageImportance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ This Source Code Form is subject to the terms of the
at http://mozilla.org/MPL/2.0/.
----------------------------------------------------------*/
using System;
using ScriptEngine.Machine.Contexts;
using ScriptEngine;

namespace OneScript.InternetMail
Expand Down
3 changes: 3 additions & 0 deletions MailComponent/Mail/Pop3Receiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,16 @@ public ArrayImpl Get(bool deleteMessages, ArrayImpl ids, bool markAsRead)
throw RuntimeException.InvalidArgumentValue(); // TODO: Внятное сообщение

var result = new ArrayImpl();

var processedMessages = GetMessagesList(ids);

foreach (var i in processedMessages)
{
var mimeMessage = client.GetMessage(i);

var iMessage = new InternetMailMessage(mimeMessage, client.GetMessageUid(i));
result.Add(iMessage);

}

if (deleteMessages && processedMessages.Count > 0)
Expand Down
22 changes: 11 additions & 11 deletions MailComponent/MailComponent.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -7,7 +7,7 @@
<OutputType>Library</OutputType>
<RootNamespace>OneScript.InternetMail</RootNamespace>
<AssemblyName>MailComponent</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -30,6 +30,15 @@
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="ScriptEngine, Version=1.0.19.104, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\OneScript.1.0.19\lib\net452\ScriptEngine.dll</HintPath>
</Reference>
<Reference Include="ScriptEngine.HostedScript, Version=1.0.19.104, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\OneScript.StandardLibrary.1.0.19\lib\net452\ScriptEngine.HostedScript.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="DotNetZip">
<HintPath>..\packages\DotNetZip.1.10.1\lib\net20\DotNetZip.dll</HintPath>
Expand All @@ -43,15 +52,6 @@
<Reference Include="MimeKit">
<HintPath>..\packages\MimeKit.1.10.0\lib\net45\MimeKit.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="ScriptEngine.HostedScript">
<HintPath>..\packages\OneScript.StandardLibrary.1.0.15\lib\net40\ScriptEngine.HostedScript.dll</HintPath>
</Reference>
<Reference Include="ScriptEngine">
<HintPath>..\packages\OneScript.1.0.15\lib\net40\ScriptEngine.dll</HintPath>
</Reference>
<Reference Include="MailKit">
<HintPath>..\packages\MailKit.1.10.1\lib\net45\MailKit.dll</HintPath>
</Reference>
Expand Down
9 changes: 7 additions & 2 deletions MailComponent/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using System.Reflection;
using System.Runtime.CompilerServices;
/*----------------------------------------------------------
This Source Code Form is subject to the terms of the
Mozilla Public License, v.2.0. If a copy of the MPL
was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.
----------------------------------------------------------*/
using System.Reflection;

// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
Expand Down
6 changes: 3 additions & 3 deletions MailComponent/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<package id="DotNetZip" version="1.10.1" targetFramework="net45" />
<package id="MailKit" version="1.10.1" targetFramework="net45" />
<package id="MimeKit" version="1.10.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
<package id="OneScript" version="1.0.15" targetFramework="net45" />
<package id="OneScript.StandardLibrary" version="1.0.15" targetFramework="net45" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
<package id="OneScript" version="1.0.19" targetFramework="net452" />
<package id="OneScript.StandardLibrary" version="1.0.19" targetFramework="net452" />
</packages>
9 changes: 7 additions & 2 deletions NUnitTests/EngineHelpWrapper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
using System;
/*----------------------------------------------------------
This Source Code Form is subject to the terms of the
Mozilla Public License, v.2.0. If a copy of the MPL
was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.
----------------------------------------------------------*/
using System;
using System.IO;
using NUnit.Framework;
using ScriptEngine.Machine.Contexts;
using ScriptEngine.HostedScript.Library;
using ScriptEngine.Machine;
Expand Down
11 changes: 6 additions & 5 deletions NUnitTests/MainTestClass.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using System.IO;
/*----------------------------------------------------------
This Source Code Form is subject to the terms of the
Mozilla Public License, v.2.0. If a copy of the MPL
was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.
----------------------------------------------------------*/
using NUnit.Framework;
using ScriptEngine.HostedScript;
using ScriptEngine.Machine;
using ScriptEngine.Environment;
using OneScript.InternetMail;

// Используется NUnit 3.6
Expand Down
26 changes: 13 additions & 13 deletions NUnitTests/NUnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -7,7 +7,7 @@
<OutputType>Library</OutputType>
<RootNamespace>NUnitTests</RootNamespace>
<AssemblyName>NUnitTests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -25,22 +25,22 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="ScriptEngine, Version=1.0.19.104, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\OneScript.1.0.19\lib\net452\ScriptEngine.dll</HintPath>
</Reference>
<Reference Include="ScriptEngine.HostedScript, Version=1.0.19.104, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\OneScript.StandardLibrary.1.0.19\lib\net452\ScriptEngine.HostedScript.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.3.4.1\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="DotNetZip">
<HintPath>..\packages\DotNetZip.1.10.1\lib\net20\DotNetZip.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="ScriptEngine.HostedScript">
<HintPath>..\packages\OneScript.StandardLibrary.1.0.15\lib\net40\ScriptEngine.HostedScript.dll</HintPath>
</Reference>
<Reference Include="ScriptEngine">
<HintPath>..\packages\OneScript.1.0.15\lib\net40\ScriptEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="EngineHelpWrapper.cs" />
Expand All @@ -51,7 +51,7 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Tests\testrunner.os" />
<EmbeddedResource Include="Tests\external.os" />
<EmbeddedResource Include="Tests\external.os" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MailComponent\MailComponent.csproj">
Expand All @@ -60,4 +60,4 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
8 changes: 7 additions & 1 deletion NUnitTests/Tests/external.os
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
Перем юТест;
//----------------------------------------------------------
//This Source Code Form is subject to the terms of the
//Mozilla Public License, v.2.0. If a copy of the MPL
//was not distributed with this file, You can obtain one
//at http://mozilla.org/MPL/2.0/.
//----------------------------------------------------------
Перем юТест;

////////////////////////////////////////////////////////////////////
// Программный интерфейс
Expand Down
6 changes: 3 additions & 3 deletions NUnitTests/packages.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="DotNetZip" version="1.10.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
<package id="NUnit" version="3.4.1" targetFramework="net45" />
<package id="OneScript" version="1.0.15" targetFramework="net45" />
<package id="OneScript.StandardLibrary" version="1.0.15" targetFramework="net45" />
<package id="OneScript" version="1.0.19" targetFramework="net452" />
<package id="OneScript.StandardLibrary" version="1.0.19" targetFramework="net452" />
</packages>
8 changes: 7 additions & 1 deletion TestApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
using System;
/*----------------------------------------------------------
This Source Code Form is subject to the terms of the
Mozilla Public License, v.2.0. If a copy of the MPL
was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.
----------------------------------------------------------*/
using System;
using System.IO;
using ScriptEngine.Machine;
using ScriptEngine.HostedScript;
Expand Down
9 changes: 7 additions & 2 deletions TestApp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using System.Reflection;
using System.Runtime.CompilerServices;
/*----------------------------------------------------------
This Source Code Form is subject to the terms of the
Mozilla Public License, v.2.0. If a copy of the MPL
was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.
----------------------------------------------------------*/
using System.Reflection;

// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
Expand Down
22 changes: 11 additions & 11 deletions TestApp/TestApp.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -7,7 +7,7 @@
<OutputType>Exe</OutputType>
<RootNamespace>TestApp</RootNamespace>
<AssemblyName>TestApp</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -27,20 +27,20 @@
<ExternalConsole>true</ExternalConsole>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="ScriptEngine, Version=1.0.19.104, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\OneScript.1.0.19\lib\net452\ScriptEngine.dll</HintPath>
</Reference>
<Reference Include="ScriptEngine.HostedScript, Version=1.0.19.104, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\OneScript.StandardLibrary.1.0.19\lib\net452\ScriptEngine.HostedScript.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="DotNetZip">
<HintPath>..\packages\DotNetZip.1.10.1\lib\net20\DotNetZip.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="ScriptEngine.HostedScript">
<HintPath>..\packages\OneScript.StandardLibrary.1.0.15\lib\net40\ScriptEngine.HostedScript.dll</HintPath>
</Reference>
<Reference Include="ScriptEngine">
<HintPath>..\packages\OneScript.1.0.15\lib\net40\ScriptEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
Expand Down
8 changes: 7 additions & 1 deletion TestApp/TestSendReceive.os
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
Функция СоздатьПрофиль(Знач SMTP = Истина, Знач POP3 = Истина, Знач IMAP = Истина)
//----------------------------------------------------------
//This Source Code Form is subject to the terms of the
//Mozilla Public License, v.2.0. If a copy of the MPL
//was not distributed with this file, You can obtain one
//at http://mozilla.org/MPL/2.0/.
//----------------------------------------------------------
Функция СоздатьПрофиль(Знач SMTP = Истина, Знач POP3 = Истина, Знач IMAP = Истина)

Профиль = Новый ИнтернетПочтовыйПрофиль;

Expand Down
6 changes: 3 additions & 3 deletions TestApp/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="DotNetZip" version="1.10.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
<package id="OneScript" version="1.0.15" targetFramework="net45" />
<package id="OneScript.StandardLibrary" version="1.0.15" targetFramework="net45" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
<package id="OneScript" version="1.0.19" targetFramework="net452" />
<package id="OneScript.StandardLibrary" version="1.0.19" targetFramework="net452" />
</packages>
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 1.0.4-{build}
version: 1.0.5-{build}
image: Visual Studio 2017
environment:
main_project: MailComponent
Expand Down
Loading

0 comments on commit 11e81fd

Please sign in to comment.