예제 #1
0
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //create bookmarks
            Bookmarks bookmarks = new Bookmarks();
            Bookmark childBookmark1 = new Bookmark();
            childBookmark1.PageNumber = 1;
            childBookmark1.Title = "First Child";
            Bookmark childBookmark2 = new Bookmark();
            childBookmark2.PageNumber = 2;
            childBookmark2.Title = "Second Child";

            bookmarks.Add(childBookmark1);
            bookmarks.Add(childBookmark2);

            Bookmark bookmark = new Bookmark();
            bookmark.Action = "GoTo";
            bookmark.PageNumber = 1;
            bookmark.Title = "Parent";

            bookmark.ChildItems = bookmarks;

            //create PdfBookmarkEditor class
            PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
            //bind PDF document
            bookmarkEditor.BindPdf(dataDir+ "input.pdf");
            //create bookmarks
            bookmarkEditor.CreateBookmarks(bookmark);
            //save updated document
            bookmarkEditor.Save(dataDir+ "output.pdf");
        }
 protected override void OnCancelTimer(Bookmark bookmark)
 {
     lock (this.ThisLock)
     {
         this.RegisteredTimers.RemoveTimer(bookmark);
     }
 }
    public static void AddBookmark(string username, string title, string url, string[] tags, string notes)
    {
        //Console.WriteLine("{0} {1} {2} {3} {4}", username, title, url, string.Join(", ", tags), notes);

        BookmarksEntities context = new BookmarksEntities();

        Bookmark newBookmark = new Bookmark();
        newBookmark.User = CreateOrLoadUser(context, username);
        newBookmark.Title = title;
        newBookmark.URL = url;
        newBookmark.Notes = notes;

        foreach (var tagName in tags)
        {
            Tag tag = CreateOrLoadTag(context, tagName);
            newBookmark.Tags.Add(tag);
        }

        //dopulnitelnite tagotve------------------------
        //string[] titleTags = Regex.Split(title, @"\W+");
        string[] titleTags = Regex.Split(title, @"[,'!\. ;?-]+");
        foreach (var titleTagName in titleTags)
        {
            Tag titleTag = CreateOrLoadTag(context, titleTagName);
            newBookmark.Tags.Add(titleTag);
        }
        //dopulnitelnite tagotve-----------------------

        context.Bookmarks.Add(newBookmark);
        context.SaveChanges();
    }
예제 #4
0
        public static void AddBookmarks(string username, string title, string url, string[] tags, string notes)
        {
            var dbCon = new BookmarksEntities();

            using (dbCon)
            {
                var bookmark = new Bookmark();
                bookmark.Notes = notes;
                bookmark.URL = url;
                bookmark.Title = title;

                bookmark.User = CreateOrLoadUser(dbCon, username);

                foreach (var tagName in tags)
                {
                    var tag = CreateOrLoadTag(dbCon, tagName);

                    bookmark.Tags.Add(tag);
                }

                var titleTags = Regex.Split(title, @"[ ,-\.;!?]+");

                foreach (var titleTag in titleTags)
                {
                    var tag = CreateOrLoadTag(dbCon, titleTag);

                    bookmark.Tags.Add(tag);
                }

                dbCon.Bookmarks.Add(bookmark);
                dbCon.SaveChanges();
            }
        }
        public static void Run()
        {
            // ExStart:AddChildBookmark
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks();
            // Create bookmarks
            Aspose.Pdf.Facades.Bookmarks bookmarks = new Aspose.Pdf.Facades.Bookmarks();
            Bookmark childBookmark1 = new Bookmark();
            childBookmark1.PageNumber = 1;
            childBookmark1.Title = "First Child";
            Bookmark childBookmark2 = new Bookmark();
            childBookmark2.PageNumber = 2;
            childBookmark2.Title = "Second Child";

            bookmarks.Add(childBookmark1);
            bookmarks.Add(childBookmark2);

            Bookmark bookmark = new Bookmark();
            bookmark.Action = "GoTo";
            bookmark.PageNumber = 1;
            bookmark.Title = "Parent";

            bookmark.ChildItems = bookmarks;

            // Create PdfBookmarkEditor class
            PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
            // Bind PDF document
            bookmarkEditor.BindPdf(dataDir+ "AddChildBookmark.pdf");
            // Create bookmarks
            bookmarkEditor.CreateBookmarks(bookmark);
            // Save updated document
            bookmarkEditor.Save(dataDir+ "AddChildBookmark_out.pdf");
            // ExEnd:AddChildBookmark
        }
예제 #6
0
 // Constructor
 public ExprNodeAssignment(Bookmark bookmark, ExprNode lhs, ExprNode rhs, Token op)
     : base(bookmark)
 {
     Lhs = lhs;
     Rhs = rhs;
     Op = op;
 }
        private void Continue(NativeActivityContext context, Bookmark bookmark, object obj)
        {
            var args = (object[])obj;
            var userID = (int)args[0];
            UserID.Set(context, userID);

            var result = 0;
            var id = ID.Get(context);
            var item = ProjectProcessService.GetById(id);
            ProjectProcessService.LoadReference(item, i => i.Owner);
            var appraisalResult = ProjectProcessService.GetAppraisalResult(item);
            var userCount = UserService.Count();

            if (appraisalResult.Item1 + appraisalResult.Item2 < userCount * 0.8)//投票人数未达到所有人的 80%
            {
                result = 0;
            }
            else
            {
                if (appraisalResult.Item1 > appraisalResult.Item2 * 2)//同意的人数大于不同意人数的两倍
                {
                    result = 1;
                    InboxService.Create(UserRoleEnum.全员, item.ID, RedirectType.项目流程查看, InboxService.APPRAISAL_FINISH_PROCESS_PROJECT, item.ID.ToString(), appraisalResult.Item1.ToString(), appraisalResult.Item2.ToString(), "通过", item.Owner.NickName);
                    InboxService.Create(UserRoleEnum.运营组成员, item.ID, RedirectType.项目流程处理, InboxService.DESIGN_PROCESS_PROJECT, item.ID.ToString(), item.Owner.NickName);
                }
                else
                {
                    result = -1;
                    InboxService.Create(UserRoleEnum.全员, item.ID, RedirectType.项目流程查看, InboxService.APPRAISAL_FINISH_PROCESS_PROJECT, item.ID.ToString(), appraisalResult.Item1.ToString(), appraisalResult.Item2.ToString(), "不通过", item.Owner.NickName);
                }
            }
            Rusult.Set(context, result);
        }
 // This ctor is only used by subclasses which make their own determination about no persist or not
 protected BookmarkWorkItem(BookmarkCallbackWrapper callbackWrapper, Bookmark bookmark, object value)
     : base(callbackWrapper.ActivityInstance)
 {
     this.callbackWrapper = callbackWrapper;
     this.bookmark = bookmark;
     this.state = value;
 }
예제 #9
0
        /// <summary>
        /// Copies content of the bookmark and adds it to the end of the specified node.
        /// The destination node can be in a different document.
        /// </summary>
        /// <param name="importer">Maintains the import context </param>
        /// <param name="srcBookmark">The input bookmark</param>
        /// <param name="dstNode">Must be a node that can contain paragraphs (such as a Story).</param>
        private static void AppendBookmarkedText(NodeImporter importer, Bookmark srcBookmark, CompositeNode dstNode)
        {
            // This is the paragraph that contains the beginning of the bookmark.
            Paragraph startPara = (Paragraph)srcBookmark.BookmarkStart.ParentNode;

            // This is the paragraph that contains the end of the bookmark.
            Paragraph endPara = (Paragraph)srcBookmark.BookmarkEnd.ParentNode;

            if ((startPara == null) || (endPara == null))
                throw new InvalidOperationException("Parent of the bookmark start or end is not a paragraph, cannot handle this scenario yet.");

            // Limit ourselves to a reasonably simple scenario.
            if (startPara.ParentNode != endPara.ParentNode)
                throw new InvalidOperationException("Start and end paragraphs have different parents, cannot handle this scenario yet.");

            // We want to copy all paragraphs from the start paragraph up to (and including) the end paragraph,
            // therefore the node at which we stop is one after the end paragraph.
            Node endNode = endPara.NextSibling;

            // This is the loop to go through all paragraph-level nodes in the bookmark.
            for (Node curNode = startPara; curNode != endNode; curNode = curNode.NextSibling)
            {
                // This creates a copy of the current node and imports it (makes it valid) in the context
                // of the destination document. Importing means adjusting styles and list identifiers correctly.
                Node newNode = importer.ImportNode(curNode, true);

                // Now we simply append the new node to the destination.
                dstNode.AppendChild(newNode);
            }
        }
예제 #10
0
        private void OnBookmarkCallback(NativeActivityContext context, Bookmark bookmark)
        {
            var log = context.Resolve<ILoggerFactory>() != null
                    ? context.Resolve<ILoggerFactory>().Create(typeof(SubProcess))
                    : null;
            var parser = context.Resolve<IScriptParser>();
            var extension = context.GetExtension<DataFieldExtension>();

            //完成规则解析
            if (this.Result != null
                && parser != null
                && this.FinishRule != null
                && this.FinishRule.Count > 0)
            {
                foreach (var i in this.FinishRule)
                    if (parser.EvaluateRule(i.Value, extension))
                    {
                        this.Result.Set(context, i.Key);
                        if (log != null)
                            log.InfoFormat("SubProcess节点完成规则“{0}”测试通过,将进入节点“{1}”", i.Value, i.Key);
                        break;
                    }
            }
            //所有逻辑完成才可删除,若上述逻辑失败则将此书签用于错误恢复
            context.RemoveBookmark(bookmark);
        }
예제 #11
0
        public void Add(string title, string url, string description, string snapshotBase64String, IEnumerable<Tag> tags, Website website, string userId)
        {
            var bookmark = new Bookmark
            {
                Description = description,
                UserId = userId,
                Title = title,
                Url = url,
                SnapshotBase64String = snapshotBase64String

            };

            //check for existing website
            var existingWebsite = websiteService.GetWebsiteByName(website.Name, userId).FirstOrDefault();
            if (existingWebsite != null)
            {
                bookmark.WebSite = existingWebsite;
            }
            else
            {
                var websiteToAdd = new Website
                {
                    Name = website.Name,
                    FaviconBase64String = website.FaviconBase64String
                };

                bookmark.WebSite = website;
            }

            AddTags(bookmark, tags, userId);

            this.bookmarks.Add(bookmark);
            this.bookmarks.SaveChanges();
        }
 public static Bookmark CreateBookmark(int bookmarkId, int userId, int ordinal)
 {
     Bookmark bookmark = new Bookmark();
     bookmark.BookmarkId = bookmarkId;
     bookmark.UserId = userId;
     bookmark.Ordinal = ordinal;
     return bookmark;
 }
예제 #13
0
        void Continue(NativeActivityContext context, Bookmark bookmark, object obj)
        {
            var eventArgs = obj as WorkflowNotificationEventArgs;
            if (eventArgs.NotificationType != WorkflowNotificationObserver.CONTENTCHANGEDNOTIFICATIONTYPE)
                return;

            InstanceManager.ReleaseWait(notificationId.Get(context));
        }
예제 #14
0
파일: Main.cs 프로젝트: Jackie-Innover/Wox
        private bool MatchProgram(Bookmark bookmark, FuzzyMatcher matcher)
        {
            if ((bookmark.Score = matcher.Evaluate(bookmark.Name).Score) > 0) return true;
            if ((bookmark.Score = matcher.Evaluate(bookmark.PinyinName).Score) > 0) return true;
            if ((bookmark.Score = matcher.Evaluate(bookmark.Url).Score / 10) > 0) return true;

            return false;
        }
예제 #15
0
 // Add another variable declaration
 public void AddDeclaration(Bookmark bookmark, string Name, ast.Expression InitialValue)
 {
     var v = new Variable();
     v.Bookmark = bookmark;
     v.Name = Name;
     v.InitialValue = InitialValue;
     Variables.Add(v);
 }
예제 #16
0
 /// <summary>
 /// 添加子流程启动信息
 /// </summary>
 /// <param name="context"></param>
 /// <param name="referredBookmark"></param>
 /// <param name="activityName"></param>
 /// <param name="flowNodeIndex"></param>
 public void AddSubProcess(NativeActivityContext context, Bookmark referredBookmark, string activityName, int flowNodeIndex)
 {
     this._instances.Add(new SubProcessActivityInstance(context.WorkflowInstanceId
         , flowNodeIndex
         , context.ActivityInstanceId
         , activityName
         , referredBookmark.Name));
 }
        private void Initialize()
        {
            // Create new map with a base map
            Map myMap = new Map(Basemap.CreateImageryWithLabels());

            // Set the map view, map property to the base map
            MyMapView.Map = myMap;

            // Create a set of predefined bookmarks; each one follows the pattern of:
            // ~ Initialize a viewpoint pointing to a latitude longitude
            // ~ Create a new bookmark
            // ~ Give the bookmark a name
            // ~ Assign the viewpoint
            // ~ Add the bookmark to bookmark collection of the map
            // ~ Add the bookmark to the UI combo box for the user to choose from 

            // Bookmark-1
            Viewpoint myViewpoint1 = new Viewpoint(27.3805833, 33.6321389, 6000);
            Bookmark myBookmark1 = new Bookmark();
            myBookmark1.Name = "Mysterious Desert Pattern";
            myBookmark1.Viewpoint = myViewpoint1;
            MyMapView.Map.Bookmarks.Add(myBookmark1);
            bookmarkChooser.Items.Add(myBookmark1);

            // Bookmark-2
            Viewpoint myViewpoint2 = new Viewpoint(37.401573, -116.867808, 6000);
            Bookmark myBookmark2 = new Bookmark();
            myBookmark2.Name = "Strange Symbol";
            myBookmark2.Viewpoint = myViewpoint2;
            MyMapView.Map.Bookmarks.Add(myBookmark2);
            bookmarkChooser.Items.Add(myBookmark2);

            // Bookmark-3
            Viewpoint myViewpoint3 = new Viewpoint(-33.867886, -63.985, 40000);
            Bookmark myBookmark3 = new Bookmark();
            myBookmark3.Name = "Guitar-Shaped Forest";
            myBookmark3.Viewpoint = myViewpoint3;
            MyMapView.Map.Bookmarks.Add(myBookmark3);
            bookmarkChooser.Items.Add(myBookmark3);

            // Bookmark-4
            Viewpoint myViewpoint4 = new Viewpoint(44.525049, -110.83819, 6000);
            Bookmark myBookmark4 = new Bookmark();
            myBookmark4.Name = "Grand Prismatic Spring";
            myBookmark4.Viewpoint = myViewpoint4;
            MyMapView.Map.Bookmarks.Add(myBookmark4);
            bookmarkChooser.Items.Add(myBookmark4);

            // Set the initial combo box selection to the lat bookmark added
            bookmarkChooser.SelectedItem = MyMapView.Map.Bookmarks.Last();

            // Zoom to the last bookmark
            myMap.InitialViewpoint = myMap.Bookmarks.Last().Viewpoint;

            // Hide the controls for adding an additional bookmark
            BorderAddBookmark.Visibility = Visibility.Collapsed;
        }
예제 #18
0
파일: Manager.cs 프로젝트: gahadzikwa/GAPP
 public void AddBookmarkToMenu(Bookmark seq)
 {
     MenuItem mi = new MenuItem();
     mi.Header = seq.Name;
     mi.Name = seq.ID;
     mi.Command = ExecuteBookmarkCommand;
     mi.CommandParameter = seq;
     Core.ApplicationData.Instance.MainWindow.gccombmmnu.Items.Add(mi);
 }
예제 #19
0
 private void OnBookmarkCallback(NativeActivityContext context, Bookmark bookmark, object value)
 {
     //HACK:【重要】子流程节点书签回调逻辑较复杂,容易出错,需要对异常进行处理以便在该回调级别重试而避免整个节点的重试
     this.ExecuteAndDealWithError(() => 
         this.OnBookmarkCallback(context, bookmark)
         , context
         //复用原书签
         , bookmark);
 }
 /// <summary>
 /// Gets a specific article from a bookmark based on its href.
 /// </summary>
 /// <param name="bookmark">The bookmark that has the article to be returned.</param>
 /// <returns>The full article as a string. This is useful for immediately saving it.</returns>
 public async Task<Article> GetArticle(Bookmark bookmark)
 {
     var request = new RestRequest(bookmark.ArticleHref.Replace("/api/rest/v1", ""));
     var content = await ReadabilityClient.MakeRequestAsync(request).ConfigureAwait(false);
     var js = new StringReader(content);
     var jr = new JsonTextReader(js);
     var serializer = new JsonSerializer();
     return serializer.Deserialize<Article>(jr);
 }
 /// <summary>
 /// Used to resume bookmark outside workflow.
 /// </summary>
 /// <param name="bookmark">The value of Bookmark to be resumed</param>
 public void ResumeBookmark(Bookmark bookmark)
 {
     // This method is necessary due to CSDMain 223257.
     IAsyncResult asyncResult = this.instance.BeginResumeBookmark(bookmark, null, Fx.ThunkCallback(new AsyncCallback(StateMachineExtension.OnResumeBookmarkCompleted)), this.instance);
     if (asyncResult.CompletedSynchronously)
     {
         this.instance.EndResumeBookmark(asyncResult);
     }
 }
 internal void Initialize(FolderWatcherExtension extension, Bookmark bookmark, string folder, string pattern, bool subfolders, string subscriberDisplayName)
 {
     if (this.IsInitialized)
     {
         throw new InvalidOperationException(String.Format(
             Properties.Resources.SubscriptionHandleAlreadyInitialized, subscriberDisplayName));
     }
     this.Id = extension.Subscribe(bookmark, folder, pattern, subfolders);
 }
 public BookmarkWorkItem(ActivityExecutor executor, bool isExternal, BookmarkCallbackWrapper callbackWrapper, Bookmark bookmark, object value)
     : this(callbackWrapper, bookmark, value)
 {
     if (isExternal)
     {
         executor.EnterNoPersist();
         this.ExitNoPersistRequired = true;
     }
 }
 protected override void OnRegisterTimer(TimeSpan timeout, Bookmark bookmark)
 {
     if (timeout < TimeSpan.MaxValue)
     {
         lock (this.ThisLock)
         {
             this.RegisteredTimers.AddTimer(timeout, bookmark);
         }
     }
 }
        /// <summary>
        /// Zooms to the selected bookmark
        /// </summary>
        /// <param name="bmk">A bookmark</param>
        /// <returns>Task returning the bookmark</returns>
        public static async Task ZoomToSelectedBmk(Bookmark bmk)
        {
            if (bmk == null)
                return;

            if (MapView.Active != null)
                return;

            await MapView.Active.ZoomToAsync(bmk); //zoom to map
        }
        internal void OnNotificationCallback(NativeActivityContext context, Bookmark bookmark, Object value)
        {
            var notification = (NotificationFailure) value;

            NotificationDescriptor.Set(context, notification.NotificationDescriptor);

            // Exit the no persist zone
            var handle = _noPersistHandle.Get(context);
            handle.Exit(context);
        }
 public ActivityExecutionWorkItem CreateWorkItem(ActivityExecutor executor, bool isExternal, Bookmark bookmark, object value)
 {
     if (this.IsCallbackNull)
     {
         return executor.CreateEmptyWorkItem(this.ActivityInstance);
     }
     else
     {
         return new BookmarkWorkItem(executor, isExternal, this, bookmark, value);
     }
 }
 public Bookmark CreateBookmark(string name, BookmarkCallback callback, System.Activities.ActivityInstance owningInstance, BookmarkOptions options)
 {
     Bookmark key = new Bookmark(name);
     if ((this.bookmarks != null) && this.bookmarks.ContainsKey(key))
     {
         throw FxTrace.Exception.AsError(new InvalidOperationException(System.Activities.SR.BookmarkAlreadyExists(name)));
     }
     this.AddBookmark(key, callback, owningInstance, options);
     this.UpdateAllExclusiveHandles(key, owningInstance);
     return key;
 }
예제 #29
0
		private void btnCreateOrEdit_Click(object sender, EventArgs e)
		{
			if (bookmark == null)
				bookmark = new Bookmark();
			bookmark.Description = tbDescription.Text;
			bookmark.FileNames = tbFileNames.Text;
			bookmark.SearchPattern = tbSearchFor.Text;
			bookmark.ReplacePattern = tbReplaceWith.Text;
			DialogResult = DialogResult.OK;
			Close();
		}
        public ActionResult View(Bookmark bookmark)
        {
            if (bookmark == null)
            {
                return this.HttpNotFound();
            }

            var bookmarkView = Mapper.Map<BookmarkDetailsViewModel>(bookmark);

            return this.View(bookmarkView);
        }
예제 #31
0
 // Constructor
 public StatementReturnThrow(Bookmark bookmark, Token op) : base(bookmark)
 {
     Op = op;
 }
예제 #32
0
 // Constructor
 public ExprNodeParens(Bookmark bookmark, ExprNode inner) : base(bookmark)
 {
     Inner = inner;
 }
예제 #33
0
        public BookmarkResumptionResult TryGenerateWorkItem(ActivityExecutor executor, ref Bookmark bookmark, BookmarkScope scope, object value, ActivityInstance isolationInstance, bool nonScopedBookmarksExist, out ActivityExecutionWorkItem workItem)
        {
            Fx.Assert(scope != null, "We should never have a null sub instance.");

            BookmarkManager manager = null;

            workItem = null;
            BookmarkScope lookupScope = scope;

            if (scope.IsDefault)
            {
                lookupScope = this.defaultScope;
            }

            // We don't really care about the return value since we'll
            // use null to know we should check uninitialized sub instances
            this.bookmarkManagers.TryGetValue(lookupScope, out manager);

            if (manager == null)
            {
                Fx.Assert(lookupScope != null, "The sub instance should not be default if we are here.");

                BookmarkResumptionResult finalResult = BookmarkResumptionResult.NotFound;

                // Check the uninitialized sub instances for a matching bookmark
                if (this.uninitializedScopes != null)
                {
                    for (int i = 0; i < this.uninitializedScopes.Count; i++)
                    {
                        BookmarkScope uninitializedScope = this.uninitializedScopes[i];

                        Fx.Assert(this.bookmarkManagers.ContainsKey(uninitializedScope), "We must always have the uninitialized sub instances.");

                        Bookmark internalBookmark;
                        BookmarkCallbackWrapper  callbackWrapper;
                        BookmarkResumptionResult resumptionResult;
                        if (!this.bookmarkManagers[uninitializedScope].TryGetBookmarkFromInternalList(bookmark, out internalBookmark, out callbackWrapper))
                        {
                            resumptionResult = BookmarkResumptionResult.NotFound;
                        }
                        else if (IsExclusiveScopeUnstable(internalBookmark))
                        {
                            resumptionResult = BookmarkResumptionResult.NotReady;
                        }
                        else
                        {
                            resumptionResult = this.bookmarkManagers[uninitializedScope].TryGenerateWorkItem(executor, true, ref bookmark, value, isolationInstance, out workItem);
                        }

                        if (resumptionResult == BookmarkResumptionResult.Success)
                        {
                            // We are using InitializeBookmarkScopeWithoutKeyAssociation because we know this is a new uninitialized scope and
                            // the key we would associate is already associated. And if we did the association here, the subsequent call to
                            // FlushBookmarkScopeKeys would try to flush it out, but it won't have the transaction correct so will hang waiting for
                            // the transaction that has the PersistenceContext locked to complete. But it won't complete successfully until
                            // we finish processing here.
                            InitializeBookmarkScopeWithoutKeyAssociation(uninitializedScope, scope.Id);

                            // We've found what we were looking for
                            return(BookmarkResumptionResult.Success);
                        }
                        else if (resumptionResult == BookmarkResumptionResult.NotReady)
                        {
                            // This uninitialized sub-instance has a matching bookmark but
                            // it can't currently be resumed.  We won't return BookmarkNotFound
                            // because of this.
                            finalResult = BookmarkResumptionResult.NotReady;
                        }
                        else
                        {
                            if (finalResult == BookmarkResumptionResult.NotFound)
                            {
                                // If we still are planning on returning failure then
                                // we'll incur the cost of seeing if this scope is
                                // stable or not.

                                if (!IsStable(uninitializedScope, nonScopedBookmarksExist))
                                {
                                    // There exists an uninitialized scope which is unstable.
                                    // At the very least this means we'll return NotReady since
                                    // this uninitialized scope might eventually contain this
                                    // bookmark.
                                    finalResult = BookmarkResumptionResult.NotReady;
                                }
                            }
                        }
                    }
                }

                return(finalResult);
            }
            else
            {
                Bookmark bookmarkFromList;
                BookmarkCallbackWrapper  callbackWrapper;
                BookmarkResumptionResult resumptionResult;
                if (!manager.TryGetBookmarkFromInternalList(bookmark, out bookmarkFromList, out callbackWrapper))
                {
                    resumptionResult = BookmarkResumptionResult.NotFound;
                }
                else
                {
                    if (IsExclusiveScopeUnstable(bookmarkFromList))
                    {
                        resumptionResult = BookmarkResumptionResult.NotReady;
                    }
                    else
                    {
                        resumptionResult = manager.TryGenerateWorkItem(executor, true, ref bookmark, value, isolationInstance, out workItem);
                    }
                }


                if (resumptionResult == BookmarkResumptionResult.NotFound)
                {
                    if (!IsStable(lookupScope, nonScopedBookmarksExist))
                    {
                        resumptionResult = BookmarkResumptionResult.NotReady;
                    }
                }

                return(resumptionResult);
            }
        }
예제 #34
0
 // Constructor
 public StatementTryCatchFinally(Bookmark bookmark) : base(bookmark)
 {
 }
예제 #35
0
 protected static string CreateReminderName(Bookmark bookmark) =>
 WorkflowNamespace.ReminderPrefixForBookmarks + bookmark.ToString();
예제 #36
0
 protected override void BookmarkResumptionCallback(NativeActivityContext context, Bookmark bookmark, object value)
 {
     try
     {
         base.BookmarkResumptionCallback(context, bookmark, value);
     }
     catch (Exception e)
     {
         if (ContinueOnError.Get(context))
         {
             Trace.TraceError(e.ToString());
         }
         else
         {
             throw;
         }
     }
 }
예제 #37
0
 public void RemoveBookmark(Bookmark bookmark)
 {
     Bookmarks.Remove(bookmark);
 }
예제 #38
0
 private void AddBookmark(Bookmark bookmark)
 {
     Bookmarks.Add(bookmark);
 }
예제 #39
0
 // Return true/false if the notebook already has this bookmark
 public bool HasBookmark(Bookmark bookmark) => Bookmarks.Contains(bookmark);
예제 #40
0
 public TimerData(Bookmark timerBookmark, DateTime expirationTime)
 {
     this.Bookmark       = timerBookmark;
     this.ExpirationTime = expirationTime;
 }
 public void OnResumeBookmark(NativeActivityContext context, Bookmark bookmark, object obj)
 {
     // When the Bookmark is resumed, assign its value to
     // the Result argument.
     Result.Set(context, (string)obj);
 }
예제 #42
0
 public bool TryGetValue(Bookmark bookmark, out TimerData timerData)
 {
     return(_dictionary.TryGetValue(bookmark, out timerData));
 }
예제 #43
0
 public void UnregisterReminder(Bookmark bookmark)
 {
     UnregisterReminder(CreateReminderName(bookmark));
 }
        public void Refresh()
        {
            if (Instance != null)
            {
                if (_InstanceUpMenuItem == null)
                {
                    _InstanceUpMenuItem = new ToolStripMenuItem(Instance.Machines.Length > 1 ? "Up All" : "Up", Resources.up, UpAllMachines_Click);
                    MenuItem.DropDownItems.Add(_InstanceUpMenuItem);
                }

                if (_SSHMenuItem == null)
                {
                    _SSHMenuItem = new ToolStripMenuItem("SSH", Resources.ssh, SSHInstance_Click);
                    MenuItem.DropDownItems.Add(_SSHMenuItem);
                }

                if (_InstanceReloadMenuItem == null)
                {
                    _InstanceReloadMenuItem = new ToolStripMenuItem(Instance.Machines.Length > 1 ? "Reload All" : "Reload", Resources.reload, ReloadAllMachines_Click);
                    MenuItem.DropDownItems.Add(_InstanceReloadMenuItem);
                }

                if (_InstanceSuspendMenuItem == null)
                {
                    _InstanceSuspendMenuItem = new ToolStripMenuItem(Instance.Machines.Length > 1 ? "Suspend All" : "Suspend", Resources.suspend, SuspendAllMachines_Click);
                    MenuItem.DropDownItems.Add(_InstanceSuspendMenuItem);
                }

                if (_InstanceHaltMenuItem == null)
                {
                    _InstanceHaltMenuItem = new ToolStripMenuItem(Instance.Machines.Length > 1 ? "Halt All" : "Halt", Resources.halt, HaltAllMachines_Click);
                    MenuItem.DropDownItems.Add(_InstanceHaltMenuItem);
                }

                if (_InstanceDestroyMenuItem == null)
                {
                    _InstanceDestroyMenuItem = new ToolStripMenuItem(Instance.Machines.Length > 1 ? "Destroy All" : "Destroy", Resources.destroy, DestroyAllMachines_Click);
                    MenuItem.DropDownItems.Add(_InstanceDestroyMenuItem);
                }

                if (_InstanceProvisionMenuItem == null)
                {
                    _InstanceProvisionMenuItem = new ToolStripMenuItem(Instance.Machines.Length > 1 ? "Provision All" : "Provision", Resources.provision, ProvisionAllMachines_Click);
                    MenuItem.DropDownItems.Add(_InstanceProvisionMenuItem);
                }

                if (_InstanceRsyncMenuItem == null)
                {
                    _InstanceRsyncMenuItem = new ToolStripMenuItem(Instance.Machines.Length > 1 ? "Rsync All" : "Rsync", Resources.rsync, RsyncAllMachines_Click);
                    MenuItem.DropDownItems.Add(_InstanceRsyncMenuItem);
                }

                if (_InstanceRsyncAutoMenuItem == null)
                {
                    _InstanceRsyncAutoMenuItem = new ToolStripMenuItem("Rsync-Auto", Resources.rsyncauto, RsyncAutoInstance_Click);
                    MenuItem.DropDownItems.Add(_InstanceRsyncAutoMenuItem);
                }

                if (_ActionSeparator == null)
                {
                    _ActionSeparator = new ToolStripSeparator();
                    MenuItem.DropDownItems.Add(_ActionSeparator);
                }

                if (_OpenInExplorerMenuItem == null)
                {
                    _OpenInExplorerMenuItem = Util.MakeBlankToolstripMenuItem("Open In Explorer", OpenInExplorerMenuItem_Click);
                    MenuItem.DropDownItems.Add(_OpenInExplorerMenuItem);
                }

                if (_OpenInTerminalMenuItem == null)
                {
                    _OpenInTerminalMenuItem = Util.MakeBlankToolstripMenuItem("Open In Terminal", OpenInTerminalMenuItem_Click);
                    MenuItem.DropDownItems.Add(_OpenInTerminalMenuItem);
                }

                if (_ChooseProviderMenuItem == null)
                {
                    _ChooseProviderMenuItem = new ToolStripMenuItem(String.Format("Provider: {0}", Instance.ProviderIdentifier ?? "Unknown"));
                    VagrantManager.Instance.GetProviderIdentifiers().ToList().ForEach(identifier => {
                        ToolStripMenuItem menuItem = Util.MakeBlankToolstripMenuItem(identifier, UpdateProviderIdentifier_Click);
                        menuItem.Tag = identifier;
                        _ChooseProviderMenuItem.DropDownItems.Add(menuItem);
                    });
                    MenuItem.DropDownItems.Add(_ChooseProviderMenuItem);
                }
                else
                {
                    _ChooseProviderMenuItem.Text = String.Format("Provider: {0}", Instance.ProviderIdentifier ?? "Unknown");
                }

                if (_RemoveBookmarkMenuItem == null)
                {
                    _RemoveBookmarkMenuItem = Util.MakeBlankToolstripMenuItem("Remove from bookmarks", RemoveBookmarkMenuItem_Click);
                    MenuItem.DropDownItems.Add(_RemoveBookmarkMenuItem);
                }

                if (_AddBookmarkMenuItem == null)
                {
                    _AddBookmarkMenuItem = Util.MakeBlankToolstripMenuItem("Add to bookmarks", AddBookmarkMenuItem_Click);
                    MenuItem.DropDownItems.Add(_AddBookmarkMenuItem);
                }

                if (Instance.HasVagrantFile())
                {
                    int runningCount   = Instance.GetRunningMachineCount();
                    int SuspendedCount = Instance.GetMachineCountWithState(VagrantMachineState.SavedState);

                    if (runningCount == 0 && SuspendedCount == 0)
                    {
                        MenuItem.Image = Resources.status_icon_off;
                    }
                    else if (runningCount == this.Instance.Machines.Length)
                    {
                        MenuItem.Image = Resources.status_icon_on;
                    }
                    else
                    {
                        MenuItem.Image = Resources.status_icon_suspended;
                    }

                    if (runningCount < Instance.Machines.Count())
                    {
                        _InstanceUpMenuItem.Visible        = true;
                        _SSHMenuItem.Visible               = false;
                        _InstanceReloadMenuItem.Visible    = false;
                        _InstanceSuspendMenuItem.Visible   = false;
                        _InstanceHaltMenuItem.Visible      = false;
                        _InstanceProvisionMenuItem.Visible = false;
                        _InstanceRsyncMenuItem.Visible     = false;
                        _InstanceRsyncAutoMenuItem.Visible = false;
                    }

                    if (runningCount > 0)
                    {
                        _InstanceUpMenuItem.Visible        = false;
                        _SSHMenuItem.Visible               = true;
                        _InstanceReloadMenuItem.Visible    = true;
                        _InstanceSuspendMenuItem.Visible   = true;
                        _InstanceHaltMenuItem.Visible      = true;
                        _InstanceProvisionMenuItem.Visible = true;
                        _InstanceRsyncMenuItem.Visible     = true;
                        _InstanceRsyncAutoMenuItem.Visible = true;
                    }

                    // hide terminal based actions if more than one instance
                    if (Instance.Machines.Count() > 1)
                    {
                        _SSHMenuItem.Visible = false;
                        _InstanceRsyncAutoMenuItem.Visible = false;
                    }

                    if (BookmarkManager.Instance.GetBookmarkWithPath(Instance.Path) != null)
                    {
                        _RemoveBookmarkMenuItem.Visible = true;
                        _AddBookmarkMenuItem.Visible    = false;
                    }
                    else
                    {
                        _AddBookmarkMenuItem.Visible    = true;
                        _RemoveBookmarkMenuItem.Visible = false;
                    }
                }
                else
                {
                    MenuItem.DropDownItems.Clear();
                }

                Bookmark bookmark = BookmarkManager.Instance.GetBookmarkWithPath(Instance.Path);
                if (bookmark != null)
                {
                    MenuItem.Text = "[B] " + bookmark.DisplayName;
                }
                else
                {
                    string title;
                    if (Properties.Settings.Default.UsePathAsInstanceDisplayName)
                    {
                        title = Instance.Path;
                    }
                    else
                    {
                        title = Instance.DisplayName;
                    }

                    if (Instance.Machines.Count() > 0 && Properties.Settings.Default.IncludeMachineNamesInMenu)
                    {
                        title = String.Format("{0} ({1})", title, String.Join(", ", Instance.Machines.Select(machine => machine.Name).ToArray()));
                    }

                    MenuItem.Text = title;
                }

                if (_MachineSeparator == null)
                {
                    _MachineSeparator = new ToolStripSeparator();
                    MenuItem.DropDownItems.Add(_MachineSeparator);
                }

                _MachineMenuItems.ForEach(machineItem => {
                    MenuItem.DropDownItems.Remove(machineItem);
                });

                _MachineMenuItems.Clear();

                if (Instance.Machines.Count() > 1)
                {
                    _MachineSeparator.Visible = true;

                    Array.ForEach(Instance.Machines, machine => {
                        ToolStripMenuItem machineItem = new ToolStripMenuItem(machine.Name);

                        ToolStripMenuItem machineUpMenuItem = new ToolStripMenuItem("Up", Resources.up, UpMachine_Click)
                        {
                            Tag = machine
                        };
                        ToolStripMenuItem machineSSHMenuItem = new ToolStripMenuItem("SSH", Resources.ssh, SSHMachine_Click)
                        {
                            Tag = machine
                        };
                        ToolStripMenuItem machineReloadMenuItem = new ToolStripMenuItem("Reload", Resources.reload, ReloadMachine_Click)
                        {
                            Tag = machine
                        };
                        ToolStripMenuItem machineSuspendMenuItem = new ToolStripMenuItem("Suspend", Resources.suspend, SuspendMachine_Click)
                        {
                            Tag = machine
                        };
                        ToolStripMenuItem machineHaltMenuItem = new ToolStripMenuItem("Halt", Resources.halt, HaltMachine_Click)
                        {
                            Tag = machine
                        };
                        ToolStripMenuItem machineDestroyMenuItem = new ToolStripMenuItem("Destroy", Resources.destroy, DestroyMachine_Click)
                        {
                            Tag = machine
                        };
                        ToolStripMenuItem machineProvisionMenuItem = new ToolStripMenuItem("Provision", Resources.provision, ProvisionMachine_Click)
                        {
                            Tag = machine
                        };
                        ToolStripMenuItem machineRsyncMenuItem = new ToolStripMenuItem("Rsync", Resources.rsync, RsyncMachine_Click)
                        {
                            Tag = machine
                        };
                        ToolStripMenuItem machineRsyncAutoMenuItem = new ToolStripMenuItem("Rsync-Auto", Resources.rsyncauto, RsyncAutoMachine_Click)
                        {
                            Tag = machine
                        };

                        machineItem.DropDownItems.AddRange(new ToolStripMenuItem[] {
                            machineUpMenuItem,
                            machineSSHMenuItem,
                            machineReloadMenuItem,
                            machineSuspendMenuItem,
                            machineHaltMenuItem,
                            machineDestroyMenuItem,
                            machineProvisionMenuItem,
                            machineRsyncMenuItem,
                            machineRsyncAutoMenuItem
                        });

                        _MachineMenuItems.Add(machineItem);
                        MenuItem.DropDownItems.Insert(MenuItem.DropDownItems.IndexOf(_MachineSeparator) + _MachineMenuItems.Count, machineItem);

                        machineItem.Image = machine.State == VagrantMachineState.RunningState ? Resources.status_icon_on : machine.State == VagrantMachineState.SavedState ? Resources.status_icon_suspended : Resources.status_icon_off;

                        if (machine.State == VagrantMachineState.RunningState)
                        {
                            machineUpMenuItem.Visible        = false;
                            machineSSHMenuItem.Visible       = true;
                            machineReloadMenuItem.Visible    = true;
                            machineSuspendMenuItem.Visible   = true;
                            machineHaltMenuItem.Visible      = true;
                            machineProvisionMenuItem.Visible = true;
                            machineRsyncMenuItem.Visible     = true;
                            machineRsyncAutoMenuItem.Visible = true;
                        }
                        else
                        {
                            machineUpMenuItem.Visible        = true;
                            machineSSHMenuItem.Visible       = false;
                            machineReloadMenuItem.Visible    = false;
                            machineSuspendMenuItem.Visible   = false;
                            machineHaltMenuItem.Visible      = false;
                            machineProvisionMenuItem.Visible = false;
                            machineRsyncMenuItem.Visible     = false;
                            machineRsyncAutoMenuItem.Visible = false;
                        }
                    });
                }
                else
                {
                    _MachineSeparator.Visible = false;
                }
            }
            else
            {
                MenuItem.DropDownItems.Clear();
            }
        }
예제 #45
0
 // Constructor
 public CatchClause(Bookmark bookmark) : base(bookmark)
 {
 }
예제 #46
0
 public void ResumeBookmark(Bookmark bookmark, object value)
 {
     this.instance.EndResumeBookmark(
         this.instance.BeginResumeBookmark(bookmark, value, null, null));
 }
예제 #47
0
 public Task <IConnection> AcquireAsync(AccessMode mode, string database, string impersonatedUser, Bookmark bookmark)
 {
     return(Task.FromResult(Connection));
 }
 public ActionResult Create(Bookmark bookmark)
 {
     bookmark.DateCreated = DateTime.UtcNow;
     _bookmarkService.Add(bookmark);
     return(RedirectToAction("Index"));
 }
예제 #49
0
 // Constructor
 public StatementReturnThrow(Bookmark bookmark, Token op, Expression value) : base(bookmark)
 {
     Op    = op;
     Value = value;
 }
예제 #50
0
 void OnBookmarkCallback(NativeActivityContext context, Bookmark bookmark, object obj)
 {
     // keep bookmark, we want to support being triggerede multiple times, so bookmark needs to be keep incase workflow is restarted
     // context.RemoveBookmark(bookmark.Name);
 }
예제 #51
0
 public void OnResumeBookmark(NativeActivityContext context, Bookmark bookmark, object obj)
 {
     NextWorkFlow.Set(context, nextWorkFlow);
     context.RemoveAllBookmarks();
 }
예제 #52
0
 public ReminderInfo(Bookmark bookmark, ReminderState reminderState, DateTime dueTime)
 {
     Bookmark      = bookmark;
     DueTime       = dueTime;
     ReminderState = reminderState;
 }
예제 #53
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Console.WriteLine("Milestone SDK Bookmarks demo (XProtect Corporate only)");
            Console.WriteLine("Creates 2 new bookmarks and retrieves them using ");
            Console.WriteLine("  1) BookmarkSearchTime ");
            Console.WriteLine("  2) BookmarkSearchFromBookmark");
            Console.WriteLine("  3) BookmarkGet");
            Console.WriteLine("");

            // Initialize the SDK - must be done in stand alone
            VideoOS.Platform.SDK.Environment.Initialize();
            VideoOS.Platform.SDK.UI.Environment.Initialize();           // Initialize ActiveX references, e.g. usage of ImageViewerActiveX etc

            #region Connect to the server
            VideoOS.Platform.SDK.UI.LoginDialog.DialogLoginForm loginForm = new VideoOS.Platform.SDK.UI.LoginDialog.DialogLoginForm(SetLoginResult, IntegrationId, IntegrationName, Version, ManufacturerName);
            Application.Run(loginForm);                                                         // Show and complete the form and login to server
            if (!Connected)
            {
                Console.WriteLine("Failed to connect or login");
                Console.ReadKey();
                return;
            }

            if (EnvironmentManager.Instance.MasterSite.ServerId.ServerType == ServerId.EnterpriseServerType)
            {
                Console.WriteLine("Bookmark is not supported on this product.");
                Console.ReadKey();
                return;
            }
            #endregion

            #region Select a camera
            Item _selectItem1 = null;
            VideoOS.Platform.UI.ItemPickerForm form = new VideoOS.Platform.UI.ItemPickerForm();
            form.KindFilter = Kind.Camera;
            form.AutoAccept = true;
            form.Init(Configuration.Instance.GetItems());
            if (form.ShowDialog() == DialogResult.OK)
            {
                _selectItem1 = form.SelectedItem;
            }
            if (_selectItem1 == null)
            {
                Console.WriteLine("Failed to pick a camera");
                Console.ReadKey();
                return;
            }
            if (_selectItem1.FQID.ServerId.ServerType == ServerId.EnterpriseServerType)
            {
                Console.WriteLine("Bookmark is not supported on this product.");
                Console.ReadKey();
                return;
            }

            FQID cameraFqid = _selectItem1.FQID;

            #endregion

            DateTime timeNow = DateTime.Now;

            // get cameras for each recording server


            // now-5:10min:                                       BookmarkSearchTime start
            // now-5:00min: (beginTime)                                         |                                                  BookmarkGet
            // now-4:59min: start recording 1                                   |
            // now-4:55min: start bookmark 1                                    |
            // now-4:45min: end bookmark 1                                      |
            //                                                                  |                BookmarkSearchFromBookmark
            // now-2:00min:                                                     |                            |
            // now-1:59min: start recording 2                                   |                            |
            // now-1:55min: start bookmark 2 (trigger time)                     |                            |
            // now-1:45min: end bookmark 2                                      |                            |
            // now                                                              v                            V

            Guid[] mediaDeviceTypes = new Guid[3];
            mediaDeviceTypes[0] = Kind.Camera;
            mediaDeviceTypes[1] = Kind.Microphone;
            mediaDeviceTypes[2] = Kind.Speaker;

            #region get bookmark reference

            Console.WriteLine("Asking for a new Bookmark Reference:");
            BookmarkReference bookmarkReference = BookmarkService.Instance.BookmarkGetNewReference(cameraFqid, true);
            Console.WriteLine(".... Received:" + bookmarkReference.Reference);

            #endregion

            #region create first bookmark
            Console.WriteLine("Creating the first bookmark");
            DateTime timeBegin = timeNow.AddMinutes(-5);

            StringBuilder bookmarkref    = new StringBuilder();
            StringBuilder bookmarkHeader = new StringBuilder();
            StringBuilder bookmarkDesc   = new StringBuilder();
            bookmarkref.AppendFormat("Mybookmark-{0}", timeBegin.ToLongTimeString());
            bookmarkHeader.AppendFormat("AutoBookmark-{0}", timeBegin.ToLongTimeString());
            bookmarkDesc.AppendFormat("AutoBookmark-{0} set for a duration of {1} seconds", timeBegin.ToLongTimeString(), (timeBegin.AddSeconds(10) - timeBegin.AddSeconds(1)).Seconds);


            Bookmark bookmark1 = null;
            try
            {
                bookmark1 = BookmarkService.Instance.BookmarkCreate(
                    cameraFqid,
                    timeBegin.AddSeconds(1),
                    timeBegin.AddSeconds(5),
                    timeBegin.AddSeconds(10),
                    bookmarkref.ToString(),
                    bookmarkHeader.ToString(),
                    bookmarkDesc.ToString());
                Console.WriteLine("Created bookmark 1 = " + bookmark1.BookmarkFQID.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine("BookmarkCreate 1 failed: " + ex.Message);
                Console.WriteLine("Press any Key");
                Console.ReadKey();
            }
            #endregion

            Console.WriteLine("");
            Console.WriteLine("Waiting 20sec ....");
            Console.WriteLine("");
            System.Threading.Thread.Sleep(20000);

            #region Create a second bookmark
            Console.WriteLine("Creating a second bookmark - 2 minutes after the first bookmark");
            DateTime timeBegin2 = timeBegin.AddMinutes(2);
            bookmarkHeader.Length = 0;
            bookmarkDesc.Length   = 0;
            StringBuilder bookmarkref2 = new StringBuilder();
            bookmarkref2.AppendFormat("Mybookmark-{0}", timeBegin2.ToLongTimeString());
            bookmarkHeader.AppendFormat("AutoBookmark-{0}", timeBegin2.ToLongTimeString());
            bookmarkDesc.AppendFormat("AutoBookmark-{0} set for a duration of {1} seconds", timeBegin2.ToLongTimeString(), (timeBegin2.AddSeconds(10) - timeBegin2.AddSeconds(1)).Seconds);

            Bookmark bookmark2 = null;
            try
            {
                bookmark2 = BookmarkService.Instance.BookmarkCreate(
                    cameraFqid,
                    timeBegin2.AddSeconds(1),
                    timeBegin2.AddSeconds(5),
                    timeBegin2.AddSeconds(10),
                    bookmarkref2.ToString(),
                    bookmarkHeader.ToString(),
                    bookmarkDesc.ToString());
                Console.WriteLine("Created bookmark 2 " + bookmark2.BookmarkFQID.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine("BookmarkCreate 2 failed: " + ex.Message);
                Console.WriteLine("Press any Key");
                Console.ReadKey();
            }

            Console.WriteLine("-> trigger time = {0}", bookmark2.TimeTrigged);
            Console.WriteLine("");
            #endregion

            #region BookmarkSearchTime

            // Get max 10 the bookmarks created after the specified time
            Console.WriteLine("");
            Console.WriteLine("Looking for bookmarks using BookmarkSearchTime (finding the 2 newly created)");
            Bookmark[] bookmarkList = BookmarkService.Instance.BookmarkSearchTime(
                cameraFqid.ServerId,
                bookmark1.TimeBegin.AddSeconds(-10),
                1800000000,
                10,
                mediaDeviceTypes,
                null,
                null,
                null);
            if (bookmarkList.Length > 0)
            {
                Console.WriteLine("-> Found {0} bookmark(s)", bookmarkList.Length);
                int counter = 1;
                foreach (Bookmark bookmark in bookmarkList)
                {
                    Console.WriteLine("{0}:", counter);
                    Item camera = Configuration.Instance.GetItem(bookmark.BookmarkFQID.ParentId, Kind.Camera);

                    FQID parent = bookmark.BookmarkFQID.GetParent();

                    Item camera2 = Configuration.Instance.GetItem(parent);

                    Console.WriteLine("     Id  ={0} ", bookmark.BookmarkFQID.ToString());
                    Console.WriteLine("     Name={0} ", bookmark.Header);
                    Console.WriteLine("     Desc={0} ", bookmark.Description);
                    Console.WriteLine("     user={0} ", bookmark.User);
                    Console.WriteLine("     Device={0} Start={1} Stop={2}  ", bookmark.GetDeviceItem().FQID.ObjectId, bookmark.TimeBegin, bookmark.TimeEnd);
                    counter++;
                }
            }
            else
            {
                Console.WriteLine("sorry no bookmarks found");
            }
            Console.WriteLine("");
            #endregion

            #region BookmarkSearchFromBookmark
            // Get the next (max 10) bookmarks after the first
            Console.WriteLine("Looking for bookmarks using BookmarSearchFromBookmark (finding the last of the 2 newly created)");
            Bookmark[] bookmarkListsFromBookmark = BookmarkService.Instance.BookmarkSearchFromBookmark(
                bookmark1.BookmarkFQID,
                1800000000,
                10,
                mediaDeviceTypes,
                null,
                null,
                null);
            if (bookmarkListsFromBookmark.Length > 0)
            {
                Console.WriteLine("-> Found {0} bookmark(s)", bookmarkListsFromBookmark.Length);
                int counter = 1;
                foreach (Bookmark bookmark in bookmarkListsFromBookmark)
                {
                    Console.WriteLine("{0}:", counter);
                    Console.WriteLine("     Id  ={0} ", bookmark.BookmarkFQID.ToString());
                    Console.WriteLine("     Name={0} ", bookmark.Header);
                    Console.WriteLine("     Desc={0} ", bookmark.Description);
                    Console.WriteLine("     user={0} ", bookmark.User);
                    Console.WriteLine("     Device={0} Start={1} Stop={2}  ", bookmark.GetDeviceItem().FQID.ObjectId, bookmark.TimeBegin, bookmark.TimeEnd);
                    counter++;
                }
            }
            else
            {
                Console.WriteLine("sorry no bookmarks found");
            }
            Console.WriteLine("");

            #endregion

            #region SearchTimeAsync
            Console.WriteLine("Looking for bookmarks using bookmarkSearchTimeAsync (finding the last of the 2 newly created)");
            _hasBeenCalledBack = false;

            BookmarkService.Instance.BookmarkSearchTimeAsync(
                cameraFqid.ServerId,
                bookmark2.TimeBegin.AddSeconds(-10),
                1800000000,
                10,
                mediaDeviceTypes,
                null,
                null,
                null,
                MyAsyncCallbackHandler,
                null);

            while (!_hasBeenCalledBack)
            {
                //Do something usefull while waiting
                System.Threading.Thread.Sleep(100);
            }
            #endregion

            #region SearchBookmarkAsync
            Console.WriteLine("Looking for bookmarks using BookmarkSearchFromBookmarkAsync (finding the last of the 2 newly created)");
            _hasBeenCalledBack = false;

            BookmarkService.Instance.BookmarkSearchFromBookmarkAsync(
                bookmark1.BookmarkFQID,
                1800000000,
                10,
                mediaDeviceTypes,
                null,
                null,
                null,
                MyAsyncCallbackHandler,
                null);

            while (!_hasBeenCalledBack)
            {
                //Do something usefull while waiting
                System.Threading.Thread.Sleep(100);
            }
            #endregion

            #region BookmarkGet
            // Get first created bookmark
            Console.WriteLine("Looking for the first bookmarks using BookmarkGet (finding the first of the 2 newly created)");
            Bookmark newbookmarkFetched = BookmarkService.Instance.BookmarkGet(bookmark1.BookmarkFQID);
            if (newbookmarkFetched != null)
            {
                Console.WriteLine("-> A bookmarks is found");
                Console.WriteLine("     Id  ={0} ", newbookmarkFetched.BookmarkFQID.ToString());
                Console.WriteLine("     Name={0} ", newbookmarkFetched.Header);
                Console.WriteLine("     Desc={0} ", newbookmarkFetched.Description);
                Console.WriteLine("     user={0} ", newbookmarkFetched.User);
                Console.WriteLine("     Device={0} Start={1} Stop={2}  ", newbookmarkFetched.GetDeviceItem().FQID.ObjectId, newbookmarkFetched.TimeBegin, newbookmarkFetched.TimeEnd);
            }
            else
            {
                Console.WriteLine("Sorry no bookmarks found");
            }
            Console.WriteLine("");
            #endregion

            #region Update Bookmark1
            Console.WriteLine("Updating the bookmark just fetched using BookmarkUpdate");
            newbookmarkFetched.Description = "Now I have updated the description of this bookmark";
            Bookmark newbookmark1 = BookmarkService.Instance.BookmarkUpdate(newbookmarkFetched);
            if (newbookmarkFetched != null)
            {
                Console.WriteLine("-> Result =");
                Console.WriteLine("     Id  ={0} ", newbookmarkFetched.BookmarkFQID.ToString());
                Console.WriteLine("     Name={0} ", newbookmarkFetched.Header);
                Console.WriteLine("     Desc={0} ", newbookmarkFetched.Description);
                Console.WriteLine("     user={0} ", newbookmarkFetched.User);
                Console.WriteLine("     Device={0} Start={1} Stop={2}  ", newbookmarkFetched.GetDeviceItem().FQID.ObjectId, newbookmarkFetched.TimeBegin, newbookmarkFetched.TimeEnd);
            }
            else
            {
                Console.WriteLine("Sorry. Failed to update the bookmark");
            }
            Console.WriteLine("");

            #endregion

            #region Deleting bookmarks
            Console.WriteLine("Deleting 2 newly created bookmarks");
            BookmarkService.Instance.BookmarkDelete(bookmark1.BookmarkFQID);
            Console.WriteLine("   -> first deleted");
            BookmarkService.Instance.BookmarkDelete(bookmark2);
            Console.WriteLine("   -> second deleted");
            #endregion

            Console.WriteLine("");
            Console.WriteLine("Press any key");
            Console.ReadKey();
        }
예제 #54
0
 public ReminderInfo(Bookmark bookmark, ReminderState reminderState)
     : this(bookmark, reminderState, default(DateTime))
 {
 }
 public ActionResult Edit(Bookmark bookmark)
 {
     _bookmarkService.Add(bookmark);
     return(RedirectToAction("Index"));
 }
예제 #56
0
        private void AddToListView(Bookmark[] bookmarks)
        {
            int limit = bookmarks.Length > bookmarksCount ? bookmarksCount : bookmarks.Length;

            for (int i = 0; i < limit; i++)
            {
                try
                {
                    Bookmark            bookmark            = bookmarks[i];
                    BookmarkDescription bookmarkDescription = Helper.ParseBookmarkDescription(bookmark.Description);

                    /*
                     * string[] row = new string[]
                     *                  {
                     *                  (i+1).ToString(),
                     *                  bookmark.TimeBegin.ToLocalTime().ToString(),
                     *                  bookmark.TimeEnd.ToLocalTime().ToString (),
                     *                  bookmark.Header,
                     *                  bookmark.Description,
                     *                  bookmarkDescription.PlateNumber,
                     *                  bookmarkDescription.Make,
                     *                  bookmarkDescription.Timestamp.ToString(),
                     *                  bookmarkDescription.BestRegion
                     *                  };
                     */
                    string[] row = new string[]
                    {
                        (i + 1).ToString(),
                        bookmark.TimeBegin.ToLocalTime().ToString(),
                        bookmark.TimeEnd.ToLocalTime().ToString(),
                        bookmarkDescription.PlateNumber,
                        bookmarkDescription.Make,
                        bookmarkDescription.BodyType,
                        bookmarkDescription.Color,
                        bookmarkDescription.BestRegion
                    };


                    ListViewItem listViewItem = new ListViewItem(row)
                    {
                        Tag = bookmark.BookmarkFQID
                    };

                    lsvBookmarks.Items.Add(listViewItem);

                    if (OpenALPRBackgroundPlugin.Stop)
                    {
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log.Error(null, ex);
                }
            }

            string plus = bookmarks.Length > bookmarksCount ? "+" : string.Empty;

            btnNext.Enabled = bookmarks.Length > bookmarksCount;
            lblMessage.Text = $"Total Bookmarks found: {limit.ToString()}{plus}";
        }
        public ViewResult Details(string id)
        {
            Bookmark model = _bookmarkService.GetById(id);

            return(View(model));
        }
예제 #58
0
 public bool ContainsKey(Bookmark bookmark)
 {
     return(_dictionary.ContainsKey(bookmark));
 }
예제 #59
0
 protected internal abstract IAsyncResult OnBeginResumeBookmark(Bookmark bookmark, object value, TimeSpan timeout, AsyncCallback callback, object state);
        public ActionResult Create()
        {
            var model = new Bookmark();

            return(View(model));
        }