4 using CPE.App.Web.Connect;
5 using CPE.App.Web.Models;
6 using CPE.App.Web.Code;
10 public static class adobe
12 public static void GetAdobeTransactions(MeetingSession meetingSession, CPEWebDataContext context)
14 Extensions.LogServiceCall("[adobe][GetAdobeTransactions]", String.Format("Parameters: meetingSession.MeetingSessionKey = {0} meetingSession.EndDate.HasValue = {1}", meetingSession.MeetingSessionKey, meetingSession.EndDate.HasValue));
16 int adobeTransactionsAdded = 0;
18 if (!meetingSession.EndDate.HasValue)
21 string login = "support@intesolv.com";
22 string password = "Cp3!nC";
23 string url = "http://cpeonline.adobeconnect.com";
24 int accountId = 1050997608;
25 Session session = Login.UserLogin(login, password, url, accountId);
29 Extensions.LogServiceCall("[adobe][GetAdobeTransactions]", String.Format("session == null; meetingSession.MeetingSessionKey = {0}", meetingSession.MeetingSessionKey));
33 var oldRecords = context.AdobeTransactions.Where(x => x.MeetingSessionKey == meetingSession.MeetingSessionKey);
35 //string dateCreatedFilter = meetingSession.StartDate.AddHours(-6).ToString("yyyy-MM-ddThh:mm:00.000-04:00"); // Striping the time is way easier than trying to use the correct time zone, even though the results may be different
36 //string dateCreatedFilter = meetingSession.StartDate.AddHours(-6).ToString("yyyy-MM-ddThh:mm"); // This sometimes fails, so adobe asked us to format the date differently
37 string dateCreatedFilter = meetingSession.StartDate.AddHours(-6).ToString("yyyy-MM-dd");
39 // https://cpeonline.adobeconnect.com/api/xml?action=report-bulk-consolidated-transactions&filter-sco-id=1091486528&filter-gt-date-created=2014-06-23T8:00
40 var request = new Connect.Request(session, "report-bulk-consolidated-transactions");
41 request.Parameters.Add("filter-sco-id", meetingSession.SCO_ID.ToString());
42 request.Parameters.Add("filter-gt-date-created", dateCreatedFilter);
44 Extensions.LogServiceCall("[adobe][GetAdobeTransactions]", String.Format("Before report-bulk-consolidated-transactions. meetingSession.MeetingSessionKey = {0} ScoIdFilter = {1} dateCreatedFilter = {2}", meetingSession.MeetingSessionKey, meetingSession.SCO_ID.ToString(), dateCreatedFilter));
46 if (request.Execute() && request.Status == Status.OK)
48 // Tyler Allen -- 08/27/2016
49 // The transaction is getting locked due to other transaction working on the same row.
52 context.AdobeTransactions.DeleteAllOnSubmit(oldRecords);
54 var xml = request.XmlResults;
55 var nodes = xml.SelectNodes("//row");
56 foreach (XmlNode node in nodes)
58 var dateString = node.SelectSingleNode("date-created")
60 var offSetString = dateString.Substring(dateString.Length - 6, 6);
61 var offSet = int.Parse(offSetString.Substring(1, 2));
62 dateString = dateString.Replace(offSetString, "");
63 var dateStart = DateTime.Parse(dateString)
65 var transaction = new AdobeTransaction()
67 Created = DateTime.UtcNow,
69 Principal_ID = int.Parse(node.Attributes["principal-id"].Value),
70 MeetingSessionKey = meetingSession.MeetingSessionKey,
72 StartDate = dateStart,
73 EndDate = (node.SelectSingleNode("date-closed") == null) ? ((meetingSession.EndDate.HasValue) ? meetingSession.EndDate.Value : DateTime.UtcNow) : DateTime.Parse(node.SelectSingleNode("date-closed").InnerText.Replace(offSetString, "")).AddHours(offSet)
75 string dateClosedForLogging = "null";
76 if (node.SelectSingleNode("date-closed") != null)
78 dateClosedForLogging = node.SelectSingleNode("date-closed").InnerText;
80 Extensions.LogServiceCall("[adobe][GetAdobeTransactions]", String.Format("Before Insert. meetingSession.MeetingSessionKey = {0} Principal_ID = {1} dateCreated = {2} dateClosed = {3}", meetingSession.MeetingSessionKey, transaction.Principal_ID, node.SelectSingleNode("date-created").InnerText, dateClosedForLogging));
81 context.AdobeTransactions.InsertOnSubmit(transaction);
82 adobeTransactionsAdded++;
84 context.SubmitChanges();
85 } catch (Exception exception) {
86 Console.WriteLine(exception);
88 var adobeTransactionsForMeeting = context.AdobeTransactions.Where(at => at.MeetingSessionKey == meetingSession.MeetingSessionKey).OrderByDescending(at => at.AdobeTransactionKey).ToList();
89 if (adobeTransactionsForMeeting.Count > 1)
91 Extensions.LogServiceCall("[adobe][GetAdobeTransactions]", String.Format("After Insert. meetingSession.MeetingSessionKey = {0} Max AdobeTransactionKey = {1}", meetingSession.MeetingSessionKey, adobeTransactionsForMeeting.First().AdobeTransactionKey));
95 Extensions.LogServiceCall("[adobe][GetAdobeTransactions]", String.Format("After Insert. meetingSession.MeetingSessionKey = {0} No AdobeTransactions found.", meetingSession.MeetingSessionKey));
100 Extensions.LogServiceCall("[adobe][GetAdobeTransactions]", String.Format("Execute failed. meetingSession.MeetingSessionKey = {0} request.Status = {1} request.XmlResults = [{2}] request.Url = {3}", meetingSession.MeetingSessionKey, request.Status, request.XmlResults.InnerXml, request.Url));
105 Extensions.LogServiceCall("[adobe][GetAdobeTransactions]", String.Format("End meetingSession.MeetingSessionKey = {0} adobeTransactionsAdded = {1}", meetingSession.MeetingSessionKey, adobeTransactionsAdded));
108 public static void GetAdobeCertificateTransactions(MeetingSession meetingSession, CPEWebDataContext context)
110 Extensions.LogServiceCall("[adobe][GetAdobeCertificateTransactions]", String.Format("Parameters: meetingSession.MeetingSessionKey = {0} meetingSession.EndDate.HasValue = {1}", meetingSession.MeetingSessionKey, meetingSession.EndDate.HasValue));
112 int adobeCertificateTransactionsAdded = 0;
114 if (!meetingSession.EndDate.HasValue)
117 string login = "support@intesolv.com";
118 string password = "Cp3!nC";
119 string url = "http://cpeonline.adobeconnect.com";
120 int accountId = 1050997608;
121 Session session = Login.UserLogin(login, password, url, accountId);
126 var oldRecords = context.AdobeCertificateTransactions.Where(x => x.MeetingSessionKey == meetingSession.MeetingSessionKey);
127 context.AdobeCertificateTransactions.DeleteAllOnSubmit(oldRecords);
129 // https://cpeonline.adobeconnect.com/api/xml?action=report-bulk-objects&filter-sco-id=1091486528
130 var request = new Connect.Request(session, "report-bulk-objects");
131 request.Parameters.Add("filter-sco-id", meetingSession.SCO_ID.ToString());
133 if (request.Execute() && request.Status == Status.OK)
135 var xml = request.XmlResults;
136 var nodes = xml.SelectNodes("//row");
137 foreach (XmlNode node in nodes)
139 var description = node.SelectSingleNode("description")
141 string[] fields = description.Split('|');
142 string presenter = fields.FirstOrDefault(p => p.Contains("Presenter"));
143 presenter = presenter?.Substring(presenter.IndexOf('=') + 1);
144 string fos = fields.FirstOrDefault(f => f.Contains("FOS") || f.Contains("Field of Study"));
145 fos = fos?.Substring(fos.IndexOf('=') + 1);
146 var transaction = new AdobeCertificateTransaction()
148 Created = DateTime.UtcNow,
149 MeetingSessionKey = meetingSession.MeetingSessionKey,
151 Presenter = presenter
153 context.AdobeCertificateTransactions.InsertOnSubmit(transaction);
154 adobeCertificateTransactionsAdded++;
158 Extensions.LogServiceCall("[adobe][GetAdobeCertificateTransactions]", String.Format("End meetingSession.MeetingSessionKey = {0} adobeCertificateTransactionsAdded = {1}", meetingSession.MeetingSessionKey, adobeCertificateTransactionsAdded));