Example #1
0
        object[] GetPathArray(PiscesObject node)
        {
            if (node == null)
            {
                return new object[] { }
            }
            ;                          // empty

            if (node.ID == m_root.ID)
            {
                return(new object[] { node });
            }
            else
            {
                Stack <object> stack         = new Stack <object>();
                var            rootObjectsID = GetRootObjects().Select(x => x.ID).ToList();
                while (!rootObjectsID.Contains(node.ID))
                {
                    stack.Push(node);
                    if (node.Parent == null)
                    {
                        //System.Windows.Forms.MessageBox.Show("oops node.Parent == null");
                        Console.WriteLine("oops node.Parent == null");
                        break;
                    }
                    node = node.Parent;
                }
                stack.Push(node); //root object
                return(stack.ToArray());
            }
        }
Example #2
0
        public List <PiscesObject> GetRootObjects()
        {
            var    tbl = new TimeSeriesDatabaseDataSet.SeriesCatalogDataTable();
            string sql = "select * from seriescatalog where id = parentid ";

            m_server.FillTable(tbl, sql);

            if (tbl.Rows.Count == 0)
            {
                Reclamation.Core.Logger.WriteLine("Tree Requires at least one root Node");
                Logger.WriteLine("AutoCreation of New Root Folder");
                CreateRootFolder();
                m_server.FillTable(tbl, sql);
            }

            List <PiscesObject> rval = new List <PiscesObject>();

            for (int i = 0; i < tbl.Rows.Count; i++)
            {
                rval.Add(Factory.CreateObject(tbl[i]));
            }

            if (rval.Count > 0)
            {
                m_root = rval[0];
            }
            return(rval);
        }
Example #3
0
        private TimeSeriesDatabaseDataSet.SeriesCatalogDataTable GetChildrenRows(PiscesObject parent)
        {
            if (Filter.Trim() == "")
            {
                string sql = "select * from seriescatalog where parentid = " + parent.ID + " and  id <> " + parent.ID + " order by sortorder";
                var    tbl = new TimeSeriesDatabaseDataSet.SeriesCatalogDataTable();
                m_server.FillTable(tbl, sql);
                return(tbl);
            }
            else
            {// filtered catalog
                var sc   = GetFilteredCatalog();
                var tbl  = new TimeSeriesDatabaseDataSet.SeriesCatalogDataTable();
                var rows = sc.Select("parentid=" + parent.ID + " and id <> parentid", "sortorder");

                foreach (var item in rows)
                {
                    var newRow = tbl.NewSeriesCatalogRow();
                    newRow.ItemArray = item.ItemArray;
                    tbl.Rows.Add(newRow);
                }
                tbl.AcceptChanges();
                return(tbl);
            }
        }
        object[] GetPathArray(PiscesObject node)
        {
            if (node == null)
            {
                return new object[] { }
            }
            ;                          // empty

            if (node.ID == m_root.ID)
            {
                return(new object[] { node });
            }
            else
            {
                Stack <object> stack = new Stack <object>();
                while (node.ID != m_root.ID)
                {
                    stack.Push(node);
                    if (node.Parent == null)
                    {
                        System.Windows.Forms.MessageBox.Show("oops node.Parent == null");
                        Console.WriteLine("oops node.Parent == null");
                        break;
                    }
                    node = node.Parent;
                }
                stack.Push(node);//root
                return(stack.ToArray());
            }
        }
Example #5
0
 public TimeSeriesDatabaseDelete(TimeSeriesDatabase db, PiscesObject o)
 {
     this.m_db          = db;
     sdi                = o.ID;
     catalog            = m_db.GetFilteredCatalog();
     m_seriesProperties = m_db.GetSeriesProperties();
     //catalog.PrimaryKey = new DataColumn[] { catalog.Columns["id"]};
 }
Example #6
0
        public PiscesFolder GetFolder(int id)
        {
            TimeSeriesDatabaseDataSet.SeriesCatalogRow sr = db.GetSeriesRow(id);
            PiscesObject o = CreateObject(sr);

            if (!(o is PiscesFolder))
            {
                throw new ArgumentException("this object is not a PiscesFolder " + id);
            }
            return(o as PiscesFolder);
        }
Example #7
0
 public void ChangeParent(PiscesObject piscesObject, PiscesFolder piscesFolder)
 {
     if (piscesObject.Parent.ID == piscesFolder.ID)
     {
         return; // nothing to do
     }
     TimeSeriesDatabaseDataSet.SeriesCatalogRow r = GetSeriesRow(piscesObject.ID);
     r.ParentID = piscesFolder.ID;
     SaveSeriesRow(r);
     OnDatabaseChanged(GetPathArray(piscesObject.Parent));
     OnDatabaseChanged(GetPathArray(piscesFolder));
 }
Example #8
0
        public PiscesObject[] GetChildren(PiscesObject parent)
        {
            var tbl = GetChildrenRows(parent);

            List <PiscesObject> rval = new List <PiscesObject>();

            for (int i = 0; i < tbl.Rows.Count; i++)
            {
                PiscesObject o = this.Factory.CreateObject(tbl[i]);
                o.Parent = parent as PiscesFolder;
                rval.Add(o);
            }
            return(rval.ToArray());
        }
Example #9
0
        public PiscesObject CreateObject(SeriesCatalogRow sr)
        {
            PiscesObject rval = null;

            if (sr.IsFolder == 1)
            {
                rval = new PiscesFolder(db, sr);
            }
            else
            {
                return(GetSeries(sr)); //11.53125 seconds elapsed.
            }

            //    rval.Icon = AssignIcon(sr.iconname);
            return(rval);
        }
Example #10
0
        public void ChangeSortOrder(PiscesObject piscesObject, int sortOrder)
        {
            if (piscesObject.SortOrder == sortOrder)
            {
                return;// nothing to do
            }

            string sql = "Update seriescatalog set sortorder = sortorder+1 where parentid = " + piscesObject.Parent.ID
                         + " and  sortorder > " + sortOrder;
            int i = m_server.RunSqlCommand(sql);

            int newSortOrder = sortOrder + 1;

            sql = "Update seriescatalog set sortorder = " + newSortOrder + " Where id = " + piscesObject.ID;
            i   = m_server.RunSqlCommand(sql);
            Logger.WriteLine("SortOrder changed for " + i + " items");

            OnDatabaseChanged(GetPathArray(piscesObject.Parent));
        }
Example #11
0
        public PiscesObject CreateObject(SeriesCatalogRow sr)
        {
            PiscesObject rval = null;

            if (sr.IsFolder)
            {
                rval = new PiscesFolder(db, sr);
            }
            else if (sr.IsMeasurement)
            {
                rval = GetMeasurement(sr);
            }
            else if (sr.IsRatingTable)
            {
                rval = GetRatingTable(sr);
            }
            else
            {
                return(GetSeries(sr)); //11.53125 seconds elapsed.
            }

            rval.Icon = AssignIcon(sr.iconname);
            return(rval);
        }
Example #12
0
 public CustomEventArgs(PiscesObject o)
 {
     this.o = o;
 }