コード例 #1
0
 public static string Get(string msi, string name)
 {
     using (var db = new QDatabase(msi.ToLower(), DatabaseOpenMode.ReadOnly))
     {
         return(db.ExecuteScalar("SELECT `Value` FROM `Property` WHERE `Property` = '{0}'", name) as string);
     }
 }
コード例 #2
0
 public static string MspGetMetadata(string msp, string name)
 {
     using (var db = new QDatabase(msp.ToLower(), DatabaseOpenMode.ReadOnly))
     {
         return(db.ExecuteScalar("SELECT `Value` FROM `MsiPatchMetadata` WHERE `Property` = '{0}'", name) as string);
     }
 }
コード例 #3
0
        public string GetScripted()
        {
            string retval = "";

            if (string.IsNullOrEmpty(name))
            {
                throw new Exception("Name is empty!");
            }
            if (databaseName.IsInvalid())
            {
                throw new Exception("Invalid database name!");
            }
            if (!CanBeScripted())
            {
                throw new Exception("Criterio cannot be scripted!Run Check.");
            }

            QDatabase db = QInstance.Environments.GetDatabase(DatabaseName);

            try
            {
                SqlCommand command = new SqlCommand("Man_ScriptCriterion_PerInstallation");
                db.Connection.InfoMessage += Connection_InfoMessage;
                command.CommandType        = CommandType.StoredProcedure;
                command.Parameters.Add("@cri_unique_id", SqlDbType.NVarChar, 255).Value = CriUniqueId;
                command.Parameters.Add("@inst_codes", SqlDbType.NVarChar, 1000).Value   = InstallationCode;
                connectionMsg.Clear();
                object ret = db.ExecuteScalar(command);
            }
            finally
            {
                db.Connection.InfoMessage -= Connection_InfoMessage;
            }

            return(connectionMsg.ToString());
        }
コード例 #4
0
ファイル: myRow.cs プロジェクト: uzairaslam/SQLSetupTools
        /// <summary>
        /// Add row for MSP package
        /// </summary>
        /// <param name="p"></param>
        public myRow(PatchInstallation p)
        {
            this.Index = myData.Index++;

            try
            {
                if (!string.IsNullOrEmpty(p.PatchCode))
                {
                    this.PatchCode = p.PatchCode;
                }

                CacheFileStatus stat = CacheFileStatus.Missing;
                if (!String.IsNullOrEmpty(p.LocalPackage))
                {
                    if (File.Exists(p.LocalPackage))
                    {
                        try
                        {
                            string cachePatchCode = MSIHelper.GetRevisionNumber(p.LocalPackage);
                            if (!string.IsNullOrEmpty(cachePatchCode) && !string.IsNullOrEmpty(this.PatchCode))
                            {
                                if (string.Compare(this.PatchCode, cachePatchCode, StringComparison.Ordinal) != 0)
                                {
                                    stat         = CacheFileStatus.Mismatched;
                                    this.Comment = "Patch code doesn't matched. cached file has package code:" + cachePatchCode + ", but Installer expected:" + this.PatchCode;
                                }
                            }

                            else //if local package exists, but the cachePatchCode is null, or this.PatchCode is null, set it mismatch

                            {
                                //if both are null, or one is null, set it mismatched
                                if (string.IsNullOrEmpty(cachePatchCode) || string.IsNullOrEmpty(this.PatchCode))
                                {
                                    stat         = CacheFileStatus.Mismatched;
                                    this.Comment = "At least one of the patch codes is null. cached file has package code:" + cachePatchCode + ", Installer one:" + this.PatchCode;
                                }
                            }
                            //String ver = MSIHelper.MspGetMetadata(p.LocalPackage, "BaselineVersion");
                            //if (!String.IsNullOrEmpty(this.ProductVersion))
                            //{
                            //    if (ver != this.ProductVersion)
                            //    {
                            //        stat = CacheFileStatus.Mismatched;
                            //        Comment = p.LocalPackage + ": BaselineVersion in MSP not matched the ProductVersion in its MSI. If SP applied this could be normal.";
                            //    }
                            //}
                            //don't check this. patch code is good enough to check mismatched msp file.

                            /*
                             * if (stat != CacheFileStatus.Mismatched)
                             * {
                             *  String pn = MSIHelper.MspGetMetadata(p.LocalPackage, "DisplayName");
                             *  if (p.DisplayName != pn)
                             *  {
                             *      stat = CacheFileStatus.Mismatched;
                             *      Comment = p.LocalPackage + ": DisplayName not matched! Cached file has DisplayName:[" + pn + "] but Installer expected: [" + p.DisplayName + "]";
                             *  }
                             * }
                             */
                        }
                        catch (Exception ex)
                        {
                            // (any exception) set it to mismatched
                            stat    = CacheFileStatus.Mismatched;
                            Comment = ex.Message;
                            Logger.LogError("[Mismatched MSP check failed]" + p.LocalPackage + " \n" + ex.Message);
                        }

                        if (stat != CacheFileStatus.Mismatched)
                        {
                            stat = CacheFileStatus.OK;
                        }
                    }
                    else
                    {
                        stat    = CacheFileStatus.Missing;
                        Comment = p.LocalPackage + " doesn't exist";
                    }
                }
                else
                {
                    stat = CacheFileStatus.Empty;
                }

                this.Status = stat;

                if (p.SourceList != null)
                {
                    this.PackageName    = p.SourceList.PackageName;
                    this.LastUsedSource = p.SourceList.LastUsedSource;
                }
                this.InstallDate = p.InstallDate;

                //patch doesn't have source
                //this.InstallSource = p.InstallSource;
                //this.IsAdvertised = p.IsAdvertised.ToString();
                this.ProductCode = p.ProductCode;
                this.ProductName = p.DisplayName;
                //patch won't have product version
                // this.ProductVersion = p.ProductVersion.ToString();
                //  this.Publisher = p.Publisher;
                this.isPatch = true;

                if (!String.IsNullOrEmpty(p.LocalPackage))
                {
                    CachedMsiMsp = Path.GetFileName(p.LocalPackage);
                    if (File.Exists(p.LocalPackage))
                    {
                        //    CachedMsiMspVersion = MSIHelper.Get(p.LocalPackage, "ProductVersion").ToString();


                        using (var db = new QDatabase(p.LocalPackage, DatabaseOpenMode.ReadOnly))
                        {
                            //using try catch since some msp doesn't all this properties
                            try { this.CachedMsiMspVersion = db.ExecuteScalar("SELECT `Value` FROM `MsiPatchMetadata` WHERE `Property` = '{0}'", "PatchVersion") as string; } catch { }
                            try { this.PatchBaselineVersion = db.ExecuteScalar("SELECT `Value` FROM `MsiPatchMetadata` WHERE `Property` = '{0}'", "BaselineVersion") as string; } catch { };
                            try { this.MoreInfoURL = db.ExecuteScalar("SELECT `Value` FROM `MsiPatchMetadata` WHERE `Property` = '{0}'", "MoreInfoURL") as string; } catch { };
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.LogError("myRow:patch:" + e.Message);
            }
        }
コード例 #5
0
        private bool CheckRecNoLCYField()
        {
            bool retval = true;

            try
            {
                QDatabase database = QInstance.Environments.GetDatabase(DatabaseName);
                // first check if the field ui record exists
                DataTable tbRec = database.ExecuteCommand(GetInstUiFieldCommand());
                if (tbRec.Rows.Count == 0)
                {
                    QCRAction check = new QCRAction()
                    {
                        State        = QCRActionState.NeedsAction,
                        ActionType   = QCRActionType.CheckDatasourceField,
                        Description  = string.Format("Add field \"{0}\" to datasource \"{1}\".", FieldName, DatasourceName),
                        DatabaseName = this.DatabaseName
                    };
                    Actions.Add(check);
                    retval = false;
                }
                else if (tbRec.Rows.Count > 0)
                {
                    // check if there are  fields in the specific installation.
                    int count = (int)database.ExecuteScalar(GetInstUIFieldsCountCommand());
                    // check if fields exists
                    DataRow[] row = tbRec.Select(string.Format("INST_CODE = {0}", InstallationCode));
                    if (row.Length == 0 && count > 0)
                    {
                        QCRAction check = new QCRAction()
                        {
                            State        = QCRActionState.NeedsAction,
                            ActionType   = QCRActionType.CheckDatasourceField,
                            Description  = string.Format("The datasource \"{0}\" contains the field \"{1}\" for the default installation only.Override for \"{2}\"", DatasourceName, FieldName, InstallationCode),
                            DatabaseName = this.DatabaseName
                        };
                        Actions.Add(check);
                        retval = false;
                    }
                    if (row.Length == 1) // record found
                    {
                        // check active flag
                        if (!((bool)row[0]["DSF_ACTIVE"]))
                        {
                            QCRAction check = new QCRAction()
                            {
                                State        = QCRActionState.NeedsAction,
                                ActionType   = QCRActionType.CheckDatasourceField,
                                Description  = string.Format("The field \"{0}\" in datasource \"{1}\" for the installation \"{2}\" is not active.", FieldName, DatasourceName, InstallationCode),
                                DatabaseName = this.DatabaseName
                            };
                            Actions.Add(check);
                            retval = false;
                        }
                        // check visible in ui flag
                        if (!((bool)row[0]["DSFU_UI_VISIBLE"]))
                        {
                            QCRAction check = new QCRAction()
                            {
                                State        = QCRActionState.NeedsAction,
                                ActionType   = QCRActionType.CheckDatasourceField,
                                Description  = string.Format("The field \"{0}\" in datasource \"{1}\" for the installation \"{2}\" is not visible in ui.", FieldName, DatasourceName, InstallationCode),
                                DatabaseName = this.DatabaseName
                            };
                            Actions.Add(check);
                            retval = false;
                        }
                        // check caption
                        if (((string)row[0]["DSFU_UI_CAPTION"]) != FieldCaption)
                        {
                            QCRAction check = new QCRAction()
                            {
                                State        = QCRActionState.NeedsAction,
                                ActionType   = QCRActionType.CheckDatasourceField,
                                Description  = string.Format("The field \"{0}\" in datasource \"{1}\" for the installation \"{2}\" has different caption than the specification.", FieldName, DatasourceName, InstallationCode),
                                DatabaseName = this.DatabaseName
                            };
                            Actions.Add(check);
                            retval = false;
                        }
                    }
                }
                // everything ok
                if (Actions.Count == 0)
                {
                    QCRAction check = new QCRAction()
                    {
                        State        = QCRActionState.WellImplemented,
                        ActionType   = QCRActionType.NoActionNeeded,
                        Description  = string.Format("Add field \"{0}\" to Datasource \"{1}\".", FieldName, DatasourceName),
                        DatabaseName = this.DatabaseName
                    };
                    Actions.Add(check);
                    retval = true;
                }
            }
            catch (Exception ex)
            {
                QCRAction check = new QCRAction()
                {
                    State        = QCRActionState.NeedsAction,
                    ActionType   = QCRActionType.CheckDatasourceField,
                    Description  = string.Format(ex.Message),
                    DatabaseName = this.DatabaseName
                };
                Actions.Add(check);

                retval = false;
            }
            return(retval);
        }