ChrisCompleteCodeTrunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.Exchange.WebServices;
using Microsoft.Exchange.WebServices.Autodiscover;
using Microsoft.Exchange.WebServices.Data;
using Microsoft.Exchange.WebServices.Dns;
using System.Data;
using System.Configuration;
using System.Net;
using System.IO;
using System.Security.Principal;
namespace CRMPortal
{
public class EWS
{
private string ewsUrl = ConfigurationManager.AppSettings["ewsUrl"];
private string ewsUser = ConfigurationManager.AppSettings["ewsUser"];
private string ewsPass = ConfigurationManager.AppSettings["ewsPass"];
private string ewsDomain = ConfigurationManager.AppSettings["ewsDomain"];
private string adminEmail = ConfigurationManager.AppSettings["adminEmail"];
private string notifyEmail = ConfigurationManager.AppSettings["notifyEmail"];
public void makeAppointment(SecurityIdentifier user, DataRow record)
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Url = new Uri(ewsUrl);
//service.UseDefaultCredentials = true;
service.Credentials = new WebCredentials(ewsUser, ewsPass, ewsDomain);
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SID, user.Value);
Appointment appt = new Appointment(service);
appt.Subject = record["Name"] + " Followup";
appt.Body = "Appointment to followup on sales prospect '" + record["Name"] + "'.";
appt.Start = DateTime.Parse(record["Followup"].ToString());
appt.End = appt.Start.AddHours(1);
appt.IsAllDayEvent = true;
appt.Save(SendInvitationsMode.SendOnlyToAll);
}
public void makeCallAppointment(SecurityIdentifier user, string CustomerName, string ContactInfo, DateTime CallDate)
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Url = new Uri(ewsUrl);
//service.UseDefaultCredentials = true;
service.Credentials = new WebCredentials(ewsUser, ewsPass, ewsDomain);
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SID, user.Value);
Appointment appt = new Appointment(service);
appt.Subject = CustomerName + " Followup";
appt.Body = "Appointment to followup on sales prospect '" + CustomerName + "'. "+ContactInfo;
appt.Start = CallDate;
appt.End = appt.Start.AddHours(1);
appt.IsAllDayEvent = true;
appt.Save(SendInvitationsMode.SendOnlyToAll);
}
public void notifyOutOfBusiness(string uid, string id)
{
DataTable cust = AJAX.GetCusts(id);
if (cust.Rows.Count < 1) return;
DataRow c = cust.Rows[0];
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Url = new Uri(ewsUrl);
service.Credentials = new WebCredentials(ewsUser, ewsPass, ewsDomain);
EmailMessage m = new EmailMessage(service);
m.ToRecipients.Add(new EmailAddress(notifyEmail));
m.From = new EmailAddress("administrator@actiontireco.com");
m.Subject = "CRM Portal: Customer Out of Business";
m.Body = DateTime.Now.ToLongDateString() + @"<br \> The Customer "+c["Name"]+" with ASA ID "+c["ASAID"]+" has been marked as Out of Business by "+uid;
m.Send();
}
public void notifyAdmin(string uid, string id, string type)
{
try
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Url = new Uri(ewsUrl);
service.Credentials = new WebCredentials(ewsUser, ewsPass, ewsDomain);
EmailMessage m = new EmailMessage(service);
m.ToRecipients.Add(new EmailAddress(adminEmail));
m.From = new EmailAddress(uid.Replace(@"ATC\", "") + "@actiontireco.com");
m.Subject = "CRM Portal: Reassignment Request";
m.Body = DateTime.Now.ToLongDateString() + @"<br \>"+
"This message was automatically generated by the ATC CRM Portal.<br \\>" +
"User: " + uid + " (" + Logic.getNAMEfromUID(uid) + @") has requested to have the " +
type + " with reference #" + id + @" assigned to them.<br \>";
if (type.Equals("customer"))
{
m.Body += "<a href='https://actionapps:15001/ViewCustomer.aspx?CUST=" + id + "'>Click here to view the customer record</a><br \\><br \\>" +
"<a href='https://actionapps:15001/Reassign.aspx?T=C&I=" + id + "'>Click here to reassign the salesperson assigned to this customer</a><br \\>";
}
if (type.Equals("prospect"))
{
m.Body += "<a href='https://actionapps:15001/ViewProspect.aspx?P=" + id + "'>Click here to view the new prospect record</a><br \\><br \\>" +
"<a href='https://actionapps:15001/Reassign.aspx?T=P&I=" + id + "'>Click here to change the salesperson assigned to this new prospect</a><br \\>";
}
m.Send();
}
catch (Exception e)
{
string log = ConfigurationManager.AppSettings["Log File"];
StreamWriter sw = new StreamWriter(log);
sw.WriteLine(uid);
sw.WriteLine(id);
sw.WriteLine(e.Message);
sw.Close();
}
}
}
}
|
Revision |
Author |
Commited |
Message |
1
|
BBDSCHRIS
|
Wed 22 Aug, 2018 20:08:03 +0000 |
|