Пример #1
0
        public bool TransferResources(ResourceTransfer[] resources)
        {
            foreach (var resource in resources)
                TransferResource(resource);

            return true;
        }
Пример #2
0
 /// <remarks/>
 public void TransferResourcesAsync(string sessionKey, ResourceTransfer[] resources, string user, string pass, object userState)
 {
     if ((this.TransferResourcesOperationCompleted == null))
     {
         this.TransferResourcesOperationCompleted = new System.Threading.SendOrPostCallback(this.OnTransferResourcesOperationCompleted);
     }
     this.InvokeAsync("TransferResources", new object[] {
             sessionKey,
             resources,
             user,
             pass}, this.TransferResourcesOperationCompleted, userState);
 }
Пример #3
0
        /* TRANSFERING ITEMS - used with extraction */
        public bool TransferResource(ResourceTransfer resource)
        {
            var provider = Umbraco.Courier.Core.ProviderModel.ItemProviderCollection.Instance.GetProvider(resource.ItemID.ProviderId, Database, ExecutionContext);
            ResolutionManager.Instance.ExtractingResource(resource.ItemID, resource.GetItemType(), resource.Resource, provider);

            if (resource.Resource.ResourceContents != null)
            {
                resource.Resource.Extract(resource.Resource.ResourceContents, resource.OverWrite);
                var path = resource.Resource.ExtractToPath;
                var file = resource.Resource.ResourceContents;
                var outPut = "";

                ExecutionContext.TryStoreFile(path, file, out outPut);

                ResolutionManager.Instance.ExtractedResource(resource.ItemID, resource.GetItemType(), resource.Resource, provider);
            }
            return true;
        }
Пример #4
0
 public bool TransferResources(string sessionKey, ResourceTransfer[] resources, string user, string pass)
 {
     object[] results = this.Invoke("TransferResources", new object[] {
             sessionKey,
             resources,
             user,
             pass});
     return ((bool)(results[0]));
 }
Пример #5
0
 /// <remarks/>
 public void TransferResourcesAsync(string sessionKey, ResourceTransfer[] resources, string user, string pass)
 {
     this.TransferResourcesAsync(sessionKey, resources, user, pass, null);
 }
Пример #6
0
        public bool TransferResources(string sessionKey, ResourceTransfer[] resources, string user, string pass)
        {
            //Auth login and IP
            AuthorizeClient(user, pass);

            foreach (var rt in resources)
            {

            if (!Core.Settings.disableBase64Encoding && !string.IsNullOrEmpty(rt.Resource.ResourceAsBase64))
            {
                rt.Resource.ResourceContents = Convert.FromBase64String(rt.Resource.ResourceAsBase64);
                rt.Resource.ResourceAsBase64 = string.Empty;
            }

            if (!Core.Settings.disableZip)
                rt.Resource.ResourceContents = Compression.Decompress(rt.Resource.ResourceContents);
            }

            LocalRepo.SessionKey = sessionKey;
            return LocalRepo.TransferResources(resources);
        }
Пример #7
0
 /// <remarks/>
 public System.IAsyncResult BeginTransferResources(string sessionKey, ResourceTransfer[] resources, string user, string pass, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("TransferResources", new object[] {
             sessionKey,
             resources,
             user,
             pass}, callback, asyncState);
 }
Пример #8
0
        public bool TransferResource(ResourceTransfer resource)
        {
            JupiterWebservice jws = new JupiterWebservice(Url);

            resource.Resource.ResourceAsBase64 = Convert.ToBase64String(resource.Resource.ResourceContents);
            resource.Resource.ResourceContents = null;

            jws.TransferResource(this.SessionKey, resource.ItemID, resource.ItemType, resource.Resource, true, Login, Password);

            jws.Dispose();
            return true;
        }
Пример #9
0
        public bool TransferResource(string sessionKey, ItemIdentifier itemId, string type, Resource resource, bool overwrite, string user, string pass)
        {
            //Auth login and IP
            AuthorizeClient(user, pass);

            ResourceTransfer rt = new ResourceTransfer();
            rt.ItemType = type;
            rt.OverWrite = overwrite;
            rt.ItemID = itemId;

            rt.Resource = resource;
            rt.Resource.ResourceAsBase64 = string.Empty;

            if (!Core.Settings.disableBase64Encoding)
            rt.Resource.ResourceContents = Convert.FromBase64String(resource.ResourceAsBase64);

            if (!Core.Settings.disableZip)
            rt.Resource.ResourceContents = Compression.Decompress(rt.Resource.ResourceContents);

            LocalRepo.SessionKey = sessionKey;
            return LocalRepo.TransferResource(rt);
        }
Пример #10
0
 public bool TransferResources(ResourceTransfer[] resources)
 {
     return true;
 }
Пример #11
0
 public bool TransferResource(ResourceTransfer resource)
 {
     return true;
 }
        public bool TransferResources(ResourceTransfer[] resources)
        {
            //encrypt login and password
            string loginName = "";
            string pass = "";
            getloginAndPass(UserId, ref loginName, ref pass);
            string _url = getWSUrl(this.Url);

            RepositoryWebservice repo = new RepositoryWebservice(_url);
            repo.Credentials = new System.Net.NetworkCredential(loginName, pass);

            int totalTransferSize = 0;

            foreach (var rt in resources)
            {
                totalTransferSize += rt.Resource.ResourceContents.Length;
                rt.Resource.ResourceContents = Compression.Compress(rt.Resource.ResourceContents);
                rt.Resource.ResourceAsBase64 = Base64Converter.ConvertToBase64(rt.Resource.ResourceContents);
                rt.Resource.ResourceContents = new byte[0];
            }

            bool transfered = false;
            try
            {
                transfered = repo.TransferResources(this.SessionKey, resources, loginName, pass);
            }
            catch (Exception ex)
            {
                RevisionLog.Instance.AddItemEntry(resources[0].ItemID, this.GetType(), "resources", ex.ToString(), LogItemEntryType.Error);
            }

            repo.Dispose();
            return transfered;
        }
        public bool TransferResource(ResourceTransfer resource)
        {
            //encrypt login and password
            string loginName = "";
            string pass = "";
            getloginAndPass(UserId, ref loginName, ref pass);
            string _url = getWSUrl(this.Url);

            RepositoryWebservice repo = new RepositoryWebservice(_url);
            repo.Credentials = new System.Net.NetworkCredential(loginName, pass);

            var res = resource.Resource;

            if (!Core.Settings.disableZip)
                res.ResourceContents = Compression.Compress(res.ResourceContents);

            if (!Core.Settings.disableBase64Encoding)
            {
                res.ResourceAsBase64 = Convert.ToBase64String(res.ResourceContents);
                res.ResourceContents = new byte[0];
            }

            bool transfered = false;

            try
            {
                transfered = repo.TransferResource(this.SessionKey, resource.ItemID, resource.ItemType, res, resource.OverWrite, loginName, pass);

                if (transfered)
                    RevisionLog.Instance.AddItemEntry(resource.ItemID, this.GetType(), "resources", resource.Resource.ExtractToPath + " transfered", LogItemEntryType.Success);
                else
                    RevisionLog.Instance.AddItemEntry(resource.ItemID, this.GetType(), "resources", resource.Resource.ExtractToPath + " not transfered", LogItemEntryType.Error);
            }
            catch (Exception ex)
            {
                RevisionLog.Instance.AddItemEntry(resource.ItemID, this.GetType(), "resources", ex.ToString(), LogItemEntryType.Error);
            }

            repo.Dispose();
            return transfered;
        }
Пример #14
0
        public bool TransferResource(string sessionKey, ItemIdentifier itemId, string type, Resource resource, bool overwrite, string user, string pass)
        {
            //Auth login and IP
            AuthorizeClient(user, pass);

            ResourceTransfer rt = new ResourceTransfer();
            rt.ItemType = type;
            rt.OverWrite = overwrite;
            rt.ItemID = itemId;

            rt.Resource = resource;
            rt.Resource.ResourceContents = Convert.FromBase64String(resource.ResourceAsBase64);
            rt.Resource.ResourceAsBase64 = string.Empty;

            if (string.IsNullOrEmpty(sessionKey))
                sessionKey = "default";

            LocalRepo.SessionKey = sessionKey;
            return LocalRepo.TransferResource(rt);
        }