public object ExecuteDataReader(EbApi Api)
        {
            EbDataSet dataSet;

            try
            {
                EbDataReader dataReader = Api.GetEbObject <EbDataReader>(this.Reference, Api.Redis, Api.ObjectsDB);

                List <DbParameter> dbParameters = new List <DbParameter>();

                List <Param> InputParams = dataReader.GetParams((RedisClient)Api.Redis);

                Api.FillParams(InputParams);

                foreach (Param param in InputParams)
                {
                    dbParameters.Add(Api.DataDB.GetNewParameter(param.Name, (EbDbTypes)Convert.ToInt32(param.Type), param.ValueTo));
                }

                dataSet = Api.DataDB.DoQueries(dataReader.Sql, dbParameters.ToArray());
            }
            catch (Exception ex)
            {
                throw new ApiException("[ExecuteDataReader], " + ex.Message);
            }
            return(dataSet);
        }
        public override List <string> DiscoverRelatedRefids()
        {
            List <string> refids = new List <string>();

            if (!DataSourceRefId.IsEmpty())
            {
                EbDataReader ds = EbDataSource;
                if (ds is null)
                {
                    refids.Add(DataSourceRefId);
                }
            }
            foreach (DVBaseColumn _col in Columns)
            {
                if (!_col.LinkRefId.IsNullOrEmpty())
                {
                    refids.Add(_col.LinkRefId);
                }
                if (!_col.GroupFormLink.IsNullOrEmpty())
                {
                    refids.Add(_col.GroupFormLink);
                }
                if (!_col.ItemFormLink.IsNullOrEmpty())
                {
                    refids.Add(_col.ItemFormLink);
                }
                if (_col is DVApprovalColumn && !(_col as DVApprovalColumn).FormRefid.IsNullOrEmpty())
                {
                    refids.Add((_col as DVApprovalColumn).FormRefid);
                }
            }
            return(refids);
        }
        public string GetSql(Service service)// duplicate
        {
            EbDataReader dr  = EbFormHelper.GetEbObject <EbDataReader>(this.DataSourceId, null, service.Redis, service);
            string       Sql = dr.Sql.Trim();

            if (Sql.LastIndexOf(";") == Sql.Length - 1)
            {
                Sql = Sql.Substring(0, Sql.Length - 1);
            }

            return(Sql);
        }
        public override void FetchParamsMeta(IServiceClient ServiceClient, IRedisClient redis, EbControl[] Allctrls, Service service)
        {
            EbChartVisualization ChartVisualization = EbFormHelper.GetEbObject <EbChartVisualization>(TVRefId, ServiceClient, redis, service);

            if (string.IsNullOrEmpty(ChartVisualization.DataSourceRefId))
            {
                throw new FormException($"Missing Data Reader of Chart control view that is connected to {this.Label}.");
            }
            EbDataReader DrObj = EbFormHelper.GetEbObject <EbDataReader>(ChartVisualization.DataSourceRefId, ServiceClient, redis, service);

            this.ParamsList = DrObj.GetParams(redis as RedisClient);
        }
 public override void AfterRedisGet(RedisClient Redis)
 {
     try
     {
         this.EbDataSource = Redis.Get <EbDataReader>(this.DataSourceRefId);
         this.EbDataSource.AfterRedisGet(Redis);
     }
     catch (Exception e)
     {
         Console.WriteLine("Exception: " + e.ToString());
     }
 }
        public override List <string> DiscoverRelatedRefids()
        {
            List <string> _refids = new List <string>();

            if (!DataSourceRefId.IsEmpty())
            {
                EbDataReader ds = EbDataSource;
                if (ds is null)
                {
                    _refids.Add(DataSourceRefId);
                }
            }
            return(_refids);
        }
        public static string ExecuteDecrypt(String ciphertext, string KeyName, string Refid, EbApi Api, EncryptionAlgorithm EncryptionAlgorithm)
        {
            string pri_key   = "";
            string plaintext = "";

            try
            {
                if (!String.IsNullOrEmpty(KeyName))
                {
                    pri_key = Api.Redis.Get <string>("privatekey_" + Api.SolutionId + "_" + KeyName);
                }

                if (String.IsNullOrEmpty(pri_key) && !String.IsNullOrEmpty(Refid))
                {
                    EbDataReader dataReader = Api.GetEbObject <EbDataReader>(Refid, Api.Redis, Api.ObjectsDB);

                    List <DbParameter> dbParameters = new List <DbParameter> {
                        Api.DataDB.GetNewParameter("keyname", EbDbTypes.String, KeyName)
                    };

                    EbDataSet dataSet = Api.DataDB.DoQueries(dataReader.Sql, dbParameters.ToArray());
                    pri_key = dataSet.Tables?[0].Rows[0]["key"].ToString();

                    Api.Redis.Set <string>("privatekey_" + Api.SolutionId + "_" + KeyName, pri_key);
                }

                if (EncryptionAlgorithm == EncryptionAlgorithm.RSA)
                {
                    plaintext = RSADecrypt(ciphertext, pri_key);
                }
            }
            catch (Exception ex)
            {
                throw new ApiException("[ExecuteEncrypt], " + ex.Message);
            }
            return(plaintext);
        }