/// <summary>
        /// Runs the specified command.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="keyValues">The key values.</param>
        /// <param name="output">The output.</param>
        /// <returns></returns>
        public override int Execute(string command, StringDictionary keyValues, out string output)
        {
            output = string.Empty;

            if (!Params["updatefarm"].UserTypedIn)
                Common.WebApplications.SetBackConnectionHostNames.SetBackConnectionRegKey(Common.WebApplications.SetBackConnectionHostNames.GetUrls());
            else
            {
                SPTimerService timerService = SPFarm.Local.TimerService;
                if (null == timerService)
                {
                    throw new SPException("The Farms timer service cannot be found.");
                }
                Common.WebApplications.SetBackConnectionHostNamesTimerJob job = new Common.WebApplications.SetBackConnectionHostNamesTimerJob(timerService);

                string user = Params["username"].Value;
                if (user.IndexOf('\\') < 0)
                    user = Environment.UserDomainName + "\\" + user;

                List<string> urls = Common.WebApplications.SetBackConnectionHostNames.GetUrls();

                job.SubmitJob(user, Params["password"].Value + "", urls);

                output += "Timer job successfully created.";
            }

            return (int)ErrorCodes.NoError;
        }
        /// <summary>
        /// Runs the specified command.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="keyValues">The key values.</param>
        /// <param name="output">The output.</param>
        /// <returns></returns>
        public override int Execute(string command, StringDictionary keyValues, out string output)
        {
            output = string.Empty;

            if (!Params["updatefarm"].UserTypedIn)
            {
                Common.WebApplications.SetBackConnectionHostNames.SetBackConnectionRegKey(Common.WebApplications.SetBackConnectionHostNames.GetUrls());
            }
            else
            {
                SPTimerService timerService = SPFarm.Local.TimerService;
                if (null == timerService)
                {
                    throw new SPException("The Farms timer service cannot be found.");
                }
                Common.WebApplications.SetBackConnectionHostNamesTimerJob job = new Common.WebApplications.SetBackConnectionHostNamesTimerJob(timerService);

                string user = Params["username"].Value;
                if (user.IndexOf('\\') < 0)
                {
                    user = Environment.UserDomainName + "\\" + user;
                }

                List <string> urls = Common.WebApplications.SetBackConnectionHostNames.GetUrls();

                job.SubmitJob(user, Params["password"].Value + "", urls);

                output += "Timer job successfully created.";
            }

            return((int)ErrorCodes.NoError);
        }
示例#3
0
        protected override void UpdateDataObject()
        {
            List <string> urls = new List <string>();

            if (WebApplication != null)
            {
                Common.WebApplications.SetBackConnectionHostNames.GetUrls(urls, WebApplication.Read());
            }
            else
            {
                urls = Common.WebApplications.SetBackConnectionHostNames.GetUrls();
            }

            string shouldProcessMsg = "Update the local server with appropriate back connection host names.";

            if (UpdateFarm.IsPresent)
            {
                shouldProcessMsg = "Update all servers with appropriate back connection host names.";
            }

            ShouldProcessReason reason;

            if (!base.ShouldProcess(shouldProcessMsg, null, null, out reason))
            {
                if (reason == ShouldProcessReason.WhatIf)
                {
                    base.WriteResult(urls);
                }
                return;
            }

            if (!UpdateFarm.IsPresent)
            {
                Common.WebApplications.SetBackConnectionHostNames.SetBackConnectionRegKey(urls);
            }
            else
            {
                SPTimerService timerService = SPFarm.Local.TimerService;
                if (null == timerService)
                {
                    throw new SPException("The Farms timer service cannot be found.");
                }
                Common.WebApplications.SetBackConnectionHostNamesTimerJob job = new Common.WebApplications.SetBackConnectionHostNamesTimerJob(timerService);

                job.SubmitJob(FarmCredentials.UserName,
                              Utilities.ConvertToUnsecureString(FarmCredentials.Password),
                              urls);

                WriteResult("Timer job successfully created.");
            }
        }