Esempio n. 1
0
        public FeedTransformationState GetTransformationById(int transformationId)
        {
            IDbCommand cmd;

            Tebaldi.MarketData.Models.State.FeedTransformationState obj = new State.FeedTransformationState();

            string strSQL;

            strSQL = "procGetTransformationsById";

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

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

            List <FeedTransformationState> lst = (from dr in ds.Tables[0].AsEnumerable()
                                                  select new State.FeedTransformationState()
            {
                TransformationId = Convert.ToInt32(dr[obj.Schema.TransformationId]),
                FeedId = Convert.ToInt32(dr[obj.Schema.FeedId]),
                ExecuteOrder = Convert.ToInt32(dr[obj.Schema.ExecuteOrder]),

                OriginalColumn = Convert.ToString(dr[obj.Schema.OriginalColumn]),
                OriginalValue = Convert.ToString(dr[obj.Schema.OriginalValue]),

                NewColumn = Convert.ToString(dr[obj.Schema.NewColumn]),
                NewValue = Convert.ToString(dr[obj.Schema.NewValue])
            }).ToList();

            return(lst[0]);
        }
Esempio n. 2
0
        public int Save(State.FeedTransformationState feedTransformation)
        {
            List <State.FeedTransformationState> lstfeedTransformation = new List <FeedTransformationState>();

            lstfeedTransformation.Add(feedTransformation);

            return(Save(lstfeedTransformation));
        }
Esempio n. 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);
        }