stage
This commit is contained in:
89
Epi2O365/EpiContacts.cs
Normal file
89
Epi2O365/EpiContacts.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using Microsoft.Graph.Models.ExternalConnectors;
|
||||
using Microsoft.Kiota.Abstractions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Epi2Exchange2
|
||||
{
|
||||
class EpiContacts
|
||||
{
|
||||
ConfigLoader Configuration = ConfigLoader.Instance;
|
||||
RestClient epirentserver;
|
||||
public EpiContacts()
|
||||
{
|
||||
epirentserver = new RestClient("http://" + Configuration.Epirent.Server + ":" + Configuration.Epirent.Port);
|
||||
}
|
||||
|
||||
|
||||
private String getContactJson()
|
||||
{
|
||||
RestRequest request = new RestRequest("/v1/contact/filter?ia=1&cl=" + Configuration.Epirent.Mandant, RestSharp.Method.Get);
|
||||
request.AddHeader("X-EPI-NO-SESSION", "True");
|
||||
request.AddHeader("X-EPI-ACC-TOK", Configuration.Epirent.Token);
|
||||
request.RequestFormat = DataFormat.Json;
|
||||
return epirentserver.ExecuteGet(request).Content;
|
||||
|
||||
}
|
||||
private String getContactDetailJson(long ContactPrimaryKey)
|
||||
{
|
||||
RestRequest request = new RestRequest("/v1/contact/"+ContactPrimaryKey+"/filter?ia=1&cl=" + Configuration.Epirent.Mandant, RestSharp.Method.Get);
|
||||
request.AddHeader("X-EPI-NO-SESSION", "True");
|
||||
request.AddHeader("X-EPI-ACC-TOK", Configuration.Epirent.Token);
|
||||
request.RequestFormat = DataFormat.Json;
|
||||
|
||||
return epirentserver.ExecuteGet(request).Content;
|
||||
|
||||
}
|
||||
private String getContactPersonJson(long ContactPersonPrimaryKey)
|
||||
{
|
||||
RestRequest request = new RestRequest("/v1/cperson/" + ContactPersonPrimaryKey + "/filter?ia=1&cl=" + Configuration.Epirent.Mandant, RestSharp.Method.Get);
|
||||
request.AddHeader("X-EPI-NO-SESSION", "True");
|
||||
request.AddHeader("X-EPI-ACC-TOK", Configuration.Epirent.Token);
|
||||
request.RequestFormat = DataFormat.Json;
|
||||
|
||||
return epirentserver.ExecuteGet(request).Content;
|
||||
|
||||
}
|
||||
|
||||
public Model.ContactList getContactList()
|
||||
{
|
||||
Model.ContactList contactList = JsonConvert.DeserializeObject<Model.ContactList>(getContactJson());
|
||||
return contactList;
|
||||
}
|
||||
|
||||
public Model.ContactList getContactList(DateTime FilterTime)
|
||||
{
|
||||
Model.ContactList contactList = JsonConvert.DeserializeObject<Model.ContactList>(getContactJson());
|
||||
|
||||
contactList.Payload.RemoveAll(p => p.getDateTimeChanged() < FilterTime);
|
||||
|
||||
return contactList;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Model.ContactDetail GetContactDetail(long primaryKey)
|
||||
{
|
||||
|
||||
Model.ContactDetail contactDetail = JsonConvert.DeserializeObject<Model.ContactDetail>(getContactDetailJson(primaryKey));
|
||||
return contactDetail;
|
||||
}
|
||||
|
||||
public Model.ContactPersonDetail GetContactPersonDetail(long primaryKey)
|
||||
{
|
||||
|
||||
Model.ContactPersonDetail cPersonDetail = JsonConvert.DeserializeObject<Model.ContactPersonDetail>(getContactPersonJson(primaryKey));
|
||||
return cPersonDetail;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user