/// <summary>
 /// Initializes a new instance of the <see cref="BluePrint"/> class.
 /// </summary>
 /// <param name="client"><see cref="T:TcmCoreService.Client" /></param>
 /// <param name="bluePrintInfo"><see cref="T:Tridion.ContentManager.CoreService.Client.BluePrintInfo" /></param>
 public BluePrint(Client client, BluePrintInfo bluePrintInfo) : base(client)
 {
     mBluePrintInfo = bluePrintInfo;
 }
예제 #2
0
        public void CheckInItem(string id, Label label)
        {
            if (label != null)
            {
                _label = label;
            }

            string tridionInstallPath = Environment.GetEnvironmentVariable("TRIDION_CM_HOME") + @"web\WebUI\Editors\AdminCheckIn\Config\";
            string filename           = "admincheckincm.config";

            string scheduleFile = System.IO.Path.Combine(tridionInstallPath, filename);

            _eventLog.WriteEntry("PATH : " + scheduleFile, EventLogEntryType.Information);
            XmlDocument doc = new XmlDocument();

            _eventLog.WriteEntry("Test");
            doc.Load(scheduleFile);
            //CultureInfo provider = CultureInfo.InvariantCulture;
            if (doc == null)
            {
                _eventLog.WriteEntry("doc is null");
            }
            _eventLog.WriteEntry("After Test");
            // has trouble accessing by selectSingleNode.
            XmlNodeList adminList         = doc.GetElementsByTagName("checkInAdminUsername");
            XmlNodeList adminPasswordList = doc.GetElementsByTagName("checkInAdminPassword");
            XmlNode     adminusername     = null;
            XmlNode     adminpassword     = null;

            if (adminList != null && adminList.Count > 0 && adminPasswordList != null && adminPasswordList.Count > 0)
            {
                adminusername = adminList[0];
                adminpassword = adminPasswordList[0];
            }
            if (adminusername == null || adminpassword == null)
            {
                label.Text = "The admin username or password is empty.  Please ensure you specified the username and password in the admincheckincm.config";
            }
            _eventLog.WriteEntry("Username: "******"PW: " + adminpassword.InnerText, EventLogEntryType.Information);
            String userName = adminusername.InnerText;
            String password = adminpassword.InnerText;

            var credentials = CredentialCache.DefaultNetworkCredentials;

            if (!string.IsNullOrWhiteSpace(userName) && !string.IsNullOrWhiteSpace(password))
            {
                credentials = new NetworkCredential(userName, password);
            }
            _client.ChannelFactory.Credentials.Windows.ClientCredential = credentials;
            try
            {
                VersionedItemData obj = _client.Read(id, new ReadOptions()) as VersionedItemData;

                if (obj is ComponentData || obj is PageData)
                {
                    BluePrintInfo   blueprintInfo = null;
                    FullVersionInfo info          = null;
                    if (obj is ComponentData)
                    {
                        ComponentData comp = obj as ComponentData;
                        info          = comp.VersionInfo as FullVersionInfo;
                        blueprintInfo = comp.BluePrintInfo as BluePrintInfo;
                    }
                    if (obj is PageData)
                    {
                        PageData page = obj as PageData;
                        info          = page.VersionInfo as FullVersionInfo;
                        blueprintInfo = page.BluePrintInfo;
                    }
                    if (info.LockType != LockType.CheckedOut)
                    {
                        _label.Text = "Item is Not Checked Out";
                        return;
                    }
                    if (blueprintInfo.IsLocalized == false && blueprintInfo.IsShared == true)
                    {
                        _label.Text = "Item is Shared Item. Please Checkin from the Owning Publication";
                        return;
                    }
                }
                if (obj is ComponentData || obj is PageData)
                {
                    _label.Text = "Checking in item";
                    this._client.CheckInCompleted += new EventHandler <CheckInCompletedEventArgs>(TridionCheckIn.CheckInCallback);
                    this._client.CheckInAsync(id, new ReadOptions());
                    _eventLog.WriteEntry("Checking in item", EventLogEntryType.Information);
                }
                else
                {
                    _label.Text = "Can not check in. Item is not Component or Page!";
                    return;
                }
            }
            catch (Exception e)
            {
                _label.Text = "Username and Password provided is invalid";
                _eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
            }
        }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BluePrint"/> class.
 /// </summary>
 /// <param name="client"><see cref="T:TcmCoreService.Client" /></param>
 /// <param name="bluePrintInfo"><see cref="T:Tridion.ContentManager.CoreService.Client.BluePrintInfo" /></param>
 public BluePrint(Client client, BluePrintInfo bluePrintInfo)
     : base(client)
 {
     mBluePrintInfo = bluePrintInfo;
 }