Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public Series GetSeries(TimeSeriesDatabaseDataSet.SeriesCatalogRow sr)
        {
            Series s   = null;// = new Series(sr, db);
            int    sdi = sr.id;

            try
            {
                if (sr.Provider.Trim() == "")
                {
                    sr.Provider = "Series";
                }

                // most common cases -- avoid reflection
                if (sr.Provider == "Series")
                {
                    s = new Series(db, sr);
                    //s.Table.TableName =
                    s.Icon = AssignIcon(sr.iconname);
                    s.TimeSeriesDatabase = this.db;
                    return(s);
                }
                // most common cases -- avoid reflection
                if (sr.Provider == "CalculationSeries")
                {
                    s      = new CalculationSeries(db, sr);
                    s.Icon = AssignIcon(sr.iconname);
                    s.TimeSeriesDatabase = this.db;
                    return(s);
                }


                if (seriesTypeList == null)
                {
                    seriesTypeList = new List <Type>();
                    var asmList = AppDomain.CurrentDomain.GetAssemblies();

                    foreach (Assembly item in asmList)
                    {
                        if (item.FullName.IndexOf("Reclamation.") < 0 &&
                            item.FullName.IndexOf("Pisces") < 0 &&
                            item.FullName.IndexOf("HDB") < 0)
                        {
                            continue;
                        }

                        var types = item.GetTypes().Where(x => x.BaseType == typeof(Series));
                        seriesTypeList.AddRange(types);
                    }
                }

                for (int i = 0; i < seriesTypeList.Count; i++)
                {
                    Type t = seriesTypeList[i];
                    if (t.Name == sr.Provider)
                    {
                        Type[] parmFaster  = new Type[] { typeof(TimeSeriesDatabase), typeof(SeriesCatalogRow) };
                        var    cInfoFaster = t.GetConstructor(parmFaster);

                        if (cInfoFaster != null)
                        {
                            object o = cInfoFaster.Invoke(new object[] { db, sr });
                            if (o is Series)
                            {
                                s = o as Series;
                            }
                            else
                            {
                                throw new InvalidOperationException("Provider '" + sr.Provider + "' is not a Series");
                            }
                        }

                        else
                        {
                            throw new InvalidOperationException("Can't find constructor for '" + sr.Provider + "'");
                        }

                        break;
                    }
                }
            }
            catch (Exception excep)
            {
                if (excep.InnerException != null)
                {
                    throw excep.InnerException;
                }
                throw new Exception(excep.Message + "\n" + sr.Provider);
            }

            if (s == null)
            {
//                Logger.WriteLine("No Class found for '"+sr.Provider +"'  ID= "+sr.id+" Name = "+sr.Name);
                s = new Series(db, sr);
            }
            s.Icon = AssignIcon(sr.iconname);
            s.TimeSeriesDatabase = this.db;
            return(s);
        }