コード例 #1
0
 private static void CreateComboBoxRecordItem(View view, int numRows, string propertyName, string text, string value)
 {
     Record record = new Record(4);
     record.SetString(1, propertyName);
     record.SetInteger(2, numRows);
     record.SetString(3, value);
     record.SetString(4, text);
     view.Modify(ViewModifyMode.InsertTemporary, record);
 }
コード例 #2
0
        /// <summary>
        /// Logs a message to the MSI log using the MSI error table.
        /// </summary>
        /// <param name="id">Error message id</param>
        /// <param name="args">Arguments to the error message (will be inserted into the formatted error message).</param>
        public void Log(int id, params string[] args)
        {
            // field 0 is free, field 1 is the id, fields 2..n are arguments
            using (Record rec = new Record(1 + args.Length))
            {
                rec.SetInteger(1, id);
                for (int i = 0; i < args.Length; i++)
                {
                    rec.SetString(2 + i, args[i]);
                }

                this.session.Message(InstallMessage.User, rec);
            }
        }
コード例 #3
0
        public static ActionResult InstallWebFeatures(Session session)
        {
            PopUpDebugger();

            var Ctx = session;
            Ctx.AttachToSetupLog();
            Log.WriteStart("InstallWebFeatures");
            var Result = ActionResult.Success;
            var Scheduled = Ctx.GetMode(InstallRunMode.Scheduled);
            var Components = new List<string>();
            var InstallIis = false;
            var InstallAspNet = false;
            var InstallNetFx3 = false;
            if (Scheduled)
            {
                InstallIis = Ctx.CustomActionData["PI_PREREQ_IIS_INSTALL"] != YesNo.No;
                InstallAspNet = Ctx.CustomActionData["PI_PREREQ_ASPNET_INSTALL"] != YesNo.No;
                InstallNetFx3 = Ctx.CustomActionData["PI_PREREQ_NETFX_INSTALL"] != YesNo.No;
            }
            else
            {
                InstallIis = Ctx["PI_PREREQ_IIS_INSTALL"] != YesNo.No;
                InstallAspNet = Ctx["PI_PREREQ_ASPNET_INSTALL"] != YesNo.No;
                InstallNetFx3 = Ctx["PI_PREREQ_NETFX_INSTALL"] != YesNo.No;
            }
            if (InstallIis)
                Components.AddRange(Tool.GetWebRoleComponents());
            if (InstallAspNet)
                Components.AddRange(Tool.GetWebDevComponents());
            if (InstallNetFx3)
                Components.AddRange(Tool.GetNetFxComponents());
            if (Scheduled)
            {
                Action<int, int> ProgressReset = (int Total, int Mode) =>
                {
                    using (var Tmp = new Record(4))
                    {
                        Tmp.SetInteger(1, 0);
                        Tmp.SetInteger(2, Total);
                        Tmp.SetInteger(3, 0);
                        Tmp.SetInteger(4, Mode);
                        Ctx.Message(InstallMessage.Progress, Tmp);
                    }
                };
                Action<int> ProgressIncrement = (int Value) =>
                {
                    using (var Tmp = new Record(2))
                    {
                        Tmp.SetInteger(1, 2);
                        Tmp.SetInteger(2, Value);
                        Ctx.Message(InstallMessage.Progress, Tmp);
                    }
                };
                Action<string> ProgressText = (string Text) =>
                {
                    using (var Tmp = new Record(2))
                    {
                        Tmp.SetString(1, "CA_InstallWebFeaturesDeferred");
                        Tmp.SetString(2, Text);
                        Ctx.Message(InstallMessage.ActionStart, Tmp);
                    }
                };
                var Frmt = "Installing web component the {0} a {1} of {2}";
                Log.WriteStart("InstallWebFeatures: components");
                ProgressReset(Components.Count + 1, 0);
                ProgressText("Installing necessary web components ...");
                var Msg = new StringBuilder();
                try
                {
                    InstallToolDelegate InstallTool = Tool.GetInstallTool();
                    if (InstallTool == null)
                        throw new ApplicationException("Install tool for copmonents is not found.");                    
                    for (int i = 0; i < Components.Count; i ++)
                    {
                        var Component = Components[i];
                        ProgressText(string.Format(Frmt, Component, i + 1, Components.Count));
                        ProgressIncrement(1);
                        Msg.AppendLine(InstallTool(Component));
                    }
                    if (InstallAspNet)
                        Tool.PrepareAspNet();                    
                    Log.WriteInfo("InstallWebFeatures: done.");
                }
                catch (Exception ex)
                {
                    Log.WriteError(string.Format("InstallWebFeatures: fail - {0}.", ex.ToString()));
                    Result = ActionResult.Failure;
                }
                finally
                {
                    ProgressReset(Components.Count * 3 + 1, 0);
                    if (Msg.Length > 0)
                        Log.WriteInfo(string.Format("InstallWebFeatures Tool Log: {0}.", Msg.ToString()));
                    Log.WriteEnd("InstallWebFeatures: components"); 
                }                               
            }
            else
            {
                Log.WriteStart("InstallWebFeatures: prepare");
                using (var ProgressRecord = new Record(2))
                {     
                    ProgressRecord.SetInteger(1, 3);
                    ProgressRecord.SetInteger(2, Components.Count);
                    Ctx.Message(InstallMessage.Progress, ProgressRecord);
                }
                Log.WriteEnd("InstallWebFeatures: prepare");
            }
            Log.WriteEnd("InstallWebFeatures");
            return Result;
        }        
コード例 #4
0
        public static ActionResult ScanNetworkForSqlServers(Session session)
        {
            sessionObj = session;
            if (xmlSettings == null)
                xmlSettings = new XMLSettingsManager();

            if ((session["HASSCANNEDFORSQL"].CompareTo("0") == 0) && (session["ISSERVERINSTALL"] != "0")) {
                if (xmlSettings.SettingsFileExists()) {
                    return ActionResult.SkipRemainingActions;
                } else {
                    DataTable dt = SqlDataSourceEnumerator.Instance.GetDataSources();
                    View sqlComboBox = session.Database.OpenView("SELECT * FROM `ComboBox`");
                    sqlComboBox.Execute();
                    int numRows = 0;
                    while (sqlComboBox.Fetch() != null) {
                        numRows++;
                    }
                    if (numRows == 1) {
                        CustomActions.LogToSession(string.Format("found {0} sql servers", dt.Rows.Count));
                        int itemNumber = 2;
                        foreach (DataRow row in dt.Rows) {
                            Record rec = new Record(3);
                            rec.SetString(1, "OMLProp_SqlServers");
                            rec.SetInteger(2, itemNumber);
                            string description = string.Format("{0} - {1}", row["ServerName"], row["InstanceName"]);
                            rec.SetString(3, description);

                            CustomActions.LogToSession(string.Format("Adding a new record, its number will be {0} and its value will be {1}", itemNumber, string.Format("{0} ({1})", row["ServerName"], row["InstanceName"])));
                            sqlComboBox.Modify(ViewModifyMode.InsertTemporary, rec);
                            itemNumber++;
                        }
                    }
                }
                session["HASSCANNEDFORSQL"] = "1";
            }
            return ActionResult.Success;
        }
コード例 #5
0
    public static void SendProgressMessageToBA(Session session, string message, int progress)
    {
        Record messageRecord = new Record(4);
        messageRecord.SetInteger(1, (int)MessageId.Progress);
        messageRecord.SetString(2, message);
        messageRecord.SetInteger(3, progress);

        session.Message(InstallMessage.Warning, messageRecord);
    }
コード例 #6
0
    public static void SendMessageBoxMessageToBA(Session session, string message)
    {
        Record messageRecord = new Record(3);
        messageRecord.SetInteger(1, (int)MessageId.MessageBox);
        messageRecord.SetString(2, message);

        session.Message(InstallMessage.Warning, messageRecord);
    }