コード例 #1
0
        // LIVE or Staging
        public void CreateNewTargetTypes()
        {
            var list = GetTargetTypes();

            // Lookup the unique names for target types in CSV
            foreach (string targetTypeName in _targets.Select(p => p.TargetType).Distinct())
            {
                // Do not add when target type is existing
                if (!list.Exists(t => t.Title == targetTypeName))
                {
                    var tt = _core.GetDefaultData(ItemType.TargetType, null) as TargetTypeData;
                    tt.Title       = targetTypeName;
                    tt.Description = targetTypeName;
                    _core.Create(tt, _readOpts);
                }
            }
        }
コード例 #2
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}'");
            }
        }
コード例 #3
0
 public IdentifiableObjectData GetDefaultData(ItemType itemType, string containerId, ReadOptions readOptions)
 {
     return(_client.GetDefaultData(itemType, containerId, readOptions));
 }