Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UserTask sample #4

Merged
merged 7 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Genetec.Dap.CodeSamples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimeAttendanceSample", "Tim
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReportExporterSample", "ReportExporterSample\ReportExporterSample.csproj", "{80235DD0-E10A-4D5A-B904-3FFAF947AE00}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserTaskSample", "UserTaskSample\UserTaskSample.csproj", "{5641FD90-74CF-47A6-87A3-45B04EB8872F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnusedCredentialQuerySample", "UnusedCredentialQuerySample\UnusedCredentialQuerySample.csproj", "{649419F6-7E22-419D-BFF4-A6674215CFDB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginDatabaseSample", "PluginDatabaseSample\PluginDatabaseSample.csproj", "{B622A780-E98F-4E65-B5CA-C305E6B45965}"
Expand Down Expand Up @@ -284,6 +286,18 @@ Global
{9C1FCCB7-A08D-4140-BFF8-949F036C50AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9C1FCCB7-A08D-4140-BFF8-949F036C50AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9C1FCCB7-A08D-4140-BFF8-949F036C50AA}.Release|Any CPU.Build.0 = Release|Any CPU
{DD133C7E-1BE3-436D-91AA-DD298A30F72E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD133C7E-1BE3-436D-91AA-DD298A30F72E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD133C7E-1BE3-436D-91AA-DD298A30F72E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD133C7E-1BE3-436D-91AA-DD298A30F72E}.Release|Any CPU.Build.0 = Release|Any CPU
{5641FD90-74CF-47A6-87A3-45B04EB8872F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5641FD90-74CF-47A6-87A3-45B04EB8872F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5641FD90-74CF-47A6-87A3-45B04EB8872F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5641FD90-74CF-47A6-87A3-45B04EB8872F}.Release|Any CPU.Build.0 = Release|Any CPU
{649419F6-7E22-419D-BFF4-A6674215CFDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{649419F6-7E22-419D-BFF4-A6674215CFDB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{649419F6-7E22-419D-BFF4-A6674215CFDB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{649419F6-7E22-419D-BFF4-A6674215CFDB}.Release|Any CPU.Build.0 = Release|Any CPU
{80235DD0-E10A-4D5A-B904-3FFAF947AE00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80235DD0-E10A-4D5A-B904-3FFAF947AE00}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80235DD0-E10A-4D5A-B904-3FFAF947AE00}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -374,6 +388,7 @@ Global
Shared\Shared.projitems*{464c76ea-da3e-4957-bbc3-2b8591e64349}*SharedItemsImports = 4
Shared\Shared.projitems*{49274831-ce4c-4b89-91b9-61c7deda2a26}*SharedItemsImports = 4
Shared\Shared.projitems*{4d27a27e-a287-4366-89dc-e89571b07321}*SharedItemsImports = 4
Shared\Shared.projitems*{5641fd90-74cf-47a6-87a3-45b04eb8872f}*SharedItemsImports = 4
Shared\Shared.projitems*{534db081-2747-4fb6-b269-c3eedbd9f30d}*SharedItemsImports = 4
Shared\Shared.projitems*{649419f6-7e22-419d-bff4-a6674215cfdb}*SharedItemsImports = 4
Shared\Shared.projitems*{73543dda-ef56-49e4-a49c-b3f162150038}*SharedItemsImports = 4
Expand Down
6 changes: 6 additions & 0 deletions UserTaskSample/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1" />
</startup>
</configuration>
5 changes: 5 additions & 0 deletions UserTaskSample/Certificates/UserTaskSample.exe.cert
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ClientCertificate>
<CompanyName>Genetec</CompanyName>
<ApplicationName>Demo Certificate for SDK Development only</ApplicationName>
<ApplicationId>KxsD11z743Hf5Gq9mv3+5ekxzemlCiUXkTFY5ba1NOGcLCmGstt2n0zYE9NsNimv</ApplicationId>
</ClientCertificate>
81 changes: 81 additions & 0 deletions UserTaskSample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Copyright (C) 2023 by Genetec, Inc. All rights reserved.
// May be used only in accordance with a valid Source Code License Agreement.

namespace Genetec.Dap.CodeSamples
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Genetec.Sdk.Entities;
using Sdk;
using Sdk.UserTaskManagement;

class Program
{
static Program() => SdkResolver.Initialize();

static async Task Main()
{
const string server = "localhost";
const string username = "admin";
const string password = "";

using var engine = new Engine();

ConnectionStateCode state = await engine.LogOnAsync(server: server, username: username, password: password);

if (state == ConnectionStateCode.Success)
{
IEnumerable<PrivateUserTask> privateTasks = engine.UserTaskManager.GetPrivateTasks().OfType<PrivateUserTask>().ToList();
dcraciunas marked this conversation as resolved.
Show resolved Hide resolved
Console.WriteLine($"Number of private tasks: {privateTasks.Count()}");
foreach (var task in privateTasks)
{
Console.WriteLine($"Task Name: {task.Name}, Task Type: {GetTaskTypeName(task.TaskType)}");
foreach (var item in task.Content.Where(item => item.Type != EntityType.None))
{
Console.WriteLine($" Content Item ID: {item.Id}, Type: {item.Type}");
}
}

Console.WriteLine();

IEnumerable<UserTask> publicTasks = engine.UserTaskManager.GetPublicTasks().OfType<UserTask>().ToList();
Console.WriteLine($"Number of public tasks: {publicTasks.Count()}");
foreach (var task in publicTasks)
{
Console.WriteLine($"Task Name: {task.Name}, Task Type: {GetTaskTypeName(task.TaskType)}");
foreach (var item in task.Content.Where(item => item.Type != EntityType.None))
{
Console.WriteLine($" Content Item ID: {item.Id}, Type: {item.Type}");
}
}
}
else
{
Console.WriteLine($"Logon failed: {state}");
}

Console.WriteLine("Press any key to exit...");
Console.ReadKey();

string GetTaskTypeName(Guid taskTypeId)
{
if (taskTypeId == TaskGuid.AlarmsTask.Id)
return TaskGuid.AlarmsTask.Name;
if (taskTypeId == TaskGuid.CardholderManagerTask.Id)
return TaskGuid.CardholderManagerTask.Name;
if (taskTypeId == TaskGuid.MapDesignerTask.Id)
return TaskGuid.MapDesignerTask.Name;
if (taskTypeId == TaskGuid.MapsTask.Id)
return TaskGuid.MapsTask.Name;
if (taskTypeId == TaskGuid.MonitoringTask.Id)
return TaskGuid.MonitoringTask.Name;
if (taskTypeId == TaskGuid.RemotingTask.Id)
return TaskGuid.RemotingTask.Name;

return $"Unknown Task Type ({taskTypeId})";
}
}
}
}
36 changes: 36 additions & 0 deletions UserTaskSample/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("UserTaskSample")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UserTaskSample")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("5641fd90-74cf-47a6-87a3-45b04eb8872f")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
67 changes: 67 additions & 0 deletions UserTaskSample/UserTaskSample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<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>{5641FD90-74CF-47A6-87A3-45B04EB8872F}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Genetec.Dap.CodeSamples</RootNamespace>
<AssemblyName>UserTaskSample</AssemblyName>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>8</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="Genetec.Sdk">
<HintPath>$(GSC_SDK)\Genetec.Sdk.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<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="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="Certificates\UserTaskSample.exe.cert">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="..\Shared\Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>