public static TrainingItem Parse(XmlNode xml) { if (xml?.Attributes == null) { return(null); } var iconString = xml.SelectAttributeValue("icon"); try { return(new TrainingItem { ScoId = xml.SelectAttributeValue("sco-id"), Type = EnumReflector.ReflectEnum(xml.SelectAttributeValue("type"), ScoType.not_set), Icon = string.IsNullOrWhiteSpace(iconString) ? ScoIcon.not_set : EnumReflector.ReflectEnum(xml.SelectAttributeValue("icon"), ScoIcon.not_set), PermissionId = xml.SelectAttributeValue("permission-id"), Name = xml.SelectSingleNodeValue("name/text()"), Description = xml.SelectSingleNodeValue("description/text()"), UrlPath = xml.SelectSingleNodeValue("url-path/text()"), DateBegin = xml.ParseNodeDateTime("date-begin/text()", default(DateTime)), DateEnd = xml.ParseNodeDateTime("date-end/text()", default(DateTime)), DateCreated = xml.ParseNodeDateTime("date-created/text()", default(DateTime)), DateModified = xml.ParseNodeDateTime("date-modified/text()", default(DateTime)), }); } catch (Exception ex) { TraceTool.TraceException(ex); } return(null); }
/// <summary> /// Parses the specified XML. /// </summary> /// <param name="xml">The XML.</param> /// <returns>SCO Content.</returns> public static LearningPathItem Parse(XmlNode xml) { if (xml == null || xml.Attributes == null) { return(null); } try { return(new LearningPathItem { CurriculumId = xml.SelectAttributeValue("curriculum-id"), CurrentScoId = xml.SelectAttributeValue("current-sco-id"), TargetScoId = xml.SelectAttributeValue("target-sco-id"), PathType = xml.SelectAttributeValue("path-type"), Name = xml.SelectSingleNodeValue("name/text()"), }); } catch (Exception ex) { TraceTool.TraceException(ex); } return(null); }
public static EventUserField Parse(XmlNode xml) { if (xml?.Attributes == null) { return(null); } try { var eventField = new EventUserField { InteractionType = xml.SelectSingleNodeValue("interaction-type/text()"), DisplayOrder = xml.ParseNodeInt("display-seq/text()"), IsRequired = xml.ParseNodeBool("is-required/text()"), InputDataType = xml.SelectSingleNodeValue("input-data-type/text()"), Description = xml.SelectSingleNodeValue("description/text()"), Name = xml.SelectSingleNodeValue("name/text()"), Response = xml.SelectSingleNodeValue("response/text()"), }; return(eventField); } catch (Exception ex) { TraceTool.TraceException(ex); } return(null); }
/// <summary> /// Parses the specified XML. /// </summary> /// <param name="xml">The XML.</param> /// <returns>User or null if it's a folder.</returns> public static User Parse(XmlNode xml) { if (xml == null || xml.Attributes == null) { return(null); } try { var item = new User { PrincipalId = xml.SelectAttributeValue("principal-id"), Type = EnumReflector.ReflectEnum(xml.SelectAttributeValue("type"), PrincipalType.user), Name = xml.SelectSingleNodeValue("name/text()"), Login = xml.SelectSingleNodeValue("login/text()"), Email = xml.SelectSingleNodeValue("email/text()"), Manager = xml.SelectSingleNodeValue("manager/text()"), }; return(item); } catch (Exception ex) { TraceTool.TraceException(ex); } return(null); }
public static ReportActiveMeetingsItem Parse(XmlNode xml) { if (xml?.Attributes == null) { return(null); } try { return(new ReportActiveMeetingsItem { ScoId = xml.SelectAttributeValue("sco-id"), ActiveParticipants = xml.ParseAttributeInt("active-participants"), LengthMinutes = xml.ParseAttributeInt("length-minutes"), Name = xml.SelectSingleNodeValue("name/text()"), UrlPath = xml.SelectSingleNodeValue("url-path/text()"), DateBegin = xml.ParseNodeDateTime("date-begin/text()", DateTime.MinValue) }); } catch (Exception ex) { TraceTool.TraceException(ex); } return(null); }
/// <summary> /// Parses the specified XML. /// </summary> /// <param name="xml">The XML.</param> /// <returns>EventInfo object.</returns> public static EventCollectionItem Parse(XmlNode xml) { if (xml == null || xml.Attributes == null) { return(null); } try { var item = new EventCollectionItem { ScoId = xml.SelectAttributeValue("sco-id"), Name = xml.SelectSingleNodeValue("name/text()"), UrlPath = xml.SelectSingleNodeValue("url-path/text()"), DateBegin = xml.ParseNodeDateTime("date-begin/text()", default(DateTime)), DateEnd = xml.ParseNodeDateTime("date-end/text()", default(DateTime)), }; item.Duration = item.DateEnd.Subtract(item.DateBegin); return(item); } catch (Exception ex) { TraceTool.TraceException(ex); } return(null); }
public static ScoNav Parse(XmlNode xml) { if (xml == null || xml.Attributes == null) { return(null); } try { return(new ScoNav { ScoId = xml.SelectAttributeValue("sco-id"), Type = xml.SelectAttributeValue("type"), Icon = xml.SelectAttributeValue("icon"), Depth = xml.ParseAttributeInt("depth"), Name = xml.SelectSingleNodeValue("name/text()") }); } catch (Exception ex) { TraceTool.TraceException(ex); } return(null); }
/// <summary> /// Parses the specified XML. /// </summary> /// <param name="xml">The XML.</param> /// <returns>EventInfo object.</returns> public static EventRegistrationDetails Parse(XmlNode xml) { if (xml == null || xml.Attributes == null) { return(null); } try { var details = new EventRegistrationDetails(); details.EventFields = GenericCollectionParser <EventField> .Parse(xml.SelectSingleNode("//event-fields"), "field", EventFieldParser.Parse); details.UserFields = GenericCollectionParser <EventUserField> .Parse(xml.SelectSingleNode("//user-fields"), "field", EventUserFieldParser.Parse); details.AssetResponses = GenericCollectionParser <AssetResponseInfo> .Parse(xml.SelectSingleNode("//asset-responses"), "response", AssetResponseInfoParser.Parse); return(details); } catch (Exception ex) { TraceTool.TraceException(ex); } return(null); }
/// <summary> /// Parses the specified XML. /// </summary> /// <param name="xml">The XML.</param> /// <returns>PermissionInfo object.</returns> public static PermissionInfo Parse(XmlNode xml) { if (xml == null || xml.Attributes == null) { return(null); } try { return(new PermissionInfo { PrincipalId = xml.SelectAttributeValue("principal-id"), PermissionStringValue = xml.SelectAttributeValue("permission-id"), PermissionId = EnumReflector.ReflectEnum(xml.SelectAttributeValue("permission-id"), PermissionId.none), IsPrimary = xml.ParseAttributeBool("is-primary"), HasChildren = xml.ParseAttributeBool("has-children"), Login = xml.SelectSingleNodeValue("login/text()"), Name = xml.SelectSingleNodeValue("name/text()"), Description = xml.SelectSingleNodeValue("description/text()") }); } catch (Exception ex) { TraceTool.TraceException(ex); } return(null); }
/// <summary> /// Parses the specified XML. /// </summary> /// <param name="xml">The XML.</param> /// <returns>SCO Content.</returns> public static ReportScoViewContent Parse(XmlNode xml) { if (xml == null || xml.Attributes == null) { return(null); } try { return(new ReportScoViewContent() { ScoId = xml.SelectAttributeValue("sco-id"), Type = xml.SelectAttributeValue("type"), IsFolder = xml.ParseAttributeInt("is-folder") != 0, Views = xml.ParseAttributeInt("views"), LastViewedDate = xml.ParseNodeDateTimeLocal("last-viewed-date/text()", default(DateTime)) }); } catch (Exception ex) { TraceTool.TraceException(ex); } return(null); }
/// <summary> /// Parses the specified XML. /// </summary> /// <param name="xml">The XML.</param> /// <returns>Principal object.</returns> public static Principal Parse(XmlNode xml) { if (xml == null || xml.Attributes == null) { if (xml != null && xml.NodeExists("//principal")) { return(Parse(xml.SelectSingleNode("//principal"))); } return(null); } try { return(new Principal { PrincipalId = xml.SelectAttributeValue("principal-id"), AccountId = xml.SelectAttributeValue("account-id"), IsHidden = xml.ParseAttributeBool("is-hidden"), IsPrimary = xml.ParseAttributeBool("is-primary"), HasChildren = xml.ParseAttributeBool("has-children"), Type = xml.SelectAttributeValue("type"), Login = xml.SelectSingleNodeValue("login/text()"), Name = xml.SelectSingleNodeValue("name/text()"), Email = xml.SelectSingleNodeValue("email/text()"), DisplayId = xml.SelectSingleNodeValue("display-uid/text()"), Description = xml.SelectSingleNodeValue("description/text()"), }); } catch (Exception ex) { TraceTool.TraceException(ex); } return(null); }
private byte[] DownloadData(string url, out string error) { error = null; var request = WebRequest.Create(url) as HttpWebRequest; request = ProcessRequest(request, contentRequest: true); // TRICK: Empty value causes 500 error for 'http://connect.uthsc.edu/' during File Download request.UserAgent = @"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"; if (request != null) { HttpWebResponse webResponse = null; try { // FIX: invalid SSL passing behavior // (Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; webResponse = request.GetResponse() as HttpWebResponse; if (webResponse == null) { return(null); } Stream receiveStream = webResponse.GetResponseStream(); if (receiveStream == null) { return(null); } using (var ms = new MemoryStream()) { receiveStream.CopyTo(ms); return(ms.ToArray()); } } catch (Exception ex) { request.Abort(); TraceTool.TraceException(ex); error = ex.ToString(); } finally { if (webResponse != null) { webResponse.Close(); } } } return(null); }
/// <summary> /// Parses the specified XML. /// </summary> /// <param name="xml">The XML.</param> /// <returns>SCO Content.</returns> public static CurriculumTaker Parse(XmlNode xml) { if (xml == null || xml.Attributes == null) { return(null); } try { return(new CurriculumTaker { Depth = xml.ParseAttributeInt("depth"), Lang = xml.SelectAttributeValue("lang"), ContentSourceScoIcon = xml.SelectAttributeValue("content-source-sco-icon"), SourceScoIcon = xml.SelectAttributeValue("source-sco-icon"), SourceScoType = xml.SelectAttributeValue("source-sco-type"), ScoId = xml.SelectAttributeValue("sco-id"), SourceScoId = xml.SelectAttributeValue("source-sco-id"), FolderId = xml.ParseAttributeLong("folder-id"), Type = xml.SelectAttributeValue("type"), Icon = xml.SelectAttributeValue("icon"), DisplaySequence = xml.ParseAttributeInt("display-seq"), Duration = xml.ParseAttributeInt("duration"), IsFolder = xml.ParseAttributeInt("is-folder") != 0, Name = xml.SelectSingleNodeValue("name/text()"), Description = xml.SelectSingleNodeValue("description/text()"), UrlPath = xml.SelectSingleNodeValue("url-path/text()"), BeginDate = xml.ParseNodeDateTime("date-begin/text()", default(DateTime)), EndDate = xml.ParseNodeDateTime("date-end/text()", default(DateTime)), DateCreated = xml.ParseNodeDateTime("date-created/text()", DateTime.Now), DateModified = xml.ParseNodeDateTime("date-modified/text()", DateTime.Now), IsSeminar = xml.ParseNodeBool("is-seminar/text()"), Access = xml.SelectSingleNodeValue("access/text()"), AssetId = xml.SelectAttributeValue("asset-id"), Attempts = xml.ParseAttributeInt("attempts"), Certificate = xml.SelectAttributeValue("certificate"), CreditGranted = xml.ParseNodeBool("credit-granted/text()"), DateTaken = xml.ParseNodeDateTime("date-taken/text()", DateTime.Now), ExternalUrl = xml.SelectSingleNodeValue("external-url/text()"), MaxRetries = xml.ParseAttributeInt("max-retries"), MaxScore = xml.ParseAttributeInt("max-score"), Override = xml.ParseNodeBool("override"), PathType = xml.SelectAttributeValue("path-type"), Status = xml.SelectAttributeValue("status"), Score = xml.ParseAttributeInt("score"), TranscriptId = xml.SelectAttributeValue("transcript-id"), }); } catch (Exception ex) { TraceTool.TraceException(ex); } return(null); }
/// <summary> /// Parses the specified XML. /// </summary> /// <param name="xml">The XML.</param> /// <returns>Collection of Meeting Items.</returns> public static IEnumerable <MeetingSession> Parse(XmlNode xml) { if (xml == null || !xml.NodeListExists(Path)) { TraceTool.TraceMessage(string.Format("Node {0} is empty: no data available", Path)); return(Enumerable.Empty <MeetingSession>()); } return(xml.SelectNodes(Path).Cast <XmlNode>().Select(MeetingSessionParser.Parse).Where(item => item != null).ToArray()); }
public static MeetingItem Parse(XmlNode xml) { if (xml?.Attributes == null) { return(null); } var iconString = xml.SelectAttributeValue("icon"); try { return(new MeetingItem { ScoId = xml.SelectAttributeValue("sco-id"), Type = EnumReflector.ReflectEnum(xml.SelectAttributeValue("type"), ScoType.not_set), Icon = string.IsNullOrWhiteSpace(iconString) ? ScoIcon.not_set : EnumReflector.ReflectEnum(xml.SelectAttributeValue("icon"), ScoIcon.not_set), PermissionId = xml.SelectAttributeValue("permission-id"), ActiveParticipants = xml.ParseAttributeInt("active-participants"), Name = xml.SelectSingleNodeValue("name/text()"), Description = xml.SelectSingleNodeValue("description/text()"), DomainName = xml.SelectSingleNodeValue("domain-name/text()"), UrlPath = xml.SelectSingleNodeValue("url-path/text()"), DateBegin = xml.ParseNodeDateTime("date-begin/text()", default(DateTime)), DateEnd = xml.ParseNodeDateTime("date-end/text()", default(DateTime)), Expired = xml.ParseNodeBool("description/text()"), Duration = xml.ParseNodeTimeSpan("duration/text()", default(TimeSpan)) }); /* * if (!string.IsNullOrEmpty(item.UrlPath) && adobeConnectRoot != null) * { * item.FullUrl = adobeConnectRoot.ToString().TrimEnd('/') + item.UrlPath; * } * * item.Duration = item.DateEnd.Subtract(item.DateBegin); * * // if item.DateBegin is not defined and duration is 0 => then this is the folder which should be ignored * if (!item.DateBegin.Equals(default(DateTime)) || item.Duration.TotalMinutes != 0) * { * return item; * } */ } catch (Exception ex) { TraceTool.TraceException(ex); } return(null); }
public static IEnumerable <Recording> Parse(XmlNode xml, string path = null) { if (xml == null || !xml.NodeListExists(path ?? Path)) { TraceTool.TraceMessage(string.Format("Node {0} is empty: no data available", path ?? Path)); return(Enumerable.Empty <Recording>()); } return(xml.SelectNodes(path ?? Path).Cast <XmlNode>() .Select(RecordingParser.Parse) .Where(item => item != null) .ToArray()); }
/// <summary> /// Parses the specified XML. /// </summary> /// <param name="xml">The XML.</param> /// <returns>Collection of Meeting Items.</returns> public static IEnumerable <MeetingAttendee> Parse(XmlNode xml, bool returnCurrentUsers = false) { if (xml == null || !xml.NodeListExists(Path)) { TraceTool.TraceMessage(string.Format("Node {0} is empty: no data available", Path)); return(Enumerable.Empty <MeetingAttendee>()); } return(xml.SelectNodes(Path) .Cast <XmlNode>() .Select(x => MeetingAttendeeParser.Parse(x, returnCurrentUsers)) .Where(item => item != null).ToArray()); }
/// <summary> /// Parses the specified XML. /// </summary> /// <param name="xml">The XML.</param> /// <returns>Collection of Meeting Items.</returns> public static IEnumerable <ScoContent> Parse(XmlNode xml) { if (xml == null || (!xml.NodeListExists(Path) && !xml.NodeListExists(Path2))) { TraceTool.TraceMessage(string.Format("Node {0} is empty: no data available", Path)); return(Enumerable.Empty <ScoContent>()); } return((xml.NodeListExists(Path) ? xml.SelectNodes(Path) : xml.SelectNodes(Path2)).Cast <XmlNode>() .Select(ScoContentParser.Parse) .Where(item => item != null) .ToArray()); }
public static IEnumerable <T> Parse(XmlNode xml, string Path, Func <XmlNode, T> singleElementParser) { if (xml == null || !xml.NodeListExists(Path)) { TraceTool.TraceMessage(string.Format("Node {0} is empty: no data available", Path)); return(Enumerable.Empty <T>()); } return(xml.SelectNodes(Path).Cast <XmlNode>() .Select(singleElementParser) .Where(item => item != null) .ToArray()); }
public static IEnumerable <ScoContent> Parse(XmlNode xml, string path = null) { if (xml == null || !xml.NodeListExists(path ?? Path)) { TraceTool.TraceMessage($"Node {path ?? Path} is empty: no data available"); return(Enumerable.Empty <ScoContent>()); } return(xml.SelectNodes(path ?? Path).Cast <XmlNode>() .Select(ScoContentParser.Parse) .Where(item => item != null) .ToArray()); }
/// <summary> /// The path. /// </summary> //private const string Path = "//report-bulk-objects/row"; /// <summary> /// Parses the specified XML. /// </summary> /// <param name="xml">The XML.</param> /// <param name="adobeConnectUrl">AdobeConnect Root Url.</param> /// <returns>Collection of Meeting Items.</returns> public static IEnumerable <MeetingItem> Parse(XmlNode xml, string path) { //path = path ?? Path; if (xml == null || !xml.NodeListExists(path)) { TraceTool.TraceMessage(string.Format("Node {0} is empty: no data available", path)); return(Enumerable.Empty <MeetingItem>()); } return(xml.SelectNodes(path).Cast <XmlNode>() .Select(node => MeetingItemParser.Parse(node)) .Where(item => item != null) .ToArray()); }
/// <summary> /// Parses the specified XML. /// </summary> /// <param name="xml"> /// The XML. /// </param> /// <returns> /// Collection of Meeting Items. /// </returns> public static PrincipalInfo Parse(XmlNode xml) { if (xml == null || !xml.NodeExists(PrincipalPath)) { TraceTool.TraceMessage(string.Format("Node {0} is empty: no data available", PrincipalPath)); return(null); } return(new PrincipalInfo { Contact = xml.NodeExists(ContactPath) ? ContactParser.Parse(xml.SelectSingleNode(ContactPath)) : null, PrincipalPreferences = xml.NodeExists(PreferencesPath) ? PrincipalPreferencesParser.Parse(xml.SelectSingleNode(PreferencesPath)) : null, Principal = PrincipalDetailParser.Parse(xml.SelectSingleNode(PrincipalPath)), Manager = xml.NodeExists(ManagerPath) ? PrincipalParser.Parse(xml.SelectSingleNode(ManagerPath)) : null, }); }
public static Recording Parse(XmlNode xml) { if (xml == null || xml.Attributes == null) { return(null); } try { return(new Recording { ScoId = xml.SelectAttributeValue("sco-id"), SourceScoId = xml.SelectAttributeValue("source-sco-id"), FolderId = xml.ParseAttributeInt("folder-id"), Type = xml.SelectAttributeValue("type"), Icon = xml.SelectAttributeValue("icon"), DisplaySequence = xml.ParseAttributeInt("display-seq"), Duration = xml.SelectSingleNodeValue("duration/text()"), IsFolder = xml.ParseAttributeInt("is-folder") != 0, Name = xml.SelectSingleNodeValue("name/text()"), Description = xml.SelectSingleNodeValue("description/text()"), UrlPath = xml.SelectSingleNodeValue("url-path/text()"), BeginDate = xml.ParseNodeDateTime("date-begin/text()", default(DateTime)), EndDate = xml.ParseNodeDateTime("date-end/text()", default(DateTime)), DateCreated = xml.ParseNodeDateTime("date-created/text()", DateTime.Now), DateModified = xml.ParseNodeDateTime("date-modified/text()", DateTime.Now), EncoderServiceJobParams = xml.SelectSingleNodeValue("encoder-service-job-params/text()"), EncoderServiceJobStatus = xml.SelectSingleNodeValue("encoder-service-job-status/text()"), Filename = xml.SelectSingleNodeValue("filename/text()"), NoOfDownloads = xml.ParseAttributeInt("no-of-downloads"), EncoderServiceJobId = xml.SelectSingleNodeValue("encoder-service-job-id"), EncoderServiceJobProgress = xml.ParseAttributeInt("encoder-service-job-progress"), JobStatus = xml.SelectAttributeValue("job-status"), AccountId = xml.SelectAttributeValue("account-id"), JobId = xml.SelectAttributeValue("job-id"), RecordingEdited = xml.ParseNodeBool("recording-edited/text()"), RecordingEditedDuration = xml.SelectSingleNodeValue("recording-edited-duration/text()"), AfRecordingDuration = xml.SelectSingleNodeValue("af-recording-duration/text()"), }); } catch (Exception ex) { TraceTool.TraceException(ex); } return(null); }
private async Task <(MemoryStream ms, string error)> DownloadDataAsync(string url) { var handler = new HttpClientHandler() { CookieContainer = new CookieContainer(), }; if (this.IsLoggedIn) { handler.CookieContainer.Add(this.sessionCookie); } var client = new System.Net.Http.HttpClient(handler) { Timeout = TimeSpan.FromMilliseconds(connectionDetails.HttpContentRequestTimeout) }; client.DefaultRequestHeaders.Add("Connection", "Keep-Alive"); //client.DefaultRequestHeaders.Add("Keep-Alive", "timeout=600"); client.DefaultRequestHeaders.Add("Accept", "*/*"); // TRICK: Empty value causes 500 error for 'http://connect.uthsc.edu/' during File Download client.DefaultRequestHeaders.Add("User-Agent", @"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"); // FIX: invalid SSL passing behavior // (Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; //ServicePointManager.SecurityProtocol = // SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3; try { using (var receiveStream = await client.GetStreamAsync(url)) using (var ms = new MemoryStream()) { receiveStream.CopyTo(ms); return(ms, null); } } catch (Exception ex) { TraceTool.TraceException(ex); return(ms : null, error : ex.ToString()); } }
/// <summary> /// The to string. /// </summary> /// <param name="value"> /// The value. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> public static string ToXmlString(this Enum value) { try { var name = Enum.GetName(value.GetType(), value); if (name != null) { return(name.Replace('_', '-').ToLower()); } } catch (Exception ex) { TraceTool.TraceException(ex); } return(null); }
/// <summary> /// Parses the specified XML. /// </summary> /// <param name="xml">The XML.</param> /// <returns>SCO Content.</returns> public static CurriculumContent Parse(XmlNode xml) { if (xml == null || xml.Attributes == null) { return(null); } try { return(new CurriculumContent { Depth = xml.ParseAttributeInt("depth"), Lang = xml.SelectAttributeValue("lang"), ContentSourceScoIcon = xml.SelectAttributeValue("content-source-sco-icon"), SourceScoIcon = xml.SelectAttributeValue("source-sco-icon"), SourceScoType = xml.SelectAttributeValue("source-sco-type"), ScoId = xml.SelectAttributeValue("sco-id"), SourceScoId = xml.SelectAttributeValue("source-sco-id"), FolderId = xml.ParseAttributeLong("folder-id"), Type = xml.SelectAttributeValue("type"), Icon = xml.SelectAttributeValue("icon"), DisplaySequence = xml.ParseAttributeInt("display-seq"), Duration = xml.ParseAttributeInt("duration"), IsFolder = xml.ParseAttributeInt("is-folder") != 0, Name = xml.SelectSingleNodeValue("name/text()"), Description = xml.SelectSingleNodeValue("description/text()"), UrlPath = xml.SelectSingleNodeValue("url-path/text()"), BeginDate = xml.ParseNodeDateTime("date-begin/text()", default(DateTime)), EndDate = xml.ParseNodeDateTime("date-end/text()", default(DateTime)), DateCreated = xml.ParseNodeDateTime("date-created/text()", DateTime.Now), DateModified = xml.ParseNodeDateTime("date-modified/text()", DateTime.Now), IsSeminar = xml.ParseNodeBool("is-seminar/text()", default(bool)), }); } catch (Exception ex) { TraceTool.TraceException(ex); } return(null); }
public async Task <(XmlDocument, StatusInfo)> ProcessUploadAsync( string action, string parameters, UploadScoInfo uploadData) { var status = new StatusInfo(); if (parameters == null) { parameters = string.Empty; } try { var url = BuildUrl(action, parameters) + $"&session={sessionCookie.Value}"; var form = new MultipartFormDataContent { { new ByteArrayContent(uploadData.fileBytes, 0, uploadData.fileBytes.Length), "file", uploadData.fileName } }; HttpResponseMessage response = null; using (var httpClient = new HttpClient()) { httpClient.Timeout = TimeSpan.FromMilliseconds(connectionDetails.HttpContentRequestTimeout); response = await httpClient.PostAsync(url, form); } response.EnsureSuccessStatusCode(); var result = await response.Content.ReadAsStringAsync(); return(ProcessXmlResult(status, result), status); } catch (Exception ex) { status.UnderlyingExceptionInfo = ex; TraceTool.TraceException(ex); return(null, status); } }
/// <summary> /// The reflect enumerable. /// </summary> /// <param name="enumFieldName"> /// The enumerable field name. /// </param> /// <param name="defaultValue"> /// The default value. /// </param> /// <typeparam name="T"> /// Any enumerable. /// </typeparam> /// <returns> /// The <see cref="T"/>. /// </returns> public static T ReflectEnum <T>(string enumFieldName, T defaultValue) { if (string.IsNullOrWhiteSpace(enumFieldName)) { throw new ArgumentException("Non-empty value expected", nameof(enumFieldName)); } try { enumFieldName = enumFieldName.Replace('-', '_'); return((T)Enum.Parse(typeof(T), enumFieldName, true)); } catch (Exception ex) { TraceTool.TraceException(ex); } return(defaultValue); }
/// <summary> /// Parses the specified XML. /// </summary> /// <param name="xml">The XML.</param> /// <returns>EventInfo object.</returns> public static EventInfo Parse(XmlNode xml) { if (xml == null || xml.Attributes == null) { return(null); } try { var ei = new EventInfo { ScoId = xml.SelectAttributeValue("sco-id"), Name = xml.SelectSingleNodeValue("name/text()"), DomainName = xml.SelectSingleNodeValue("domain-name/text()"), UrlPath = xml.SelectSingleNodeValue("url-path/text()"), DateBegin = xml.ParseNodeDateTime("date-begin/text()", default(DateTime)), DateEnd = xml.ParseNodeDateTime("date-end/text()", default(DateTime)), Expired = xml.ParseNodeBool("expired/text()"), SpeakerName = xml.SelectSingleNodeValue("speaker-name/text()"), Info = xml.SelectSingleNodeValue("event-info/text()"), SpeakerImage = xml.SelectSingleNodeValue("speaker-image/text()"), SpeakerBriefOverview = xml.SelectSingleNodeValue("speaker-brief-overview/text()"), SpeakerDetailedOverview = xml.SelectSingleNodeValue("speaker-detailed-overview/text()"), PasswordBypass = xml.ParseNodeBool("password-bypass/text()"), }; ei.Duration = ei.DateEnd.Subtract(ei.DateBegin); // if mDetail.DateBegin is not defined and duration is 0 => then this is the folder which should be ignored if (!ei.DateBegin.Equals(default(DateTime)) || ei.Duration.TotalMinutes != 0) { return(ei); } } catch (Exception ex) { TraceTool.TraceException(ex); } return(null); }
public static CommonInfo Parse(XmlNode xml) { if (xml == null || xml.Attributes == null) { return(null); } try { // NOTE: account - Information about the account the user belongs to. Returned if you are logged in to Adobe Connect or are making the call on a Adobe Connect hosted account. long?accountId = xml.NodeExists("//account") ? long.Parse(xml.SelectSingleNodeValue("//account/@account-id")) : default(long?); var result = new CommonInfo { AccountUrl = xml.SelectSingleNodeValue("host/text()"), Version = xml.SelectSingleNodeValue("version/text()"), Cookie = xml.SelectSingleNodeValue("cookie/text()"), Date = xml.ParseNodeDateTime("date/text()", default(DateTime)), AdminHost = xml.SelectSingleNodeValue("admin-host/text()"), LocalHost = xml.SelectSingleNodeValue("local-host/text()"), AccountId = accountId, MobileAppPackage = xml.SelectSingleNodeValue("mobile-app-package/text()"), Url = xml.SelectSingleNodeValue("url/text()"), TimeZoneId = int.Parse(xml.SelectSingleNodeValue("@time-zone-id")), TimeZoneJavaId = xml.SelectSingleNodeValue("@time-zone-java-id"), Locale = xml.SelectSingleNodeValue("@locale"), }; result.OWASP_CSRF_TOKEN = OwaspParser.Parse(xml); result.User = UserInfoParser.Parse(xml); return(result); } catch (Exception ex) { TraceTool.TraceException(ex); } return(null); }