Example #1
0
        public CoreServiceClient GetNewNetTcpClient()
        {
            string username = _Config.AppSettings.Settings["impersonation_user"].Value;
            string password = _Config.AppSettings.Settings["impersonation_password"].Value;
            string address  = _Config.AppSettings.Settings["nettcpaddress"].Value;

            var binding = new NetTcpBinding
            {
                MaxReceivedMessageSize = 2147483647,
                ReaderQuotas           = new XmlDictionaryReaderQuotas
                {
                    MaxStringContentLength = 2147483647,
                    MaxArrayLength         = 2147483647
                }
            };
            var endpoint = new EndpointAddress(address);

            var client = new CoreServiceClient(binding, endpoint);

            client.ChannelFactory.Credentials.Windows.ClientCredential = new System.Net.NetworkCredential(username, password);
            try
            {
                client.GetApiVersion();
            }
            catch {
                return(null);
            }

            return(client);
        }
        private void InitializeClient(string endPoint, NetworkCredential credentials)
        {
            try
            {
                _client = new CoreServiceClient(endPoint);
                _client.ChannelFactory.Credentials.Windows.ClientCredential = credentials;

                if (_client != null) _coreServiceVersion = _client.GetApiVersion();
            }

            catch (EndpointNotFoundException e) { }
            catch (Exception e) { }
        }
Example #3
0
        public void CreateFolder(string threadId)
        {
            try
            {
                Console.WriteLine($"{threadId} - Start thread to create folder '{_folderPath}'");

                CoreServiceClient client = new CoreServiceClient(ConfigurationManager.AppSettings["endpointName"], ConfigurationManager.AppSettings["endpointURI"]);
                client.ClientCredentials.Windows.ClientCredential = new NetworkCredential(ConfigurationManager.AppSettings["username"], ConfigurationManager.AppSettings["password"]);

                Console.WriteLine($"{threadId} - trying to connect to core service at {ConfigurationManager.AppSettings["endpointURI"]}");
                string apiVersion = client.GetApiVersion();
                Console.WriteLine($"{threadId} - API version: {apiVersion}");

                int    lastSlashIdx  = _folderPath.LastIndexOf("/");
                string newFolderPath = _folderPath.Substring(lastSlashIdx + 1);
                string parentFolder  = _folderPath.Substring(0, lastSlashIdx);

                if (!client.IsExistingObject(parentFolder))
                {
                    Console.WriteLine($"{threadId} - ERROR base path does not exist '{parentFolder}'");
                    return;
                }

                FolderData parentFolderData = (FolderData)client.Read(parentFolder, new ReadOptions());

                if (client.IsExistingObject(_folderPath))
                {
                    FolderData folderData = (FolderData)client.Read(_folderPath, new ReadOptions());
                    Console.WriteLine($"{threadId} - OK folder already exists {folderData.Id} '{_folderPath}'");
                }
                else
                {
                    FolderData newFolderData = (FolderData)client.GetDefaultData(ItemType.Folder, parentFolderData.Id, new ReadOptions());
                    newFolderData.Title = newFolderPath;
                    FolderData folderData = (FolderData)client.Save(newFolderData, new ReadOptions());
                    _folders.Add(folderData.Id);
                    Console.WriteLine($"{threadId} - Created new content folder {folderData.Id} '{newFolderPath}' under folder '{parentFolderData.Title}'");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{threadId} - ERROR exception: '{ex.Message}'");
            }
        }
Example #4
0
        private void InitializeClient(string endPoint, NetworkCredential credentials)
        {
            try
            {
                var binding = new BasicHttpBinding()
                {
                    MaxReceivedMessageSize = 2147483647,
                    ReaderQuotas           = new XmlDictionaryReaderQuotas
                    {
                        MaxStringContentLength = 2147483647,
                        MaxArrayLength         = 2147483647
                    },
                    Security =
                    {
                        Mode      = BasicHttpSecurityMode.TransportCredentialOnly,
                        Transport = new HttpTransportSecurity
                        {
                            ClientCredentialType = HttpClientCredentialType.Windows
                        }
                    }
                };

                _client = new CoreServiceClient(binding, new EndpointAddress(endPoint + "/basicHttp"));

                if (_client.ClientCredentials != null)
                {
                    _client.ClientCredentials.Windows.ClientCredential = credentials;
                }

                if (_client != null)
                {
                    _coreServiceVersion = _client.GetApiVersion();
                }
            }

            catch (EndpointNotFoundException e) { }
            catch (Exception e) { }
        }
        public CoreServiceClient GetNewNetTcpClient()
        {
            string username = _Config.AppSettings.Settings["impersonation_user"].Value;
            string password = _Config.AppSettings.Settings["impersonation_password"].Value;
            string address = _Config.AppSettings.Settings["nettcpaddress"].Value;

            var binding = new NetTcpBinding
            {
                MaxReceivedMessageSize = 2147483647,
                ReaderQuotas = new XmlDictionaryReaderQuotas
                {
                    MaxStringContentLength = 2147483647,
                    MaxArrayLength = 2147483647
                }
            };
            var endpoint = new EndpointAddress(address);

            var client = new CoreServiceClient(binding, endpoint);
            client.ChannelFactory.Credentials.Windows.ClientCredential = new System.Net.NetworkCredential(username, password);
            try
            {
                client.GetApiVersion();
            }
            catch {
                return null;
            }

            return client;
        }
Example #6
0
 /// <summary>
 /// Provides a one-time, preprocessing functionality for the cmdlet.
 /// </summary>
 /// <remarks>
 /// We open the Core Service proxy here.
 /// </remarks>
 protected override void BeginProcessing()
 {
     WriteVerbose("TcmCmdlet.BeginProcessing...");
     TcmApiVersion = CoreServiceClient.GetApiVersion();
     WriteVerbose("TCM API version = " + TcmApiVersion);
 }
Example #7
0
        static void Main(string[] args)
        {
            CoreServiceClient client = Utility.CoreServiceSource;

            client.GetApiVersion();
        }