/// <summary> /// Creates metadata for a SCO, or updates existing metadata describing a SCO. /// Call sco-update to create metadata only for SCOs that represent Content, including /// meetings. You also need to upload Content files with either sco-upload or Connect Enterprise Manager. /// You must provide a folder-id or a sco-id, but not both. If you pass a folder-id, scoupdate /// creates a new SCO and returns a sco-id. If the SCO already exists and you pass a /// sco-id, sco-update updates the metadata describing the SCO. /// After you create a new SCO with sco-update, call permissions-update to specify which /// users and groups can access it. /// </summary> /// <returns> /// <see cref="ApiStatus" /> /// </returns> internal ApiStatus ScoUpdate(MeetingUpdateItem meetingUpdateItem, out MeetingDetail meetingDetail) { meetingDetail = null; if (meetingUpdateItem == null) { return(null); } string cmdParams = Helpers.StructToQueryString(meetingUpdateItem, true); ApiStatus s = this.ProcessApiRequest("sco-update", cmdParams); if (s.Code != StatusCodes.OK || s.ResultDocument == null) { return(s); } //notice: no '/sco' will be returned during update XElement meetingDetailNode = s.ResultDocument.XPathSelectElement("//sco"); if (meetingDetailNode == null) { return(s); } try { meetingDetail = XmlSerializerHelpersGeneric.FromXML <MeetingDetail>(meetingDetailNode.CreateReader()); meetingDetail.FullUrl = this.ResolveFullUrl(meetingDetail.UrlPath); } catch (Exception ex) { s.Code = StatusCodes.Invalid; s.SubCode = StatusSubCodes.Format; s.InnerException = ex; //rollback: delete the meeting if (!string.IsNullOrEmpty(meetingDetail.ScoId)) { this.ScoDelete(new[] { meetingDetail.ScoId }); } throw ex.InnerException; } return(s); }
/// <summary> /// Provides information about a SCO on Connect Enterprise. The object can have any valid /// SCO type. See type for a list of the allowed SCO types. /// The response includes the account the SCO belongs to, the dates it was created and last /// modified, the owner, the URL that reaches it, and other data. For some types of SCOs, the /// response also includes information about a template from which this SCO was created. /// </summary> /// <param name="sco_id">meeting id</param> /// <returns><see cref="MeetingDetail"/></returns> public MeetingDetail GetMeetingDetail(string sco_id) { //act: "sco-info" StatusInfo iStatus; XmlDocument xDoc = _ProcessRequest("sco-info", string.Format("sco-id={0}", sco_id), out iStatus); if (iStatus.Code != StatusCodes.ok || xDoc == null || !xDoc.HasChildNodes) return null; XmlNode MeetingDetailNode = xDoc.SelectSingleNode("//sco"); if (MeetingDetailNode == null || !MeetingDetailNode.HasChildNodes) return null; try { MeetingDetail mDetail = new MeetingDetail(); mDetail.sco_id = MeetingDetailNode.Attributes["sco-id"].Value; mDetail.account_id = MeetingDetailNode.Attributes["account-id"].Value; mDetail.folder_id = MeetingDetailNode.Attributes["folder-id"].Value; mDetail.name = MeetingDetailNode.SelectSingleNode("name/text()").Value; if (MeetingDetailNode.SelectSingleNode("description/text()") != null) mDetail.description = MeetingDetailNode.SelectSingleNode("description/text()").Value; mDetail.url_path = MeetingDetailNode.SelectSingleNode("url-path/text()").Value; /* if (!string.IsNullOrEmpty(mDetail.url_path)) { Uri u = new Uri(m_serviceURL); mDetail.FullUrl = "https://" + u.GetComponents(UriComponents.Host, UriFormat.SafeUnescaped) + mDetail.url_path; } */ if (!DateTime.TryParseExact(MeetingDetailNode.SelectSingleNode("date-created/text()").Value, @"yyyy-MM-dd\THH:mm:ss.fffzzz", DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AdjustToUniversal, out mDetail.date_created)) mDetail.date_created = default(DateTime); if (!DateTime.TryParseExact(MeetingDetailNode.SelectSingleNode("date-modified/text()").Value, @"yyyy-MM-dd\THH:mm:ss.fffzzz", DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AdjustToUniversal, out mDetail.date_modified)) mDetail.date_modified = default(DateTime); if (MeetingDetailNode.SelectSingleNode("passing-score/text()") == null || !int.TryParse(MeetingDetailNode.SelectSingleNode("passing-score/text()").Value, NumberStyles.Number, NumberFormatInfo.InvariantInfo, out mDetail.passing_score)) mDetail.passing_score = -1; if (MeetingDetailNode.SelectSingleNode("duration/text()") == null || !int.TryParse(MeetingDetailNode.SelectSingleNode("duration/text()").Value, NumberStyles.Number, NumberFormatInfo.InvariantInfo, out mDetail.duration)) mDetail.duration = -1; if (!DateTime.TryParseExact(MeetingDetailNode.SelectSingleNode("date-begin/text()").Value, @"yyyy-MM-dd\THH:mm:ss.fffzzz", DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AdjustToUniversal, out mDetail.date_begin)) mDetail.date_begin = default(DateTime); if (!DateTime.TryParseExact(MeetingDetailNode.SelectSingleNode("date-end/text()").Value, @"yyyy-MM-dd\THH:mm:ss.fffzzz", DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AdjustToUniversal, out mDetail.date_end)) mDetail.date_end = default(DateTime); return mDetail; } catch (Exception ex) { TraceTool.TraceException(ex); } return null; }
/// <summary> /// Creates metadata for a SCO, or updates existing metadata describing a SCO. /// Call sco-update to create metadata only for SCOs that represent content, including /// meetings. You also need to upload content files with either sco-upload or Connect Enterprise Manager. /// You must provide a folder-id or a sco-id, but not both. If you pass a folder-id, scoupdate /// creates a new SCO and returns a sco-id. If the SCO already exists and you pass a /// sco-id, sco-update updates the metadata describing the SCO. /// After you create a new SCO with sco-update, call permissions-update to specify which /// users and groups can access it. /// </summary> private StatusInfo UpdateSCO(MeetingUpdateItem mItem, out MeetingDetail mDetail) { mDetail = null; if (mItem == null) return null; string _cmdParams = this.StructToQueryString(mItem, true); StatusInfo iStatus; XmlDocument xDoc = _ProcessRequest("sco-update", _cmdParams, out iStatus); if (iStatus.Code != StatusCodes.ok || xDoc == null || !xDoc.HasChildNodes) return iStatus; //notice: no '/sco' will be returned during update XmlNode MeetingDetailNode = xDoc.SelectSingleNode("//sco"); if (MeetingDetailNode == null) return iStatus; try { mDetail = new MeetingDetail(); mDetail.date_created = DateTime.UtcNow; mDetail.date_modified = DateTime.UtcNow; mDetail.sco_id = MeetingDetailNode.Attributes["sco-id"].Value; mDetail.folder_id = MeetingDetailNode.Attributes["folder-id"].Value; mDetail.account_id = MeetingDetailNode.Attributes["account-id"].Value; mDetail.url_path = MeetingDetailNode.SelectSingleNode("url-path/text()").Value; if (!string.IsNullOrEmpty(mDetail.url_path)) { Uri u = new Uri(m_serviceURL); mDetail.FullUrl = "http://" + u.GetComponents(UriComponents.Host, UriFormat.SafeUnescaped) + mDetail.url_path; } mDetail.name = MeetingDetailNode.SelectSingleNode("name/text()").Value; if (MeetingDetailNode.SelectSingleNode("description/text()") != null) mDetail.description = MeetingDetailNode.SelectSingleNode("description/text()").Value; } catch (Exception ex) { TraceTool.TraceException(ex); iStatus.Code = StatusCodes.invalid; iStatus.SubCode = StatusSubCodes.format; iStatus.UndeliningExceptionInfo = ex; //delete meeting try { if (!string.IsNullOrEmpty(mDetail.sco_id)) this.DeleteSCO(mDetail.sco_id); } finally { } } return iStatus; }
/// <summary> /// Creates a new meeting. /// </summary> /// <param name="mItem">MeetingUpdateItem</param> /// <param name="mDetail">returns created MeetingDetail</param> /// <returns>StatusInfo</returns> public StatusInfo CreateMeeting(MeetingUpdateItem mItem, out MeetingDetail mDetail) { mDetail = null; if (mItem == null) return null; if (string.IsNullOrEmpty(mItem.folder_id)) { return ReportStatus(StatusCodes.invalid, StatusSubCodes.format, new ArgumentNullException("MeetingItem", "folder_id must be set to create new item")); //throw new ArgumentNullException("MeetingItem", "folder_id must be set to create new item"); } if (mItem.type == SCOtype.not_set) { return ReportStatus(StatusCodes.invalid, StatusSubCodes.format, new ArgumentNullException("MeetingItem", "SCOtype must be set")); //throw new ArgumentNullException("MeetingItem", "SCOtype must be set"); } mItem.sco_id = null; return this.UpdateSCO(mItem, out mDetail); }