Beispiel #1
0
        public string GetSynchronized(SyncParams syncParams)
        {
            string tcmURI = syncParams.Tcm;
            string status = string.Empty;

            try
            {
                if (!string.IsNullOrEmpty(tcmURI) && TcmUri.IsValid(tcmURI))
                {
                    SynchronizeOptions syncOptions = GetSyncOptions(syncParams.Flag);
                    TcmUri             uri         = new TcmUri(tcmURI);
                    switch (uri.ItemType)
                    {
                    case ItemType.Schema:
                        status = SyncAllComponentsBasedOnSchema(tcmURI, uri.GetContextRepositoryUri(), syncOptions);
                        break;

                    case ItemType.Component:
                        SynchronizationResult result = Client.SynchronizeWithSchemaAndUpdate(tcmURI, syncOptions);
                        status = string.Format("Component Synchronization is successfull for Component: {0} ({1})", result.SynchronizedItem.Title, result.SynchronizedItem.Id);
                        break;
                    }
                    return(status);
                }
                else
                {
                    return("Component Synchronization Failed - Invalid TCM URI");
                }
            }
            catch (Exception ex)
            {
                string errorMessage = "An error occured while synchronizing components. Error Message: " + ex.Message + ex.StackTrace;
                return(errorMessage);
            }
        }