public COMAdminCatalogCollection GetAppItems()
 {
     if (oCollection == null)
     {
         try
         {
             COMAdminCatalogCollection appColl = GetCatalogCollection();
             foreach (COMAdminCatalogObject app in appColl)
             {
                 if (app.Name.ToString().ToLower() == "")                         //Config.ComApplication.ToLower() )
                 {
                     oCollection = (COMAdminCatalogCollection)appColl.GetCollection("Components", app.Key);
                     oCollection.Populate();
                     break;
                 }
             }
         }
         catch (Exception oEx)
         {
             Common.Log.Write(this, oEx);
         }
     }
     return(oCollection);
 }
Exemplo n.º 2
0
        private void SetConstructor()
        {
            if (!this.CheckApplicationExists())
            {
                return;
            }

            this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "SetConstructor on Component: {0}", this.ComponentName));
            COMAdminCatalogCollection appCollection = GetApplications();

            foreach (COMAdmin.COMAdminCatalogObject app in appCollection)
            {
                if (app.Name.ToString() == this.ApplicationName)
                {
                    COMAdmin.ICatalogCollection componentCollection = (COMAdmin.ICatalogCollection)appCollection.GetCollection("Components", app.Key);
                    componentCollection.Populate();
                    foreach (COMAdmin.COMAdminCatalogObject component in componentCollection)
                    {
                        if (component.Name.ToString() == this.ComponentName)
                        {
                            component.set_Value("ConstructorString", this.ConstructorString ?? string.Empty);
                            component.set_Value("ConstructionEnabled", !string.IsNullOrEmpty(this.ConstructorString));
                            componentCollection.SaveChanges();
                            break;
                        }
                    }

                    break;
                }
            }

            appCollection.SaveChanges();
        }
Exemplo n.º 3
0
        private void SetAccessIisIntrinsicProperties()
        {
            if (!this.CheckApplicationExists())
            {
                return;
            }

            this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "SetAccessIisIntrinsicProperties on Component: {0}", this.ComponentName));
            COMAdminCatalogCollection appCollection = GetApplications();

            foreach (COMAdmin.COMAdminCatalogObject app in appCollection)
            {
                if (app.Name.ToString() == this.ApplicationName)
                {
                    COMAdmin.ICatalogCollection componentCollection = (COMAdmin.ICatalogCollection)appCollection.GetCollection("Components", app.Key);
                    componentCollection.Populate();
                    foreach (COMAdmin.COMAdminCatalogObject component in componentCollection)
                    {
                        if (component.Name.ToString() == this.ComponentName)
                        {
                            component.set_Value("IISIntrinsics", this.AllowIntrinsicIisProperties);
                            componentCollection.SaveChanges();
                            break;
                        }
                    }

                    break;
                }
            }

            appCollection.SaveChanges();
        }
Exemplo n.º 4
0
        static private void performccreatecomappop(appoptions apopts)
        {
            try
            {
                bool bins   = ((apopts & appoptions.install) != 0);
                bool bunins = ((apopts & appoptions.uninstall) != 0);
                bool bstart = ((apopts & appoptions.start) != 0);
                bool bstop  = ((apopts & appoptions.stop) != 0);

                COMAdminCatalog           catalog      = new COMAdminCatalog();
                COMAdminCatalogCollection applications = catalog.GetCollection("Applications") as COMAdminCatalogCollection;
                applications.Populate();
                if (bins || bunins || bstart || bstop || breg)
                {
                    for (int i = 0; i < applications.Count; ++i)
                    {
                        COMAdminCatalogObject app = applications.get_Item(i) as COMAdminCatalogObject;
                        if (app.Name.ToString() == appname)
                        {
                            if (bstart)
                            {
                                catalog.StartApplication(appname);
                                return;
                            }

                            catalog.ShutdownApplication(appname);
                            if (bins || bunins)
                            {
                                applications.Remove(i);
                                applications.SaveChanges();
                            }
                            break;
                        }
                    }


                    if (bins)
                    {
                        applications.Populate();

                        COMAdminCatalogObject application = applications.Add() as COMAdminCatalogObject;
                        application.Value["ID"]         = Guid.NewGuid().ToString("B");
                        application.Value["Name"]       = appname;
                        application.Value["RunForever"] = brunforever;
                        applications.SaveChanges();

                        if (System.Environment.OSVersion.Version.Major > 5)
                        {
                            COMAdminCatalogCollection roles = (COMAdminCatalogCollection)applications.GetCollection("Roles", application.Key);
                            roles.Populate();
                            COMAdminCatalogObject role = roles.Add() as COMAdminCatalogObject;
                            role.Value["Name"] = "DefaultRole";
                            roles.SaveChanges();
                            COMAdminCatalogCollection users = (COMAdminCatalogCollection)roles.GetCollection("UsersInRole", role.Key);
                            users.Populate();
                            COMAdminCatalogObject user = users.Add() as COMAdminCatalogObject;
                            user.Value["User"] = "******";
                            users.SaveChanges();
                        }
                        applications.SaveChanges();
                    }
                }

                if (breg || bunreg)
                {
                    if (data.Count == 0)
                    {
                        if (filename == "")
                        {
                            ShowSyntax();
                        }

                        List <KeyValuePair <string, string> > progclsidlst = new List <KeyValuePair <string, string> >();
                        if (filename.ToLower().IndexOf(".wsc") != -1)
                        {
                            progclsidlst = CodeGenHelper.GetclsidsfromWSC(filename);
                        }
                        else
                        {
                            progclsidlst = CodeGenHelper.GetclsidsfromAssembly(filename);
                            if (progclsidlst.Count == 0)
                            {
                                progclsidlst = CodeGenHelper.GetclsidsfromTLB(filename);
                            }
                        }

                        foreach (var kv in progclsidlst)
                        {
                            data.Add(kv.Key);
                        }
                    }

                    foreach (string d in data)
                    {
                        if (breg)
                        {
                            catalog.ImportComponent(appname, d);
                        }
                    }
                }
                else if (bgac || bungac)
                {
                    if (bgac)
                    {
                        catalog.InstallComponent(appname, filename, "", "");
                    }
                }

                applications.SaveChanges();
            }
            catch
            {
            }
        }