Exemplo n.º 1
1
        private void DumpCOMInfo()
        {
            COMAdminCatalog catalog;
            COMAdminCatalogCollection applications;

            catalog = new COMAdminCatalog();

            // COM+ Applications
            applications = (COMAdminCatalogCollection)catalog.GetCollection("Applications");
            applications.Populate();

            foreach (COMAdminCatalogObject application in applications)
            {
                Log("\nApplication Name: " + application.Name);

                COMAdminCatalogCollection components;
                components = (COMAdminCatalogCollection)applications.GetCollection("Components", application.Key);
                components.Populate(); // Forgot to call this
                foreach (COMAdminCatalogObject component in components)
                {
                    Log("Component Name: " + component.Name);
                    Log("Constructor String: " + component.get_Value("ConstructorString"));
                }
            }
        }
Exemplo n.º 2
0
        public void UnregisterComTransactionEventsListener()
        {
            ICOMAdminCatalog   pICat  = new COMAdminCatalog();
            ICatalogCollection pISubs = (ICatalogCollection)pICat.GetCollection("TransientSubscriptions");

            long           lCount = 0;
            int            i      = 0;
            ICatalogObject pISub;

            pISubs.Populate();
            lCount = pISubs.Count;
            if (lCount == 0)
            {
                return;
            }
            for (i = 0; i < lCount; i++)
            {
                pISub = (ICatalogObject)pISubs.get_Item(i);

                if (subID == (string)pISub.get_Value("ID"))
                {
                    pISubs.Remove(i);
                    pISubs.SaveChanges();
                    return;
                }
            }
        }
Exemplo n.º 3
0
        private void AddNativeComponent()
        {
            this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Adding Native Component: {0} to Application: {1}", this.Path, this.ApplicationName));
            if (System.IO.File.Exists(this.Path) == false)
            {
                this.Log.LogError(string.Format(CultureInfo.CurrentCulture, "Path not found: {0}", this.Path));
                return;
            }

            COMAdminCatalogCollection appCollection = GetApplications();
            bool appExists = false;

            foreach (COMAdmin.COMAdminCatalogObject app in appCollection)
            {
                if (app.Name.ToString() == this.ApplicationName)
                {
                    appExists = true;
                    var cat = new COMAdminCatalog();
                    cat.InstallComponent(app.Key.ToString(), this.Path, string.Empty, string.Empty);
                    break;
                }
            }

            if (!appExists)
            {
                this.Log.LogError(string.Format(CultureInfo.CurrentCulture, "Application not found: {0}", this.ApplicationName));
            }
        }
Exemplo n.º 4
0
        public static COMAdminCatalogCollection GetApplicationCollection()
        {
            objAdmin      = new COMAdmin.COMAdminCatalog();
            objCollection = (COMAdmin.COMAdminCatalogCollection)objAdmin.GetCollection("Applications");

            return(objCollection);
        }
Exemplo n.º 5
0
        private void DumpCOMInfo()
        {
            COMAdminCatalog           catalog;
            COMAdminCatalogCollection applications;

            catalog = new COMAdminCatalog();

            // COM+ Applications
            applications = (COMAdminCatalogCollection)catalog.GetCollection("Applications");
            applications.Populate();

            foreach (COMAdminCatalogObject application in applications)
            {
                Log("\nApplication Name: " + application.Name);

                COMAdminCatalogCollection components;
                components = (COMAdminCatalogCollection)applications.GetCollection("Components", application.Key);
                components.Populate(); // Forgot to call this
                foreach (COMAdminCatalogObject component in components)
                {
                    Log("Component Name: " + component.Name);
                    Log("Constructor String: " + component.get_Value("ConstructorString"));
                }
            }
        }
Exemplo n.º 6
0
        public void Refresh()
        {
            _componentes.Clear();

            COMAdminCatalogCollection applications;
            COMAdminCatalog           catalog;

            catalog      = new COMAdminCatalog();
            applications = (COMAdminCatalogCollection)catalog.GetCollection("Applications");
            applications.Populate();

            foreach (COMAdminCatalogObject application in applications)
            {
                //do something with the application
                if (application.Name.Equals("RepomComponentsNET"))
                {
                    COMAdminCatalogCollection components;


                    components = applications.GetCollection("Components", application.Key);

                    components.Populate();
                    foreach (COMAdminCatalogObject component in components)
                    {
                        _componentes.Add(component.Name);
                    }
                }
            }
        }
Exemplo n.º 7
0
        //these method comes almost unmodified from the msdn example:
        //http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/concreatingcomperfmoncounters.asp
        public void RegisterComTransactionEventsListener()
        {
            ICatalogObject     pISub, pIProp;
            ICatalogCollection pISubs, pIProps;
            long lret = 0;

            ICOMAdminCatalog pICat = new COMAdminCatalog();

            pISubs = (ICatalogCollection)pICat.GetCollection("TransientSubscriptions");

            pISubs.Populate();
            pISub = (ICatalogObject)pISubs.Add();
            pISub.set_Value("Name", "Method");
            pISub.set_Value("EventCLSID", "{ECABB0C3-7F19-11D2-978E-0000F8757E2A}");
            pISub.set_Value("InterfaceID", "{683130A8-2E50-11D2-98A5-00C04F8EE1C4}");
            IntPtr thisRef = Marshal.GetIUnknownForObject(this);

            pISub.set_Value("SubscriberInterface", thisRef);
            lret  = pISubs.SaveChanges();
            subID = (string)pISub.get_Value("ID");
            string strKey = (pISub.Key).ToString();

            pIProps =
                (ICatalogCollection)pISubs.GetCollection("TransientPublisherProperties",
                                                         strKey);
            pIProps.Populate();
            ICatalogObject pITPP = (ICatalogObject)pIProps.Add();

            pITPP.set_Value("Name", "AppID");
            pITPP.set_Value("Value", "{071FB34B-9465-40B8-99B7-B68B66813E8D}");
            lret = pIProps.SaveChanges();
        }
Exemplo n.º 8
0
 private void ShutDownApplication()
 {
     if (this.CheckApplicationExists())
     {
         this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Stopping Application: {0}", this.ApplicationName));
         COMAdmin.COMAdminCatalog f = new COMAdminCatalog();
         f.ShutdownApplication(this.ApplicationName);
     }
 }
 static void Main(string[] args)
 {
     COMAdminCatalog catalog = new COMAdminCatalog();
     COMAdminCatalogCollection applications = catalog.GetCollection("Applications");
     applications.Populate();
     for (int i = 0; i < applications.Count; i++)
     {
         COMAdminCatalogObject application = applications.Item[i];
         Console.WriteLine(application.Name);
         Console.WriteLine(application.Value["Identity"]);
     }
     Console.WriteLine("Press any key to continue...");
     Console.ReadKey();
 }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            ServiceController[] scServices;
            scServices = ServiceController.GetServices();

            foreach (ServiceController scTemp in scServices)
            {
                Console.WriteLine(scTemp.ServiceName + " : " + scTemp.Status
                                  + (scTemp.CanPauseAndContinue ? " : CanPauseAndContinue" : ""));
            }

            ICOMAdminCatalog2 oCatalog = (ICOMAdminCatalog2)Activator.CreateInstance(Type.GetTypeFromProgID("ComAdmin.COMAdminCatalog"));

            ICatalogCollection applications = (ICatalogCollection)oCatalog.GetCollection("Applications");

            applications.Populate();
            foreach (ICatalogObject applicationInstance in applications)
            {
                ICatalogCollection comps = (ICatalogCollection)applications.GetCollection("Components", applicationInstance.Key);
                comps.Populate();
                foreach (ICatalogObject comp in comps)
                {
                    Console.WriteLine("{0} - {1} - {2}", comp.Name, comp.Key, comp.ToString());
                }
            }

            COMAdminCatalogCollection applications2;
            COMAdminCatalog           catalog;

            catalog       = new COMAdminCatalog();
            applications2 = (COMAdminCatalogCollection)catalog.GetCollection("Applications");
            applications2.Populate();

            foreach (COMAdminCatalogObject application in applications2)
            {
                //do something with the application
                //if(  application.Name.Equals("MyAppName") )
                {
                    COMAdminCatalogCollection components;
                    components = (COMAdminCatalogCollection)applications2.GetCollection("Components", application.Key);

                    foreach (COMAdminCatalogObject component in components)
                    {
                        // do something with component
                    }
                }
            }
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            //var a = Environment.SystemDirectory;
            //Console.WriteLine(a);
            //var wrapper = new Wrapper();
            //wrapper.Setup();
            //wrapper.Run();

            COMAdminCatalog c  = new COMAdminCatalog();
            var             cl = (COMAdminCatalogCollection)c.GetCollection("Applications");

            cl.Populate();

            foreach (COMAdminCatalogObject obj in cl)
            {
                Console.WriteLine(obj.Name);
            }

            Console.ReadLine();
        }
        public void write(string connString)
        {
            try
            {
                // Get all the Applications
                COMAdminCatalog    cat  = new COMAdminCatalog();
                ICatalogCollection colA = cat.GetCollection("Applications") as ICatalogCollection;
                colA.Populate();

                // Find the component
                foreach (ICatalogObject co in colA)
                {
                    if ((string)co.Name == "SecureConnectionString")
                    {
                        ICatalogCollection colC = colA.GetCollection("Components", co.Key) as ICatalogCollection;
                        colC.Populate();

                        foreach (ICatalogObject co2 in colC)
                        {
                            if ((string)co2.Name == "SecureConnectionString.COMPlusStorage")
                            {
                                co2.set_Value("ConstructorString", connString);
                                break;
                            }
                        }
                        colC.SaveChanges();
                        break;
                    }
                }

                colA.SaveChanges();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
        }
        public void UnregisterComTransactionEventsListener()
        {
            ICOMAdminCatalog pICat = new COMAdminCatalog();
            ICatalogCollection pISubs = (ICatalogCollection)pICat.GetCollection("TransientSubscriptions");

            long lCount = 0;
            int i = 0;
            ICatalogObject pISub;

            pISubs.Populate();
            lCount = pISubs.Count;
            if (lCount == 0)
            {
                return;
            }
            for (i=0; i<lCount; i++)
            {
                pISub = (ICatalogObject)pISubs.get_Item(i);

                if (subID == (string)pISub.get_Value("ID"))
                {
                    pISubs.Remove(i);
                    pISubs.SaveChanges();
                    return;
                }
            }
        }
        //these method comes almost unmodified from the msdn example:
        //http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/concreatingcomperfmoncounters.asp
        public void RegisterComTransactionEventsListener()
        {
            ICatalogObject pISub, pIProp;
            ICatalogCollection pISubs, pIProps;
            long lret=0;

            ICOMAdminCatalog pICat = new COMAdminCatalog();

            pISubs = (ICatalogCollection)pICat.GetCollection("TransientSubscriptions");

            pISubs.Populate();
            pISub = (ICatalogObject)pISubs.Add();
            pISub.set_Value("Name", "Method");
            pISub.set_Value("EventCLSID", "{ECABB0C3-7F19-11D2-978E-0000F8757E2A}");
            pISub.set_Value("InterfaceID", "{683130A8-2E50-11D2-98A5-00C04F8EE1C4}");
            IntPtr thisRef = Marshal.GetIUnknownForObject(this);
            pISub.set_Value("SubscriberInterface", thisRef);
            lret = pISubs.SaveChanges();
            subID = (string)pISub.get_Value("ID");
            string strKey = (pISub.Key).ToString();
            pIProps =
                (ICatalogCollection)pISubs.GetCollection("TransientPublisherProperties",
                strKey);
            pIProps.Populate();
            ICatalogObject pITPP = (ICatalogObject)pIProps.Add();
            pITPP.set_Value("Name", "AppID");
            pITPP.set_Value("Value", "{071FB34B-9465-40B8-99B7-B68B66813E8D}");
            lret = pIProps.SaveChanges();
        }
        private void AddNativeComponent()
        {
            this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Adding Native Component: {0} to Application: {1}", this.Path, this.ApplicationName));
            if (System.IO.File.Exists(this.Path) == false)
            {
                this.Log.LogError(string.Format(CultureInfo.CurrentCulture, "Path not found: {0}", this.Path));
                return;
            }

            COMAdminCatalogCollection appCollection = GetApplications();
            bool appExists = false;
            foreach (COMAdmin.COMAdminCatalogObject app in appCollection)
            {
                if (app.Name.ToString() == this.ApplicationName)
                {
                    appExists = true;
                    var cat = new COMAdminCatalog();
                    cat.InstallComponent(app.Key.ToString(), this.Path, string.Empty, string.Empty);
                    break;
                }
            }

            if (!appExists)
            {
                this.Log.LogError(string.Format(CultureInfo.CurrentCulture, "Application not found: {0}", this.ApplicationName));
            }
        }
Exemplo n.º 16
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
            {
            }
        }
Exemplo n.º 17
-1
        public static string GetComponentProperty(string applicationName, string componentName, string propertyName)
        {
            COMAdminCatalog comAdminCatalog = new COMAdminCatalog();
            try
            {
                ICatalogCollection appCatalog = (ICatalogCollection)comAdminCatalog.GetCollection(COMConstants.APPLICATIONS_CATALOG_NAME);
                appCatalog.Populate();
                foreach (COMAdminCatalogObject application in appCatalog)
                {
                    if (!application.Name.Equals(applicationName)) continue;

                    ICatalogCollection componentCatalog = (ICatalogCollection)appCatalog.GetCollection(COMConstants.COMPONENTS_CATALOG_NAME, application.Key);
                    componentCatalog.Populate();
                    foreach (COMAdminCatalogObject comComp in componentCatalog)
                    {
                        if (((string)comComp.Name).Equals(componentName, StringComparison.InvariantCulture))
                        {
                            return comComp.get_Value(propertyName).ToString();
                        }
                    }
                }

                return null;
            }
            finally
            {
                Marshal.ReleaseComObject(comAdminCatalog);
            }
        }
Exemplo n.º 18
-1
 private void ShutDownApplication()
 {
     if (this.CheckApplicationExists())
     {
         this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Stopping Application: {0}", this.ApplicationName));
         COMAdmin.COMAdminCatalog f = new COMAdminCatalog();
         f.ShutdownApplication(this.ApplicationName);
     }
 }