Exemplo n.º 1
0
        public void LinqFourWayJoin()
        {
            using (QDatabase db = new QDatabase("testlinq.msi", DatabaseOpenMode.Create))
            {
                this.InitLinqTestDatabase(db);
                int count;

                IList <string> pretest = db.ExecuteStringQuery(
                    "SELECT `Feature`.`Feature` " +
                    "FROM `Feature`, `FeatureComponents`, `Component`, `Registry` " +
                    "WHERE `Feature`.`Feature` = `FeatureComponents`.`Feature_` " +
                    "AND `FeatureComponents`.`Component_` = `Component`.`Component` " +
                    "AND `Component`.`Component` = `Registry`.`Component_` " +
                    "AND (`Registry`.`Registry` = 'MyTestRegCompReg1')");
                Assert.AreEqual <int>(1, pretest.Count);

                var features = from f in db.Features
                               join fc in db.FeatureComponents on f.Feature equals fc.Feature_
                               join c in db.Components on fc.Component_ equals c.Component
                               join r in db.Registries on c.Component equals r.Component_
                               where r.Registry == "MyTestRegCompReg1"
                               select f.Feature;

                count = 0;
                foreach (var featureName in features)
                {
                    Console.WriteLine(featureName);
                    count++;
                }
                Assert.AreEqual <int>(1, count);
            }
        }
Exemplo n.º 2
0
        public MspPackage(string mspFile)
        {
            PackageName = Path.GetFileName(mspFile);
            FullPath    = mspFile;

            try
            {
                //Note:have to use using to open the Qdatabase otherwise will get error 110
                //if open a few msi/msp:
                // QDatabase not able to open file name in uppper case. so lower case to open it.
                using (var qData = new QDatabase(mspFile.ToLower(), DatabaseOpenMode.ReadOnly))
                {
                    if (mspFile.ToUpper().EndsWith(".MSP"))
                    {
                        var tbl = qData.Tables["MsiPatchMetadata"];

                        if (tbl != null)
                        {
                            var props = qData.ExecuteStringQuery("SELECT `Property`,`Value` FROM `MsiPatchMetadata`");



                            for (int i = 0; i < props.Count - 1; i++)
                            {
                                string prop = props[i];
                                switch (prop)
                                {
                                case "DisplayName": this.DisplayName = props[i + 1]; break;

                                case "PatchVersion": this.PatchVersion = props[i + 1]; break;

                                case "BaselineVersion": this.BaselineVersion = props[i + 1]; break;

                                case "TargetProductName": this.TargetProductName = props[i + 1]; break;

                                case "MoreInfoURL": this.MoreInfoURL = props[i + 1]; break;

                                case "KBArticle": this.KBArticle = props[i + 1]; break;

                                case "Description": this.Description = props[i + 1]; break;

                                default:; break;
                                }
                            }
                        }


                        this.PatchCode = qData.SummaryInfo.RevisionNumber;
                        this.Targets   = qData.SummaryInfo.Template;
                    }

                    else
                    {
                        throw new InvalidDataException("Invalid file name:" + mspFile);
                    };
                }
            }
            catch (Exception ex)
            {
                Logger.LogError("MspPackage:" + ex.Message);

                failedPackage = true;
                return;
            }
        }
Exemplo n.º 3
0
        // public QDatabase qData;



        public MsiMspPackage(string msimspFileName)
        {
            MsiMspFileName = Path.GetFileName(msimspFileName);
            FullPath       = msimspFileName;

            try
            {
                //Note:have to use using to open the Qdatabase otherwise will get error 110
                //if open a few msi/msp:
                // QDatabase not able to open file name in uppper case. so lower case to open it.
                using (var qData = new QDatabase(msimspFileName.ToLower(), DatabaseOpenMode.ReadOnly))
                {
                    if (MsiMspFileName.ToUpper().EndsWith(".MSI"))
                    {
                        foreach (var p in qData.Properties)
                        {
                            if (p.Property == "ProductName")
                            {
                                ProductName = p.Value;
                            }
                            if (p.Property == "ProductVersion")
                            {
                                ProductVersion = p.Value;
                            }
                            if (p.Property == "ProductCode")
                            {
                                ProductCode = p.Value;
                            }
                            if (p.Property == "UpgradeCode")
                            {
                                UpgradeCode = p.Value;
                            }
                        }

                        try
                        {
                            this.PackageCode = qData.SummaryInfo.RevisionNumber;
                            if (String.IsNullOrEmpty(this.PackageCode))
                            {
                                this.failedPackage = true;
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.LogError("SummaryInfo.RevisionNumber:" + ex.Message);
                            this.failedPackage = true;
                        }
                    }
                    else if (MsiMspFileName.ToUpper().EndsWith(".MSP"))
                    {
                        var tbl = qData.Tables["MsiPatchMetadata"];

                        if (tbl != null)
                        {
                            var props = qData.ExecuteStringQuery("SELECT `Property`,`Value` FROM `MsiPatchMetadata`");



                            for (int i = 0; i < props.Count - 1; i++)
                            {
                                string prop = props[i];
                                if (prop == "DisplayName")
                                {
                                    this.ProductName = props[i + 1];
                                }
                                if (prop == "PatchVersion")
                                {
                                    this.ProductVersion = props[i + 1];
                                }
                                if (prop == "BaselineVersion")
                                {
                                    this.BaselineVersion = props[i + 1];
                                }
                            }

                            //  var  PatchVersion= qData.ExecuteScalar("SELECT `Value` FROM `MsiPatchMetadata` WHERE `Property` = '{0}'", "PatchVersion") ;
                            //  string name = qData.ExecuteScalar("SELECT `Value` FROM `MsiPatchMetadata` WHERE `Property` = '{0}'", "DisplayName") as string;
                            // string baselineVersion = qData.ExecuteScalar("SELECT `Value` FROM `MsiPatchMetadata` WHERE `Property` = '{0}'", "BaselineVersion") as string;
                        }

                        this.ProductCode = qData.SummaryInfo.Template;
                        this.isMsp       = true;

                        try
                        {
                            this.PatchCode = qData.SummaryInfo.RevisionNumber;
                            if (String.IsNullOrEmpty(this.PatchCode))
                            {
                                this.failedPackage = true;
                            }
                        }
                        catch (Exception ex)
                        {
                            this.failedPackage = true;
                            Logger.LogError("SummaryInfo.RevisionNumber:" + ex.Message);
                        }
                    }

                    else
                    {
                        throw new InvalidDataException("Invalid file name:" + msimspFileName);
                    };
                }
            }
            catch (Exception ex)
            {
                Logger.LogError("MsiMspPackage:" + ex.Message);

                failedPackage = true;
                return;
            }
        }