Esempio n. 1
0
        public Dictionary <int, ObjectInfo> GetEventObjectCustom(ref string errMessage, int eventid)
        {
            Database db = DatabaseFactory.CreateDatabase();

            errMessage = "";
            Dictionary <int, ObjectInfo> list     = new Dictionary <int, ObjectInfo>();
            Dictionary <int, EventRect>  listRect = new Dictionary <int, EventRect>();

            try
            {
                DataSet    ds = ObjectDataAccess.GetObjectCustom(db, eventid);
                ObjectInfo obj;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    obj          = new ObjectInfo(ds.Tables[0].Rows[i]);
                    obj.listRect = EventRectBusiness.Instance.GetEventRectCustom(ref errMessage, obj.ObjectId);
                    list.Add(obj.ObjectId, obj);
                }
                return(list);
            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return(null);
            }
        }
Esempio n. 2
0
        public ObjectDataAccess CreateFromObjects(object[] objects)
        {
            var objectDataAccess = new ObjectDataAccess();

            foreach (var instance in objects)
            {
                objectDataAccess.Add(instance);
                (instance as Keyword)?.Hydrate();
            }



            return(objectDataAccess);
        }
Esempio n. 3
0
        public int Insert(ref string errMessage, ObjectInfo oObject)
        {
            Database db = DatabaseFactory.CreateDatabase();

            errMessage = "";
            try
            {
                return(ObjectDataAccess.Insert(db, oObject));
            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return(-1);
            }
        }
Esempio n. 4
0
        public ObjectDataAccess CreateFromArguments(string[] arguments)
        {
            var objectDataAccess = new ObjectDataAccess();


            var nonparametricArguments = arguments.Where(x => !x.Contains("=")).ToList();
            var parametricArguments    = arguments.Where(x => x.Contains("=")).ToList();

            foreach (var parametricArgument in parametricArguments)
            {
                var name           = parametricArgument.Substring(1, parametricArgument.IndexOf('=') - 1);
                var value          = parametricArgument.Substring(parametricArgument.IndexOf('=') + 1);
                var rememberedText = new RememberedText(name, value);
                SharedObjectDataAccess.Instance.Value.Add(rememberedText);
            }

            foreach (var argument in nonparametricArguments)
            {
                var dtoTypes = (IEnumerable <Type>)_registry.Types;
                var type     =
                    dtoTypes.FirstOrDefault(registeredType => registeredType.Name.ToLower() == argument.Substring(1).ToLower());

                if (type == null)
                {
                    //throw new ArgumentException($"Argument {argument} is not recognized.");

                    objectDataAccess.Add(new CorruptObject()
                    {
                        Description = $"Argument {argument} is not recognized."
                    });

                    continue;
                }
                var instance = Activator.CreateInstance(type);

                objectDataAccess.Add(instance);
            }

            foreach (var obj in objectDataAccess.GetAll())
            {
                (obj as Keyword)?.Hydrate();
            }

            return(objectDataAccess);
        }