Esempio n. 1
0
        public override bool Execute()
        {
            var result = false;

            try
            {
                Log.LogMessage("Sitecore Ship Publish Start: {0} | {1} | {2} | {3} | {4}", HostName, Mode, Source, Targets, Languages);

                HostName = HostName.TrimEnd('/');
                string absolutUrl = string.Format("{0}{1}", HostName, string.Format(Path, Mode));

                string formData = string.Format("source={0}&targets={1}&languages={2}",
                                                HttpUtility.UrlEncode(Source),
                                                HttpUtility.UrlEncode(Targets),
                                                HttpUtility.UrlEncode(Languages)
                                                );

                WebClient client = new WebClient();
                client.UploadString(absolutUrl, "POST", formData);

                result = true;

                Log.LogMessage("Sitecore Ship Publish Finished: {0} | {1} | {2} | {3} | {4}", HostName, Mode, Source, Targets, Languages);
            }
            catch (Exception ex)
            {
                Log.LogErrorFromException(ex, true);
            }

            return(result);
        }
        public override bool Execute()
        {
            var result = false;

            Log.LogMessage("Sitecore Ship Upload Start: {0}", FilePath);

            if (File.Exists(FilePath))
            {
                try
                {
                    HostName = HostName.TrimEnd('/');
                    string absolutUrl = string.Format("{0}{1}", HostName, Path);

                    Log.LogMessage("Sitecore Ship Upload: Pushing to {0}", absolutUrl);


                    if (PackageId > 0 && !string.IsNullOrEmpty(Description))
                    {
                        //this is hack for now
                        absolutUrl = absolutUrl +
                                     string.Format("?packageId={0}&description={1}", PackageId, Description);
                    }

                    Log.LogWarning("Sitecore Ship Upload Finished to {0}, timeout {1}", absolutUrl, Timeout == 0 ? 100 : Timeout);

                    WebClientEx client = new WebClientEx();
                    client.Timeout = Timeout == 0 ? 100 : Timeout;
                    client.UploadFile(absolutUrl, "POST", FilePath);
                    result = true;

                    Log.LogMessage("Sitecore Ship Upload Finished: {0}", FilePath);
                }
                catch (Exception ex)
                {
                    Log.LogErrorFromException(ex, true);
                }
            }
            else
            {
                Log.LogError(string.Format("Sitecore Ship Upload Failed: Failed to find file {0}", FilePath));
            }

            return(result);
        }