Exemplo n.º 1
0
        public static async Task <ApiStatusWithSco> CreateFile(this AdobeConnectXmlAPI adobeConnectXmlApi, string folderId, string fileName, byte[] Data)
        {
            var sco = new Sco()
            {
                FolderId = folderId,
                Name     = fileName,
                ItemType = SCOtype.Content,
                Data     = Data
            };
            var scoInfo = await ScoUpdate(adobeConnectXmlApi, sco);

            if (scoInfo.Code == StatusCodes.OK && !string.IsNullOrEmpty(scoInfo.Sco.ScoId))
            {
                sco.ScoId = scoInfo.Sco.ScoId;
                try
                {
                    await Upload(adobeConnectXmlApi, sco);
                }
                catch (Exception e)
                {
                    //rollback if upload fails
                    await DeleteByScoId(adobeConnectXmlApi, sco.ScoId);

                    scoInfo.Code           = StatusCodes.InternalError;
                    scoInfo.InnerException = e;
                }
            }

            return(scoInfo);
        }
Exemplo n.º 2
0
        public static async Task <ApiStatus> RenameSco(this AdobeConnectXmlAPI adobeConnectXmlApi, string scoId, string newName)
        {
            var sco = new Sco()
            {
                ScoId = scoId,
                Name  = newName
            };

            return(await ScoUpdate(adobeConnectXmlApi, sco));
        }
Exemplo n.º 3
0
        public static async Task <ApiStatusWithSco> CreateFolder(this AdobeConnectXmlAPI adobeConnectXmlApi, string parentScoId, string name)
        {
            var sco = new Sco()
            {
                Name     = name,
                FolderId = parentScoId,
                ItemType = SCOtype.Folder
            };

            return(await ScoUpdate(adobeConnectXmlApi, sco));
        }
Exemplo n.º 4
0
 public static async Task Upload(this AdobeConnectXmlAPI adobeConnectXmlApi, Sco content)
 {
     using (var httpClient = new HttpClient())
     {
         if (adobeConnectXmlApi.Settings.HttpTimeoutSeconds.HasValue)
         {
             httpClient.Timeout = TimeSpan.FromSeconds(adobeConnectXmlApi.Settings.HttpTimeoutSeconds.Value);
         }
         var form = new MultipartFormDataContent();
         form.Add(new ByteArrayContent(content.Data), "file", content.Name);
         var url = string.Format("{0}/api/xml?action=sco-upload&sco-id={1}&session={2}",
                                 adobeConnectXmlApi.Settings.ServiceURL, content.ScoId, adobeConnectXmlApi.SessionInfo);
         await httpClient.PostAsync(url, form);
     }
 }
Exemplo n.º 5
0
        public static async Task <ApiStatusWithSco> ScoGenericOperation(AdobeConnectXmlAPI adobeConnectXmlApi, Sco sco, string operation)
        {
            var response = ApiStatusWithSco.FromApiStatus(await adobeConnectXmlApi.ProcessApiRequest(operation, Helpers.StructToQueryString(sco, true)));

            if (response.Code != StatusCodes.OK || response.ResultDocument == null)
            {
                return(response);
            }

            XElement scoNode = response.ResultDocument.XPathSelectElement("//sco");

            if (scoNode == null)
            {
                return(response);
            }

            try
            {
                response.Sco         = XmlSerializerHelpersGeneric.FromXML <Sco>(scoNode.CreateReader());
                response.Sco.FullUrl = adobeConnectXmlApi.ResolveFullUrl(response.Sco.UrlPath);
            }
            catch (Exception ex)
            {
                response.Code           = StatusCodes.Invalid;
                response.SubCode        = StatusSubCodes.Format;
                response.InnerException = ex;

                throw ex.InnerException;
            }

            return(response);
        }
Exemplo n.º 6
0
 public static async Task <ApiStatusWithSco> ScoUpdate(AdobeConnectXmlAPI adobeConnectXmlApi, Sco sco)
 {
     return(await ScoGenericOperation(adobeConnectXmlApi, sco, "sco-update"));
 }
Exemplo n.º 7
0
 public override int GetHashCode()
 {
     return(Sco.GetHashCode() ^ FolderId.GetHashCode());
 }
Exemplo n.º 8
0
 public bool Equals(RecIdentity other)
 {
     return(Sco.Equals(other.Sco) && FolderId.Equals(other.FolderId));
 }