示例#1
0
 private void StartApplication()
 {
     if (this.CheckApplicationExists())
     {
         this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Starting Application: {0}", this.ApplicationName));
         COMAdmin.COMAdminCatalog f = new COMAdminCatalog();
         f.StartApplication(this.ApplicationName);
     }
 }
 private void StartApplication()
 {
     if (this.CheckApplicationExists())
     {
         this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Starting Application: {0}", this.ApplicationName));
         COMAdmin.COMAdminCatalog f = new COMAdminCatalog();
         f.StartApplication(this.ApplicationName);
     }
 }
示例#3
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
            {
            }
        }