Example #1
0
        public void Deploy()
        {
            // Do the install.
            JavaScriptSerializer  jsonSer = new JavaScriptSerializer();
            SessionDataController dc      = new SessionDataController();

            // Set as started.
            Session.Status = SessionStatus.InProgess;
            dc.Update(Session);

            // Install in order.
            foreach (KeyValuePair <int, InstallJob> keyPair in OrderedInstall)
            {
                // Get install job.
                InstallJob job = keyPair.Value;

                // Attempt install.
                job.Install();

                // Log package installs.
                foreach (PackageJob package in job.Packages)
                {
                    string log = string.Format("Package successfully installed: {0} @ {1}, session: {2}.", package.Name, package.VersionStr, Session.Guid);

                    EventLogManager.Log("PACKAGE_INSTALLED", EventLogSeverity.Info, log);
                }

                // Make sorted list serialisable.
                SortedList <string, InstallJob> serOrderedInstall = new SortedList <string, InstallJob>();

                foreach (KeyValuePair <int, InstallJob> pair in OrderedInstall)
                {
                    serOrderedInstall.Add(pair.Key.ToString(), pair.Value);
                }

                // After each install job, update response.
                Session.Response = jsonSer.Serialize(serOrderedInstall);
                dc.Update(Session);
            }

            // Done.
            Session.Status = SessionStatus.Complete;
            dc.Update(Session);
        }