Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ossamaSaleh authored Dec 13, 2020
0 parents commit 065121a
Show file tree
Hide file tree
Showing 19 changed files with 271 additions and 0 deletions.
25 changes: 25 additions & 0 deletions CustomActivity.Appointment.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.645
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomActivity.Appointment", "FDF.CustomActivity.Appointment\CustomActivity.Appointment.csproj", "{9375C8FC-26B0-4701-A70C-75C69EE7F031}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9375C8FC-26B0-4701-A70C-75C69EE7F031}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9375C8FC-26B0-4701-A70C-75C69EE7F031}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9375C8FC-26B0-4701-A70C-75C69EE7F031}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9375C8FC-26B0-4701-A70C-75C69EE7F031}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4CEEEBCA-2872-4CD3-8781-23C42FC59080}
EndGlobalSection
EndGlobal
107 changes: 107 additions & 0 deletions CustomActivity.Appointment/CustomActivity.Appointment.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\ILMerge.3.0.41\build\ILMerge.props" Condition="Exists('..\packages\ILMerge.3.0.41\build\ILMerge.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9375C8FC-26B0-4701-A70C-75C69EE7F031}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CustomActivity.Appointment</RootNamespace>
<AssemblyName>CustomActivity.Appointment</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>ossamaA.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="DDay.iCal, Version=1.0.2.575, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DDay.iCal.1.0.2.575\lib\DDay.iCal.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Crm.Sdk.Proxy, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CrmSdk.CoreAssemblies.9.0.2.3\lib\net452\Microsoft.Crm.Sdk.Proxy.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CrmSdk.CoreAssemblies.9.0.2.3\lib\net452\Microsoft.Xrm.Sdk.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xrm.Sdk.Workflow, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CrmSdk.Workflow.9.0.2.29\lib\net462\Microsoft.Xrm.Sdk.Workflow.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Activities" />
<Reference Include="System.Activities.Presentation" />
<Reference Include="System.Core" />
<Reference Include="System.DirectoryServices" />
<Reference Include="System.DirectoryServices.AccountManagement" />
<Reference Include="System.IdentityModel" />
<Reference Include="System.Reflection, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reflection.4.1.0\lib\net462\System.Reflection.dll</HintPath>
</Reference>
<Reference Include="System.Reflection.TypeExtensions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reflection.TypeExtensions.4.1.0\lib\net462\System.Reflection.TypeExtensions.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Runtime.Serialization.Primitives, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.Serialization.Primitives.4.3.0\lib\net46\System.Runtime.Serialization.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Security" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Web" />
<Reference Include="System.Web" />
<Reference Include="System.Workflow.Activities" />
<Reference Include="System.Workflow.ComponentModel" />
<Reference Include="System.Workflow.Runtime" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="SendAppointment.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="ossamaA.snk" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\ILMerge.3.0.41\build\ILMerge.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\ILMerge.3.0.41\build\ILMerge.props'))" />
<Error Condition="!Exists('..\packages\ILMerge.MSBuild.Task.1.0.7\build\ILMerge.MSBuild.Task.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\ILMerge.MSBuild.Task.1.0.7\build\ILMerge.MSBuild.Task.targets'))" />
</Target>
<Import Project="..\packages\ILMerge.MSBuild.Task.1.0.7\build\ILMerge.MSBuild.Task.targets" Condition="Exists('..\packages\ILMerge.MSBuild.Task.1.0.7\build\ILMerge.MSBuild.Task.targets')" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;
using Microsoft.Xrm.Sdk.Query;
using System;
using System.Activities;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DDay.iCal;
using DDay.iCal.Serialization.iCalendar;
using System.Net.Mail;

namespace CustomActivity.Appointment
{
public class SendAppointment : CodeActivity
{
[RequiredArgument]
[Input("Start Date")]
public InArgument<DateTime> From { get; set; }
[RequiredArgument]
[Input("EndDate")]
public InArgument<DateTime> To { get; set; }
[RequiredArgument]
[Input("Email")]
public InArgument<string> Email { get; set; }
[RequiredArgument]
[Input("Subject")]
public InArgument<string> Subject { get; set; }
[RequiredArgument]
[Input("Location")]
public InArgument<string> Location { get; set; }
[RequiredArgument]
[Input("EnableSSL")]
public InArgument<bool> IsEnableSSL { get; set; }
[RequiredArgument]
[Input("SMTP Configuration")]
[ReferenceTarget("os_emailconfiguration")]
public InArgument<EntityReference> Configuration { get; set; }
protected override void Execute(CodeActivityContext context)
{
ITracingService tracingService = context.GetExtension<ITracingService>();
var workflowContext = context.GetExtension<IWorkflowContext>();
var serviceFactory = context.GetExtension<IOrganizationServiceFactory>();
var orgService = serviceFactory.CreateOrganizationService(workflowContext.UserId);
DateTime AcStartDate = this.From.Get<DateTime>(context);
DateTime AcEndDate = this.To.Get<DateTime>(context);
string _email = this.Email.Get<string>(context);
string _subject = this.Subject.Get<string>(context);
string _location = this.Location.Get<string>(context);
var _isSSL = this.IsEnableSSL.Get<bool>(context);
//Get the Configuration
EntityReference _config = this.Configuration.Get<EntityReference>(context);
var ConfigData = orgService.Retrieve(_config.LogicalName, _config.Id, new ColumnSet(true));
var _smtpIP = ConfigData.GetAttributeValue<string>("os_smtpip");
var _username = ConfigData.GetAttributeValue<string>("os_username");
var _pass = ConfigData.GetAttributeValue<string>("os_password");
var _sender = ConfigData.GetAttributeValue<string>("emailaddress");
var _orgName = ConfigData.GetAttributeValue<string>("os_name");
var _port = ConfigData.GetAttributeValue<int>("os_port");
IICalendar iCal = new iCalendar();
iCal.Method = "Request";
IEvent evt = iCal.Create<Event>();
evt.Summary = _subject;
evt.Start = new iCalDateTime(AcStartDate);
evt.End = new iCalDateTime(AcEndDate);
evt.Description = _subject;
evt.Location = _location;
tracingService.Trace("evt done");
//evt.Name = _subject;
//evt.Organizer = new Organizer("MAILTO:" + _sender);
//evt.Organizer.CommonName = _orgName;
Alarm alarm = new Alarm();

// Display the alarm somewhere on the screen.
alarm.Action = AlarmAction.Display;

// This is the text that will be displayed for the alarm.
alarm.Summary = _subject;

// The alarm is set to occur 30 minutes before the event
alarm.Trigger = new Trigger(TimeSpan.FromMinutes(-30));
var serializer = new iCalendarSerializer(iCal);
var iCalString = serializer.SerializeToString(iCal);
var msg = new MailMessage();
msg.Subject = _subject;
msg.Body = _subject;
msg.From = new MailAddress(_sender);
msg.To.Add(_email);

tracingService.Trace("mail done");
// Create the Alternate view object with Calendar MIME type
var ct = new System.Net.Mime.ContentType("text/calendar");
if (ct.Parameters != null) ct.Parameters.Add("method", "REQUEST");

//Provide the framed string here
AlternateView avCal = AlternateView.CreateAlternateViewFromString(iCalString, ct);
msg.AlternateViews.Add(avCal);

// Send email
try
{
SendSMTP(_smtpIP, _port, _username, _pass, _isSSL);
tracingService.Trace("done");

}
catch (Exception ex) { throw new InvalidPluginExecutionException("Error " + ex.Message); }

}
void SendSMTP(string SMTPHost, int Port, string Username, string Password, bool isSSL)
{
SmtpClient smtp = new SmtpClient();
smtp.Host = SMTPHost;

smtp.Port = Port;
smtp.UseDefaultCredentials = false;
//smtp.DeliveryMethod = SmtpDeliveryMethod.Network;

if (isSSL)
smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new System.Net.NetworkCredential(Username, Password);
}
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="DDay.iCal" version="1.0.2.575" targetFramework="net462" />
<package id="ILMerge" version="3.0.41" targetFramework="net462" />
<package id="ILMerge.MSBuild.Task" version="1.0.7" targetFramework="net462" />
<package id="Microsoft.CrmSdk.CoreAssemblies" version="9.0.2.3" targetFramework="net462" />
<package id="Microsoft.CrmSdk.Workflow" version="9.0.2.29" targetFramework="net462" />
<package id="NodaTime" version="2.0.2" targetFramework="net462" />
<package id="System.Reflection" version="4.1.0" targetFramework="net462" />
<package id="System.Reflection.TypeExtensions" version="4.1.0" targetFramework="net462" />
<package id="System.Runtime.Serialization.Primitives" version="4.3.0" targetFramework="net462" />
</packages>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"General":{"OutputFile":"C:\\Users\\SalmanTariq\\Documents\\FDF.CustomActivity.Appointment\\FDF.CustomActivity.Appointment\\bin\\Debug\\ILMerge\\CustomActivity.Appointment.dll","TargetPlatform":"v4,C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319","KeyFile":"C:\\Users\\SalmanTariq\\Documents\\FDF.CustomActivity.Appointment\\FDF.CustomActivity.Appointment\\ossamaA.snk","AlternativeILMergePath":null,"InputAssemblies":["C:\\Users\\SalmanTariq\\Documents\\FDF.CustomActivity.Appointment\\FDF.CustomActivity.Appointment\\bin\\Debug\\CustomActivity.Appointment.dll","C:\\Users\\SalmanTariq\\Documents\\FDF.CustomActivity.Appointment\\packages\\DDay.iCal.1.0.2.575\\lib\\DDay.iCal.dll","C:\\Users\\SalmanTariq\\Documents\\FDF.CustomActivity.Appointment\\packages\\System.Reflection.4.1.0\\lib\\net462\\System.Reflection.dll","C:\\Users\\SalmanTariq\\Documents\\FDF.CustomActivity.Appointment\\packages\\System.Reflection.TypeExtensions.4.1.0\\lib\\net462\\System.Reflection.TypeExtensions.dll","C:\\Users\\SalmanTariq\\Documents\\FDF.CustomActivity.Appointment\\packages\\System.Runtime.Serialization.Primitives.4.3.0\\lib\\net46\\System.Runtime.Serialization.Primitives.dll"]},"Advanced":{"AllowMultipleAssemblyLevelAttributes":false,"AllowWildCards":false,"AllowZeroPeKind":false,"AttributeFile":null,"Closed":false,"CopyAttributes":true,"DebugInfo":true,"DelaySign":false,"DeleteCopiesOverwriteTarget":false,"ExcludeFile":"","FileAlignment":512,"Internalize":false,"Log":false,"LogFile":null,"PublicKeyTokens":true,"TargetKind":null,"UnionMerge":false,"Version":null,"XmlDocumentation":false,"AllowDuplicateType":null,"SearchDirectories":["C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.2\\","C:\\Users\\SalmanTariq\\Documents\\FDF.CustomActivity.Appointment\\FDF.CustomActivity.Appointment\\bin\\Debug\\","C:\\Users\\SalmanTariq\\Documents\\FDF.CustomActivity.Appointment\\packages\\Microsoft.CrmSdk.CoreAssemblies.9.0.2.3\\lib\\net452\\","C:\\Users\\SalmanTariq\\Documents\\FDF.CustomActivity.Appointment\\packages\\Microsoft.CrmSdk.Workflow.9.0.2.29\\lib\\net462\\"]}}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"General":{"OutputFile":"C:\\Users\\SalmanTariq\\Documents\\FDF.CustomActivity.Appointment\\FDF.CustomActivity.Appointment\\bin\\Debug\\ILMerge\\FDF.CustomActivity.Appointment.dll","TargetPlatform":"v4,C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319","KeyFile":"C:\\Users\\SalmanTariq\\Documents\\FDF.CustomActivity.Appointment\\FDF.CustomActivity.Appointment\\ossamaA.snk","AlternativeILMergePath":null,"InputAssemblies":["C:\\Users\\SalmanTariq\\Documents\\FDF.CustomActivity.Appointment\\FDF.CustomActivity.Appointment\\bin\\Debug\\FDF.CustomActivity.Appointment.dll","C:\\Users\\SalmanTariq\\Documents\\FDF.CustomActivity.Appointment\\packages\\DDay.iCal.1.0.2.575\\lib\\DDay.iCal.dll","C:\\Users\\SalmanTariq\\Documents\\FDF.CustomActivity.Appointment\\packages\\System.Reflection.4.1.0\\lib\\net462\\System.Reflection.dll","C:\\Users\\SalmanTariq\\Documents\\FDF.CustomActivity.Appointment\\packages\\System.Reflection.TypeExtensions.4.1.0\\lib\\net462\\System.Reflection.TypeExtensions.dll","C:\\Users\\SalmanTariq\\Documents\\FDF.CustomActivity.Appointment\\packages\\System.Runtime.Serialization.Primitives.4.3.0\\lib\\net46\\System.Runtime.Serialization.Primitives.dll"]},"Advanced":{"AllowMultipleAssemblyLevelAttributes":false,"AllowWildCards":false,"AllowZeroPeKind":false,"AttributeFile":null,"Closed":false,"CopyAttributes":true,"DebugInfo":true,"DelaySign":false,"DeleteCopiesOverwriteTarget":false,"ExcludeFile":"","FileAlignment":512,"Internalize":false,"Log":false,"LogFile":null,"PublicKeyTokens":true,"TargetKind":null,"UnionMerge":false,"Version":null,"XmlDocumentation":false,"AllowDuplicateType":null,"SearchDirectories":["C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.2\\","C:\\Users\\SalmanTariq\\Documents\\FDF.CustomActivity.Appointment\\FDF.CustomActivity.Appointment\\bin\\Debug\\","C:\\Users\\SalmanTariq\\Documents\\FDF.CustomActivity.Appointment\\packages\\Microsoft.CrmSdk.CoreAssemblies.9.0.2.3\\lib\\net452\\","C:\\Users\\SalmanTariq\\Documents\\FDF.CustomActivity.Appointment\\packages\\Microsoft.CrmSdk.Workflow.9.0.2.29\\lib\\net462\\"]}}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 065121a

Please sign in to comment.