CPE_learningsite
This repository has no backups
This repository's network speed is throttled to 100KB/sec
Upgrade your account to fix these warnings, or use backups.vc for automated backups
4cd176a439ea516368a5d8827cdf8726027259a6
CPE_learningsite / CPE / CPE.App / CPE.App.Web / Helpers / adobe.cs
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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
using System; using System.Linq; using System.Xml; using CPE.App.Web.Connect; using CPE.App.Web.Models; using CPE.App.Web.Code; namespace CPE.App.Web { public static class adobe { public static void GetAdobeTransactions(MeetingSession meetingSession, CPEWebDataContext context) { Extensions.LogServiceCall("[adobe][GetAdobeTransactions]", String.Format("Parameters: meetingSession.MeetingSessionKey = {0} meetingSession.EndDate.HasValue = {1}", meetingSession.MeetingSessionKey, meetingSession.EndDate.HasValue)); int adobeTransactionsAdded = 0; if (!meetingSession.EndDate.HasValue) return; string login = "support@intesolv.com"; string password = "Cp3!nC"; string url = "http://cpeonline.adobeconnect.com"; int accountId = 1050997608; Session session = Login.UserLogin(login, password, url, accountId); if (session == null) { Extensions.LogServiceCall("[adobe][GetAdobeTransactions]", String.Format("session == null; meetingSession.MeetingSessionKey = {0}", meetingSession.MeetingSessionKey)); return; } var oldRecords = context.AdobeTransactions.Where(x => x.MeetingSessionKey == meetingSession.MeetingSessionKey); //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 //string dateCreatedFilter = meetingSession.StartDate.AddHours(-6).ToString("yyyy-MM-ddThh:mm"); // This sometimes fails, so adobe asked us to format the date differently string dateCreatedFilter = meetingSession.StartDate.AddHours(-6).ToString("yyyy-MM-dd"); // https://cpeonline.adobeconnect.com/api/xml?action=report-bulk-consolidated-transactions&filter-sco-id=1091486528&filter-gt-date-created=2014-06-23T8:00 var request = new Connect.Request(session, "report-bulk-consolidated-transactions"); request.Parameters.Add("filter-sco-id", meetingSession.SCO_ID.ToString()); request.Parameters.Add("filter-gt-date-created", dateCreatedFilter); 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)); if (request.Execute() && request.Status == Status.OK) { // Tyler Allen -- 08/27/2016 // The transaction is getting locked due to other transaction working on the same row. try { context.AdobeTransactions.DeleteAllOnSubmit(oldRecords); var xml = request.XmlResults; var nodes = xml.SelectNodes("//row"); foreach (XmlNode node in nodes) { var dateString = node.SelectSingleNode("date-created") .InnerText; var offSetString = dateString.Substring(dateString.Length - 6, 6); var offSet = int.Parse(offSetString.Substring(1, 2)); dateString = dateString.Replace(offSetString, ""); var dateStart = DateTime.Parse(dateString) .AddHours(offSet); var transaction = new AdobeTransaction() { Created = DateTime.UtcNow, Principal_ID = int.Parse(node.Attributes["principal-id"].Value), MeetingSessionKey = meetingSession.MeetingSessionKey, StartDate = dateStart, 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) }; string dateClosedForLogging = "null"; if (node.SelectSingleNode("date-closed") != null) { dateClosedForLogging = node.SelectSingleNode("date-closed").InnerText; } 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)); context.AdobeTransactions.InsertOnSubmit(transaction); adobeTransactionsAdded++; } context.SubmitChanges(); } catch (Exception exception) { Console.WriteLine(exception); } var adobeTransactionsForMeeting = context.AdobeTransactions.Where(at => at.MeetingSessionKey == meetingSession.MeetingSessionKey).OrderByDescending(at => at.AdobeTransactionKey).ToList(); if (adobeTransactionsForMeeting.Count > 1) { Extensions.LogServiceCall("[adobe][GetAdobeTransactions]", String.Format("After Insert. meetingSession.MeetingSessionKey = {0} Max AdobeTransactionKey = {1}", meetingSession.MeetingSessionKey, adobeTransactionsForMeeting.First().AdobeTransactionKey)); } else { Extensions.LogServiceCall("[adobe][GetAdobeTransactions]", String.Format("After Insert. meetingSession.MeetingSessionKey = {0} No AdobeTransactions found.", meetingSession.MeetingSessionKey)); } } else { 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)); // Retry? } Extensions.LogServiceCall("[adobe][GetAdobeTransactions]", String.Format("End meetingSession.MeetingSessionKey = {0} adobeTransactionsAdded = {1}", meetingSession.MeetingSessionKey, adobeTransactionsAdded)); } public static void GetAdobeCertificateTransactions(MeetingSession meetingSession, CPEWebDataContext context) { Extensions.LogServiceCall("[adobe][GetAdobeCertificateTransactions]", String.Format("Parameters: meetingSession.MeetingSessionKey = {0} meetingSession.EndDate.HasValue = {1}", meetingSession.MeetingSessionKey, meetingSession.EndDate.HasValue)); int adobeCertificateTransactionsAdded = 0; if (!meetingSession.EndDate.HasValue) return; string login = "support@intesolv.com"; string password = "Cp3!nC"; string url = "http://cpeonline.adobeconnect.com"; int accountId = 1050997608; Session session = Login.UserLogin(login, password, url, accountId); if (session == null) return; var oldRecords = context.AdobeCertificateTransactions.Where(x => x.MeetingSessionKey == meetingSession.MeetingSessionKey); context.AdobeCertificateTransactions.DeleteAllOnSubmit(oldRecords); // https://cpeonline.adobeconnect.com/api/xml?action=report-bulk-objects&filter-sco-id=1091486528 var request = new Connect.Request(session, "report-bulk-objects"); request.Parameters.Add("filter-sco-id", meetingSession.SCO_ID.ToString()); if (request.Execute() && request.Status == Status.OK) { var xml = request.XmlResults; var nodes = xml.SelectNodes("//row"); foreach (XmlNode node in nodes) { var description = node.SelectSingleNode("description") .InnerText; string[] fields = description.Split('|'); string presenter = fields.FirstOrDefault(p => p.Contains("Presenter")); presenter = presenter?.Substring(presenter.IndexOf('=') + 1); string fos = fields.FirstOrDefault(f => f.Contains("FOS") || f.Contains("Field of Study")); fos = fos?.Substring(fos.IndexOf('=') + 1); var transaction = new AdobeCertificateTransaction() { Created = DateTime.UtcNow, MeetingSessionKey = meetingSession.MeetingSessionKey, Fos = fos, Presenter = presenter }; context.AdobeCertificateTransactions.InsertOnSubmit(transaction); adobeCertificateTransactionsAdded++; } } Extensions.LogServiceCall("[adobe][GetAdobeCertificateTransactions]", String.Format("End meetingSession.MeetingSessionKey = {0} adobeCertificateTransactionsAdded = {1}", meetingSession.MeetingSessionKey, adobeCertificateTransactionsAdded)); } } } |
Commits for CPE_learningsiteCPE/CPE.App/CPE.App.Web/Helpers/adobe.cs
Revision | Author | Commited | Message |
---|---|---|---|
4cd176 ... | v.shishlov | Fri 27 Aug, 2021 14:33:17 +0000 | initial commit |