/// <summary>
        /// Execute the REST request
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        private IRestResponse ExecuteInternal(PackageManagerRequest m)
        {
            if (m == null)
            {
                throw new Exception("Request object is not instance of type PackageManagerRequest.");
            }

            var req = new RestRequest(m.Path, m.HttpMethod);

            m.Build(ref req);

            /// For GET request we need to pass AFC(Affiliation Code) in request header.
            /// For all other request and Member requests we need to pass additional X-Session in request header.
            /// X-Session header should be added from AuthProvider.SignRequest (ACG Auth Provider which is part of ACG login implementation) method.
            /// If request is for upload file _flieClient is used, as URL for ACG API and File Upload server are different.
            if (m.HttpMethod == Method.GET && !m.Path.Contains("members"))
            {
                SignRequest(req);
            }
            else
            {
                AuthProvider.SignRequest(ref req, _client);
            }

            if (m.fileRequest)
            {
                return(_fileClient.Execute(req));
            }
            else
            {
                return(_client.Execute(req));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Download and Install Dynamo Package
        /// pkg input parameter contains comma delimitted value as "assetId,fileID"
        /// </summary>
        /// <param name="pkg"></param>
        public void DownloadAndInstall(string package)
        {
            //Get Asset Details
            string[] packageToInstall                  = package.Split(',');
            PackageManagerRequest             req      = new PackageManagerRequest(string.Format("assets/{0}", packageToInstall[0]), Method.GET);
            ResponseWithContentBody <dynamic> response = Client.ExecuteAndDeserializeDynamoRequest(req);

            DownloadRequest = response.content;

            //Donwload the file
            PackageManagerRequest fileReq = new PackageManagerRequest(string.Format("files/download?file_ids={0}&asset_id={1}", packageToInstall[1], packageToInstall[0]), Method.GET, true);
            Response res           = Client.ExecuteDynamoRequest(fileReq);
            var      pathToPackage = Client.GetFileFromResponse(res);

            InstallPackage(pathToPackage);
        }
Exemplo n.º 3
0
        private void GetDependencies(dynamic version, out List <Tuple <dynamic, dynamic> > packageVersionData)
        {
            packageVersionData = new List <Tuple <dynamic, dynamic> >();
            // get all of the headers
            PackageManagerRequest req;

            string[] depends = version["dependencies"].Split(',');
            foreach (string depend in depends)
            {
                string[] temp = depend.Split('|');
                req = new PackageManagerRequest((string.Format("assets/{0}/customdata", temp[0])).Trim(), Method.GET);
                ResponseWithContentBody <dynamic> response = Client.ExecuteAndDeserializeDynamoRequest(req);
                var customData = response.content;

                req      = new PackageManagerRequest(("assets/" + temp[0]).Trim(), Method.GET);
                response = Client.ExecuteAndDeserializeDynamoRequest(req);
                var depAsset = response.content;

                if (customData.custom_data.Count > 0)
                {
                    dynamic versionData;
                    string  json;
                    for (int i = 0; i < customData.custom_data.Count; i++)
                    {
                        if (customData.custom_data[i].key == string.Format("version:{0}", temp[1]))
                        {
                            json        = System.Uri.UnescapeDataString(customData.custom_data[i].data.ToString());
                            versionData = JsonConvert.DeserializeObject <dynamic>(json);

                            packageVersionData.Add(new Tuple <dynamic, dynamic>(depAsset, versionData));
                            PackagesToInstall.Add(string.Format("{0},{1},{2}", temp[0], versionData.file_id.Value, depAsset.asset_name));
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void GetDependencies(dynamic version, out List<Tuple<dynamic, dynamic>> packageVersionData)
        {
            packageVersionData = new List<Tuple<dynamic, dynamic>>();
            // get all of the headers
            PackageManagerRequest req;
            string[] depends = version["dependencies"].Split(',');
            foreach (string depend in depends)
            {
                string[] temp = depend.Split('|');
                req = new PackageManagerRequest((string.Format("assets/{0}/customdata", temp[0])).Trim(), Method.GET);
                ResponseWithContentBody<dynamic> response = Client.ExecuteAndDeserializeDynamoRequest(req);
                var customData = response.content;

                req = new PackageManagerRequest(("assets/" + temp[0]).Trim(), Method.GET);
                response = Client.ExecuteAndDeserializeDynamoRequest(req);
                var depAsset = response.content;

                if (customData.custom_data.Count > 0)
                {
                    dynamic versionData;
                    string json;
                    for (int i = 0; i < customData.custom_data.Count; i++)
                    {
                        if (customData.custom_data[i].key == string.Format("version:{0}", temp[1]))
                        {
                            json = System.Uri.UnescapeDataString(customData.custom_data[i].data.ToString());
                            versionData = JsonConvert.DeserializeObject<dynamic>(json);

                            packageVersionData.Add(new Tuple<dynamic, dynamic>(depAsset, versionData));
                            PackagesToInstall.Add(string.Format("{0},{1},{2}", temp[0], versionData.file_id.Value, depAsset.asset_name));
                        }

                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Download and Install Dynamo Package
        /// pkg input parameter contains comma delimitted value as "assetId,fileID"
        /// </summary>
        /// <param name="pkg"></param>
        public void DownloadAndInstall(string package)
        {
            //Get Asset Details
            string[] packageToInstall = package.Split(',');
            PackageManagerRequest req = new PackageManagerRequest(string.Format("assets/{0}", packageToInstall[0]), Method.GET);
            ResponseWithContentBody<dynamic> response = Client.ExecuteAndDeserializeDynamoRequest(req);
            DownloadRequest = response.content;

            //Donwload the file
            PackageManagerRequest fileReq = new PackageManagerRequest(string.Format("files/download?file_ids={0}&asset_id={1}", packageToInstall[1], packageToInstall[0]), Method.GET, true);
            Response res = Client.ExecuteDynamoRequest(fileReq);
            var pathToPackage = Client.GetFileFromResponse(res);
            InstallPackage(pathToPackage);
        }