Beispiel #1
0
        protected static void AddPropertiesForRepositoryLocalObject(RepositoryLocalObjectData rlo, PeekResult result, string currentUserId)
        {
            if (rlo == null)
            {
                return;
            }

            result.LockedBy       = LinkEntry.From(rlo.LockInfo.LockUser, Resources.LabelLockedBy, currentUserId);
            result.MetadataSchema = LinkEntry.From(rlo.MetadataSchema, Resources.LabelMetadataSchema, currentUserId);

            if (rlo.LocationInfo != null)
            {
                result.WebDavUrl = TextEntry.From(rlo.LocationInfo.WebDavUrl, Resources.LabelWebDavUrl);
            }

            FullVersionInfo versionInfo = rlo.VersionInfo as FullVersionInfo;

            if (versionInfo != null)
            {
                if (result.CreationDate != null)
                {
                    result.CreationDate.User = GetUserTitle(versionInfo.Creator, currentUserId);
                }

                if (result.RevisionDate != null)
                {
                    result.RevisionDate.User = GetUserTitle(versionInfo.Revisor, currentUserId);
                }

                if (versionInfo.LastVersion != null && versionInfo.LastVersion.Value > 1)
                {
                    result.Versions = NumberEntry.From(versionInfo.LastVersion.Value, Resources.LabelVersions);
                }
            }
        }
Beispiel #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);
            }
        }