Пример #1
0
        public SPServiceApplicationProxy CreateProxy(string name, bool checkIfExist, SPServiceApplication serviceApplication, SPServiceProvisioningContext provisioningContext)
        {
            if (serviceApplication == null)
            {
                throw new ArgumentNullException("serviceApplication");
            }

            Type serviceApplicationType = serviceApplication.GetType();

            if (serviceApplicationType == null || serviceApplicationType != typeof(ParagoServiceApplication))
            {
                throw new NotSupportedException();
            }

            ParagoServiceProxy serviceProxy = (ParagoServiceProxy)Farm.GetObject(ParagoServiceProxy.DefaultName, Farm.Id, typeof(ParagoServiceProxy));

            if (serviceProxy == null)
            {
                serviceProxy = new ParagoServiceProxy(Farm);
                serviceProxy.Update(true);
                serviceProxy.Provision();
            }

            if (checkIfExist)
            {
                ParagoServiceApplicationProxy serviceApplicationProxy = serviceProxy.ApplicationProxies.GetValue <ParagoServiceApplicationProxy>(name);

                if (serviceApplicationProxy != null)
                {
                    return(serviceApplicationProxy);
                }
            }

            return(new ParagoServiceApplicationProxy(name, serviceProxy, ((ParagoServiceApplication)serviceApplication).Uri));
        }
Пример #2
0
        public ParagoServiceClient(ParagoServiceApplicationProxy proxy)
        {
            if (proxy == null)
            {
                throw new ArgumentNullException("proxy");
            }

            _proxy = proxy;
        }
Пример #3
0
        public ParagoServiceClient(SPServiceContext serviceContext)
        {
            if (serviceContext == null)
            {
                throw new ArgumentNullException("serviceContext");
            }

            _proxy = serviceContext.GetDefaultProxy(typeof(ParagoServiceApplicationProxy)) as ParagoServiceApplicationProxy;

            if (_proxy == null)
            {
                throw new InvalidOperationException("Parago Service Application Proxy not found");
            }
        }
Пример #4
0
        public static void SetDefaultServiceApplicationProxy(ParagoServiceApplicationProxy serviceApplicationProxy)
        {
            if (serviceApplicationProxy != null)
            {
                SPServiceApplicationProxyGroup proxyGroup = SPServiceApplicationProxyGroup.Default;

                if (proxyGroup != null)
                {
                    // Remove all existing service application proxies available
                    foreach (ParagoServiceApplicationProxy proxy in proxyGroup.DefaultProxies.OfType <ParagoServiceApplicationProxy>().ToList())
                    {
                        proxyGroup.Remove(proxy.Id);
                    }

                    proxyGroup.Add(serviceApplicationProxy);
                    proxyGroup.Update(true);
                }
            }
        }