Skip to content

Commit

Permalink
1.0.46.0 - New Feature: Date Functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Demian Adolfo Raschkovan committed Nov 25, 2017
1 parent d38b32a commit 29c22a9
Show file tree
Hide file tree
Showing 24 changed files with 145 additions and 11 deletions.
Binary file modified msdyncrmWorkflowTools/.vs/msdyncrmWorkflowTools/v15/.suo
Binary file not shown.
105 changes: 105 additions & 0 deletions msdyncrmWorkflowTools/msdyncrmWorkflowTools/Class/DateFunctions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Workflow;
using System;
using System.Activities;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace msdyncrmWorkflowTools
{
public class DateFunctions : CodeActivity
{
#region "Parameter Definition"
[RequiredArgument]
[Input("Date 1")]
public InArgument<DateTime> Date1 { get; set; }

[Input("Date 2")]
public InArgument<DateTime> Date2 { get; set; }


[Output("Total Days")]
public OutArgument<double> TotalDays { get; set; }

[Output("Total Hours")]
public OutArgument<double> TotalHours { get; set; }

[Output("Total Milliseconds")]
public OutArgument<double> TotalMilliseconds { get; set; }

[Output("Total Minutes")]
public OutArgument<double> TotalMinutes { get; set; }

[Output("Total Seconds")]
public OutArgument<double> TotalSeconds { get; set; }

[Output("Day Of Week")]
public OutArgument<int> DayOfWeek { get; set; }
[Output("Day Of Year")]
public OutArgument<int> DayOfYear { get; set; }
[Output("Day")]
public OutArgument<int> Day { get; set; }
[Output("Month")]
public OutArgument<int> Month { get; set; }
[Output("Year")]
public OutArgument<int> Year { get; set; }
[Output("Week Of Year")]
public OutArgument<int> WeekOfYear { get; set; }

#endregion

protected override void Execute(CodeActivityContext executionContext)
{

#region "Load CRM Service from context"

Common objCommon = new Common(executionContext);
objCommon.tracingService.Trace("Load CRM Service from context --- OK");
#endregion

#region "Read Parameters"
DateTime date1 = this.Date1.Get(executionContext);
DateTime date2 = this.Date2.Get(executionContext);

#endregion



msdyncrmWorkflowTools_Class commonClass = new msdyncrmWorkflowTools_Class(objCommon.service, objCommon.tracingService);
TimeSpan difference = new TimeSpan();
int DayOfWeek = 0;
int DayOfYear = 0;
int Day = 0;
int Month = 0;
int Year = 0;
int WeekOfYear = 0;
commonClass.DateFunctions(date1, date2, ref difference,
ref DayOfWeek, ref DayOfYear, ref Day, ref Month, ref Year, ref WeekOfYear);


this.TotalDays.Set(executionContext, difference.TotalDays);
this.TotalHours.Set(executionContext, difference.TotalHours);
this.TotalMilliseconds.Set(executionContext, difference.TotalMilliseconds);
this.TotalMinutes.Set(executionContext, difference.TotalMinutes);
this.TotalSeconds.Set(executionContext, difference.TotalSeconds);


this.DayOfWeek.Set(executionContext, DayOfWeek);
this.DayOfYear.Set(executionContext, DayOfYear);
this.Day.Set(executionContext, Day);
this.Month.Set(executionContext, Month);
this.Year.Set(executionContext, Year);
this.WeekOfYear.Set(executionContext, WeekOfYear);



}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
// Puede especificar todos los valores o usar los valores predeterminados (número de compilación y de revisión)
// usando el símbolo '*' como se muestra a continuación:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.45.0")]
[assembly: AssemblyFileVersion("1.0.45.0")]
[assembly: AssemblyVersion("1.0.46.0")]
[assembly: AssemblyFileVersion("1.0.46.0")]
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
<Compile Include="Class\SendEmailFromTemplateToUsersInRole.cs" />
<Compile Include="Class\ExecuteWorkflowByID.cs" />
<Compile Include="Class\JsonParser.cs" />
<Compile Include="Class\DateFunctions.cs" />
<Compile Include="Class\UpdateChildRecords.cs" />
<Compile Include="Class\AddUserToTeam.cs" />
<Compile Include="Class\SetState.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
C:\Users\DemianRaschkovan\Source\Repos\Dynamics-365-Workflow-Tools\msdyncrmWorkflowTools\msdyncrmWorkflowTools\obj\Debug\msdyncrmWorkflowTools.csprojResolveAssemblyReference.cache
C:\Users\DemianRaschkovan\Source\Repos\Dynamics-365-Workflow-Tools\msdyncrmWorkflowTools\msdyncrmWorkflowTools\obj\Debug\msdyncrmWorkflowTools.dll
C:\Users\DemianRaschkovan\Source\Repos\Dynamics-365-Workflow-Tools\msdyncrmWorkflowTools\msdyncrmWorkflowTools\obj\Debug\msdyncrmWorkflowTools.pdb
C:\Users\DemianRaschkovan\Source\Repos\Dynamics-365-Workflow-Tools\msdyncrmWorkflowTools\msdyncrmWorkflowTools\obj\Debug\msdyncrmWorkflowTools.csproj.CoreCompileInputs.cache
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
Expand Up @@ -19,6 +19,7 @@
using Microsoft.Crm.Sdk.Messages;
using System.Text.RegularExpressions;
using Newtonsoft.Json.Linq;
using System.Globalization;

namespace msdyncrmWorkflowTools
{
Expand Down Expand Up @@ -162,6 +163,22 @@ private string BuildFetchXml(Guid roleId)
return string.Format(fetchXml, roleId);
}

public bool DateFunctions(DateTime date1, DateTime date2, ref TimeSpan difference,
ref int DayOfWeek, ref int DayOfYear, ref int Day, ref int Month, ref int Year, ref int WeekOfYear)
{
difference = date1 - date2;
DayOfWeek = (int)date1.DayOfWeek;
DayOfYear=date1.DayOfYear;
Day = date1.Day;
Month = date1.Month;
Year = date1.Year;
DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo;
Calendar cal = dfi.Calendar;
WeekOfYear=cal.GetWeekOfYear(date1, dfi.CalendarWeekRule, dfi.FirstDayOfWeek);

return true;
}

public bool StringFunctions(bool capitalizeAllWords, string inputText, string padCharacter, bool padontheLeft,
int finalLengthwithPadding, bool caseSensitive, string replaceOldValue, string replaceNewValue,
int subStringLength, int startIndex, bool fromLefttoRight, string regularExpression,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ C:\Users\DemianRaschkovan\Source\Repos\Dynamics-365-Workflow-Tools\msdyncrmWorkf
C:\Users\DemianRaschkovan\Source\Repos\Dynamics-365-Workflow-Tools\msdyncrmWorkflowTools\msdyncrmWorkflowTools_Class\obj\Debug\msdyncrmWorkflowTools_Class.pdb
C:\Users\DemianRaschkovan\Source\Repos\Dynamics-365-Workflow-Tools\msdyncrmWorkflowTools\msdyncrmWorkflowTools_Class\bin\Debug\Newtonsoft.Json.dll
C:\Users\DemianRaschkovan\Source\Repos\Dynamics-365-Workflow-Tools\msdyncrmWorkflowTools\msdyncrmWorkflowTools_Class\bin\Debug\Newtonsoft.Json.xml
C:\Users\DemianRaschkovan\Source\Repos\Dynamics-365-Workflow-Tools\msdyncrmWorkflowTools\msdyncrmWorkflowTools_Class\obj\Debug\msdyncrmWorkflowTools_Class.csproj.CoreCompileInputs.cache
Binary file not shown.
Binary file not shown.
26 changes: 17 additions & 9 deletions msdyncrmWorkflowTools/msdyncrmWorkflowTools_ConsoleTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,22 @@ static void Main(string[] args)
{
var classObj = new msdyncrmWorkflowTools_Class(service);


TimeSpan difference=new TimeSpan();
int DayOfWeek = 0;
int DayOfYear = 0;
int Day = 0;
int Month = 0;
int Year = 0;
int WeekOfYear = 0;
classObj.DateFunctions(DateTime.Now, new DateTime(2018, 01, 01), ref difference,
ref DayOfWeek, ref DayOfYear, ref Day, ref Month, ref Year, ref WeekOfYear);


//var details = JObject.Parse(jsonData);

string json = @"{""deviceid"":""G7BF20DB2060"",""readingtype"":""Status"",""reading"":""Status"",""eventtoken"":null,""description"":""Engine speed"",""parameters"":{""VehicleName"":""Jeep Wrangler"",""VehicleSerialNumber"":""G7BF20DB2060"",""VIN"":""1J4FA69S74P704699"",""Date"":""10 / 2 / 2017 3:35:48 AM"",""DiagnosticName"":""Engine speed"",""DiagnosticCode"":""107"",""SourceName"":"" * *Go"",""Value"":""1363"",""Unit"":""Engine.UnitOfMeasureRevolutionsPerMinute""},""time"":""2017 - 10 - 02T03: 37:18.863Z""}";
string jsonpath = "parameters.DiagnosticCode";
string res=classObj.JsonParser(json, jsonpath);
//string json = @"{""deviceid"":""G7BF20DB2060"",""readingtype"":""Status"",""reading"":""Status"",""eventtoken"":null,""description"":""Engine speed"",""parameters"":{""VehicleName"":""Jeep Wrangler"",""VehicleSerialNumber"":""G7BF20DB2060"",""VIN"":""1J4FA69S74P704699"",""Date"":""10 / 2 / 2017 3:35:48 AM"",""DiagnosticName"":""Engine speed"",""DiagnosticCode"":""107"",""SourceName"":"" * *Go"",""Value"":""1363"",""Unit"":""Engine.UnitOfMeasureRevolutionsPerMinute""},""time"":""2017 - 10 - 02T03: 37:18.863Z""}";
//string jsonpath = "parameters.DiagnosticCode";
//string res=classObj.JsonParser(json, jsonpath);

//string result = classObj.AzureTranslateText("9e244b5792ed4d6792b44603801e93cb", "Hola como te va?", "", "en");

Expand Down Expand Up @@ -55,12 +63,12 @@ static void Main(string[] args)


//classObj.UpdateChildRecords("SalesOrderDetail_Dynamicpropertyinstance", "salesorderdetail", "3BDA2E2D-6C6A-E711-8106-5065F38A1B01", "", "333", "valuestring");
/* EntityReference securityRoleLookup = new EntityReference("role", new Guid("EC013771-633B-E711-8104-5065F38B2601"));
EntityReference emailTemplateLookup = new EntityReference("template", new Guid("e3b8956e-bab0-e711-810f-5065f38bf4a1"));
/* EntityReference securityRoleLookup = new EntityReference("role", new Guid("EC013771-633B-E711-8104-5065F38B2601"));
EntityReference emailTemplateLookup = new EntityReference("template", new Guid("e3b8956e-bab0-e711-810f-5065f38bf4a1"));
classObj.SendEmailFromTemplateToUsersInRole(securityRoleLookup, emailTemplateLookup);
*/
// classObj.SendEmailToUsersInRole(securityRoleLookup, new EntityReference("email",new Guid("B96825B7-CCB0-E711-810F-5065F38BF4A1")));
classObj.SendEmailFromTemplateToUsersInRole(securityRoleLookup, emailTemplateLookup);
*/
// classObj.SendEmailToUsersInRole(securityRoleLookup, new EntityReference("email",new Guid("B96825B7-CCB0-E711-810F-5065F38BF4A1")));

//classObj.InsertOptionValue(true, "purchaseprocess", "opportunity", "Tipo22", 22, 3082);
//classObj.InsertOptionValue(false, "cdi_test", "opportunity", "Tipo4", 1, 3082);
Expand Down
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
Expand Up @@ -22,3 +22,4 @@ C:\Users\DemianRaschkovan\Source\Repos\Dynamics-365-Workflow-Tools\msdyncrmWorkf
C:\Users\DemianRaschkovan\Source\Repos\Dynamics-365-Workflow-Tools\msdyncrmWorkflowTools\msdyncrmWorkflowTools_ConsoleTest\bin\Debug\Microsoft.IdentityModel.dll
C:\Users\DemianRaschkovan\Source\Repos\Dynamics-365-Workflow-Tools\msdyncrmWorkflowTools\msdyncrmWorkflowTools_ConsoleTest\bin\Debug\Newtonsoft.Json.dll
C:\Users\DemianRaschkovan\Source\Repos\Dynamics-365-Workflow-Tools\msdyncrmWorkflowTools\msdyncrmWorkflowTools_ConsoleTest\bin\Debug\Newtonsoft.Json.xml
C:\Users\DemianRaschkovan\Source\Repos\Dynamics-365-Workflow-Tools\msdyncrmWorkflowTools\msdyncrmWorkflowTools_ConsoleTest\obj\Debug\msdyncrmWorkflowTools_ConsoleTest.csproj.CoreCompileInputs.cache
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 29c22a9

Please sign in to comment.