Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <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;
        }
Esempio n. 3
0
        //, out MeetingDetail mDetail
        /// <summary>
        /// Updates the meeting.
        /// </summary>
        /// <param name="mItem">MeetingUpdateItem</param>
        /// <returns>StatusInfo</returns>
        public StatusInfo UpdateMeeting(MeetingUpdateItem mItem)
        {
            MeetingDetail mDetail = null;
            if (mItem == null) return null;
            if (string.IsNullOrEmpty(mItem.sco_id))
            {
                return ReportStatus(StatusCodes.invalid, StatusSubCodes.format, new ArgumentNullException("MeetingItem", "sco_id must be set to update existing item"));
                //throw new ArgumentNullException("MeetingItem", "sco_id must be set to update existing item");
            }
            mItem.folder_id = null;

            return this.UpdateSCO(mItem, out mDetail);
        }
Esempio n. 4
0
        /// <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);
        }