예제 #1
0
        public static long AddOrUpdate(T Entity)
        {
            long Id = Convert.ToInt64(Entity.GetType().GetProperties().FirstOrDefault(p => p.Name == "Id").GetValue(Entity));

            if (Id == 0)
            {
                var  list    = SelectAll();
                long GivenId = DateTime.Now.Ticks;
                Entity.GetType().GetProperties().FirstOrDefault(p => p.Name == "Id").SetValue(Entity, GivenId);
                Entity.GetType().GetProperties().FirstOrDefault(p => p.Name == "DateCreated").SetValue(Entity, DateTime.Now);
                list.Add(Entity);
                Save(list);
                return(GivenId);
            }
            else
            {
                var list = SelectAll();
                foreach (var EntProp in Entity.GetType().GetProperties())
                {
                    var obj = list.FirstOrDefault(s => Convert.ToInt64(s.GetType().GetProperty("Id").GetValue(s)) == Id);
                    foreach (var DataProp in obj.GetType().GetProperties())
                    {
                        if (DataProp.Name == EntProp.Name)
                        {
                            var value = EntProp.GetValue(Entity);
                            DataProp.SetValue(list.FirstOrDefault(s => Convert.ToInt64(s.GetType().GetProperty("Id").GetValue(s)) == Id), value);
                        }
                    }
                }

                Save(list);
                return(Id);
            }
        }
예제 #2
0
        public void Init()
        {
            NetworkEventManager.Register(NetworkEventKey.Warehouse, OnReceivedInformation);

            DataProp data = DataManager.Instance.Load <DataProp>();

            for (int i = 0; i < data.props.Count; i++)
            {
                _props.Add(new Prop()
                {
                    identification = (uint)i,
                    number         = 999,
                    parallelism    = data.props[i].primary,
                });
            }
        }
예제 #3
0
        public List <Prop> Column(int index)
        {
            _column.Clear();

            DataProp data = DataManager.Instance.Load <DataProp>();

            PropInformation prop;

            int count = _props.Count;

            for (int i = 0; i < count; i++)
            {
                prop = data.Get(_props[i].parallelism);

                if (prop != null && prop.category == index)
                {
                    _column.Add(_props[i]);
                }
            }
            return(_column);
        }