Example #1
0
        protected string GetXslPath(BaseBookmark xmlBm, string bizName, bool isIf, List <string> selectedTables,
                                    Relations relations, XmlNode startNode = null)
        {
            BookmarkType type = xmlBm == null ? BookmarkType.Select : xmlBm.Type;

            switch (type)
            {
            case BookmarkType.PdeTag:
            case BookmarkType.PdeChart:
                return(GetPdeXslPath(bizName, selectedTables));

            case BookmarkType.StartForeach:
                if (_foreach[_foreach.Count - 1].IsContainPdeTag)
                {
                    return(GetPdeXslPath(bizName, selectedTables));
                }
                else
                {
                    return(GetPdwXslPath(bizName, isIf, selectedTables, relations, startNode));
                }

            default:
                return(GetPdwXslPath(bizName, isIf, selectedTables, relations, startNode));
            }
        }
        /// <summary>
        /// Creates the bookmark.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="node">The node.</param>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public Bookmark CreateBookmark(IDocument document,XmlNode node, BookmarkType type)
        {
            try
            {
                Bookmark bookmark		= null;
                if(type == BookmarkType.Standard)
                    bookmark			= new Bookmark(document, BookmarkType.Standard, "noname");
                else if(type == BookmarkType.Start)
                    bookmark			= new Bookmark(document, BookmarkType.Start, "noname");
                else
                    bookmark			= new Bookmark(document, BookmarkType.End, "noname");

                bookmark.Node			= node.CloneNode(true);

                return bookmark;
            }
            catch(Exception ex)
            {
                AODLException exception		= new AODLException("Exception while trying to create a Bookmark.");
                exception.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                exception.Node				= node;
                exception.OriginalException	= ex;

                throw exception;
            }
        }
Example #3
0
 public MslBookmark(BookmarkType type, string title, int position)
 {
     this.type     = type;
     this.title    = title;
     this.position = position;
     this.endLine  = -1;
 }
Example #4
0
        private void SetBookmarksFromConfig()
        {
            int    i = 0;
            string bookmark;

            do
            {
                bookmark = m_config.GetValue($"bookmark{i}");
                if (bookmark != null)
                {
                    string[] bookmarkData = bookmark.Split('|');

                    if (bookmarkData.Length == 4)
                    {
                        BookmarkContainer container   = (bookmarkData[0] == "Tree") ? BookmarkContainer.TreeView : BookmarkContainer.Toolbar;
                        BookmarkType      type        = (bookmarkData[1] == "File") ? BookmarkType.File : BookmarkType.Directory;
                        string            displayName = bookmarkData[2];
                        string            path        = bookmarkData[3];

                        AddBookmark(path, displayName, type, container);
                    }
                }

                i++;
            } while (bookmark != null);
        }
Example #5
0
        /// <summary>
        /// Creates the bookmark.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="node">The node.</param>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public Bookmark CreateBookmark(IDocument document, XmlNode node, BookmarkType type)
        {
            try
            {
                Bookmark bookmark = null;
                if (type == BookmarkType.Standard)
                {
                    bookmark = new Bookmark(document, BookmarkType.Standard, "noname");
                }
                else if (type == BookmarkType.Start)
                {
                    bookmark = new Bookmark(document, BookmarkType.Start, "noname");
                }
                else
                {
                    bookmark = new Bookmark(document, BookmarkType.End, "noname");
                }

                bookmark.Node = node.CloneNode(true);

                return(bookmark);
            }
            catch (Exception ex)
            {
                AODLException exception = new AODLException("Exception while trying to create a Bookmark.");
                exception.InMethod          = AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                exception.Node              = node;
                exception.OriginalException = ex;

                throw exception;
            }
        }
Example #6
0
        public Bookmark(BookmarkType bookmarkType, int lineNumber)
        {
            BookmarkType = bookmarkType;
            LineNumber = lineNumber;

            _errorList = IoC.Get<IErrorList>();
        }
Example #7
0
        public Bookmark(BookmarkType bookmarkType, int lineNumber)
        {
            BookmarkType = bookmarkType;
            LineNumber   = lineNumber;

            _errorList = IoC.Get <IErrorList>();
        }
Example #8
0
        /// <summary>
        /// Creates the bookmark.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="node">The node.</param>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public Bookmark CreateBookmark(IDocument document, XElement node, BookmarkType type)
        {
            try
            {
                Bookmark bookmark;
                if (type == BookmarkType.Standard)
                {
                    bookmark = new Bookmark(document, BookmarkType.Standard, "noname");
                }
                else if (type == BookmarkType.Start)
                {
                    bookmark = new Bookmark(document, BookmarkType.Start, "noname");
                }
                else
                {
                    bookmark = new Bookmark(document, BookmarkType.End, "noname");
                }

                bookmark.Node = new XElement(node);

                return(bookmark);
            }
            catch (Exception ex)
            {
                throw new AODLException("Exception while trying to create a Bookmark.", ex);
            }
        }
Example #9
0
 private void PageLeft()
 {
     if (page == 1)
     {
         // Cannot see auto save and quick save in save mode
         if (saveViewMode == SaveViewMode.Load)
         {
             if (saveViewBookmarkType == BookmarkType.QuickSave)
             {
                 saveViewBookmarkType = BookmarkType.AutoSave;
                 page = 1;
             }
             else if (saveViewBookmarkType == BookmarkType.NormalSave)
             {
                 saveViewBookmarkType = BookmarkType.QuickSave;
                 page = 1;
             }
         }
     }
     else
     {
         --page;
     }
     ShowPage();
 }
 public NumberBookmark(MonoDevelop.Core.FilePath fileName, int lineNumber, int column, int bookmarkNumber, BookmarkType bookmarkType)
 {
     FileName = fileName;
     Column = column;
     Number = bookmarkNumber;
     BookmarkType = bookmarkType;
     LineNumber = lineNumber;
 }
Example #11
0
        private void ChangeType(BookmarkType type)
        {
            var bookmark = type == BookmarkType.AVATAR;

            SimsTabButton.Selected   = bookmark;
            SimsTab.Visible          = bookmark;
            IgnoreTabButton.Selected = !bookmark;
            IgnoreTab.Visible        = !bookmark;
        }
Example #12
0
        public Bookmark(BookmarkType bookmarkType, TextMarkerService textMarkerService, int lineNumber, int column, int startOffset, int length, string message, string fileName)
        {
            BookmarkType = bookmarkType;
            LineNumber = lineNumber;
            Message = message;

            _textMarkerService = textMarkerService;
            _errorList = IoC.Get<IErrorList>();

            InitializeBookmark(textMarkerService, lineNumber, column, startOffset, length, message, fileName);
        }
Example #13
0
        public Bookmark(BookmarkType bookmarkType, TextMarkerService textMarkerService, int lineNumber, int column, int startOffset, int length, string message, string fileName)
        {
            BookmarkType = bookmarkType;
            LineNumber   = lineNumber;
            Message      = message;

            _textMarkerService = textMarkerService;
            _errorList         = IoC.Get <IErrorList>();

            InitializeBookmark(textMarkerService, lineNumber, column, startOffset, length, message, fileName);
        }
Example #14
0
        private void ChangeType(BookmarkType type)
        {
            FindController <BookmarksController>().ChangeType(type);

            var bookmark = type == BookmarkType.AVATAR;

            SimsTabButton.Selected   = bookmark;
            SimsTab.Visible          = bookmark;
            IgnoreTabButton.Selected = !bookmark;
            IgnoreTab.Visible        = !bookmark;
        }
Example #15
0
 public void ShowLoad()
 {
     if (!savePanel.activeSelf)
     {
         // Locate to the latest slot
         saveViewBookmarkType = BookmarkType.NormalSave;
         int latestSaveId = checkpointManager.QuerySaveIdByTime((int)BookmarkType.NormalSave, int.MaxValue, SaveIdQueryType.Latest);
         page = SaveIdToPage(latestSaveId);
     }
     saveViewMode = SaveViewMode.Load;
     Show();
 }
Example #16
0
        public void ChangeBookmarkType(string uid, BookmarkType type)
        {
            using (var db = _dbContextFactory.CreateApplicationDbContext())
            {
                var found = db.Bookmarks.Find(uid);

                if (found != null)
                {
                    found.BookmarkType = type;
                    db.SaveChanges();
                }
            }
        }
Example #17
0
        public void RemoveAt(BookmarkType bookmarkType, int lineNumber)
        {
            var bookmarks =
                _bookmarks.Where(item => item.BookmarkType.Equals(bookmarkType) && item.LineNumber.Equals(lineNumber)).ToList();

            foreach (var bookmark in bookmarks)
            {
                bookmark.CleanUp();
                _bookmarks.Remove(bookmark);
                OnBookmarkUpdated?.Invoke(this, new BookmarkEventArgs(bookmark, true));
            }

            OnRedrawRequested?.Invoke(this, new EventArgs());
        }
Example #18
0
        private void AddBookmark(string path, string displayName, BookmarkType type, BookmarkContainer container)
        {
            int         imageIndex = 0;
            BookmarkTag tag        = null;

            if (type == BookmarkType.Directory)
            {
                imageIndex = m_iconListManager.AddFolderIcon(path, true);
                tag        = new BookmarkDirectoryTag(path);
            }
            else
            {
                imageIndex = m_iconListManager.AddFileIcon(path, true);
                tag        = new BookmarkFileTag(path);
            }

            if (tag != null)
            {
                tag.DisplayName = displayName;

                if (container == BookmarkContainer.Toolbar)
                {
                    var item = new ToolStripButtonWithContextMenu()
                    {
                        Text              = displayName,
                        Image             = m_smallImageList.Images[imageIndex],
                        TextImageRelation = TextImageRelation.ImageAboveText,
                        Tag = tag,
                        ContextMenuStrip = BookmarksContextMenuStrip,
                        Font             = BackToolStripButton.Font,
                        ToolTipText      = (tag as BookmarkTag).Path
                    };

                    item.Click += Bookmark_Click;

                    NavigationToolStrip.Items.Add(item);
                }
                else if (container == BookmarkContainer.TreeView)
                {
                    TreeNode item = new TreeNode(displayName);
                    item.ImageIndex  = item.SelectedImageIndex = imageIndex;
                    item.Tag         = tag;
                    item.ToolTipText = (tag as BookmarkTag).Path;

                    DrivesTreeView.Nodes[0].Nodes.Add(item);
                }
            }
        }
Example #19
0
        /// <summary>
        /// Create the XElement.
        /// </summary>
        /// <param name="type">The bookmark type.</param>
        /// <param name="bookmarkname">The bookmark name.</param>
        private void NewXmlNode(BookmarkType type, string bookmarkname)
        {
            if (type == BookmarkType.Start)
            {
                Node = new XElement(Ns.Text + "bookmark-start");
            }
            else if (type == BookmarkType.End)
            {
                Node = new XElement(Ns.Text + "bookmark-end");
            }
            else
            {
                Node = new XElement(Ns.Text + "bookmark");
            }

            Node.SetAttributeValue(Ns.Text + "name", bookmarkname);
        }
Example #20
0
        public void RecalculateOffsets(TextArea textArea, BookmarkType bookmarkType, int lineNumberOrCaretOffset, int textLength = 1)
        {
            switch (bookmarkType)
            {
            case BookmarkType.Breakpoint:
                // lineNumberOrCaretOffset: This will be a line number since breakpoints only work on whole lines

                foreach (var marker in _bookmarks.Where(item => item.LineNumber >= lineNumberOrCaretOffset).ToList())
                {
                    if (marker.TextMarker == null)
                    {
                        _bookmarks.Remove(marker);
                        continue;
                    }

                    var line = textArea.Document.GetLineByNumber(marker.LineNumber);
                    marker.TextMarker.StartOffset = line.Offset;
                    marker.TextMarker.Length      = line.Length;
                }
                break;

            case BookmarkType.AnalyzerInfo:
            case BookmarkType.AnalyzerWarning:
            case BookmarkType.ParseError:
                // lineNumberOrCaretOffset: This will be the caret offset
                foreach (var marker in _bookmarks.Where(item => item.TextMarker.StartOffset >= lineNumberOrCaretOffset && item.BookmarkType == bookmarkType))
                {
                    if (marker.TextMarker == null)
                    {
                        _bookmarks.Remove(marker);
                        continue;
                    }

                    marker.TextMarker.StartOffset += textLength;
                }
                break;

            default:
                break;
            }

            Execute.OnUIThread(() =>
            {
                textArea.TextView.InvalidateLayer(ICSharpCode.AvalonEdit.Rendering.KnownLayer.Selection);
            });
        }
Example #21
0
 public void ShowSave()
 {
     saveViewMode = SaveViewMode.Save;
     if (!savePanel.activeSelf)
     {
         // Locate to the first unused slot
         saveViewBookmarkType = BookmarkType.NormalSave;
         int minUnusedSaveId = checkpointManager.QueryMinUnusedSaveId((int)BookmarkType.NormalSave, int.MaxValue);
         page = SaveIdToPage(minUnusedSaveId);
     }
     // Cannot see auto save and quick save in save mode
     if (saveViewBookmarkType != BookmarkType.NormalSave)
     {
         saveViewBookmarkType = BookmarkType.NormalSave;
         page = 1;
     }
     Show();
 }
Example #22
0
        public void RecalculateOffsets(TextArea textArea, BookmarkType bookmarkType, int lineNumberOrCaretOffset, int textLength = 1)
        {
            switch (bookmarkType)
            {
                case BookmarkType.Breakpoint:
                    // lineNumberOrCaretOffset: This will be a line number since breakpoints only work on whole lines

                    foreach (var marker in _bookmarks.Where(item => item.LineNumber >= lineNumberOrCaretOffset).ToList())
                    {
                        if (marker.TextMarker == null)
                        {
                            _bookmarks.Remove(marker);
                            continue;
                        }

                        var line = textArea.Document.GetLineByNumber(marker.LineNumber);
                        marker.TextMarker.StartOffset = line.Offset;
                        marker.TextMarker.Length = line.Length;
                    }
                    break;
                case BookmarkType.AnalyzerInfo:
                case BookmarkType.AnalyzerWarning:
                case BookmarkType.ParseError:
                    // lineNumberOrCaretOffset: This will be the caret offset
                    foreach (var marker in _bookmarks.Where(item => item.TextMarker.StartOffset >= lineNumberOrCaretOffset && item.BookmarkType == bookmarkType))
                    {
                        if (marker.TextMarker == null)
                        {
                            _bookmarks.Remove(marker);
                            continue;
                        }

                        marker.TextMarker.StartOffset += textLength;
                    }
                    break;
                default:
                    break;
            }

            Execute.OnUIThread(() =>
            {
                textArea.TextView.InvalidateLayer(ICSharpCode.AvalonEdit.Rendering.KnownLayer.Selection);
            });
        }
Example #23
0
        /// <summary>
        /// Updates bookmark in the document.
        /// </summary>
        /// <param name="fileName">File name.</param>
        /// <param name="number">Bookmark number.</param>
        /// <param name="type">Bookmark type.</param>
        public void UpdateBookmark(string fileName, int number, BookmarkType type)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException(nameof(fileName));
            }

            if ((number < 1) || (number > 10))
            {
                throw new ArgumentOutOfRangeException(nameof(number));
            }

            if (_bookmarks.ContainsKey(fileName) && _bookmarkCallbacks.ContainsKey(fileName))
            {
                var bookmark = _bookmarks[fileName].First(b => (b.Number == number) && (b.Type == type));
                var client   = _bookmarkCallbacks[fileName];
                var line     = client.GetBookmarkLine(bookmark);
                bookmark.Line = line;
            }
        }
Example #24
0
 private void PageRight()
 {
     if (page == maxPage)
     {
         if (saveViewBookmarkType == BookmarkType.AutoSave)
         {
             saveViewBookmarkType = BookmarkType.QuickSave;
             page = 1;
         }
         else if (saveViewBookmarkType == BookmarkType.QuickSave)
         {
             saveViewBookmarkType = BookmarkType.NormalSave;
             page = 1;
         }
     }
     else
     {
         ++page;
     }
     ShowPage();
 }
Example #25
0
        /// <summary>
        /// When a bookmarkable item gets deleted then delete any bookmarks to that item, since its a generic column there is not FK setup.
        /// </summary>
        public async Task <OperationResult <bool> > RemoveAllBookmarksForItem(BookmarkType type, int id)
        {
            var bookmarks = await DbContext.Bookmarks.Include(x => x.User)
                            .Where(x => x.BookmarkType == type && x.BookmarkTargetId == id)
                            .ToListAsync();

            var users = bookmarks.Select(x => x.User).ToList().Distinct();

            DbContext.Bookmarks.RemoveRange(bookmarks);
            await DbContext.SaveChangesAsync();

            foreach (var user in users)
            {
                CacheManager.ClearRegion(user.CacheRegion);
            }
            return(new OperationResult <bool>
            {
                IsSuccess = true,
                Data = true
            });
        }
Example #26
0
        /// <summary>
        /// Create the XmlNode.
        /// </summary>
        /// <param name="type">The bookmark type.</param>
        /// <param name="bookmarkname">The bookmark name.</param>
        private void NewXmlNode(BookmarkType type, string bookmarkname)
        {
            if (type == BookmarkType.Start)
            {
                this.Node = this.Document.CreateNode("bookmark-start", "text");
            }
            else if (type == BookmarkType.End)
            {
                this.Node = this.Document.CreateNode("bookmark-end", "text");
            }
            else
            {
                this.Node = this.Document.CreateNode("bookmark", "text");
            }

            XmlAttribute xa = this.Document.CreateAttribute("name", "text");

            xa.Value = bookmarkname;

            this.Node.Attributes.Append(xa);
        }
Example #27
0
        /// <summary>
        /// Removes bookmark from the document.
        /// </summary>
        /// <param name="fileName">File name.</param>
        /// <param name="number">Bookmark number.</param>
        /// <param name="type">Bookmark type.</param>
        public void RemoveBookmark(string fileName, int number, BookmarkType type)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException(nameof(fileName));
            }

            if ((number < 1) || (number > 10))
            {
                throw new ArgumentOutOfRangeException(nameof(number));
            }

            if (_bookmarks.ContainsKey(fileName))
            {
                var bookmarks = _bookmarks[fileName];
                var bookmark  = bookmarks.FirstOrDefault(b => (b.Number == number) && (b.Type == type));
                if ((bookmark != null) && bookmarks.Contains(bookmark))
                {
                    bookmarks.Remove(bookmark);
                }
            }
        }
Example #28
0
        public Bookmark(BookmarkType type, int number, int line, int column)
        {
            if (number <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(number));
            }

            if (line <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(line));
            }

            if (column <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(column));
            }

            this.Type   = type;
            this.Number = number;
            this.Line   = line;
            this.Column = column;
        }
Example #29
0
        /// <summary>
        /// Raises Changed event and subscribes to and unsubscribes from solution events as necessary.
        /// </summary>
        private void DoChanged(string fileName, int number, BookmarkType type)
        {
            Changed?.Invoke(this, new BookmarkEventArgs {
                FileName = fileName, Number = number, Type = type
            });

            // Dynamically subscribe to solution events - no need to keep responding to them if this feature is dormant
            if (this.BookmarkCount > 0)
            {
                if (!_solutionEvents)
                {
                    _shellEventsService.SubscribeSolutionEvents(this);
                    _solutionEvents = true;
                }
            }
            else
            {
                if (_solutionEvents)
                {
                    _solutionEvents = false;
                    _shellEventsService.UnsubscribeSolutionEvents(this);
                }
            }
        }
Example #30
0
 public override int GetHashCode()
 {
     return(BookmarkType.GetHashCode() ^ LineNumber.GetHashCode());
 }
Example #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Bookmark"/> class.
 /// </summary>
 /// <param name="document">The document.</param>
 /// <param name="type">The type.</param>
 /// <param name="bookmarkname">The bookmarkname.</param>
 public Bookmark(IDocument document, BookmarkType type, string bookmarkname)
 {
     this.Document = document;
     this.NewXmlNode(type, bookmarkname);
 }
Example #32
0
		/// <summary>
		/// Create the XmlNode.
		/// </summary>
		/// <param name="type">The bookmark type.</param>
		/// <param name="bookmarkname">The bookmark name.</param>
		private void NewXmlNode(BookmarkType type, string bookmarkname)
		{
			if (type == BookmarkType.Start)
				this.Node		= this.Document.CreateNode("bookmark-start", "text");
			else if (type == BookmarkType.End)
				this.Node		= this.Document.CreateNode("bookmark-end", "text");
			else
				this.Node		= this.Document.CreateNode("bookmark", "text");

			XmlAttribute xa		= this.Document.CreateAttribute("name", "text");
			xa.Value			= bookmarkname;

			this.Node.Attributes.Append(xa);
		}
Example #33
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Bookmark"/> class.
		/// </summary>
		/// <param name="document">The document.</param>
		/// <param name="type">The type.</param>
		/// <param name="bookmarkname">The bookmarkname.</param>
		public Bookmark(IDocument document, BookmarkType type, string bookmarkname)
		{
			this.Document				= document;
			this.NewXmlNode(type, bookmarkname);
		}
Example #34
0
        public static List <Bookmark> GetAll(BookmarkType bookmarkType)
        {
            var db = HohoemaLiteDb.GetLocalLiteRepository();

            return(db.Fetch <Bookmark>(x => x.BookmarkType == bookmarkType));
        }
        /// <summary>
        /// This method is used to find row for a table
        /// </summary>
        /// <param name="findRowFlags">Identify the flags for this operation</param>
        /// <param name="origin">Identify the bookmark</param>
        /// <param name="isValidRestriction">Identify whether the restriction is valid</param>
        /// <returns>Table ROP return value</returns>
        public TableRopReturnValues RopFindRow(FindRowFlags findRowFlags, BookmarkType origin, bool isValidRestriction)
        {
            RopFindRowRequest findRowRequest;
            RopFindRowResponse findRowResponse;

            findRowRequest.RopId = 0x4F;
            findRowRequest.LogonId = 0x00;
            findRowRequest.InputHandleIndex = 0x00;
            findRowRequest.FindRowFlags = (byte)findRowFlags;
            byte[] data;
            if (isValidRestriction)
            {
                data = AdapterHelper.GenerateValidRestrictData(this.Site, this.tableType);
            }
            else
            {
                data = new byte[] { 0x03, 0x02, 0x00, 0x04, 0x00, 0x1f, 0x00, 0x1a, 0x0c, 0x1f, 0x00, 0x1a, 0x0c, 0x24 }; // SenderName is $, which is not exist.
            }

            findRowRequest.RestrictionDataSize = (ushort)data.Length;
            findRowRequest.RestrictionData = data;
            findRowRequest.Origin = (byte)origin;
            if (origin == BookmarkType.BOOKMARK_CUSTOM)
            {
                findRowRequest.Bookmark = this.userDefinedBookmark; // Returned by a previous RopCreateBookmark request.
                findRowRequest.BookmarkSize = this.userDefinedBookmarkSize;
            }
            else
            {
                findRowRequest.Bookmark = null;
                findRowRequest.BookmarkSize = 0x0;
            }

            if (Common.IsRequirementEnabled(827, this.Site))
            {
                this.DoSingleCallROP(findRowRequest, this.tableHandle, ref this.response, ref this.rawData);
            }
            else
            {
                try
                {
                    this.DoSingleCallROP(findRowRequest, this.tableHandle, ref this.response, ref this.rawData);
                }
                catch (Exception ex)
                {
                    Site.Log.Add(LogEntryKind.Comment, ex.Message);
                    Site.Log.Add(LogEntryKind.Comment, "The behavior when a RopFindRow ROP is sent before a successful RopSetColumns ROP is undefined for implementation following Exchange 2007.");
                    return TableRopReturnValues.unexpected;
                }
            }

            findRowResponse = (RopFindRowResponse)this.response;
            bool rowNoLongerVisible = findRowResponse.RowNoLongerVisible == 0x01 ? true : false;

            bool hasRowData = Convert.ToBoolean(findRowResponse.HasRowData);

            bool isCorrectRowData = true;
            bool isLastSetColumnData = true;
            if ((TableRopReturnValues)findRowResponse.ReturnValue == TableRopReturnValues.success)
            {
                if (hasRowData)
                {
                    if (this.tableType == TableType.CONTENT_TABLE)
                    {
                        // Gets the SenderName.
                        string strSenderName = Encoding.Unicode.GetString(findRowResponse.RowData.PropertyValues[2].Value);

                        // TRUE:the senderName is Test1.
                        isCorrectRowData = this.IsExpectedSender(strSenderName, Common.GetConfigurationPropertyValue("Sender1Name", this.Site));
                    }
                    else if (this.tableType == TableType.HIERARCHY_TABLE)
                    {
                        // Gets the DisplayName.
                        string strDisplayName = Encoding.Unicode.GetString(findRowResponse.RowData.PropertyValues[5].Value);

                        // TRUE:the displayName is Test1.
                        isCorrectRowData = strDisplayName == (Constants.TestGetHierarchyTableFolderName1 + '\0');
                    }
                    else if (this.tableType == TableType.RULES_TABLE)
                    {
                        // Gets the RuleName property.
                        string strRuleName = Encoding.Unicode.GetString(findRowResponse.RowData.PropertyValues[1].Value);

                        // TRUE:the RuleName is MarkAsRead.
                        isCorrectRowData = strRuleName == (Constants.RuleNameMarkAsRead + '\0');
                    }

                    isLastSetColumnData = this.latestPropertyTags.Length == findRowResponse.RowData.PropertyValues.Count;
                }
            }

            if (this.RopFindRowResponse != null)
            {
                this.RopFindRowResponse(findRowFlags, isValidRestriction, hasRowData, isCorrectRowData, rowNoLongerVisible, isLastSetColumnData);
            }

            return (TableRopReturnValues)findRowResponse.ReturnValue;
        }
Example #36
0
        /// <summary>
        /// Reconciles bookmark service bookmarks on hand with bookmark spans.
        /// </summary>
        private void DoChanged(int number, BookmarkType type)
        {
            if (!InitializeServices(false))
            {
                return;
            }

            var fileName = GetFileName();

            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }

            _log?.LogMessage($"File '{Path.GetFileName(fileName)}' bookmark {number} change ({type})", LOG_CATEGORY);

            try
            {
                var bookmarks = this.BookmarksService?.GetFileBookmarks(fileName);
                if ((bookmarks.Count() == 0) && (_bookmarkSpans.Count == 0))
                {
                    return;
                }

                using (Update())
                {
                    // Remove changed bookmark so that it gets re-added further down
                    if (number > 0)
                    {
                        var changedBookmark = _bookmarkSpans.Keys.FirstOrDefault(b => (b.Number == number) && type.HasFlag(b.Type));
                        if (changedBookmark != null)
                        {
                            _log?.LogMessage($"Removed changed {changedBookmark.Type} bookmark {changedBookmark.Number} tag", LOG_CATEGORY);

                            if (!RemoveTagSpan(_bookmarkSpans[changedBookmark]))
                            {
                                _log?.LogMessage($"Failed to remove changed {changedBookmark.Type} bookmark {changedBookmark.Number} tag span", LOG_CATEGORY);
                            }
                            _bookmarkSpans.Remove(changedBookmark);
                        }
                    }

                    var newBookmarks = bookmarks.Where(b => !_bookmarkSpans.ContainsKey(b)).ToList();
                    newBookmarks.ForEach(b =>
                    {
                        if ((b.Line >= 1) && (b.Line <= _buffer.CurrentSnapshot.LineCount))
                        {
                            var line         = _buffer.CurrentSnapshot.GetLineFromLineNumber(b.Line - 1);
                            var span         = _buffer.CurrentSnapshot.CreateTrackingSpan(new SnapshotSpan(line.Start, 1), SpanTrackingMode.EdgeExclusive);                     // can't be span of 0 length
                            var trackingSpan = CreateTagSpan(span, new BookmarkTag(b.Number, b.Type));
                            _bookmarkSpans.Add(b, trackingSpan);

                            _log?.LogMessage($"Added {b.Type} bookmark {b.Number} tag on line {b.Line}", LOG_CATEGORY);
                        }
                        else
                        {
                            _log?.LogMessage($"{b.Type} bookmark {b.Number} invalid tag line {b.Line}", LOG_CATEGORY);
                        }
                    });

                    var deleteBookmarks = _bookmarkSpans.Keys.Where(b => !bookmarks.Contains(b)).ToList();
                    deleteBookmarks.ForEach(b =>
                    {
                        _log?.LogMessage($"Removed deleted {b.Type} bookmark {b.Number} tag", LOG_CATEGORY);

                        if (!RemoveTagSpan(_bookmarkSpans[b]))
                        {
                            _log?.LogMessage($"Failed to remove deleted {b.Type} bookmark {b.Number} tag span", LOG_CATEGORY);
                        }
                        _bookmarkSpans.Remove(b);
                    });
                }
            }
            catch (Exception ex)
            {
                if (_log != null)
                {
                    _log.LogMessage(ex, LOG_CATEGORY);
                }
                else
                {
                    Trace.TraceError(ex.ToString());
                }
            }
        }
Example #37
0
 public void ChangeType(BookmarkType type)
 {
     CurrentType = type;
     RefreshResults();
 }
Example #38
0
        public void RemoveAt(BookmarkType bookmarkType, int lineNumber)
        {
            var bookmarks =
                _bookmarks.Where(item => item.BookmarkType.Equals(bookmarkType) && item.LineNumber.Equals(lineNumber)).ToList();

            foreach (var bookmark in bookmarks)
            {
                bookmark.CleanUp();
                _bookmarks.Remove(bookmark);
                OnBookmarkUpdated?.Invoke(this, new BookmarkEventArgs(bookmark, true));
            }

            OnRedrawRequested?.Invoke(this, new EventArgs());
        }
Example #39
0
        public static void RopQueryRowsResponse(QueryRowsFlags queryRowFlags, bool isForwardRead, bool isZeroRow, TableRopType ropType, bool isCorrectRowCount, bool isCursorPositionChanged, bool isLatestRopData, bool isLastSuccessRopData, BookmarkType queryRowOrigin, bool isRequestCountTooLarger)
        {
            // If the NoAdvance flag (0x01) is set in the QueryRowsFlags field, the server MUST NOT change the position of the cursor.
            if (queryRowFlags == QueryRowsFlags.NoAdvance)
            {
                Condition.IsTrue(!isCursorPositionChanged);
                ModelHelper.CaptureRequirement(470, @"[In Processing RopQueryRows] If the NoAdvance flag (0x01) is set in the QueryRowsFlags field, the server MUST NOT change the position of the cursor.");
                if (queryRowOrigin == BookmarkType.BOOKMARK_BEGINNING)
                {
                    ModelHelper.CaptureRequirement(27, @"[In Predefined Bookmarks] When the Predefined Bookmarks is BOOKMARK_BEGINNING with value 0x00 means points to the beginning position of the table, or the first row.");
                }
            }

            // Test RopSetColumns MUST be sent on the table prior to sending RopQueryRows
            bool latestSetColumnFlag = false;
            setColumnsFlags.TryGetValue((uint)setColumnsFlags.Count, out latestSetColumnFlag);
            if (latestSetColumnFlag)
            {
                Condition.IsTrue(isCorrectRowCount);

                // If the ForwardRead field is TRUE, RopQueryRows MUST return the rows beginning at the origin, reading forward.
                if (isForwardRead)
                {
                    // In the Test Suite, the origin is beginning, and if the enough row is true, 
                    // the RowCount rows will be queried from table. Also, here it only verify whether the correct row count 
                    // is returned, because for the details of the table row, it can't be verified.
                    ModelHelper.CaptureRequirement(468, @"[In Processing RopQueryRows] If rows are returned by the RopQueryRows ROP and the ForwardRead field is set to ""TRUE"" (0x01), the RopQueryRows ROP returns the rows beginning at the position pointed to by the Origin field, reading forward.");
                }
                else
                { 
                    Condition.IsTrue((requirementContainer[896] && !requirementContainer[897]) || (!requirementContainer[896] && requirementContainer[897]));

                    // if there are no more rows to return and the ForwardRead field in the ROP request is set to "false",
                    // Exchange 2007 will set the Origin field to "BOOKMARK_BEGINNING".
                    if (requirementContainer[896] && isRequestCountTooLarger)
                    {
                        Condition.IsTrue(queryRowOrigin == BookmarkType.BOOKMARK_BEGINNING);
                        ModelHelper.CaptureRequirement(896, @"[In Appendix A: Product Behavior] Implementation does set the Origin field to ""BOOKMARK_BEGINNING"", if there are no more rows to return and the ForwardRead field in the ROP request is set to ""FALSE"". (Exchange Server 2007 follows this behavior.)");
                    }

                    // if there are no more rows to return and the ForwardRead field in the ROP request is set to "false",
                    // Exchange 2010 and above will set the Origin field to "BOOKMARK_END".
                    if (requirementContainer[897] && isRequestCountTooLarger)
                    {
                        Condition.IsTrue(queryRowOrigin == BookmarkType.BOOKMARK_END);
                        ModelHelper.CaptureRequirement(897, @"[In Appendix A: Product Behavior] Implementation does set the Origin field to ""BOOKMARK_END"", if there are no more rows to return and the ForwardRead field in the ROP request is set to ""FALSE"". (<25> Section 3.2.5.5: Exchange 2010, Exchange 2013, and Exchange 2016 set the Origin field to ""BOOKMARK_END"".)");
                    }

                    // When ForwardRead in request is false, if the correct row count is returned, this requirement can be verified.
                    ModelHelper.CaptureRequirement(469, @"[In Processing RopQueryRows] If it [ForeardRead] is set to ""FALSE"" (0x00), the server returns the rows starting at the number of rows equal to the value of the RowCount field before the position pointed to by the Origin field, such that the rows returned are those between the value of the Origin field minus the value of the RowCount field and the position pointed to by the Origin field.");
                }

                // If the RopRestrict ROP has not been issued, the RowData field MUST include all rows.
                bool isLastestRestrictFlags = false;
                restrictFlags.TryGetValue((uint)restrictFlags.Count, out isLastestRestrictFlags);
                
                if (!isLastestRestrictFlags)
                {
                    ModelHelper.CaptureRequirement(118, @"[In RopQueryRows ROP Response Buffer] If the RopRestrict ROP has not been issued, the RowData field MUST include all rows.");
                }

                // When correct row count is returned and the returned row count is zero, the R467 is verified. 
                if (isZeroRow)
                {
                    ModelHelper.CaptureRequirement(467, @"[In Processing RopQueryRows] This ROP MUST only send zero rows when there are no more rows in the table.");
                }
            }

            ModelHelper.CaptureRequirement(462, @"[In Processing RopQueryRows] When a RopQueryRows ROP request ([MS-OXCROPS] section 2.2.5.4) is sent, the server MUST send the rows from the table starting at the current cursor position.");

            // If there are no more rows to return, the Origin field will be set to BOOKMARK_END if the ForwardRead field in the ROP request is set to true.
            if (isCursorPositionChanged && isForwardRead && queryRowOrigin == BookmarkType.BOOKMARK_END)
            {
                ModelHelper.CaptureRequirement(29, @"[In Predefined Bookmarks] When the Predefined Bookmarks is BOOKMARK_END with value 0x02 means points to the ending position of the table, or the location after the last row.");
                ModelHelper.CaptureRequirement(725, @"[In Processing RopQueryRows] If there are no more rows to return and the ForwardRead field in the ROP request is set to ""TRUE"", then the Origin field is set to ""BOOKMARK_END"".");
            }

            if (!isRequestCountTooLarger && isForwardRead && isCursorPositionChanged)
            {
                Condition.IsTrue(queryRowOrigin == BookmarkType.BOOKMARK_CURRENT);
                ModelHelper.CaptureRequirement(28, @"[In Predefined Bookmarks] When the Predefined Bookmarks is BOOKMARK_CURRENT with value 0x01 means points to the current position of the table, or the current row.");
                ModelHelper.CaptureRequirement(726, @"[In Processing RopQueryRows] Otherwise,[If there are more rows to return] it [Origin] will be set to ""BOOKMARK_CURRENT"".");
            }

            // Below is to parse the data queried
            switch (ropType)
            {
                // Query rows is called after a SetColumn request
                case TableRopType.SETCOLUMNS:
                    {
                        ParseQueryRowsAfterSetColumns(isLatestRopData, isLastSuccessRopData);
                        break;
                    }

                // Query rows is called after sort table request
                case TableRopType.SORTTABLE:
                    {
                        ParseQueryRowsAfterSortTable(isLatestRopData, isLastSuccessRopData);
                        break;
                    }

                // Query rows is called after restrict table request
                case TableRopType.RESTRICT:
                    {
                        ParseQueryRowsAfterRestrict(isLatestRopData, isLastSuccessRopData);
                        break;
                    }

                // If no above operation, query rows must return all rows, the parameter bIsLatestRopData is used to identify whether all row data is returned
                default:
                    {
                        break;
                    }
            }
        }
		/// <summary>
		/// Creates the bookmark.
		/// </summary>
		/// <param name="document">The document.</param>
		/// <param name="node">The node.</param>
		/// <param name="type">The type.</param>
		/// <returns></returns>
		public Bookmark CreateBookmark(IDocument document,XmlNode node, BookmarkType type)
		{
			try
			{
				Bookmark bookmark		= null;
				if (type == BookmarkType.Standard)
					bookmark			= new Bookmark(document, BookmarkType.Standard, "noname");
				else if (type == BookmarkType.Start)
					bookmark			= new Bookmark(document, BookmarkType.Start, "noname");
				else
					bookmark			= new Bookmark(document, BookmarkType.End, "noname");

				bookmark.Node			= node.CloneNode(true);

				return bookmark;
			}
			catch(Exception ex)
			{
				throw new AODLException("Exception while trying to create a Bookmark.", ex);
			}
		}
        /// <summary>
        /// This method is used to query rows for a table
        /// </summary>
        /// <param name="queryRowFlags">A flag for the query row operation</param>
        /// <param name="forwardRead">Identify whether to read the data forward</param>
        /// <returns>Table ROP return value</returns>
        public TableRopReturnValues RopQueryRows(QueryRowsFlags queryRowFlags, bool forwardRead)
        {
            // The enabled property value for MS-OXCTABL_R768, MS-OXCTABL_R866 and MS-OXCTABL_R867 must the same.
            if (!(Common.IsRequirementEnabled(768, this.Site) == Common.IsRequirementEnabled(866, this.Site) == Common.IsRequirementEnabled(867, this.Site) == true) && !(Common.IsRequirementEnabled(768, this.Site) == Common.IsRequirementEnabled(866, this.Site) == Common.IsRequirementEnabled(867, this.Site) == false))
            {
                Site.Assert.Inconclusive("Requirements implementation conflict, the conflict requirements number are: MS-OXCTABL_R768, MS-OXCTABL_R866 and MS-OXCTABL_R867");
            }

            uint tempRowCount = this.GetRowsCount(forwardRead); // Gets the number of rows from current location to begin row or last row.

            RopQueryRowsRequest queryRowsRequest;
            RopQueryRowsResponse queryRowsResponse;

            queryRowsRequest.RopId = 0x15;
            queryRowsRequest.LogonId = 0x00;
            queryRowsRequest.InputHandleIndex = 0x00;
            queryRowsRequest.QueryRowsFlags = (byte)queryRowFlags; // Whether advance the table cursor. 
            queryRowsRequest.ForwardRead = Convert.ToByte(forwardRead); // It is set to FALSE (0x00) to read the table backwards. It MUST NOT be set to any other value.
            queryRowsRequest.RowCount = 0x0003; // Return a maximum of 3 rows.
            this.rowCountInQueryRowsRequest = queryRowsRequest.RowCount;

            if (Common.IsRequirementEnabled(768, this.Site))
            {
                this.DoSingleCallROP(queryRowsRequest, this.tableHandle, ref this.response, ref this.rawData);
            }
            else
            {
                // In order to test the case when buffer is smaller.
                try
                {
                    this.DoSingleCallROP(queryRowsRequest, this.tableHandle, ref this.response, ref this.rawData);
                }
                catch (Exception ex)
                {
                    if (ex.Message == Constants.BufferTooSmall)
                    {
                        return TableRopReturnValues.ecBufferTooSmall;
                    }
                    else
                    {
                        Site.Log.Add(LogEntryKind.Comment, ex.Message);
                        Site.Log.Add(LogEntryKind.Comment, "The behavior when a RopQueryRows ROP is sent before a successful RopSetColumns ROP is undefined for implementation following Exchange 2007.");
                        return TableRopReturnValues.unexpected;
                    }
                }
            }

            queryRowsResponse = (RopQueryRowsResponse)this.response;

            int queryRowCount = 0;
            bool isLatestRopData = false;
            bool isLastSuccessRopData = false;
            bool zeroRow = false;
            bool isCorrectRowCountReturned = false;
            bool cursorPositionChanged = false;
            bool isRequestCountTooLarger = this.rowCountInQueryRowsRequest > tempRowCount;
            if ((TableRopReturnValues)queryRowsResponse.ReturnValue == TableRopReturnValues.success)
            {
                queryRowCount = queryRowsResponse.RowCount;
                this.queryRowOrigin = (BookmarkType)queryRowsResponse.Origin;
                isCorrectRowCountReturned = tempRowCount > this.rowCountInQueryRowsRequest ? queryRowCount == this.rowCountInQueryRowsRequest : queryRowCount == tempRowCount; // It MUST be less than or equal to the RowCount that is specified in the request
                cursorPositionChanged = tempRowCount != this.GetRowsCount(forwardRead);
                if (queryRowCount == 0)
                {
                    zeroRow = true;
                }
                else
                {
                    this.propertyValues = queryRowsResponse.RowData.PropertyRows[0].PropertyValues; // Gets the first row 
                    isLastSuccessRopData = this.latestSuccessPropertyTages.Length == queryRowsResponse.RowData.PropertyRows[0].PropertyValues.Count;
                    isLatestRopData = this.latestPropertyTags.Length == queryRowsResponse.RowData.PropertyRows[0].PropertyValues.Count;

                    if (this.tableType == TableType.CONTENT_TABLE)
                    {
                        bool isCorrectSortOrder = true;

                        // Gets the value of PidTagSenderName.
                        string tempSenderName = Encoding.Unicode.GetString(queryRowsResponse.RowData.PropertyRows[0].PropertyValues[2].Value);
                        if (this.latestSuccessSortOrder == SortOrderFlag.SortOrderASC)
                        {
                            // The PidTagSenderName must be Test1 when sortOrder is ascend.
                            isCorrectSortOrder = this.IsExpectedSender(tempSenderName, Common.GetConfigurationPropertyValue("Sender1Name", this.Site));
                        }
                        else if (this.latestSuccessSortOrder == SortOrderFlag.SortOrderDESC)
                        {
                            // The PidTagSenderName must be Test2 when sortOrder is descend.
                            isCorrectSortOrder = this.IsExpectedSender(tempSenderName, Common.GetConfigurationPropertyValue("Sender2Name", this.Site));
                        }

                        bool isCorrectRestriction = true;
                        if (this.latestSuccessRestrict == RestrictFlag.SenderIsTest1Restrict)
                        {
                            foreach (PropertyRow pr in queryRowsResponse.RowData.PropertyRows)
                            {
                                if (!this.IsExpectedSender(Encoding.Unicode.GetString(pr.PropertyValues[2].Value), Common.GetConfigurationPropertyValue("Sender1Name", this.Site)))
                                {
                                    isCorrectRestriction = false;
                                }
                            }
                        }

                        if (this.latestSuccessRestrict == RestrictFlag.SenderIsTest2Restriction)
                        {
                            foreach (PropertyRow pr in queryRowsResponse.RowData.PropertyRows)
                            {
                                if (!this.IsExpectedSender(Encoding.Unicode.GetString(pr.PropertyValues[2].Value), Common.GetConfigurationPropertyValue("Sender2Name", this.Site)))
                                {
                                    isCorrectRestriction = false;
                                }
                            }
                        }

                        bool isFirstHeaderExpanded = true;
                        bool areAllCategoryExpanded = true;
                        bool isCorrectSortOrderAndCategory = true;
                        if (this.latestSuccessSortOrder != SortOrderFlag.NotSort)
                        {
                            if (this.isExpanded == true)
                            {
                                if (BitConverter.ToInt32(queryRowsResponse.RowData.PropertyRows[0].PropertyValues[3].Value, 0) != 0x03)
                                {
                                    isFirstHeaderExpanded = false;
                                }
                            }

                            if (this.areAllCategoryExpanded)
                            {
                                foreach (PropertyRow pr in queryRowsResponse.RowData.PropertyRows)
                                {
                                    if (BitConverter.ToInt32(pr.PropertyValues[3].Value, 0) == 0x04)
                                    {
                                        areAllCategoryExpanded = false;
                                        break;
                                    }
                                }
                            }

                            if (!this.areAllSortOrdersUsedAsCategory)
                            {
                                if (this.areMultipleSortOrders)
                                {
                                    foreach (PropertyRow pr in queryRowsResponse.RowData.PropertyRows)
                                    {
                                        // Since the PidTagSenderName property is used in the first sortOrder structure, it will be used as category.
                                        if (BitConverter.ToInt32(pr.PropertyValues[3].Value, 0) == 0x03 || BitConverter.ToInt32(pr.PropertyValues[3].Value, 0) == 0x04)
                                        {
                                            if (!this.IsExpectedSender(Encoding.Unicode.GetString(pr.PropertyValues[2].Value), Common.GetConfigurationPropertyValue("Sender1Name", this.Site)) &&
                                                !this.IsExpectedSender(Encoding.Unicode.GetString(pr.PropertyValues[2].Value), Common.GetConfigurationPropertyValue("Sender2Name", this.Site)))
                                            {
                                                isCorrectSortOrderAndCategory = false;
                                                break;
                                            }
                                        }
                                    }

                                    if (isCorrectSortOrderAndCategory)
                                    {
                                        for (int i = 0; i < queryRowsResponse.RowData.PropertyRows.Count - 1; i++)
                                        {
                                            // Since the PidTagInstID property is used in the second sortOrder structure, it will be used to sort the rows within the category.
                                            if (BitConverter.ToInt32(queryRowsResponse.RowData.PropertyRows[i].PropertyValues[3].Value, 0) == 0x01 &&
                                                BitConverter.ToInt32(queryRowsResponse.RowData.PropertyRows[i + 1].PropertyValues[3].Value, 0) == 0x01)
                                            {
                                                if ((this.latestSuccessSortOrder == SortOrderFlag.SortOrderASC && BitConverter.ToInt32(queryRowsResponse.RowData.PropertyRows[i].PropertyValues[0].Value, 0) <
                                                    BitConverter.ToInt32(queryRowsResponse.RowData.PropertyRows[i + 1].PropertyValues[0].Value, 0)) ||
                                                    (this.latestSuccessSortOrder == SortOrderFlag.SortOrderDESC && BitConverter.ToInt32(queryRowsResponse.RowData.PropertyRows[i].PropertyValues[0].Value, 0) >
                                                    BitConverter.ToInt32(queryRowsResponse.RowData.PropertyRows[i + 1].PropertyValues[0].Value, 0)))
                                                {
                                                    isCorrectSortOrderAndCategory = false;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        isLastSuccessRopData = isLastSuccessRopData && isCorrectSortOrder && isCorrectRestriction && isFirstHeaderExpanded && areAllCategoryExpanded && isCorrectSortOrderAndCategory;

                        if (this.latestSortOrder == SortOrderFlag.SortOrderASC)
                        {
                            // The PidTagSenderName must be Test1 when sortOrder is ascend.
                            isCorrectSortOrder = this.IsExpectedSender(tempSenderName, Common.GetConfigurationPropertyValue("Sender1Name", this.Site));
                        }
                        else if (this.latestSortOrder == SortOrderFlag.SortOrderDESC)
                        {
                            // The PidTagSenderName must be Test2 when sortOrder is descend.
                            isCorrectSortOrder = this.IsExpectedSender(tempSenderName, Common.GetConfigurationPropertyValue("Sender2Name", this.Site));
                        }

                        if (this.latestRestrict == RestrictFlag.SenderIsTest1Restrict)
                        {
                            foreach (PropertyRow pr in queryRowsResponse.RowData.PropertyRows)
                            {
                                if (!this.IsExpectedSender(Encoding.Unicode.GetString(pr.PropertyValues[2].Value), Common.GetConfigurationPropertyValue("Sender1Name", this.Site)))
                                {
                                    isCorrectRestriction = false;
                                }
                            }
                        }

                        if (this.latestRestrict == RestrictFlag.SenderIsTest2Restriction)
                        {
                            foreach (PropertyRow pr in queryRowsResponse.RowData.PropertyRows)
                            {
                                if (!this.IsExpectedSender(Encoding.Unicode.GetString(pr.PropertyValues[2].Value), Common.GetConfigurationPropertyValue("Sender2Name", this.Site)))
                                {
                                    isCorrectRestriction = false;
                                }
                            }
                        }

                        isLatestRopData = isLatestRopData && isCorrectSortOrder && isCorrectRestriction;
                    }
                }
            }
            else
            {
                isCorrectRowCountReturned = false;
            }

            if (this.RopQueryRowsResponse != null)
            {
                this.RopQueryRowsResponse(queryRowFlags, forwardRead, zeroRow, this.ropType, isCorrectRowCountReturned, cursorPositionChanged, isLatestRopData, isLastSuccessRopData, this.queryRowOrigin, isRequestCountTooLarger);
            }

            return (TableRopReturnValues)queryRowsResponse.ReturnValue;
        }
Example #42
0
        public static TableRopReturnValues RopSeekRow(BookmarkType origin, bool isForwardSeek, bool isWantRowMovedCountout, bool isEnoughRow)
        {
            // This ROP is only valid on Table objects.
            if (globleTableType == TableType.CONTENT_TABLE)
            {
                // The RopSeekRow ROP MUST be supported for contents tables.
                ModelHelper.CaptureRequirement(850, @"[In Processing RopSeekRow] The RopSeekRow ROP MUST be supported for contents tables.");
            }
            else if (globleTableType == TableType.HIERARCHY_TABLE)
            {
                // The RopSeekRow ROP MUST be supported for hierarchy tables.
                ModelHelper.CaptureRequirement(848, @"[In Processing RopSeekRow] The RopSeekRow ROP MUST be supported for hierarchy tables.");
            }
            else if (globleTableType == TableType.RULES_TABLE)
            {
                // The RopSeekRow ROP MUST be supported for attachments tables.
                ModelHelper.CaptureRequirement(849, @"[In Processing RopSeekRow] The RopSeekRow ROP MUST be supported for rules tables.");
            }
            else
            {
                // If the table type is invalid, ecNotSupported will be returned, in this test suite, invalid table
                // is referred as a folderId, for details, see the table initial method in adapter project
                ModelHelper.CaptureRequirement(142, @"[In RopSeekRow ROP] This ROP is valid only on Table objects.");
                ModelHelper.CaptureRequirement(502, @"[In Processing RopSeekRow] The error code ecNotSupported will be returned with value 0x80040102,%x02.01.04.80 ,if the object on which this ROP was sent is not of type table.");
                return TableRopReturnValues.ecNotSupported;
            }

            return TableRopReturnValues.success;
        }
        /// <summary>
        /// This method is used to seek row for a table
        /// </summary>
        /// <param name="origin">Identify the origin position</param>
        /// <param name="forwardSeek">Identify whether to seek row forward</param>
        /// <param name="wantRowMovedCountout">Identify whether to return the actual moved row number</param>
        /// <param name="enoughRow">Identify whether there is enough row to seek</param>
        /// <returns>Table ROP return value</returns>
        public TableRopReturnValues RopSeekRow(BookmarkType origin, bool forwardSeek, bool wantRowMovedCountout, bool enoughRow)
        {
            uint tempRowCount = this.GetRowsCount(forwardSeek); // Gets the number of rows from current location to begin row or last row.

            RopSeekRowRequest seekRowRequest = new RopSeekRowRequest();
            RopSeekRowResponse seekRowResponse;

            seekRowRequest.RopId = 0x18;
            seekRowRequest.LogonId = 0x00;
            seekRowRequest.InputHandleIndex = 0x00;
            seekRowRequest.Origin = (byte)origin;

            if (origin == BookmarkType.BOOKMARK_BEGINNING)
            {
                if (forwardSeek)
                {
                    if (enoughRow)
                    {
                        seekRowRequest.RowCount = (int)this.rowCount;
                    }
                    else
                    {
                        // Identify there is not enough row to forward seek.
                        seekRowRequest.RowCount = (int)(this.rowCount + 1);
                    }
                }
                else
                {
                    if (enoughRow)
                    {
                        seekRowRequest.RowCount = 0;
                    }
                    else
                    {
                        seekRowRequest.RowCount = -1; // Identify there is not enough row to backward seek when the location is beginning.
                    }
                }
            }
            else if (origin == BookmarkType.BOOKMARK_END)
            {
                if (forwardSeek)
                {
                    if (enoughRow)
                    {
                        seekRowRequest.RowCount = 0;
                    }
                    else
                    {
                        seekRowRequest.RowCount = 1;
                    }
                }
                else
                {
                    if (enoughRow)
                    {
                        seekRowRequest.RowCount = -(int)this.rowCount;
                    }
                    else
                    {
                        seekRowRequest.RowCount = -(int)(this.rowCount + 1);
                    }
                }
            }
            else
            {
                if (forwardSeek)
                {
                    if (enoughRow)
                    {
                        seekRowRequest.RowCount = (int)tempRowCount;
                    }
                    else
                    {
                        seekRowRequest.RowCount = (int)(tempRowCount + 1);
                    }
                }
                else
                {
                    if (enoughRow)
                    {
                        seekRowRequest.RowCount = -(int)tempRowCount;
                    }
                    else
                    {
                        seekRowRequest.RowCount = -(int)(tempRowCount + 1);
                    }
                }
            }

            seekRowRequest.WantRowMovedCount = Convert.ToByte(wantRowMovedCountout);

            this.rowCountInSeekRowRequest = seekRowRequest.RowCount;

            this.DoSingleCallROP(seekRowRequest, this.tableHandle, ref this.response, ref this.rawData);
            seekRowResponse = (RopSeekRowResponse)this.response;

            this.ropType = TableRopType.MOVECURSOR;
            bool hasSoughtLess = false;
            bool isActualRowsCount = false;
            if (wantRowMovedCountout)
            {
                hasSoughtLess = Convert.ToBoolean(seekRowResponse.HasSoughtLess);
                if (origin == BookmarkType.BOOKMARK_BEGINNING)
                {
                    if (forwardSeek)
                    {
                        isActualRowsCount = seekRowResponse.RowsSought == this.rowCount;
                    }
                    else
                    {
                        isActualRowsCount = seekRowResponse.RowsSought == 0;
                    }
                }

                if (origin == BookmarkType.BOOKMARK_END)
                {
                    if (forwardSeek)
                    {
                        isActualRowsCount = seekRowResponse.RowsSought == 0;
                    }
                    else
                    {
                        isActualRowsCount = seekRowResponse.RowsSought == -this.rowCount;
                    }
                }

                if (origin == BookmarkType.BOOKMARK_CURRENT)
                {
                    isActualRowsCount = System.Math.Abs(seekRowResponse.RowsSought) == tempRowCount;
                }
            }
            else
            {
                hasSoughtLess = true;
                isActualRowsCount = true;
            }

            if (this.RopSeekRowResponse != null)
            {
                this.RopSeekRowResponse(wantRowMovedCountout, enoughRow, hasSoughtLess, isActualRowsCount);
            }

            return (TableRopReturnValues)seekRowResponse.ReturnValue;
        }
Example #44
0
        public static TableRopReturnValues RopFindRow(FindRowFlags findRowFlags, BookmarkType origin, bool isValidRestriction)
        {
            // This ROP is valid only on contents table, rules table and hierarchy table.
            if (globleTableType == TableType.ATTACHMENTS_TABLE || globleTableType == TableType.PERMISSIONS_TABLE)
            {
                ModelHelper.CaptureRequirement(544, @"[In Processing RopFindRow] The error code ecNotSupported will be returned with value 0x80040102,%x02.01.04.80, if the object on which this ROP was sent is not a contents table, hierarchy table, or rules table.");
                return TableRopReturnValues.ecNotSupported;
            }
            else if (globleTableType == TableType.CONTENT_TABLE)
            {
                // The RopFindRow ROP MUST be supported on contents tables.
                ModelHelper.CaptureRequirement(859, @"[In Processing RopFindRow] The RopFindRow ROP MUST be supported on contents tables.");
            }
            else if (globleTableType == TableType.HIERARCHY_TABLE)
            {
                // The RopFindRow ROP MUST be supported on hierarchy tables.
                ModelHelper.CaptureRequirement(858, @"[In Processing RopFindRow] The RopFindRow ROP MUST be supported on hierarchy tables.");
            }
            else if (globleTableType == TableType.RULES_TABLE)
            {
                // The RopFindRow ROP MUST be supported on rules tables.
                ModelHelper.CaptureRequirement(874, @"[In Processing RopFindRow] The RopFindRow ROP MUST be supported on rules tables.");
            }
            else
            {
                // If the table type is invalid, ecNotSupported will be returned, in this test suite, invalid table
                // is referred as a folderId, for details, see the table initial method in adapter project
                ModelHelper.CaptureRequirement(682, @"[In RopFindRow ROP] This ROP is valid only on Table objects.");
                return TableRopReturnValues.ecNotSupported;
            }

            // Before a success SetColumnsRop, FindRowRop will fail in Exchange2010 and above
            if (!setColumnsFlags.ContainsValue(true))
            {
                if (requirementContainer[827])
                {
                    ModelHelper.CaptureRequirement(827, @"[In Appendix A: Product Behavior] If a RopFindRow ROP is sent before a successful RopSetColumns ROP, then the implementation fails the ROP with ""ecNullObject"". (Microsoft Exchange Server 2010 and above follow this behavior.)");
                    return TableRopReturnValues.ecNullObject;
                }
                else
                {
                    return TableRopReturnValues.unexpected;
                }
            }

            if (!validBookmark && bookmarkCreated)
            {
                // After resetTable Rop, attempts to use the bookmark will fail with ecInvalidBookmark except Exchange 2007.
                if (resetTableDone)
                {
                    Condition.IsTrue((requirementContainer[902] && !requirementContainer[903]) || (!requirementContainer[902] && requirementContainer[903]));
                    if (requirementContainer[902])
                    {
                        ModelHelper.CaptureRequirement(902, @"[In Appendix A: Product Behavior] Implementation does set the ReturnValue field to ""ecInvalidBookmark"" [for RopFindRow], if the client requested that the find be performed from a custom bookmark, as specified in section 2.2.2.1.2, but the bookmark has become invalid because of a RopResetTable ([MS-OXCROPS] section 2.2.5.15) ROP request. (Exchange Server 2010 and above follow this behavior.)");
                        return TableRopReturnValues.ecInvalidBookmark;
                    }

                    if (requirementContainer[903])
                    {
                        ModelHelper.CaptureRequirement(903, @"[In Appendix A: Product Behavior] Implementation returns ecSuccess [for RopFindRow], if the client requested that the find be performed from a custom bookmark, as specified in section 2.2.2.1.2, but the bookmark has become invalid because of a RopResetTable ([MS-OXCROPS] section 2.2.5.15) ROP request. (<33> Section 3.2.5.14: Exchange 2007 returns ecSuccess.)");
                    }
                }

                // After sortTable Rop, attempts to use the bookmark will fail with ecInvalidBookmark except Exchange 2007.
                if (sortTableFlags.ContainsValue(true))
                {
                    Condition.IsTrue((requirementContainer[898] && !requirementContainer[899]) || (!requirementContainer[898] && requirementContainer[899]));
                    if (requirementContainer[898])
                    {
                        ModelHelper.CaptureRequirement(898, @"[In Appendix A: Product Behavior] Implementation does set the ReturnValue field to ""ecInvalidBookmark"" [for RopFindRow], if the client requested that the find be performed from a custom bookmark, as specified in section 2.2.2.1.2, but the bookmark has become invalid because of a RopSortTable ([MS-OXCROPS] section 2.2.5.2) ROP request. (Exchange Server 2010 and above follow this behavior.)");
                        return TableRopReturnValues.ecInvalidBookmark;
                    }

                    if (requirementContainer[899])
                    {
                        ModelHelper.CaptureRequirement(899, @"[In Appendix A: Product Behavior] Implementation returns ecSuccess [for RopFindRow], if the client requested that the find be performed from a custom bookmark, as specified in section 2.2.2.1.2, but the bookmark has become invalid because of a RopSortTable ([MS-OXCROPS] section 2.2.5.2) ROP request. (<33> Section 3.2.5.14: Exchange 2007 returns ecSuccess.)");
                    }
                }

                // After restrict Table Rop, attempts to use the bookmark will fail with ecInvalidBookmark in Exchange 2010 and above.
                if (restrictFlags.ContainsValue(true))
                {
                    if (requirementContainer[900])
                    {
                        ModelHelper.CaptureRequirement(900, @"[In Appendix A: Product Behavior] Implementation does set the ReturnValue field to ""ecInvalidBookmark"" [for RopFindRow], if the client requested that the find be performed from a custom bookmark, as specified in section 2.2.2.1.2, but the bookmark has become invalid because of a RopRestrict ([MS-OXCROPS] section 2.2.5.3) ROP request. (Exchange Server 2010 and above follow this behavior.)");
                        return TableRopReturnValues.ecInvalidBookmark;
                    }
                }
            }

            return TableRopReturnValues.success;
        }
Example #45
0
        public static Bookmark Get(BookmarkType bookmarkType, string content)
        {
            var db = HohoemaLiteDb.GetLocalLiteRepository();

            return(db.SingleOrDefault <Bookmark>(x => x.BookmarkType == bookmarkType && x.Content == content));
        }