Exemplo n.º 1
0
        private void CreateDepartament(string pwaOrigem, string pwaDestino)
        {
            SvcResource.ResourceClient         client     = new SvcResource.ResourceClient(Binding, endPointAdress(pwaOrigem, "/_vti_bin/psi/Resource.asmx"));
            SvcResourcePlan.ResourcePlanClient clientPlan = new SvcResourcePlan.ResourcePlanClient(Binding, endPointAdress(pwaOrigem, "/_vti_bin/psi/Resource.asmx"));

            //adminClient.re
        }
        // Programmatically set the WCF endpoint for the LookupTable client.
        private void SetClientEndpoint(Guid pwaUid)
        {
            const int MAXSIZE = 500000000;
            const string svcRouter = "/_vti_bin/PSI/ProjectServer.svc";

            BasicHttpBinding binding = null;
            //TODO: look for dispose issue
            using (SPSite pwaSite = new SPSite(pwaUid))
            {
                string pwaUrl = pwaSite.Url;

                if (pwaUrl.Contains("https:"))
                {
                    // Create a binding for HTTPS.
                    binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
                }
                else
                {
                    // Create a binding for HTTP.
                    binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
                }

                binding.Name = "basicHttpConf";
                binding.SendTimeout = TimeSpan.MaxValue;
                binding.MaxReceivedMessageSize = MAXSIZE;
                binding.ReaderQuotas.MaxNameTableCharCount = MAXSIZE;
                binding.MessageEncoding = WSMessageEncoding.Text;
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;

                // The endpoint address is the ProjectServer.svc router for all public PSI calls.
                EndpointAddress address = new EndpointAddress(pwaUrl + svcRouter);

                timesheetClient = new SvcTimeSheet.TimeSheetClient(binding, address);
                timesheetClient.ChannelFactory.Credentials.Windows.AllowedImpersonationLevel
                    = TokenImpersonationLevel.Impersonation;
                timesheetClient.ChannelFactory.Credentials.Windows.AllowNtlm = true;

                adminClient = new SvcAdmin.AdminClient(binding, address);
                adminClient.ChannelFactory.Credentials.Windows.AllowedImpersonationLevel
                    = TokenImpersonationLevel.Impersonation;
                adminClient.ChannelFactory.Credentials.Windows.AllowNtlm = true;

                resourceClient = new SvcResource.ResourceClient(binding, address);
                resourceClient.ChannelFactory.Credentials.Windows.AllowedImpersonationLevel
                    = TokenImpersonationLevel.Impersonation;
                resourceClient.ChannelFactory.Credentials.Windows.AllowNtlm = true;

                queueClient = new SvcQueueSystem.QueueSystemClient(binding, address);
                queueClient.ChannelFactory.Credentials.Windows.AllowedImpersonationLevel
                    = TokenImpersonationLevel.Impersonation;
                queueClient.ChannelFactory.Credentials.Windows.AllowNtlm = true;
            }
        }