Ejemplo n.º 1
0
        //This is just proves a deeper system. Will need to be done properly, probably via an AddIn
        //right now the context is GetLayoutBy("section", "writing")
        //returns a random NOTE  matching context INCLUDING notes on subpanels
        public static string GetRandomNoteBy(string typeofsearch, string param)
        {
            typeofsearch = dbConstants.NOTEBOOK;

            BaseDatabase    MyDatabase = CreateDatabase();
            List <object[]> results    = MyDatabase.GetValues(dbConstants.table_name, new string[2] {
                dbConstants.NAME, dbConstants.GUID
            }, typeofsearch, param);
            // Do a query on the database
            // then process, grabbing first ONE Layout out of the mix
            //

            string temp = "";
            string guid = Constants.BLANK;

            if (results != null && results.Count > 0)
            {
                int pickme = LayoutDetails.Instance.RandomNumbers.Next(1, results.Count + 1);
                temp = results [pickme - 1] [0].ToString();
                guid = results [pickme - 1] [1].ToString();
            }



            if (Constants.BLANK != guid)
            {
                // we load it
                LayoutInterface layoutdata = LayoutDetails.DATA_Layout(guid);
                //	LayoutPanelBase panel = new Layout.LayoutPanel();
                layoutdata.LoadFrom(null);
                System.Collections.ObjectModel.ReadOnlyCollection <NoteDataInterface> listofnotes = layoutdata.GetNotes();
                if (listofnotes != null && listofnotes.Count > 0)
                {
                    int pickme = LayoutDetails.Instance.RandomNumbers.Next(1, listofnotes.Count + 1);
                    NoteDataInterface randomNote = (NoteDataInterface)listofnotes[pickme - 1];
                    temp = String.Format("Layout: {0} Note Caption: {1}", temp, randomNote.Caption);
                }
            }
            MyDatabase.Dispose();
            // additional hack is just to return the CAPTION, not the GUID, else I won't know if it worked!
            return(temp);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the note from inside layout. Called from the LinkNote note type
        /// </summary>
        /// <returns>
        /// The note from inside layout.
        /// </returns>
        /// <param name='ParentGuid'>
        /// Parent GUID.
        /// </param>
        /// <param name='NoteGuid'>
        /// Note GUID.
        /// </param>
        public static NoteDataInterface GetNoteFromInsideLayout(string ParentGuid, string NoteGuid)
        {
            if (ParentGuid == Constants.BLANK || NoteGuid == Constants.BLANK)
            {
                throw new Exception("Must define valid GUIDs for the Layout and the Note");
            }


            BaseDatabase MyDatabase = CreateDatabase();



            {
                // we load it
                LayoutInterface layoutdata = LayoutDetails.DATA_Layout(ParentGuid);
                //	LayoutPanelBase panel = new Layout.LayoutPanel();
                layoutdata.LoadFrom(null);
                System.Collections.ObjectModel.ReadOnlyCollection <NoteDataInterface> listofnotes = layoutdata.GetNotes();
                if (listofnotes != null && listofnotes.Count > 0)
                {
                    foreach (NoteDataInterface note in listofnotes)
                    {
                        if (NoteGuid == note.GuidForNote)
                        {
                            // we found the note we search for
                            return(note);
                        }
                    }
//					int pickme = LayoutDetails.Instance.RandomNumbers.Next (1, listofnotes.Count + 1);
//					NoteDataInterface randomNote = (NoteDataInterface)listofnotes[pickme-1];
                    //temp = String.Format ("Layout: {0} Note Caption: {1}", temp, randomNote.Caption);
                }
            }

            return(null);
        }