Exemplo n.º 1
0
        public static string[] GetPolicyList(int itemId, SfBPolicyType type, string name)
        {
            string[] ret = null;
            try
            {
                if (itemId == -1)
                {
                    // policy list in all sfb servers
                    List <string>     allpolicylist = new List <string>();
                    List <ServerInfo> servers       = ServerController.GetAllServers();
                    foreach (ServerInfo server in servers)
                    {
                        List <ServiceInfo> services = ServerController.GetServicesByServerIdGroupName(server.ServerId, ResourceGroups.SfB);
                        foreach (ServiceInfo service in services)
                        {
                            SfBServer sfb    = GetSfBServer(service.ServiceId, -1);
                            string[]  values = sfb.GetPolicyList(type, name);
                            foreach (string val in values)
                            {
                                if (allpolicylist.IndexOf(val) == -1)
                                {
                                    allpolicylist.Add(val);
                                }
                            }
                        }
                    }
                    ret = allpolicylist.ToArray();
                }
                else
                {
                    Organization org = (Organization)PackageController.GetPackageItem(itemId);

                    int       sfbServiceId = GetSfBServiceID(org.PackageId);
                    SfBServer sfb          = GetSfBServer(sfbServiceId, org.ServiceId);

                    ret = sfb.GetPolicyList(type, name);
                }
            }
            catch (Exception)
            {
            }
            finally
            {
            }

            return(ret);
        }
Exemplo n.º 2
0
        public string[] GetPolicyList(SfBPolicyType type, string name)
        {
            string[] ret = null;

            try
            {
                Log.WriteStart("{0}.GetPolicyList", ProviderSettings.ProviderName);
                ret = SfB.GetPolicyList(type, name);
                Log.WriteEnd("{0}.GetPolicyList", ProviderSettings.ProviderName);
            }
            catch (Exception ex)
            {
                Log.WriteError(String.Format("Error: {0}.GetPolicyList", ProviderSettings.ProviderName), ex);
                throw;
            }

            return(ret);
        }
Exemplo n.º 3
0
        internal override string[] GetPolicyListInternal(SfBPolicyType type, string name)
        {
            List <string> ret = new List <string>();

            switch (type)
            {
            case SfBPolicyType.Archiving:
            {
                Runspace runSpace            = OpenRunspace();
                Command  cmd                 = new Command("Get-CsArchivingPolicy");
                Collection <PSObject> result = ExecuteShellCommand(runSpace, cmd, false);
                if ((result != null) && (result.Count > 0))
                {
                    foreach (PSObject res in result)
                    {
                        string Identity = GetPSObjectProperty(res, "Identity").ToString();
                        ret.Add(Identity);
                    }
                }
            }
            break;

            case SfBPolicyType.DialPlan:
            {
                Runspace runSpace            = OpenRunspace();
                Command  cmd                 = new Command("Get-CsDialPlan");
                Collection <PSObject> result = ExecuteShellCommand(runSpace, cmd, false);
                if ((result != null) && (result.Count > 0))
                {
                    foreach (PSObject res in result)
                    {
                        string Identity    = GetPSObjectProperty(res, "Identity").ToString();
                        string Description = "" + (string)GetPSObjectProperty(res, "Description");
                        if (Description.ToLower().IndexOf(name.ToLower()) == -1)
                        {
                            continue;
                        }
                        ret.Add(Identity);
                    }
                }
            }
            break;

            case SfBPolicyType.Voice:
            {
                Runspace runSpace            = OpenRunspace();
                Command  cmd                 = new Command("Get-CsVoicePolicy");
                Collection <PSObject> result = ExecuteShellCommand(runSpace, cmd, false);
                if ((result != null) && (result.Count > 0))
                {
                    foreach (PSObject res in result)
                    {
                        string Identity    = GetPSObjectProperty(res, "Identity").ToString();
                        string Description = "" + (string)GetPSObjectProperty(res, "Description");
                        if (Description.ToLower().IndexOf(name.ToLower()) == -1)
                        {
                            continue;
                        }

                        ret.Add(Identity);
                    }
                }
            }
            break;

            case SfBPolicyType.Pin:
            {
                Runspace runSpace            = OpenRunspace();
                Command  cmd                 = new Command("Get-CsPinPolicy");
                Collection <PSObject> result = ExecuteShellCommand(runSpace, cmd, false);
                if ((result != null) && (result.Count > 0))
                {
                    foreach (PSObject res in result)
                    {
                        string Identity = GetPSObjectProperty(res, "Identity").ToString();
                        string str      = "" + GetPSObjectProperty(res, name);
                        ret.Add(str);
                    }
                }
            }
            break;
            }

            return(ret.ToArray());
        }
Exemplo n.º 4
0
 internal virtual string[] GetPolicyListInternal(SfBPolicyType type, string name)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 public virtual string[] GetPolicyList(SfBPolicyType type, string name)
 {
     return(GetPolicyListInternal(type, name));
 }
Exemplo n.º 6
0
 public string[] GetPolicyList(int itemId, SfBPolicyType type, string name)
 {
     return(SfBController.GetPolicyList(itemId, type, name));
 }