示例#1
0
        public KeyValueState GetKeyValueById(int keyValueId)
        {
            IDbCommand cmd;

            State.KeyValueState obj = new State.KeyValueState();

            string strSQL;

            strSQL = "procGetKeyValueById";

            cmd = DataLayer.CreateCommand(strSQL, mstrConnectString);
            cmd.Parameters.Add(DataLayer.CreateParameter("@KeyValueId", DbType.Int32, keyValueId, mstrConnectString));
            cmd.CommandType = CommandType.StoredProcedure;

            DataSet ds = DataLayer.GetDataSet(cmd, mstrConnectString);

            List <KeyValueState> lst = (from dr in ds.Tables[0].AsEnumerable()
                                        select new State.KeyValueState()
            {
                KeyValueId = Convert.ToInt32(dr[obj.Schema.Id]),
                FeedId = Convert.ToInt32(dr[obj.Schema.FeedId]),
                Key = Convert.ToString(dr[obj.Schema.Key]),
                Value = Convert.ToString(dr[obj.Schema.Value]),
                FeedSpecific = Convert.ToBoolean(dr[obj.Schema.FeedSpecific])
            }).ToList();

            return(lst[0]);
        }
示例#2
0
        public int Save(State.KeyValueState keyValueState)
        {
            List <State.KeyValueState> lst = new List <KeyValueState>();

            lst.Add(keyValueState);

            return(Save(lst));
        }
示例#3
0
        private List <FeedState> GetFeeds(int?feedId)
        {
            IDbCommand cmd;

            State.FeedState obj = new State.FeedState();

            string strSQL;

            strSQL = "procGetFeed";

            cmd             = DataLayer.CreateCommand(strSQL, mstrConnectString);
            cmd.CommandType = CommandType.StoredProcedure;
            if (feedId != null)
            {
                cmd.Parameters.Add(DataLayer.CreateParameter("@FeedId", DbType.Int32, feedId, mstrConnectString));
            }

            DataSet ds = DataLayer.GetDataSet(cmd, mstrConnectString);

            // Set table names, just for information
            ds.Tables[0].TableName = "TB_Feed";
            ds.Tables[1].TableName = "TB_FeedKeyValue";
            ds.Tables[2].TableName = "TB_FeedTransformation";
            ds.Tables[3].TableName = "TB_FeedFilter";

            List <FeedState> lstFeeds = (from dr in ds.Tables["TB_Feed"].AsEnumerable()
                                         select new State.FeedState()
            {
                ID = Convert.ToInt32(dr[obj.Schema.FeedId]),
                Name = dr[obj.Schema.Name].ToString(),
                Type = (FeedTypeEnum)dr[obj.Schema.FeedTypeId],
            }).ToList();



            State.KeyValueState           objKV = new State.KeyValueState();
            State.FeedTransformationState objTR = new State.FeedTransformationState();
            State.FeedFilterState         objFL = new State.FeedFilterState();
            foreach (FeedState feed in lstFeeds)
            {
                feed.KeyValues = (from dr in ds.Tables["TB_FeedKeyValue"].AsEnumerable()
                                  where dr.Field <int>("FeedId") == feed.ID
                                  select new State.KeyValueState()
                {
                    KeyValueId = Convert.ToInt32(dr[objKV.Schema.Id]),
                    FeedId = Convert.ToInt32(dr[objKV.Schema.FeedId]),
                    FeedSpecific = Convert.ToBoolean(dr[objKV.Schema.Id]),
                    Key = Convert.ToString(dr[objKV.Schema.Key]),
                    Value = Convert.ToString(dr[objKV.Schema.Value])
                }).ToList();

                feed.Transformations = (from dr in ds.Tables["TB_FeedTransformation"].AsEnumerable()
                                        where dr.Field <int>("FeedId") == feed.ID
                                        select new State.FeedTransformationState()
                {
                    TransformationId = Convert.ToInt32(dr[objTR.Schema.TransformationId]),
                    FeedId = Convert.ToInt32(dr[objTR.Schema.FeedId]),
                    ExecuteOrder = Convert.ToInt32(dr[objTR.Schema.ExecuteOrder]),
                    OriginalValue = Convert.ToString(dr[objTR.Schema.OriginalValue]),
                    OriginalColumn = Convert.ToString(dr[objTR.Schema.OriginalColumn]),
                    NewValue = Convert.ToString(dr[objTR.Schema.NewValue]),
                    NewColumn = Convert.ToString(dr[objTR.Schema.NewColumn])
                }).ToList();

                feed.Filter = (from dr in ds.Tables["TB_FeedFilter"].AsEnumerable()
                               where dr.Field <int>("FeedId") == feed.ID
                               select new State.FeedFilterState()
                {
                    Id = Convert.ToInt32(dr[objFL.Schema.Id]),
                    FeedId = Convert.ToInt32(dr[objFL.Schema.FeedId]),
                    ColumnName = Convert.ToString(dr[objFL.Schema.ColumnName]),
                    ColumnValue = Convert.ToString(dr[objFL.Schema.ColumnValue])
                }).ToList();
            }

            return(lstFeeds);
        }