Initial Commit

This commit is contained in:
2025-02-12 09:46:23 +01:00
parent d37d4b7b64
commit d9a655a1bc
24 changed files with 2607 additions and 0 deletions

63
.gitattributes vendored Normal file
View File

@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

364
.gitignore vendored Normal file
View File

@@ -0,0 +1,364 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
/Epi2Exchange/App.config

25
Epi2Exchange.sln Normal file
View File

@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30523.141
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Epi2Exchange", "Epi2Exchange\Epi2Exchange.csproj", "{6ED87064-301E-4A3C-A7F1-AD10B5F55183}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6ED87064-301E-4A3C-A7F1-AD10B5F55183}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6ED87064-301E-4A3C-A7F1-AD10B5F55183}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6ED87064-301E-4A3C-A7F1-AD10B5F55183}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6ED87064-301E-4A3C-A7F1-AD10B5F55183}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AAF830DE-2DB6-44FA-8746-EF99837D444C}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Epi2Exchange.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup>
<userSettings>
<Epi2Exchange.Properties.Settings>
<setting name="EpiServer" serializeAs="String">
<value>xxx</value>
</setting>
<setting name="EpiToken" serializeAs="String">
<value>xxx</value>
</setting>
<setting name="EpiPort" serializeAs="String">
<value>8080</value>
</setting>
<setting name="EpiMandant" serializeAs="String">
<value>2</value>
</setting>
<setting name="ExchangeEWS" serializeAs="String">
<value>xxx</value>
</setting>
<setting name="ExchangeUser" serializeAs="String">
<value>xxx</value>
</setting>
<setting name="ExchangePassword" serializeAs="String">
<value>xxx</value>
</setting>
<setting name="ExchangeDomain" serializeAs="String">
<value />
</setting>
</Epi2Exchange.Properties.Settings>
</userSettings>
</configuration>

518
Epi2Exchange/Converter.cs Normal file
View File

@@ -0,0 +1,518 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Exchange.WebServices.Data;
using System.Net;
using System.Windows;
namespace Epi2Exchange
{
class Converter
{
EpiContacts epicontacts;
public Converter()
{
epicontacts = new EpiContacts();
Console.WriteLine("########## EPI2EXCHANGE ##########");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine(Properties.Settings.Default.ExchangeEWS);
Console.WriteLine(Properties.Settings.Default.ExchangeUser);
Console.WriteLine(Properties.Settings.Default.ExchangePassword);
Console.WriteLine(Properties.Settings.Default.ExchangeDomain);
Console.WriteLine("");
Console.WriteLine("");
}
public void MainUpdateProcedure()
{
//Epirent-Daten über die Rest-API (JSON) in eine Objektstruktur /model parsen und dort als entsprechend vernetzte Objekte ablegen.
Model.ContactList contactList = epicontacts.getContactListFromJson(epicontacts.getContactJson());
//Durchlaufe jede Adresse - Firma
foreach (Model.ContactListPayload contact in contactList.ContactListPayload)
{
string VarName = "";
string VarSalutation = "";
string VarFirstname = "";
string VarLastname = "";
string VarCompany = "";
string VarMail1 = "";
string VarMail2 = "";
string VarMail3 = "";
string VarChataddressAliasID = "";
string VarPhone1 = "";
string VarPhone2 = "";
string VarMobilphone1 = "";
string VarFax = "";
string VarHomepage = "";
string VarStreet = "";
string VarPlz = "";
string VarCity = "";
string VarState = "";
string VarCountry = "";
try
{
//Hole die Details eines Kontakts
contact.setContactDetail();
}catch(Exception ex)
{
Console.WriteLine(ex);
try
{
//Hole die Details eines Kontakts
contact.setContactDetail();
}
catch(Exception ex1)
{
Console.WriteLine(ex1);
}
}
VarChataddressAliasID = contact.PrimaryKey;
VarName = contact.Name;
VarFirstname = contact.Name1;
VarLastname = contact.Name2;
VarSalutation = contact.ContactDetail.ContactDetailPayload[0].salutation;
VarStreet = contact.ContactDetail.ContactDetailPayload[0].address.Street;
VarPlz = contact.ContactDetail.ContactDetailPayload[0].address.PostalCode;
VarCity = contact.ContactDetail.ContactDetailPayload[0].address.City;
VarState = contact.ContactDetail.ContactDetailPayload[0].address.FederalState;
VarCountry = contact.ContactDetail.ContactDetailPayload[0].address.Country;
VarCompany = contact.Name;
if (contact.ContactDetail.ContactDetailPayload[0] != null)
{
int mailcounter = 0;
int phonecounter = 0;
foreach (Model.ContactDetailCommunication communication in contact.ContactDetail.ContactDetailPayload[0].communication)
{
switch (Convert.ToInt32(communication.Type))
{
case 0:
switch (phonecounter)
{
case 0:
VarPhone1 = communication.ContactData;
break;
case 1:
VarPhone2 = communication.ContactData;
break;
}
phonecounter++;
break;
case 1:
VarFax = communication.ContactData;
break;
case 2:
VarMobilphone1 = communication.ContactData;
break;
case 3:
switch (mailcounter)
{
case 0:
VarMail1 = communication.ContactData;
break;
case 1:
VarMail2 = communication.ContactData;
break;
case 2:
VarMail3 = communication.ContactData;
break;
}
mailcounter++;
break;
case 4:
VarHomepage = communication.ContactData;
break;
}
}
Console.WriteLine("Name: " + VarName + Environment.NewLine + "Salutation: " + VarSalutation + Environment.NewLine + "Company: " + VarCompany + Environment.NewLine + "Mail1: " + VarMail1 + Environment.NewLine + "Mail2: " + VarMail2 + Environment.NewLine + "Mail3: " + VarMail3 + Environment.NewLine + "ID: " + VarChataddressAliasID + Environment.NewLine + "Phone1: " + VarPhone1 + Environment.NewLine + "Phone2: " + VarPhone2 + Environment.NewLine + "Mobilphone: " + VarMobilphone1 + Environment.NewLine + "Fax: " + VarFax + Environment.NewLine + "Homepage: " + VarHomepage + Environment.NewLine + "Adresse: " + VarStreet + " " + VarPlz + " " + VarCity + " " + VarState + " " + VarCountry + Environment.NewLine + "##########");
String ContactID = findContactInAddressbook(VarChataddressAliasID);
if (!ContactID.Equals(""))
{
updateContact(ContactID, VarName, VarSalutation, VarFirstname, VarLastname, VarCompany, VarMail1, VarMail2, VarMail3, VarChataddressAliasID, VarPhone1, VarPhone2, VarMobilphone1, VarFax, VarHomepage, VarStreet, VarPlz, VarCity, VarState, VarCountry);
}
else
{
storeNewContact(VarName, VarSalutation, VarFirstname, VarLastname, VarCompany, VarMail1, VarMail2, VarMail3, VarChataddressAliasID, VarPhone1, VarPhone2, VarMobilphone1, VarFax, VarHomepage, VarStreet, VarPlz, VarCity, VarState, VarCountry);
}
//Contact Person
string VarCPName = "";
string VarCPSalutation = "";
string VarCPFirstname = "";
string VarCPLastname = "";
string VarCPCompany = "";
string VarCPMail1 = "";
string VarCPMail2 = "";
string VarCPMail3 = "";
string VarCPChataddressAliasID = "";
string VarCPPhone1 = "";
string VarCPPhone2 = "";
string VarCPMobilphone1 = "";
string VarCPFax = "";
string VarCPHomepage = "";
string VarCPStreet = "";
string VarCPPlz = "";
string VarCPCity = "";
string VarCPState = "";
string VarCPCountry = "";
if (contact.ContactDetail.ContactDetailPayload[0].contactPerson != null)
{
foreach (Model.ContactPerson cperson in contact.ContactDetail.ContactDetailPayload[0].contactPerson)
{
if (cperson != null)
{
cperson.setContactPersonDetail();
VarCPName = cperson.ContactPersonDetail.ContactPersonDetailPayload[0].name;
VarCPSalutation = cperson.ContactPersonDetail.ContactPersonDetailPayload[0].salutation;
VarCPFirstname = cperson.ContactPersonDetail.ContactPersonDetailPayload[0].firstname;
VarCPLastname = cperson.ContactPersonDetail.ContactPersonDetailPayload[0].lastname;
VarCPChataddressAliasID = contact.PrimaryKey + "-" + cperson.PrimaryKey;
int cpersCommailcounter = 0;
int cpersComphonecounter = 0;
foreach (Model.ContactDetailCommunication cpersCom in cperson.ContactPersonDetail.ContactPersonDetailPayload[0].communication)
{
switch (Convert.ToInt32(cpersCom.Type))
{
case 0:
switch (cpersComphonecounter)
{
case 0:
VarCPPhone1 = cpersCom.ContactData;
break;
case 1:
VarCPPhone2 = cpersCom.ContactData;
break;
}
cpersComphonecounter++;
break;
case 1:
VarCPFax = cpersCom.ContactData;
break;
case 2:
VarCPMobilphone1 = cpersCom.ContactData;
break;
case 3:
switch (cpersCommailcounter)
{
case 0:
VarCPMail1 = cpersCom.ContactData;
break;
case 1:
VarCPMail2 = cpersCom.ContactData;
break;
case 2:
VarCPMail3 = cpersCom.ContactData;
break;
}
cpersCommailcounter++;
break;
case 4:
VarCPHomepage = cpersCom.ContactData;
break;
}
}
if (VarCPName.Equals(""))
VarCPName = VarName;
if (VarCPSalutation.Equals(""))
VarCPSalutation = VarSalutation;
if (VarCPFirstname.Equals(""))
VarCPFirstname = VarFirstname;
if (VarCPLastname.Equals(""))
VarCPLastname = VarLastname;
if (VarCPMail1.Equals(""))
VarCPMail1 = VarMail1;
if (VarCPMail2.Equals(""))
VarCPMail2 = VarMail2;
if (VarCPMail3.Equals(""))
VarCPMail3 = VarMail3;
if (VarCPPhone1.Equals(""))
VarCPPhone1 = VarPhone1;
if (VarCPPhone2.Equals(""))
VarCPPhone2 = VarPhone2;
if (VarCPMobilphone1.Equals(""))
VarCPMobilphone1 = VarMobilphone1;
if (VarCPPhone1.Equals(""))
VarCPPhone1 = VarPhone1;
if (VarCPFax.Equals(""))
VarCPFax = VarFax;
if (VarCPHomepage.Equals(""))
VarCPHomepage = VarHomepage;
if (VarCPPhone1.Equals(""))
VarCPPhone1 = VarPhone1;
if (VarCPStreet.Equals(""))
VarCPStreet = VarStreet;
if (VarCPPlz.Equals(""))
VarCPPlz = VarPlz;
if (VarCPCity.Equals(""))
VarCPCity = VarCity;
if (VarCPState.Equals(""))
VarCPState = VarState;
if (VarCPCountry.Equals(""))
VarCPCountry = VarCountry;
Console.WriteLine("##CPERSON##" + Environment.NewLine + "Name: " + VarCPName + Environment.NewLine + "Salutation: " + VarCPSalutation + Environment.NewLine + "Company: " + VarCPCompany + Environment.NewLine + "Mail1: " + VarCPMail1 + Environment.NewLine + "Mail2: " + VarCPMail2 + Environment.NewLine + "Mail3: " + VarCPMail3 + Environment.NewLine + "ID: " + VarCPChataddressAliasID + Environment.NewLine + "Phone1: " + VarCPPhone1 + Environment.NewLine + "Phone2: " + VarCPPhone2 + Environment.NewLine + "Mobilphone: " + VarCPMobilphone1 + Environment.NewLine + "Fax: " + VarCPFax + Environment.NewLine + "Homepage: " + VarCPHomepage + Environment.NewLine + "Adresse: " + VarCPStreet + " " + VarCPPlz + " " + VarCPCity + " " + VarCPState + " " + VarCPCountry + Environment.NewLine + "##########");
String CPersContactID = findContactInAddressbook(VarCPChataddressAliasID);
if (!CPersContactID.Equals(""))
{
updateContact(CPersContactID, VarCPName, VarCPSalutation, VarCPFirstname, VarCPLastname, VarCompany, VarCPMail1, VarCPMail2, VarCPMail3, VarCPChataddressAliasID, VarCPPhone1, VarCPPhone2, VarCPMobilphone1, VarCPFax, VarCPHomepage, VarCPStreet, VarCPPlz, VarCPCity, VarCPState, VarCPCountry);
}
else
{
storeNewContact(VarCPName, VarCPSalutation, VarCPFirstname, VarCPLastname, VarCompany, VarCPMail1, VarCPMail2, VarCPMail3, VarCPChataddressAliasID, VarCPPhone1, VarCPPhone2, VarCPMobilphone1, VarCPFax, VarCPHomepage, VarCPStreet, VarCPPlz, VarCPCity, VarCPState, VarCPCountry);
}
}
VarCPName = "";
VarCPSalutation = "";
VarCPFirstname = "";
VarCPLastname = "";
VarCPCompany = "";
VarCPMail1 = "";
VarCPMail2 = "";
VarCPMail3 = "";
VarCPChataddressAliasID = "";
VarCPPhone1 = "";
VarCPPhone2 = "";
VarCPMobilphone1 = "";
VarCPFax = "";
VarCPHomepage = "";
VarCPStreet = "";
VarCPPlz = "";
VarCPCity = "";
VarCPState = "";
VarCPCountry = "";
mailcounter = 0;
phonecounter = 0;
}
}
}
VarName = "";
VarSalutation = "";
VarFirstname = "";
VarLastname = "";
VarCompany = "";
VarMail1 = "";
VarMail2 = "";
VarMail3 = "";
VarChataddressAliasID = "";
VarPhone1 = "";
VarPhone2 = "";
VarMobilphone1 = "";
VarFax = "";
VarHomepage = "";
VarStreet = "";
VarPlz = "";
VarCity = "";
VarState = "";
VarCountry = "";
}
}
private void storeNewContact(string name, string salutation, string firstname, string lastname, string company, string mail1, string mail2, string mail3, string chataddressAliasID, string phone1, string phone2, string mobilphone1, string fax, string homepage, string street, string plz, string city, string state, string country)
{
ExchangeService service;
service = new ExchangeService();
service.Credentials = new WebCredentials(Properties.Settings.Default.ExchangeUser, Properties.Settings.Default.ExchangePassword);
service.UseDefaultCredentials = false;
service.Url = new Uri(Properties.Settings.Default.ExchangeEWS);
Microsoft.Exchange.WebServices.Data.Contact contact = new Microsoft.Exchange.WebServices.Data.Contact(service);
contact.FileAsMapping = FileAsMapping.CompanySurnameCommaGivenName;
ExtendedPropertyDefinition oTitleProp = new ExtendedPropertyDefinition(0x3A45, MapiPropertyType.String);
if (!name.Equals(""))
contact.DisplayName = name;
if (!salutation.Equals(""))
contact.SetExtendedProperty(oTitleProp, salutation);
if (!firstname.Equals(""))
contact.GivenName = firstname;
if (!lastname.Equals(""))
contact.Surname = lastname;
if (!lastname.Equals(""))
contact.DisplayName = name;
if (!company.Equals(""))
contact.CompanyName = company;
if (!mail1.Equals(""))
contact.EmailAddresses[EmailAddressKey.EmailAddress1] = new Microsoft.Exchange.WebServices.Data.EmailAddress(mail1);
if (!mail2.Equals(""))
contact.EmailAddresses[EmailAddressKey.EmailAddress2] = new Microsoft.Exchange.WebServices.Data.EmailAddress(mail2);
if (!mail3.Equals(""))
contact.EmailAddresses[EmailAddressKey.EmailAddress3] = new Microsoft.Exchange.WebServices.Data.EmailAddress(mail3);
if (!chataddressAliasID.Equals(""))
contact.ImAddresses[ImAddressKey.ImAddress1] = chataddressAliasID;
if (!homepage.Equals(""))
contact.BusinessHomePage = homepage;
if (!phone1.Equals(""))
contact.PhoneNumbers[PhoneNumberKey.BusinessPhone] = phone1;
if (!phone2.Equals(""))
contact.PhoneNumbers[PhoneNumberKey.BusinessPhone2] = phone2;
if (!mobilphone1.Equals(""))
contact.PhoneNumbers[PhoneNumberKey.MobilePhone] = mobilphone1;
if (!fax.Equals(""))
contact.PhoneNumbers[PhoneNumberKey.BusinessFax] = fax;
//Address
PhysicalAddressEntry paEntry1 = new PhysicalAddressEntry();
if (!street.Equals(""))
paEntry1.Street = street;
if (!plz.Equals(""))
paEntry1.PostalCode = plz;
if (!city.Equals(""))
paEntry1.City = city;
if (!state.Equals(""))
paEntry1.State = state;
if (!country.Equals(""))
paEntry1.CountryOrRegion = country;
contact.PhysicalAddresses[PhysicalAddressKey.Business] = paEntry1;
contact.Save();
}
private void updateContact(string ExchangeContactID, string name, string salutation, string firstname, string lastname, string company, string mail1, string mail2, string mail3, string chataddressAliasID, string phone1, string phone2, string mobilphone1, string fax, string homepage, string street, string plz, string city, string state, string country)
{
ExchangeService service;
service = new ExchangeService();
service.Credentials = new WebCredentials(Properties.Settings.Default.ExchangeUser, Properties.Settings.Default.ExchangePassword);
service.UseDefaultCredentials = false;
service.Url = new Uri(Properties.Settings.Default.ExchangeEWS);
Microsoft.Exchange.WebServices.Data.Contact contact = Microsoft.Exchange.WebServices.Data.Contact.Bind(service, new Microsoft.Exchange.WebServices.Data.ItemId(ExchangeContactID));
contact.FileAsMapping = FileAsMapping.CompanySurnameCommaGivenName;
ExtendedPropertyDefinition oTitleProp = new ExtendedPropertyDefinition(0x3A45, MapiPropertyType.String);
if (!name.Equals(""))
contact.DisplayName = name;
if (!salutation.Equals(""))
contact.SetExtendedProperty(oTitleProp, salutation);
if (!firstname.Equals(""))
contact.GivenName = firstname;
if (!lastname.Equals(""))
contact.Surname = lastname;
if (!company.Equals(""))
contact.CompanyName = company;
if (!mail1.Equals(""))
contact.EmailAddresses[EmailAddressKey.EmailAddress1] = mail1;
if (!mail2.Equals(""))
contact.EmailAddresses[EmailAddressKey.EmailAddress2] = mail2;
if (!mail3.Equals(""))
contact.EmailAddresses[EmailAddressKey.EmailAddress3] = mail3;
if (!chataddressAliasID.Equals(""))
contact.ImAddresses[ImAddressKey.ImAddress1] = chataddressAliasID;
if (!homepage.Equals(""))
contact.BusinessHomePage = homepage;
if (!phone1.Equals(""))
contact.PhoneNumbers[PhoneNumberKey.BusinessPhone] = phone1;
if (!phone2.Equals(""))
contact.PhoneNumbers[PhoneNumberKey.BusinessPhone2] = phone2;
if (!mobilphone1.Equals(""))
contact.PhoneNumbers[PhoneNumberKey.MobilePhone] = mobilphone1;
if (!fax.Equals(""))
contact.PhoneNumbers[PhoneNumberKey.BusinessFax] = fax;
//Address
//PhysicalAddressEntry PABusinessEntry = new PhysicalAddressEntry();
if (!street.Equals(""))
contact.PhysicalAddresses[PhysicalAddressKey.Business].Street = street;
if (!plz.Equals(""))
contact.PhysicalAddresses[PhysicalAddressKey.Business].PostalCode = plz;
if (!city.Equals(""))
contact.PhysicalAddresses[PhysicalAddressKey.Business].City = city;
if (!state.Equals(""))
contact.PhysicalAddresses[PhysicalAddressKey.Business].State = state;
if (!country.Equals(""))
contact.PhysicalAddresses[PhysicalAddressKey.Business].CountryOrRegion = country;
//contact.PhysicalAddresses[PhysicalAddressKey.Business] = PABusinessEntry;
contact.Update(ConflictResolutionMode.AlwaysOverwrite);
}
public string findContactInAddressbook(String id)
{
string contactid = "";
ExchangeService service;
service = new ExchangeService();
service.Credentials = new WebCredentials(Properties.Settings.Default.ExchangeUser, Properties.Settings.Default.ExchangePassword, Properties.Settings.Default.ExchangeDomain);
service.UseDefaultCredentials = false;
service.Url = new Uri(Properties.Settings.Default.ExchangeEWS);
// Microsoft.Exchange.WebServices.Data.Contact contact = new Microsoft.Exchange.WebServices.Data.Contact(service);
Microsoft.Exchange.WebServices.Data.ContactsFolder contactsfolder = Microsoft.Exchange.WebServices.Data.ContactsFolder.Bind(service, WellKnownFolderName.Contacts);
int numItems = contactsfolder.TotalCount < 50 ? contactsfolder.TotalCount : 50;
ItemView view = new ItemView(1);
// To keep the request smaller, request only the display name property.
view.PropertySet = new PropertySet(BasePropertySet.IdOnly, ContactSchema.ImAddress1);
// Retrieve the items in the Contacts folder that have the properties that you selected.
FindItemsResults<Microsoft.Exchange.WebServices.Data.Item> contactItems = service.FindItems(WellKnownFolderName.Contacts, new SearchFilter.IsEqualTo(ContactSchema.ImAddress1, id), view);
// Display the list of contacts.
foreach (Microsoft.Exchange.WebServices.Data.Item item in contactItems)
{
if (item is Microsoft.Exchange.WebServices.Data.Contact)
{
Microsoft.Exchange.WebServices.Data.Contact contact = item as Microsoft.Exchange.WebServices.Data.Contact;
//Console.WriteLine(contact.ImAddresses[ImAddressKey.ImAddress1]);
Console.WriteLine("Found existing contact:\n" + contact.Id);
Console.WriteLine(contact.ImAddresses[ImAddressKey.ImAddress1]);
contactid = contact.Id.ToString();
}
}
return contactid;
}
}
}

View File

@@ -0,0 +1,139 @@
<?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>{6ED87064-301E-4A3C-A7F1-AD10B5F55183}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Epi2Exchange</RootNamespace>
<AssemblyName>Epi2Exchange</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</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>
<Prefer32Bit>false</Prefer32Bit>
</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>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Exchange.WebServices, Version=15.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Exchange.WebServices.2.2\lib\40\Microsoft.Exchange.WebServices.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Exchange.WebServices.Auth, Version=15.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Exchange.WebServices.2.2\lib\40\Microsoft.Exchange.WebServices.Auth.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="PresentationFramework" />
<Reference Include="RestSharp, Version=106.11.7.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.106.11.7\lib\net452\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Converter.cs" />
<Compile Include="Model\ContactPersonDetailPayload.cs" />
<Compile Include="EpiContacts.cs" />
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Model\ContactDetail.cs" />
<Compile Include="Model\ContactDetailPayload.cs" />
<Compile Include="Model\ContactList.cs" />
<Compile Include="Model\ContactListPayload.cs" />
<Compile Include="Model\ContactListPayloadData.cs" />
<Compile Include="Model\ContactPersonDetail.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="App.example.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 und x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RestSharp;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace Epi2Exchange
{
class EpiContacts
{
RestClient epirentserver;
public EpiContacts()
{
epirentserver = new RestClient("http://" + Properties.Settings.Default.EpiServer + ":" + Properties.Settings.Default.EpiPort);
}
public String getContactJson()
{
RestRequest request = new RestRequest("/v1/contact/filter?ia=1&cl=" + Properties.Settings.Default.EpiMandant, Method.GET);
request.AddHeader("X-EPI-NO-SESSION", "True");
request.AddHeader("X-EPI-ACC-TOK", Properties.Settings.Default.EpiToken);
request.RequestFormat = DataFormat.Json;
return epirentserver.ExecuteAsGet(request, "GET").Content;
}
public Model.ContactList getContactListFromJson(String ContactJson)
{
Model.ContactList contactList = JsonConvert.DeserializeObject<Model.ContactList>(ContactJson);
return contactList;
}
}
}

108
Epi2Exchange/Form1.Designer.cs generated Normal file
View File

@@ -0,0 +1,108 @@
namespace Epi2Exchange
{
partial class Form1
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Windows Form-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.tb_DataBox = new System.Windows.Forms.TextBox();
this.btn_getContacts = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.btn_UpdateContact = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// tb_DataBox
//
this.tb_DataBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tb_DataBox.Location = new System.Drawing.Point(12, 12);
this.tb_DataBox.Multiline = true;
this.tb_DataBox.Name = "tb_DataBox";
this.tb_DataBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.tb_DataBox.Size = new System.Drawing.Size(776, 395);
this.tb_DataBox.TabIndex = 0;
this.tb_DataBox.TextChanged += new System.EventHandler(this.tb_DataBox_TextChanged);
//
// btn_getContacts
//
this.btn_getContacts.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btn_getContacts.Location = new System.Drawing.Point(12, 415);
this.btn_getContacts.Name = "btn_getContacts";
this.btn_getContacts.Size = new System.Drawing.Size(75, 23);
this.btn_getContacts.TabIndex = 1;
this.btn_getContacts.Text = "getContacts";
this.btn_getContacts.UseVisualStyleBackColor = true;
this.btn_getContacts.Click += new System.EventHandler(this.button1_Click);
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.button1.Location = new System.Drawing.Point(93, 415);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(114, 23);
this.button1.TabIndex = 2;
this.button1.Text = "checkTestContact";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click_1);
//
// btn_UpdateContact
//
this.btn_UpdateContact.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btn_UpdateContact.Location = new System.Drawing.Point(213, 415);
this.btn_UpdateContact.Name = "btn_UpdateContact";
this.btn_UpdateContact.Size = new System.Drawing.Size(114, 23);
this.btn_UpdateContact.TabIndex = 3;
this.btn_UpdateContact.Text = "UpdateContact";
this.btn_UpdateContact.UseVisualStyleBackColor = true;
this.btn_UpdateContact.Click += new System.EventHandler(this.btn_UpdateContact_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.btn_UpdateContact);
this.Controls.Add(this.button1);
this.Controls.Add(this.btn_getContacts);
this.Controls.Add(this.tb_DataBox);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox tb_DataBox;
private System.Windows.Forms.Button btn_getContacts;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button btn_UpdateContact;
}
}

478
Epi2Exchange/Form1.cs Normal file
View File

@@ -0,0 +1,478 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Exchange.WebServices.Data;
using System.Net;
namespace Epi2Exchange
{
public partial class Form1 : Form
{
EpiContacts epicontacts;
public Form1()
{
InitializeComponent();
epicontacts = new EpiContacts();
MainUpdateProcedure();
}
private static bool RedirectionUrlValidationCallback(string redirectionUrl)
{
// The default for the validation callback is to reject the URL.
bool result = false;
Uri redirectionUri = new Uri(redirectionUrl);
// Validate the contents of the redirection URL. In this simple validation
// callback, the redirection URL is considered valid if it is using HTTPS
// to encrypt the authentication credentials.
if (redirectionUri.Scheme == "https")
{
result = true;
}
return result;
}
private void button1_Click(object sender, EventArgs e)
{
MainUpdateProcedure();
}
private void MainUpdateProcedure()
{
//Epirent-Daten über die Rest-API (JSON) in eine Objektstruktur /model parsen und dort als entsprechend vernetzte Objekte ablegen.
Model.ContactList contactList = epicontacts.getContactListFromJson(epicontacts.getContactJson());
//Durchlaufe jede Adresse - Firma
foreach (Model.ContactListPayload contact in contactList.ContactListPayload)
{
string VarName="";
string VarFirstname = "";
string VarLastname = "";
string VarCompany="";
string VarMail1="";
string VarMail2="";
string VarMail3="";
string VarChataddressAliasID="";
string VarPhone1="";
string VarPhone2="";
string VarMobilphone1="";
string VarFax="";
string VarHomepage="";
string VarStreet="";
string VarPlz="";
string VarCity="";
string VarState="";
string VarCountry="";
//Hole die Details eines Kontakts
contact.setContactDetail();
VarChataddressAliasID = contact.PrimaryKey;
VarName = contact.Name;
VarStreet = contact.ContactDetail.ContactDetailPayload[0].address.Street;
VarPlz = contact.ContactDetail.ContactDetailPayload[0].address.PostalCode;
VarCity = contact.ContactDetail.ContactDetailPayload[0].address.City;
VarState = contact.ContactDetail.ContactDetailPayload[0].address.FederalState;
VarCountry = contact.ContactDetail.ContactDetailPayload[0].address.Country;
VarCompany = contact.Name;
if (contact.ContactDetail.ContactDetailPayload[0] != null)
{
int mailcounter = 0;
int phonecounter = 0;
foreach (Model.ContactDetailCommunication communication in contact.ContactDetail.ContactDetailPayload[0].communication)
{
switch (Convert.ToInt32(communication.Type))
{
case 0:
switch (phonecounter)
{
case 0:
VarPhone1 = communication.ContactData;
break;
case 1:
VarPhone2 = communication.ContactData;
break;
}
phonecounter++;
break;
case 1:
VarFax = communication.ContactData;
break;
case 2:
VarMobilphone1 = communication.ContactData;
break;
case 3:
switch (mailcounter)
{
case 0:
VarMail1 = communication.ContactData;
break;
case 1:
VarMail2 = communication.ContactData;
break;
case 2:
VarMail3 = communication.ContactData;
break;
}
mailcounter++;
break;
case 4:
VarHomepage = communication.ContactData;
break;
}
}
Console.WriteLine("Name: " + VarName + Environment.NewLine + "Company: " + VarCompany + Environment.NewLine + "Mail1: " + VarMail1 + Environment.NewLine + "Mail2: " + VarMail2 + Environment.NewLine + "Mail3: " + VarMail3 + Environment.NewLine + "ID: " + VarChataddressAliasID + Environment.NewLine + "Phone1: " + VarPhone1 + Environment.NewLine + "Phone2: " + VarPhone2 + Environment.NewLine + "Mobilphone: " + VarMobilphone1 + Environment.NewLine + "Fax: " + VarFax + Environment.NewLine + "Homepage: " + VarHomepage + Environment.NewLine + "Adresse: " + VarStreet + " " + VarPlz + " " + VarCity + " " + VarState + " " + VarCountry + Environment.NewLine + "##########");
String ContactID = findContactInAddressbook(VarChataddressAliasID);
if (!ContactID.Equals(""))
{
updateContact(ContactID, VarName, VarFirstname, VarLastname, VarCompany, VarMail1, VarMail2, VarMail3, VarChataddressAliasID, VarPhone1, VarPhone2, VarMobilphone1, VarFax, VarHomepage, VarStreet, VarPlz, VarCity, VarState, VarCountry);
}
else
{
storeNewContact(VarName, VarFirstname, VarLastname, VarCompany, VarMail1, VarMail2, VarMail3, VarChataddressAliasID, VarPhone1, VarPhone2, VarMobilphone1, VarFax, VarHomepage, VarStreet, VarPlz, VarCity, VarState, VarCountry);
}
if (contact.ContactDetail.ContactDetailPayload[0].contactPerson != null)
{
foreach (Model.ContactPerson cperson in contact.ContactDetail.ContactDetailPayload[0].contactPerson)
{
if (cperson != null)
{
cperson.setContactPersonDetail();
VarName = cperson.ContactPersonDetail.ContactPersonDetailPayload[0].name;
VarFirstname = cperson.ContactPersonDetail.ContactPersonDetailPayload[0].firstname;
VarLastname = cperson.ContactPersonDetail.ContactPersonDetailPayload[0].lastname;
VarChataddressAliasID = contact.PrimaryKey + "-" + cperson.PrimaryKey;
int cpersCommailcounter = 0;
int cpersComphonecounter = 0;
foreach (Model.ContactDetailCommunication cpersCom in cperson.ContactPersonDetail.ContactPersonDetailPayload[0].communication)
{
switch (Convert.ToInt32(cpersCom.Type))
{
case 0:
switch (cpersComphonecounter)
{
case 0:
VarPhone1 = cpersCom.ContactData;
break;
case 1:
VarPhone2 = cpersCom.ContactData;
break;
}
cpersComphonecounter++;
break;
case 1:
VarFax = cpersCom.ContactData;
break;
case 2:
VarMobilphone1 = cpersCom.ContactData;
break;
case 3:
switch (cpersCommailcounter)
{
case 0:
VarMail1 = cpersCom.ContactData;
break;
case 1:
VarMail2 = cpersCom.ContactData;
break;
case 2:
VarMail3 = cpersCom.ContactData;
break;
}
cpersCommailcounter++;
break;
case 4:
VarHomepage = cpersCom.ContactData;
break;
}
}
Console.WriteLine("##CPERSON##"+Environment.NewLine+"Name: " + VarName + Environment.NewLine + "Company: " + VarCompany + Environment.NewLine + "Mail1: " + VarMail1 + Environment.NewLine + "Mail2: " + VarMail2 + Environment.NewLine + "Mail3: " + VarMail3 + Environment.NewLine + "ID: " + VarChataddressAliasID + Environment.NewLine + "Phone1: " + VarPhone1 + Environment.NewLine + "Phone2: " + VarPhone2 + Environment.NewLine + "Mobilphone: " + VarMobilphone1 + Environment.NewLine + "Fax: " + VarFax + Environment.NewLine + "Homepage: " + VarHomepage + Environment.NewLine + "Adresse: " + VarStreet + " " + VarPlz + " " + VarCity + " " + VarState + " " + VarCountry + Environment.NewLine + "##########");
String CPersContactID = findContactInAddressbook(VarChataddressAliasID);
if (!CPersContactID.Equals(""))
{
updateContact(CPersContactID, VarName, VarFirstname, VarLastname, VarCompany, VarMail1, VarMail2, VarMail3, VarChataddressAliasID, VarPhone1, VarPhone2, VarMobilphone1, VarFax, VarHomepage, VarStreet, VarPlz, VarCity, VarState, VarCountry);
}
else
{
storeNewContact(VarName, VarFirstname, VarLastname, VarCompany, VarMail1, VarMail2, VarMail3, VarChataddressAliasID, VarPhone1, VarPhone2, VarMobilphone1, VarFax, VarHomepage, VarStreet, VarPlz, VarCity, VarState, VarCountry);
}
}
VarFirstname = "";
VarLastname = "";
VarName = "";
mailcounter = 0;
phonecounter = 0;
foreach (Model.ContactDetailCommunication communication in contact.ContactDetail.ContactDetailPayload[0].communication)
{
switch (Convert.ToInt32(communication.Type))
{
case 0:
switch (phonecounter)
{
case 0:
VarPhone1 = communication.ContactData;
break;
case 1:
VarPhone2 = communication.ContactData;
break;
}
phonecounter++;
break;
case 1:
VarFax = communication.ContactData;
break;
case 2:
VarMobilphone1 = communication.ContactData;
break;
case 3:
switch (mailcounter)
{
case 0:
VarMail1 = communication.ContactData;
break;
case 1:
VarMail2 = communication.ContactData;
break;
case 2:
VarMail3 = communication.ContactData;
break;
}
mailcounter++;
break;
case 4:
VarHomepage = communication.ContactData;
break;
}
}
}
}
}
}
}
private void storeNewContact(string name, string firstname, string lastname, string company, string mail1, string mail2, string mail3, string chataddressAliasID, string phone1, string phone2, string mobilphone1, string fax, string homepage, string street, string plz, string city, string state, string country)
{
ExchangeService service;
service = new ExchangeService();
service.Credentials = new WebCredentials(Properties.Settings.Default.ExchangeUser, Properties.Settings.Default.ExchangePassword);
service.UseDefaultCredentials = true;
service.Url = new Uri(Properties.Settings.Default.ExchangeEWS);
Microsoft.Exchange.WebServices.Data.Contact contact = new Microsoft.Exchange.WebServices.Data.Contact(service);
if (!name.Equals(""))
contact.DisplayName = name;
if (!firstname.Equals(""))
contact.GivenName = firstname;
if (!lastname.Equals(""))
contact.Surname = lastname;
if (!lastname.Equals(""))
contact.DisplayName = name;
if (!company.Equals(""))
contact.CompanyName = company;
if (!mail1.Equals(""))
contact.EmailAddresses[EmailAddressKey.EmailAddress1] = new Microsoft.Exchange.WebServices.Data.EmailAddress(mail1);
if (!mail2.Equals(""))
contact.EmailAddresses[EmailAddressKey.EmailAddress2] = new Microsoft.Exchange.WebServices.Data.EmailAddress(mail2);
if (!mail3.Equals(""))
contact.EmailAddresses[EmailAddressKey.EmailAddress3] = new Microsoft.Exchange.WebServices.Data.EmailAddress(mail3);
if (!chataddressAliasID.Equals(""))
contact.ImAddresses[ImAddressKey.ImAddress1] = chataddressAliasID;
if (!homepage.Equals(""))
contact.BusinessHomePage = homepage;
if (!phone1.Equals(""))
contact.PhoneNumbers[PhoneNumberKey.BusinessPhone] = phone1;
if (!phone2.Equals(""))
contact.PhoneNumbers[PhoneNumberKey.BusinessPhone2] = phone2;
if (!mobilphone1.Equals(""))
contact.PhoneNumbers[PhoneNumberKey.MobilePhone] = mobilphone1;
if (!fax.Equals(""))
contact.PhoneNumbers[PhoneNumberKey.BusinessFax] = fax;
//Address
PhysicalAddressEntry paEntry1 = new PhysicalAddressEntry();
if (!street.Equals(""))
paEntry1.Street = street;
if (!plz.Equals(""))
paEntry1.PostalCode = plz;
if (!city.Equals(""))
paEntry1.City = city;
if (!state.Equals(""))
paEntry1.State = state;
if (!country.Equals(""))
paEntry1.CountryOrRegion = country;
contact.PhysicalAddresses[PhysicalAddressKey.Business] = paEntry1;
contact.Save();
}
private void updateContact(string ExchangeContactID, string name, string firstname, string lastname, string company, string mail1, string mail2, string mail3, string chataddressAliasID, string phone1, string phone2, string mobilphone1, string fax, string homepage, string street, string plz, string city, string state, string country)
{
ExchangeService service;
service = new ExchangeService();
service.Credentials = new WebCredentials(Properties.Settings.Default.ExchangeUser, Properties.Settings.Default.ExchangePassword);
service.UseDefaultCredentials = true;
service.Url = new Uri(Properties.Settings.Default.ExchangeEWS);
Microsoft.Exchange.WebServices.Data.Contact contact = Microsoft.Exchange.WebServices.Data.Contact.Bind(service, new Microsoft.Exchange.WebServices.Data.ItemId(ExchangeContactID));
if (!name.Equals(""))
contact.DisplayName = name;
if (!firstname.Equals(""))
contact.GivenName = firstname;
if (!lastname.Equals(""))
contact.Surname = lastname;
if (!company.Equals(""))
contact.CompanyName = company;
if (!mail1.Equals(""))
contact.EmailAddresses[EmailAddressKey.EmailAddress1] = new Microsoft.Exchange.WebServices.Data.EmailAddress(mail1);
if (!mail2.Equals(""))
contact.EmailAddresses[EmailAddressKey.EmailAddress2] = new Microsoft.Exchange.WebServices.Data.EmailAddress(mail2);
if (!mail3.Equals(""))
contact.EmailAddresses[EmailAddressKey.EmailAddress3] = new Microsoft.Exchange.WebServices.Data.EmailAddress(mail3);
if (!chataddressAliasID.Equals(""))
contact.ImAddresses[ImAddressKey.ImAddress1] = chataddressAliasID;
if (!homepage.Equals(""))
contact.BusinessHomePage = homepage;
if (!phone1.Equals(""))
contact.PhoneNumbers[PhoneNumberKey.BusinessPhone] = phone1;
if (!phone2.Equals(""))
contact.PhoneNumbers[PhoneNumberKey.BusinessPhone2] = phone2;
if (!mobilphone1.Equals(""))
contact.PhoneNumbers[PhoneNumberKey.MobilePhone] = mobilphone1;
if (!fax.Equals(""))
contact.PhoneNumbers[PhoneNumberKey.BusinessFax] = fax;
//Address
PhysicalAddressEntry paEntry1 = new PhysicalAddressEntry();
if (!street.Equals(""))
paEntry1.Street = street;
if (!plz.Equals(""))
paEntry1.PostalCode = plz;
if (!city.Equals(""))
paEntry1.City = city;
if (!state.Equals(""))
paEntry1.State = state;
if (!country.Equals(""))
paEntry1.CountryOrRegion = country;
contact.PhysicalAddresses[PhysicalAddressKey.Business] = paEntry1;
contact.Update(ConflictResolutionMode.AlwaysOverwrite);
}
public string findContactInAddressbook(String id)
{
string contactid = "";
ExchangeService service;
service = new ExchangeService();
service.Credentials = new WebCredentials(Properties.Settings.Default.ExchangeUser, Properties.Settings.Default.ExchangePassword);
service.UseDefaultCredentials = true;
service.Url = new Uri(Properties.Settings.Default.ExchangeEWS);
// Microsoft.Exchange.WebServices.Data.Contact contact = new Microsoft.Exchange.WebServices.Data.Contact(service);
Microsoft.Exchange.WebServices.Data.ContactsFolder contactsfolder = Microsoft.Exchange.WebServices.Data.ContactsFolder.Bind(service, WellKnownFolderName.Contacts);
int numItems = contactsfolder.TotalCount < 50 ? contactsfolder.TotalCount : 50;
ItemView view = new ItemView(numItems);
// To keep the request smaller, request only the display name property.
view.PropertySet = new PropertySet(BasePropertySet.IdOnly, ContactSchema.ImAddress1);
// Retrieve the items in the Contacts folder that have the properties that you selected.
FindItemsResults<Microsoft.Exchange.WebServices.Data.Item> contactItems = service.FindItems(WellKnownFolderName.Contacts, new SearchFilter.IsEqualTo(ContactSchema.ImAddress1, id),view);
// Display the list of contacts.
foreach (Microsoft.Exchange.WebServices.Data.Item item in contactItems)
{
if (item is Microsoft.Exchange.WebServices.Data.Contact)
{
Microsoft.Exchange.WebServices.Data.Contact contact = item as Microsoft.Exchange.WebServices.Data.Contact;
//Console.WriteLine(contact.ImAddresses[ImAddressKey.ImAddress1]);
Console.WriteLine("Found existing contact:\n" + contact.Id);
Console.WriteLine(contact.ImAddresses[ImAddressKey.ImAddress1]);
contactid= contact.Id.ToString();
}
}
return contactid;
}
private void button1_Click_1(object sender, EventArgs e)
{
}
private void btn_UpdateContact_Click(object sender, EventArgs e)
{
findContactInAddressbook("1291");
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void tb_DataBox_TextChanged(object sender, EventArgs e)
{
}
}
}

120
Epi2Exchange/Form1.resx Normal file
View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace Epi2Exchange.Model
{
class ContactDetail
{
[JsonProperty("payload")]
public List<ContactDetailPayload> ContactDetailPayload { get; set; }
}
}

View File

@@ -0,0 +1,124 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using RestSharp;
namespace Epi2Exchange.Model
{
class ContactDetailPayload
{
[JsonProperty("primary_key")]
public String PrimaryKey { get; set; }
[JsonProperty("customer_no")]
public String CustomerNumber { get; set; }
[JsonProperty("supplier_no")]
public String SupplierNumber { get; set; }
[JsonProperty("name")]
public String Name { get; set; }
[JsonProperty("salutation")]
public String salutation { get; set; }
[JsonProperty("is_customer")]
public bool IsCustomer { get; set; }
[JsonProperty("is_supplier")]
public bool IsSupplier { get; set; }
[JsonProperty("address")]
public ContactDetailAddress address { get; set; }
[JsonProperty("communication")]
public List<ContactDetailCommunication> communication { get; set; }
[JsonProperty("contact_person")]
public List<ContactPerson> contactPerson { get; set; }
}
class ContactDetailAddress
{
[JsonProperty("primary_key")]
public String PrimaryKey { get; set; }
[JsonProperty("postal_code")]
public String PostalCode { get; set; }
[JsonProperty("street")]
public String Street { get; set; }
[JsonProperty("city")]
public String City { get; set; }
[JsonProperty("country")]
public String Country { get; set; }
[JsonProperty("federal_state")]
public String FederalState { get; set; }
}
class ContactDetailCommunication
{
[JsonProperty("primary_key")]
public String PrimaryKey { get; set; }
[JsonProperty("uplink")]
public String ContactData { get; set; }
[JsonProperty("type")]
public String Type { get; set; }
}
class ContactPerson
{
RestClient epirentserver;
[JsonProperty("primary_key")]
public String PrimaryKey { get; set; }
public ContactPersonDetail ContactPersonDetail { get; set; }
public ContactPerson()
{
epirentserver = new RestClient("http://" + Properties.Settings.Default.EpiServer + ":" + Properties.Settings.Default.EpiPort);
}
public void setContactPersonDetail()
{
ContactPersonDetail = GetContactPersonDetailFromJson(getContactPersonDetailJson());
}
public String getContactPersonDetailJson()
{
RestRequest request = new RestRequest("/v1/cperson/" + PrimaryKey + "/filter?ia=1&cl=" + Properties.Settings.Default.EpiMandant, Method.GET);
request.AddHeader("X-EPI-NO-SESSION", "True");
request.AddHeader("X-EPI-ACC-TOK", Properties.Settings.Default.EpiToken);
request.RequestFormat = DataFormat.Json;
return epirentserver.ExecuteAsGet(request, "GET").Content;
}
public Model.ContactPersonDetail GetContactPersonDetailFromJson(String ContactDetailJson)
{
Model.ContactPersonDetail contactDetail = JsonConvert.DeserializeObject<Model.ContactPersonDetail>(ContactDetailJson);
return contactDetail;
}
}
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace Epi2Exchange.Model
{
class ContactList
{
[JsonProperty("payload")]
public List<ContactListPayload> ContactListPayload { get; set; }
}
}

View File

@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RestSharp;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Windows.Forms;
namespace Epi2Exchange.Model
{
class ContactListPayload
{
RestClient epirentserver;
[JsonProperty("primary_key")]
public String PrimaryKey { get; set; }
[JsonProperty("customer_no")]
public String CustomerNumber { get; set; }
[JsonProperty("supplier_no")]
public String SupplierNumber { get; set; }
[JsonProperty("name")]
public String Name { get; set; }
[JsonProperty("name1")]
public String Name1 { get; set; }
[JsonProperty("name2")]
public String Name2 { get; set; }
[JsonProperty("is_customer")]
public bool IsCustomer { get; set; }
[JsonProperty("is_supplier")]
public bool IsSupplier { get; set; }
[JsonProperty("contact_data")]
public ContactListPayloadData ContactListPayloadData { get; set; }
public ContactDetail ContactDetail { get; set; }
public ContactListPayload()
{
epirentserver = new RestClient("http://" + Properties.Settings.Default.EpiServer + ":" + Properties.Settings.Default.EpiPort);
}
public void setContactDetail()
{
ContactDetail = GetContactDetailFromJson(getContactDetailJson());
}
public String getContactDetailJson()
{
RestRequest request = new RestRequest("/v1/contact/" + PrimaryKey + "/filter?ia=1&cl=" + Properties.Settings.Default.EpiMandant, Method.GET);
request.AddHeader("X-EPI-NO-SESSION", "True");
request.AddHeader("X-EPI-ACC-TOK", Properties.Settings.Default.EpiToken);
request.RequestFormat = DataFormat.Json;
return epirentserver.ExecuteAsGet(request, "GET").Content;
}
public Model.ContactDetail GetContactDetailFromJson(String ContactDetailJson)
{
Model.ContactDetail contactDetail = JsonConvert.DeserializeObject<Model.ContactDetail>(ContactDetailJson);
return contactDetail;
}
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace Epi2Exchange.Model
{
class ContactListPayloadData
{
[JsonProperty("primary_key")]
public String PrimaryKey { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Epi2Exchange.Model
{
class ContactPersonDetail
{
[JsonProperty("payload")]
public List<ContactPersonDetailPayload> ContactPersonDetailPayload { get; set; }
}
}

View File

@@ -0,0 +1,28 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Epi2Exchange
{
class ContactPersonDetailPayload
{
[JsonProperty("name")]
public String name { get; set; }
[JsonProperty("salutation")]
public String salutation { get; set; }
[JsonProperty("first_name")]
public String firstname { get; set; }
[JsonProperty("last_name")]
public String lastname { get; set; }
[JsonProperty("communication")]
public List<Model.ContactDetailCommunication> communication { get; set; }
}
}

28
Epi2Exchange/Program.cs Normal file
View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Epi2Exchange
{
static class Program
{
static Converter converter;
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main()
{
converter = new Converter();
converter.MainUpdateProcedure();
//Application.EnableVisualStyles();
//Application.SetCompatibleTextRenderingDefault(false);
//Application.Run(new Form1());
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("Epi2Exchange")]
[assembly: AssemblyDescription("Importtool von Epirent in Exchange")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("VT-Media Axel Reisinger & Leopold Strobl GbR")]
[assembly: AssemblyProduct("Epi2Exchange")]
[assembly: AssemblyCopyright("Copyright © Leopold Strobl 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("6ed87064-301e-4a3c-a7f1-ad10b5f55183")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.5.2")]
[assembly: AssemblyFileVersion("1.0.5.2")]

View File

@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.42000
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Epi2Exchange.Properties {
using System;
/// <summary>
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
/// </summary>
// Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
// -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
// mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Epi2Exchange.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
/// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,122 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.42000
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Epi2Exchange.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.7.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("sv-epi01")]
public string EpiServer {
get {
return ((string)(this["EpiServer"]));
}
set {
this["EpiServer"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("BCEF15F4DC1F2F448BA07E5364EDDAE3")]
public string EpiToken {
get {
return ((string)(this["EpiToken"]));
}
set {
this["EpiToken"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("8080")]
public string EpiPort {
get {
return ((string)(this["EpiPort"]));
}
set {
this["EpiPort"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("2")]
public string EpiMandant {
get {
return ((string)(this["EpiMandant"]));
}
set {
this["EpiMandant"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("https://snmxcluster.s-nuernberger.de/EWS/Exchange.asmx")]
public string ExchangeEWS {
get {
return ((string)(this["ExchangeEWS"]));
}
set {
this["ExchangeEWS"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("leopold.strobl@vt-media.de")]
public string ExchangeUser {
get {
return ((string)(this["ExchangeUser"]));
}
set {
this["ExchangeUser"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("14032015-Leopold")]
public string ExchangePassword {
get {
return ((string)(this["ExchangePassword"]));
}
set {
this["ExchangePassword"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string ExchangeDomain {
get {
return ((string)(this["ExchangeDomain"]));
}
set {
this["ExchangeDomain"] = value;
}
}
}
}

View File

@@ -0,0 +1,30 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Epi2Exchange.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="EpiServer" Type="System.String" Scope="User">
<Value Profile="(Default)">sv-epi01</Value>
</Setting>
<Setting Name="EpiToken" Type="System.String" Scope="User">
<Value Profile="(Default)">BCEF15F4DC1F2F448BA07E5364EDDAE3</Value>
</Setting>
<Setting Name="EpiPort" Type="System.String" Scope="User">
<Value Profile="(Default)">8080</Value>
</Setting>
<Setting Name="EpiMandant" Type="System.String" Scope="User">
<Value Profile="(Default)">2</Value>
</Setting>
<Setting Name="ExchangeEWS" Type="System.String" Scope="User">
<Value Profile="(Default)">https://snmxcluster.s-nuernberger.de/EWS/Exchange.asmx</Value>
</Setting>
<Setting Name="ExchangeUser" Type="System.String" Scope="User">
<Value Profile="(Default)">leopold.strobl@vt-media.de</Value>
</Setting>
<Setting Name="ExchangePassword" Type="System.String" Scope="User">
<Value Profile="(Default)">14032015-Leopold</Value>
</Setting>
<Setting Name="ExchangeDomain" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Exchange.WebServices" version="2.2" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
<package id="RestSharp" version="106.11.7" targetFramework="net472" />
</packages>