예제 #1
0
        public void AddRecentFile(string filename)
        {
            if (string.IsNullOrEmpty(filename) || filename.ToLower() == "untitled")
            {
                return;
            }

            if (RecentDocuments.Contains(filename))
            {
                RecentDocuments.Remove(filename);
            }

            RecentDocuments.Insert(0, filename);
            OnPropertyChanged(nameof(RecentDocuments));

            if (RecentDocuments.Count > RecentDocumentsLength)
            {
                // the hard way to force collection to properly refresh so bindings work properly
                var recents = RecentDocuments.Take(RecentDocumentsLength);
                RecentDocuments.Clear();
                foreach (var recent in recents)
                {
                    RecentDocuments.Add(recent);
                }
            }
        }
예제 #2
0
 private void RenderRecent()
 {
     SheerResponse.DisableOutput();
     try
     {
         foreach (var uri in RecentDocuments.GetRecentDocuments())
         {
             var item = Database.GetItem(uri);
             if (item != null)
             {
                 var child = new MenuItem();
                 RecentMenu.Controls.Add(child);
                 child.Header = item.DisplayName;
                 child.Icon   = item.Appearance.Icon;
                 child.Click  = "Load(\"" + uri + "\")";
             }
         }
         if (RecentMenu.Controls.Count == 0)
         {
             RecentMenu.Add("(empty)", string.Empty, string.Empty);
         }
     }
     finally
     {
         SheerResponse.EnableOutput();
     }
 }
예제 #3
0
        public void Handle(DocumentDeleted message)
        {
            RecentDocuments
            .Where(x => x.Id == message.DocumentId)
            .ToList()
            .Apply(x => RecentDocuments.Remove(x));

            //TODO: update collections
            //Collections
            //    .Where(x => x.Name == message.Document.CollectionType)
            //    .Apply(x => x.Count--);
        }
예제 #4
0
        public ActionResult List(bool?pinned, int?docType, RecentDocDatePeriod period, string orderBy, string orderDir)
        {
            int curProductId = 1;

            if (Session["SelectedProductId"] != null)
            {
                curProductId = int.Parse(Session["SelectedProductId"].ToString());
            }

            RecentDocuments rd = Doc.GetRecentDocs(this.UserData.UserId, Language.Id, pinned, docType, period, orderBy, orderDir, curProductId);

            return(PartialView(rd));
        }
        /// <summary>
        /// Logs out the current user.
        /// </summary>
        public override void Logout()
        {
            base.Logout();
            RecentDocuments.Remove();
            SessionSecurityToken sessionToken;

            if (!FederatedAuthentication.SessionAuthenticationModule.TryReadSessionTokenFromCookie(out sessionToken))
            {
                FormsAuthentication.SignOut();
                ClearFormCookies();
            }
            FederatedAuthentication.SessionAuthenticationModule.SignOut();
        }
예제 #6
0
        //

        public void ReferenceRecentDocument(string path)
        {
            int i = RecentDocuments.IndexOf(path);

            if (i >= 0)
            {
                RecentDocuments.RemoveAt(i);
            }
            RecentDocuments.Insert(0, path);
            while (RecentDocuments.Count > RecentDocumentsMax) // BindingList doesn't support RemoveRange()
            {
                RecentDocuments.RemoveAt(RecentDocuments.Count - 1);
            }
        }
예제 #7
0
        protected void Logout(object sender, EventArgs e)
        {
            CacheManager.ClearSecurityCache(Sitecore.Context.User.Name);
            RecentDocuments.Remove(Sitecore.Context.User.Name);
            Sitecore.Shell.Framework.Security.Abandon();
            string currentTicketId = TicketManager.GetCurrentTicketId();

            if (string.IsNullOrEmpty(currentTicketId))
            {
                return;
            }
            TicketManager.RemoveTicket(currentTicketId);


            Response.Redirect(WebUtil.GetFullUrl(Factory.GetSiteInfo("shell").LoginPage) + "?redirect=" + Request.RawUrl);
        }
예제 #8
0
        protected void Load(string uri)
        {
            Assert.ArgumentNotNull(uri, "uri");
            var uri2 = ItemUri.Parse(uri);

            if (uri2 != null)
            {
                var item = Database.GetItem(uri2);
                if (item != null)
                {
                    RecentDocuments.AddToRecentDocuments(item.Uri);
                    SheerResponse.Eval(
                        string.Concat("scForm.getParentForm().invoke(\"ise:setcontextitem(id=", item.ID, ",language=",
                                      item.Language, ",version=", item.Version, ",db=", item.Database.Name, ")\")"));
                }
            }
        }
        public void AddRecentFile(string filename)
        {
            if (string.IsNullOrEmpty(filename) || filename.ToLower() == "untitled")
            {
                return;
            }

            if (RecentDocuments.Contains(filename))
            {
                RecentDocuments.Remove(filename);
            }

            RecentDocuments.Insert(0, filename);
            OnPropertyChanged(nameof(RecentDocuments));

            if (RecentDocuments.Count > 12)
            {
                RecentDocuments = RecentDocuments.Take(12).ToList();
            }
        }
예제 #10
0
        // add a document to the MRU list
        public void AddDocument(string fileName)
        {
            // look for the file in the current list
            RecentDocumentItem doc = RecentDocuments.FirstOrDefault(x => x.FileName == fileName);

            if (doc != null)
            {
                // update date
                doc.Date = DateTime.Now;
            }
            else if (!string.IsNullOrEmpty(fileName))
            {
                // not a member, add
                doc = new RecentDocumentItem
                {
                    Text    = Path.GetFileName(fileName),
                    SubText = Path.GetDirectoryName(fileName),
                    Date    = DateTime.Now
                };
                RecentDocuments.Add(doc);
            }

            // trim list
            while (RecentDocuments.Count > MAX_ITEMS)
            {
                // first - check not pinned docs
                var notPinned = RecentDocuments.Where(x => !x.Pinned).OrderBy(x => x.Date);
                if (notPinned.Count() > 0)
                {
                    RecentDocuments.Remove(notPinned.Last());
                }
                else
                {
                    // remove last pinned doc
                    RecentDocuments.Remove(RecentDocuments.OrderBy(x => x.Date).Last());
                }
            }
        }
        public void AddRecentFile(string filename)
        {
            if (string.IsNullOrEmpty(filename) || filename.ToLower() == "untitled")
            {
                return;
            }

            if (RecentDocuments.Contains(filename))
            {
                RecentDocuments.Remove(filename);
            }

            RecentDocuments.Insert(0, filename);
            OnPropertyChanged(nameof(RecentDocuments));

            if (RecentDocuments.Count > RecentDocumentsLength)
            {
                RecentDocuments.Clear();
                foreach (var recent in RecentDocuments.Take(RecentDocumentsLength))
                {
                    RecentDocuments.Add(recent);
                }
            }
        }