// Creates a Dictionary of DGS Applications, using the server name as the key
        private static ApplicationCollection CreateApplicationItemList()
        {
            ApplicationCollection itemDic = new ApplicationCollection();

            // Get the Server Inventory as a ListItemCollection
            ListItemCollection list = GetApplicationListItems();

            // Itterate through each item in the list
            foreach (ListItem lItem in list)
            {
                try
                {
                    ApplicationItem app = new ApplicationItem(lItem["Title"].ToString());

                    // Set the simple text fields
                    app.SupportContact  = lItem[_supportContactField] != null ? (string)lItem[_supportContactField] : "";
                    app.SupportGroup    = lItem[_supportGroupField] != null ? (string)lItem[_supportGroupField] : "";
                    app.Status          = lItem[_statusField] != null ? (string)lItem[_statusField] : "";
                    app.ApplicationType = lItem[_applicationTypeField] != null ? (string)lItem[_applicationTypeField] : "";
                    app.Description     = lItem[_descriptionField] != null ? (string)lItem[_descriptionField] : "";

                    // Add server to the Dictionary
                    if (!itemDic.ContainsKey(app.ApplicationName))
                    {
                        itemDic.Add(app);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            return(itemDic);
        }
        private void GetApplicationRole()
        {
            List <AppRoles> allRoles = new List <AppRoles>();

            OguObjectCollection <IUser> users = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.Guid, Data.ID);

            ExceptionHelper.FalseThrow(users.Count > 0, "不能找到ID为\"{0}\"的用户", Data.ID);

            ApplicationCollection result = PermissionMechanismFactory.GetMechanism().GetAllApplications();

            foreach (IApplication app in result)
            {
                RoleCollection roles = users[0].Roles[app.CodeName];
                if (roles.Count > 0)
                {
                    AppRoles ar = new AppRoles();

                    ar.AppName = app.Name;
                    ar.Roles   = GetRoleNames(roles);

                    allRoles.Add(ar);
                }
            }

            gridAppRoles.DataSource = allRoles;
            gridAppRoles.DataBind();
        }
Example #3
0
        public void OguApplicationCollectionSerializationTest()
        {
            JSONSerializerExecute.RegisterConverter(typeof(OguApplicationConverter));

            ApplicationCollection    originalApps = PermissionMechanismFactory.GetMechanism().GetAllApplications();
            OguApplicationCollection apps         = new OguApplicationCollection(originalApps);

            CheckOguApplicationCollectionItems(apps);

            //测试Set操作
            for (int i = 0; i < apps.Count; i++)
            {
                apps[i] = originalApps[i];
            }

            CheckOguApplicationCollectionItems(apps);

            string serializedData = JSONSerializerExecute.Serialize(apps);

            Console.WriteLine(serializedData);

            OguApplicationCollection deserializedData = JSONSerializerExecute.Deserialize <OguApplicationCollection>(serializedData);

            for (int i = 0; i < apps.Count; i++)
            {
                ValidatePermissionObject(apps[i], deserializedData[i]);
            }
        }
        /// <summary>
        /// Create a fresh test app with the given name, delete the existing
        /// test app and reboot Splunk.
        /// </summary>
        /// <param name="name">The app name</param>
        public void CreateApp(string name)
        {
            //EntityCollection<App> apps;

            Service service = this.Connect();

            ApplicationCollection apps = service.GetApplicationsAsync(new ApplicationCollectionArgs()).Result;

            if (apps.Any(a => a.ResourceName.Title == name))
            {
                service.RemoveApplicationAsync(name).Wait();
                this.SplunkRestart();
                service = this.Connect();
                apps    = service.GetApplicationsAsync().Result;
            }

            Assert.False(apps.Any(a => a.ResourceName.Title == name), this.assertRoot + "#1");

            //apps.Create(name);
            service.CreateApplicationAsync(name, "sample_app").Wait();

            this.SplunkRestart();

            service = this.Connect();

            apps = service.GetApplicationsAsync().Result;
            Assert.True(apps.Any(a => a.Name == name), this.assertRoot + "#2");
        }
        internal Application(ConfigurationElement element, ApplicationCollection parent)
            : base(element, "application", null, parent, null, null)
        {
            Parent = parent;

            // IMPORTANT: avoid duplicate application tag.
            ForceCreateEntity();
            if (string.IsNullOrWhiteSpace(Path))
            {
                // IMPORTANT: fix path attribute after initialization.
                Path = "/";
            }

            _collection = new VirtualDirectoryCollection(this);
            if (element == null)
            {
                return;
            }

            foreach (ConfigurationElement node in (ConfigurationElementCollection)element)
            {
                _collection.InternalAdd(new VirtualDirectory(node, _collection));
            }

            Location = this.Site.Name + this.Path;
            foreach (ApplicationPool pool in Server.ApplicationPools)
            {
                if (pool.Name == ApplicationPoolName)
                {
                    pool.ApplicationCount++;
                }
            }
        }
        private void LoadApplications()
        {
            appCollection = explorerHelper.GetApplicationCollection();
            List <string> appList = explorerHelper.GetApplicationList(appCollection);

            comboBoxAppList.Items.AddRange(RemoveSystemApplication(appList).ToArray());
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="strUserName"></param>
        /// <returns></returns>
        public ApplicationCollection GetApplicationByUser(string strUserName)
        {
            try
            {
                ApplicationCollection appCollection = new ApplicationCollection();
                appCollection.Clear();

                // create sql parameters
                SqlParameter prmUsername = new SqlParameter("@Username", SqlDbType.VarChar, 128);
                prmUsername.Direction = ParameterDirection.Input;
                prmUsername.Value     = strUserName;

                using (IDataReader dr = Database.ExecuteReader("UspGetApplicationByUser", CommandType.StoredProcedure, prmUsername))
                {
                    while (dr.Read())
                    {
                        Application app = Populate(dr);

                        appCollection.Add(app);
                    }
                }

                return(appCollection);
            }
            catch (Exception ex)
            { throw ex; }
        }
        /// <summary>
        /// Lay danh sach ung dung
        /// </summary>
        /// <returns></returns>
        public ApplicationCollection GetAllApplications()
        {
            try
            {
                ApplicationCollection appCollection = new ApplicationCollection();

                appCollection.Clear();

                using (IDataReader dr = Database.ExecuteReader("UspGetAllApplications", CommandType.StoredProcedure))
                {
                    while (dr.Read())
                    {
                        Application app = Populate(dr);

                        appCollection.Add(app);
                    }
                }

                return(appCollection);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        int GetAppIndex(int[] selectedRoleID)
        {
            ApplicationManager    appManager = new ApplicationManager();
            ApplicationCollection apps       = new ApplicationCollection();

            apps = appManager.GetAllApplications();
            RoleManager    roleManager = new RoleManager();
            RoleCollection roles       = new RoleCollection();

            List <int> selectedRoleIDList = selectedRoleID.ToList();
            int        index = 0;

            foreach (Inside.SecurityProviders.Application appItem in apps)
            {
                roles = roleManager.GetRoleInApplication(appItem.ApplicationID);
                foreach (Role roleItem in roles)
                {
                    if (selectedRoleIDList.IndexOf(roleItem.RoleID) >= 0)
                    {
                        return(index);
                    }
                }
                index++;
            }

            return(index);
        }
Example #10
0
        private void LoadApplications()
        {
            try
            {
                ApplicationManager    appMan = new ApplicationManager();
                ApplicationCollection apps   = appMan.GetAllApplications();

                if (apps.Count > 0)
                {
                    ddlApplications.DataSource     = apps;
                    ddlApplications.DataValueField = "ApplicationID";
                    ddlApplications.DataTextField  = "Name";
                    ddlApplications.DataBind();

                    if (Request["id"] != null)
                    {
                        ddlApplications.SelectedValue = Request["id"].ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                ucErrorBox.Message = "Lỗi đọc danh sách ứng dụng.";
                this.SaveErrorLog(ex);
            }
        }
Example #11
0
        public void TestCreateAndRemoveAppsInNamespace()
        {
            string appname1 = "sdk-app1";
            string appname2 = "sdk-app2";

            CleanupApps(appname1, appname2);
            Service service            = Connect();
            ApplicationCollection apps = service.GetApplicationsAsync().Result;

            Assert.False(apps.Any(a => a.Name == appname1), "Expected app " + appname1 + " to not be in the collection");
            Assert.False(apps.Any(a => a.Name == appname2), "Expected app " + appname2 + " to not be in the collection");

            // Create apps
            SetupApps(appname1, appname2);

            service = Connect();
            apps    = service.GetApplicationsAsync().Result;
            Assert.True(apps.Any(a => a.Name == appname1), "Expected app to contain " + appname1);
            Assert.True(apps.Any(a => a.Name == appname2), "Expected app to contain " + appname2);

            // Remove apps
            CleanupApps(appname1, appname2);

            service = Connect();
            apps    = service.GetApplicationsAsync().Result;
            Assert.False(apps.Any(a => a.Name == appname1), "Expected app " + appname1 + " to be removed");
            Assert.False(apps.Any(a => a.Name == appname1), "Expected app " + appname2 + " to be removed");
        }
Example #12
0
        List <ApplicationPoolCustom> ListApplicationPools(ApplicationCollection applications)
        {
            List <ApplicationPoolCustom> pools = new List <ApplicationPoolCustom>();

            // Go through each Application.
            foreach (Microsoft.Web.Administration.Application application in applications)
            {
                ApplicationPoolCustom pool = new ApplicationPoolCustom();

                // Store Pool Name.
                pool.poolName = application.ApplicationPoolName;

                // Get all Directories associated.
                VirtualDirectoryCollection directories = application.VirtualDirectories;
                List <string> dirs = ListDirectivesNames(directories);

                // Store list of Directories.
                pool.directories = dirs;

                // Add Pool to list of Pools.
                pools.Add(pool);
            }

            return(pools);
        }
Example #13
0
        /// <summary>
        /// 根据描述得到一组角色集合
        /// </summary>
        /// <param name="rolesDesp"></param>
        /// <returns></returns>
        public static IRole[] GetRoles(string rolesDesp)
        {
            List <IRole> result = new List <IRole>();

            if (string.IsNullOrEmpty(rolesDesp) == false)
            {
                AppRolesDespsCollection allAppRolesDesps = GetAppRolesDesps(rolesDesp);

                ApplicationCollection apps = PermissionMechanismFactory.GetMechanism().GetApplications(allAppRolesDesps.GetAppNames());

                foreach (AppRolesDesps appRolesDesps in allAppRolesDesps)
                {
                    if (apps.ContainsKey(appRolesDesps.AppName))
                    {
                        IApplication app = apps[appRolesDesps.AppName];

                        foreach (string roleName in appRolesDesps.RolesDesp)
                        {
                            if (app.Roles.ContainsKey(roleName))
                            {
                                result.Add(app.Roles[roleName]);
                            }
                        }
                    }
                }
            }

            return(result.ToArray());
        }
        private void LoadApplicationList(int curPage)
        {
            ApplicationManager    app  = new ApplicationManager();
            ApplicationCollection apps = new ApplicationCollection();

            apps = app.GetAllApplications();
            if (apps.Count == 0)
            {
                uctErrorBox.Visible = true;
                uctErrorBox.Message = "Không có dữ liệu";
                return;
            }

            PagedDataSource page = new PagedDataSource();

            page.AllowPaging      = true;
            page.PageSize         = pagesize;
            page.CurrentPageIndex = curPage;
            page.DataSource       = apps;

            //if (!IsPostBack)
            //{
            Pager1.SetPageNumber(page.PageCount, curPage);
            //}

            dgridApplicationList.DataSource = page;
            dgridApplicationList.DataBind();
        }
        async Task CanConstructApplicationCollection()
        {
            var feed = await TestAtomFeed.ReadFeed(Path.Combine(TestAtomFeed.Directory, "ApplicationCollection.GetAsync.xml"));

            using (var context = new Context(Scheme.Https, "localhost", 8089))
            {
                var expectedApplicationNames = new string[] 
                { 
                    "delete-me-cc314e4eda254dec885f9465e55729e5",
                    "delete-me-db1bc2678174495a9f91d0c2360f53bc",
                    "delete-me-decd5a97569440768914cd0629c5501d",
                    "delete-me-e341f711346a4898b15accd7f77c5c92",
                    "framework",
                    "gettingstarted",
                    "introspection_generator_addon",
                    "launcher",
                    "learned",
                    "legacy",
                    "sample_app",
                    "search",
                    "splunk_datapreview",
                    "SplunkForwarder",
                    "SplunkLightForwarder"
                };

                var applications = new ApplicationCollection(context, feed);

                Assert.Equal(expectedApplicationNames, from application in applications select application.Title);
                Assert.Equal(expectedApplicationNames.Length, applications.Count);

                for (int i = 0; i < applications.Count; i++)
                {
                    Assert.Equal(expectedApplicationNames[i], applications[i].Title);

                    Assert.DoesNotThrow(() => { 
                        Version value = applications[i].GeneratorVersion;
                        Assert.NotNull(value);
                    });

                    Assert.DoesNotThrow(() => 
                    { 
                        Uri value = applications[i].Id;
                        Assert.NotNull(value);
                    });

                    Assert.DoesNotThrow(() => 
                    { 
                        string value = applications[i].Title;
                        Assert.NotNull(value);
                    });

                    Assert.DoesNotThrow(() => 
                    { 
                        DateTime value = applications[i].Updated;
                        Assert.NotEqual(DateTime.MinValue, value);
                    });
                }
            }
        }
        async Task CanConstructApplicationCollection()
        {
            var feed = await TestAtomFeed.ReadFeed(Path.Combine(TestAtomFeed.Directory, "ApplicationCollection.GetAsync.xml"));

            using (var context = new Context(Scheme.Https, "localhost", 8089))
            {
                var expectedApplicationNames = new string[]
                {
                    "delete-me-cc314e4eda254dec885f9465e55729e5",
                    "delete-me-db1bc2678174495a9f91d0c2360f53bc",
                    "delete-me-decd5a97569440768914cd0629c5501d",
                    "delete-me-e341f711346a4898b15accd7f77c5c92",
                    "framework",
                    "gettingstarted",
                    "introspection_generator_addon",
                    "launcher",
                    "learned",
                    "legacy",
                    "sample_app",
                    "search",
                    "splunk_datapreview",
                    "SplunkForwarder",
                    "SplunkLightForwarder"
                };

                var applications = new ApplicationCollection(context, feed);

                Assert.Equal(expectedApplicationNames, from application in applications select application.Title);
                Assert.Equal(expectedApplicationNames.Length, applications.Count);

                for (int i = 0; i < applications.Count; i++)
                {
                    Assert.Equal(expectedApplicationNames[i], applications[i].Title);

                    Assert.DoesNotThrow(() => {
                        Version value = applications[i].GeneratorVersion;
                        Assert.NotNull(value);
                    });

                    Assert.DoesNotThrow(() =>
                    {
                        Uri value = applications[i].Id;
                        Assert.NotNull(value);
                    });

                    Assert.DoesNotThrow(() =>
                    {
                        string value = applications[i].Title;
                        Assert.NotNull(value);
                    });

                    Assert.DoesNotThrow(() =>
                    {
                        DateTime value = applications[i].Updated;
                        Assert.NotEqual(DateTime.MinValue, value);
                    });
                }
            }
        }
Example #17
0
        public static Application AddNewWithDefaults(this ApplicationCollection applications)
        {
            Application defaultApplication = applications.DefaultApplication();

            string path = "/application" + applications.Count;

            return(applications.Add(path, defaultApplication.VirtualDirectory().PhysicalPath));
        }
Example #18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="argument"></param>
        public override void Execute(string argument)
        {
            ApplicationCollection applications = PermissionMechanismFactory.GetMechanism().GetApplications(argument);

            ExceptionHelper.FalseThrow(applications.Count > 0, "不能查询到CodeName为\"{0}\"应用", argument);

            applications[0].Permissions.ForEach(p => OutputHelper.OutputPermissionInfo(p));
        }
Example #19
0
        private static IApplication GetApplicationByCodeName(string codeName)
        {
            ApplicationCollection apps = PermissionMechanismFactory.GetMechanism().GetApplications(codeName);

            ExceptionHelper.FalseThrow(apps.Count > 0,
                                       Translator.Translate(Define.DefaultCulture, "不能在授权系统中找到CodeName为'{0}'的应用", codeName));

            return(apps[0]);
        }
Example #20
0
        /*
         *
         * Collection fill callbacks and event handlers.
         *
         */
        public void FillApplicationCollection(ApplicationOrganizationItem[] applicationArray)
        {
            ApplicationCollection.Clear();
            foreach (ApplicationOrganizationItem item in applicationArray)
            {
                ApplicationCollection.Add(new ApplicationOrganizationVMItem(item));
            }

            SelectedApplication = ApplicationCollection.Count() > 0 ? ApplicationCollection[0] : null;
        }
Example #21
0
        public List <string> GetApplicationList(ApplicationCollection appCollection)
        {
            List <string> applicationNameList = new List <string>();

            for (int i = 0; i < appCollection.Count; i++)
            {
                applicationNameList.Add(appCollection[i].Name);
            }
            return(applicationNameList);
        }
        public void ApplicationSiteList()
        {
            ServerManager  serverManager  = new ServerManager();
            SiteCollection siteCollection = serverManager.Sites;

            BindingCollection     bindings     = null;
            ApplicationCollection applications = null;

            _logger.InfoFormat("[{0}] - =======================================================================================", MethodInfo.GetCurrentMethod().Name);
            _logger.InfoFormat("[{0}] - Begin SiteCollection", MethodInfo.GetCurrentMethod().Name);
            _logger.InfoFormat("[{0}] - =============================================", MethodInfo.GetCurrentMethod().Name);
            foreach (Site itemSite in siteCollection)
            {
                _logger.InfoFormat("[{0}] - itemSite.Id: {1}", MethodInfo.GetCurrentMethod().Name, itemSite.Id);
                _logger.InfoFormat("[{0}] - itemSite.Name: {1}", MethodInfo.GetCurrentMethod().Name, itemSite.Name);
                _logger.InfoFormat("[{0}] - itemSite.ServerAutoStart: {1}", MethodInfo.GetCurrentMethod().Name, itemSite.ServerAutoStart);
                _logger.InfoFormat("[{0}] - itemSite.State: {1}", MethodInfo.GetCurrentMethod().Name, (int)itemSite.State);
                _logger.InfoFormat("[{0}] - itemSite.State[string]: {1}", MethodInfo.GetCurrentMethod().Name, itemSite.State);

                bindings = itemSite.Bindings;
                _logger.InfoFormat("[{0}] - ======================", MethodInfo.GetCurrentMethod().Name);
                foreach (Binding binding in bindings)
                {
                    _logger.InfoFormat("[{0}] - binding.Protocol: {1}", MethodInfo.GetCurrentMethod().Name, binding.Protocol);
                    _logger.InfoFormat("[{0}] - binding.BindingInformation: {1}", MethodInfo.GetCurrentMethod().Name, binding.BindingInformation);
                    _logger.InfoFormat("[{0}] - ===========", MethodInfo.GetCurrentMethod().Name);
                }
                _logger.InfoFormat("[{0}] - ======================", MethodInfo.GetCurrentMethod().Name);

                applications = itemSite.Applications;
                foreach (Application itemApplication in itemSite.Applications)
                {
                    _logger.InfoFormat("[{0}] - itemApplication.ApplicationPoolName: {1}", MethodInfo.GetCurrentMethod().Name, itemApplication.ApplicationPoolName);
                    _logger.InfoFormat("[{0}] - itemApplication.EnabledProtocols: {1}", MethodInfo.GetCurrentMethod().Name, itemApplication.EnabledProtocols);
                    _logger.InfoFormat("[{0}] - itemApplication.Path: {1}", MethodInfo.GetCurrentMethod().Name, itemApplication.Path);

                    _logger.InfoFormat("[{0}] - ===========", MethodInfo.GetCurrentMethod().Name);
                    foreach (VirtualDirectory itemVirtualDirectory in itemApplication.VirtualDirectories)
                    {
                        _logger.InfoFormat("[{0}] - itemVirtualDirectory.LogonMethod: {1}", MethodInfo.GetCurrentMethod().Name, (int)itemVirtualDirectory.LogonMethod);
                        _logger.InfoFormat("[{0}] - itemVirtualDirectory.LogonMethod[string]: {1}", MethodInfo.GetCurrentMethod().Name, itemVirtualDirectory.LogonMethod);
                        _logger.InfoFormat("[{0}] - itemVirtualDirectory.UserName: {1}", MethodInfo.GetCurrentMethod().Name, itemVirtualDirectory.UserName);
                        _logger.InfoFormat("[{0}] - itemVirtualDirectory.Password: {1}", MethodInfo.GetCurrentMethod().Name, itemVirtualDirectory.Password);
                        _logger.InfoFormat("[{0}] - itemVirtualDirectory.Path: {1}", MethodInfo.GetCurrentMethod().Name, itemVirtualDirectory.Path);
                        _logger.InfoFormat("[{0}] - itemVirtualDirectory.PhysicalPath: {1}", MethodInfo.GetCurrentMethod().Name, itemVirtualDirectory.PhysicalPath);
                        _logger.InfoFormat("[{0}] - ===========", MethodInfo.GetCurrentMethod().Name);
                    }
                    _logger.InfoFormat("[{0}] - ======================", MethodInfo.GetCurrentMethod().Name);
                }
                _logger.InfoFormat("[{0}] - =============================================", MethodInfo.GetCurrentMethod().Name);
            }
            _logger.InfoFormat("[{0}] - End SiteCollection", MethodInfo.GetCurrentMethod().Name);
            _logger.InfoFormat("[{0}] - =======================================================================================", MethodInfo.GetCurrentMethod().Name);
        }
Example #23
0
        private static IApplication GetApplicationByID(string id)
        {
            ApplicationCollection apps = PermissionMechanismFactory.GetMechanism().GetAllApplications();

            IApplication app = apps.Find(a => string.Compare(a.ID, id, true) == 0);

            ExceptionHelper.FalseThrow(app != null,
                                       Translator.Translate(Define.DefaultCulture, "不能在授权系统中找到ID为'{0}'的应用", id));

            return(app);
        }
Example #24
0
        static void Main(string[] args)
        {
            ServerManager server = new ServerManager();

            SiteCollection sites = server.Sites;

            foreach (Site site in sites)
            {
                //Console.Out.WriteLine(site);
                //ApplicationDefaults defaults = site.ApplicationDefaults;

                ////get the name of the ApplicationPool under which the Site runs
                //string appPoolName = defaults.ApplicationPoolName;

                //ConfigurationAttributeCollection attributes = defaults.Attributes;
                //foreach (ConfigurationAttribute configAttribute in attributes)
                //{
                //    Console.Out.WriteLine(configAttribute);
                //    //put code here to work with each ConfigurationAttribute
                //}

                //ConfigurationAttributeCollection attributesCollection = site.Attributes;
                //foreach (ConfigurationAttribute attribute in attributesCollection)
                //{
                //    Console.Out.WriteLine(attribute);
                //    //put code here to work with each ConfigurationAttribute
                //}

                ////Get the Binding objects for this Site
                //BindingCollection bindings = site.Bindings;
                //foreach (Microsoft.Web.Administration.Binding binding in bindings)
                //{
                //    Console.Out.WriteLine(binding);
                //    //put code here to work with each Binding
                //}

                ////retrieve the State of the Site
                //ObjectState siteState = site.State;
                //Console.Out.WriteLine(siteState);

                //Get the list of all Applications for this Site
                ApplicationCollection applications = site.Applications;
                foreach (Application application in applications)
                {
                    VirtualDirectoryCollection vDirectories = application.VirtualDirectories;
                    foreach (VirtualDirectory vDirectory in vDirectories)
                    {
                        Console.Out.WriteLine("{0}\t{1}", vDirectory.Path, vDirectory.PhysicalPath);
                    }
                }
            }
            Console.ReadLine();
        }
        private static Application FindApplication(ApplicationCollection applications, string path)
        {
            foreach (Application application in applications)
            {
                if (application.Path.Equals(path))
                {
                    return(application);
                }
            }

            return(null);
        }
Example #26
0
        /// <summary>
        /// Cleans an application from Splunk -- requires a restart
        /// </summary>
        /// <param name="appName">The app name</param>
        /// <param name="service">The connected service</param>
        /// <returns>The new connection</returns>
        private Service CleanApp(string appName, Service service)
        {
            ApplicationCollection apps = service.GetApplicationsAsync().Result;

            if (apps.Any(a => a.Name == appName))
            {
                service.RemoveApplicationAsync(appName).Wait();
                this.SplunkRestart();
                service = this.Connect();
            }

            return(service);
        }
Example #27
0
        public OguRoleCollection GetAppRoles(string codeName)
        {
            ApplicationCollection apps = PermissionMechanismFactory.GetMechanism().GetApplications(codeName);

            OguRoleCollection roles = new OguRoleCollection();

            if (apps.Count > 0)
            {
                roles.CopyFrom(apps[0].Roles);
            }

            return(roles);
        }
Example #28
0
        /// <summary>
        /// Asynchronously removes an application by name, if it exists.
        /// </summary>
        /// <returns>
        /// <c>true</c> if the application existed and was removed; otherwise, if
        /// the application did not exist, <c>false</c>.
        /// </returns>
        /// <param name="applications">Applications.</param>
        /// <param name="name">Name.</param>
        public static async Task <bool> RemoveAsync(this ApplicationCollection applications, string name)
        {
            Application app = await applications.GetOrNullAsync(name);

            if (app == null)
            {
                return(false);
            }

            await app.RemoveAsync();

            return(true);
        }
Example #29
0
        private List <ApplicationDesiredState> GetApplications(ApplicationCollection applications, string siteKey, string siteName)
        {
            var webApplicationList = new List <ApplicationDesiredState>();

            foreach (var application in applications)
            {
                var b = new ApplicationDesiredState(application, siteKey, siteName);

                webApplicationList.Add(b);
            }

            return(webApplicationList);
        }
        private static IApplication GetSelectedApplication(string appCodeName)
        {
            IApplication app = null;

            if (appCodeName.IsNotEmpty())
            {
                ApplicationCollection apps = GetAppCollection();

                app = apps[appCodeName];
            }

            return(app);
        }
        private void LoadApplications()
        {
            ApplicationManager    appMan = new ApplicationManager();
            ApplicationCollection apps   = appMan.GetAllApplications();

            if (apps.Count > 0)
            {
                ddlApplications.DataSource     = apps;
                ddlApplications.DataValueField = "ApplicationID";
                ddlApplications.DataTextField  = "Name";
                ddlApplications.DataBind();
            }
        }
        private async void btnOK_Click(object sender, EventArgs e)
        {
            foreach (var ch in ApplicationCollection.InvalidApplicationPathCharacters())
            {
                if (txtAlias.Text.Contains(ch.ToString(CultureInfo.InvariantCulture)))
                {
                    MessageBox.Show("The application path cannot contain the following characters: \\, ?, ;, :, @, &, =, +, $, ,, |, \", <, >, *.", Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
            }

            foreach (var ch in SiteCollection.InvalidSiteNameCharactersJexus())
            {
                if (txtAlias.Text.Contains(ch.ToString(CultureInfo.InvariantCulture)))
                {
                    MessageBox.Show("The site name cannot contain the following characters: ' '.", Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
            }

            if (!await _site.Server.VerifyAsync(txtPhysicalPath.Text))
            {
                MessageBox.Show("The specified directory does not exist on the server.", Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (Application == null)
            {
                Application = new Application(_site.Applications)
                {
                    Name = txtAlias.Text,
                    ApplicationPoolName = txtPool.Text
                };
                Application.Path = string.Format("{0}/{1}", _parentPath.TrimEnd('/'), Application.Name);
                Application.Load(Application.Path, txtPhysicalPath.Text);
                Application.Parent.Add(Application);
            }
            else
            {
                foreach (VirtualDirectory directory in Application.VirtualDirectories)
                {
                    if (directory.Path == Application.Path)
                    {
                        directory.PhysicalPath = txtPhysicalPath.Text;
                    }
                }
            }

            DialogResult = DialogResult.OK;
        }
        private static ApplicationCollection Convert(IEnumerable<ApplicationEntity> entities)
        {
            var collection = new ApplicationCollection();

            foreach (var entity in entities)
            {
                collection.Add(
                    new Application(entity.Id)
                        {
                            LastName = entity.LastName,
                            FirstName = entity.FirstName,
                            MiddleInitial = entity.MiddleInitial,
                            Suffix = entity.Suffix,
                            DateOfBirth = entity.DateOfBirth,
                            DateOnApplication = entity.DateOnApplication,
                            Principal = entity.Principal,
                            AnnualPercentageRate = entity.AnnualPercentageRate,
                            TotalPayments = entity.TotalPayments,
                        });
            }

            return collection;
        }
 private static Application FindApplication(ApplicationCollection applications, string path)
 {
     foreach (Application application in applications)
         if (application.Path.Equals(path))
             return application;
     
     return null;
 }
Example #35
0
		private List<ApplicationDesiredState> GetApplications(ApplicationCollection applications, string siteKey, string siteName)
		{
			var webApplicationList = new List<ApplicationDesiredState>();

			foreach (var application in applications)
			{

					var b = new ApplicationDesiredState(application,siteKey, siteName);

					webApplicationList.Add(b);

			}

			return webApplicationList;
		}
        internal async Task RemoveApplicationsAsync()
        {
            foreach (Application application in Applications)
            {
                await application.RemoveAsync();
            }

            Applications = new ApplicationCollection(this);
        }
 internal Application(ApplicationCollection parent)
     : this(null, parent)
 {
 }
 /// <summary>
 /// Asynchronously retrieves a collection of installed applications.
 /// </summary>
 /// <param name="args">
 /// Specification of the collection of applications to retrieve.
 /// </param>
 /// <returns>
 /// An object representing the collection of installed applications
 /// specified by <see cref="args"/>.
 /// </returns>
 /// <remarks>
 /// This method uses the <a href="http://goo.gl/iiCmcY">GET apps/local</a> 
 /// endpoint to construct the <see cref="ApplicationCollection"/> object
 /// it returns.
 /// </remarks>
 public async Task<ApplicationCollection> GetApplicationsAsync(ApplicationCollectionArgs args = null)
 {
     var collection = new ApplicationCollection(this.Context, this.Namespace, args);
     await collection.GetAsync();
     return collection;
 }
        internal async Task<ApplicationCollection> RemoveAsync()
        {
            if (Path == RootPath)
            {
                throw new InvalidOperationException("Root application cannot be removed. Please remove the site.");
            }

            var newApps = new ApplicationCollection(Site);
            foreach (Application item in Parent)
            {
                if (item == this)
                {
                    item.Delete();
                    continue;
                }

                item.Parent = newApps;
                newApps.Add(item);
            }

            newApps.Parent.Applications = newApps;
            return newApps;
        }