Ejemplo n.º 1
0
        public IEnumerable <string> Get()
        {
            PostgresqlHelper postgresqlHelper = new PostgresqlHelper("User ID=core;Password=core;Host=10.36.36.12;Port=5432;Database=core;");

            //postgresqlHelper.ExecuteStore();
            return(new string[] { "value1", "value2" });
        }
Ejemplo n.º 2
0
        private string BuildSearchExtension(SearchModuleInfo searchInfo, SearchConditionInstance conditionIntance)
        {
            var fields = FieldUtils.GetModuleFields(searchInfo.ModuleID);

            using (var conn = new NpgsqlConnection(ConnectionString))
            {
                using (var comm = new NpgsqlCommand(searchInfo.WhereExtension, conn))
                {
                    conn.Open();
                    comm.CommandType = CommandType.StoredProcedure;
                    PostgresqlHelper.DiscoveryParameters(comm);

                    foreach (var field in
                             fields.Where(field => field.WhereExtension == WebCore.CODES.DEFMODFLD.WHEREEXTENSION.YES))
                    {
                        comm.Parameters[field.FieldName].Value = DBNull.Value;
                        foreach (var condition in conditionIntance.SubCondition)
                        {
                            if (condition.ConditionID == field.FieldID && string.IsNullOrEmpty(condition.SQLLogic))
                            {
                                comm.Parameters[field.FieldName].Value = condition.Operator;
                            }
                        }
                    }
                    comm.ExecuteNonQuery();
                    return(comm.Parameters["RETURN_VALUE"].Value.ToString());
                }
            }
        }
Ejemplo n.º 3
0
        public async Task <string> ExcuteStore2DataTable(ParramModuleQuery query)
        {
            var outPut = new RestOutput <string>();

            try
            {
                var m_Client = new CoreController(_configuration);
                PostgresqlHelper postgresqlHelper = new PostgresqlHelper();
                var param = m_Client.DiscoveryParameters(query.Store);
                // var checkParram = param.Where(x => x.SqlDbType != SqlDbType.);
                if (param != null && param.Any())
                {
                    if (query.Parram.Length > 0)
                    {
                        param.First().Value = query.Parram.First();
                    }
                }
                var tb = (DataTable)m_Client.RunStoreToDataTable(query.Store, param); //m_Client.ExecuteStoreProcedurePostgreSQL(query.Store, query.Parram.Length>0? query.Parram.First().ToString():"");
                if (tb != null)
                {
                    outPut.Data       = JsonConvert.SerializeObject(tb);
                    outPut.ResultCode = 1;
                    outPut.Message    = "";
                    return(JsonConvert.SerializeObject(outPut));
                }
            }
            catch (Exception ex)
            {
                outPut.ResultCode = -1;
                outPut.Message    = ex.ToString();
                return(JsonConvert.SerializeObject(outPut));
            }

            return(JsonConvert.SerializeObject(outPut));
        }
Ejemplo n.º 4
0
        public void BuildStaticConditions(SearchModuleInfo searchInfo, NpgsqlCommand comm, List <SearchConditionInstance> staticConditionInstances)
        {
            var fields = FieldUtils.GetModuleFields(searchInfo.ModuleID, WebCore.CODES.DEFMODFLD.FLDGROUP.PARAMETER);

            if (fields == null || fields.Count == 0)
            {
                fields = PostgresqlHelper.ExecuteStoreProcedurePostgreSQL <ModuleFieldInfo>(ConnectionString, SYSTEM_STORE_PROCEDURES.LIST_FIELD_INFO_BY_MODID, searchInfo.ModuleID);
                if (AllCaches.ModuleFieldsInfo == null)
                {
                    AllCaches.ModuleFieldsInfo = new List <ModuleFieldInfo>();
                }
                AllCaches.ModuleFieldsInfo.AddRange(fields);
            }
            foreach (var field in fields)
            {
                switch (field.FieldName)
                {
                case CONSTANTS.ORACLE_SESSION_USER:
                    //comm.Parameters.Add(":" + field.ParameterName, Session.Username);
                    break;

                case CONSTANTS.ORACLE_CURSOR_OUTPUT:
                    //comm.Parameters.Add(new OracleParameter(":" + field.ParameterName, OracleDbType.RefCursor))
                    //    .Direction = ParameterDirection.Output;
                    break;
                }
            }
            var parameter = new NpgsqlParameter();

            fields = FieldUtils.GetModuleFields(searchInfo.ModuleID, WebCore.CODES.DEFMODFLD.FLDGROUP.SEARCH_CONDITION);
            foreach (var condition in staticConditionInstances)
            {
                foreach (var field in fields)
                {
                    if (field.FieldID == condition.ConditionID)
                    {
                        if (string.IsNullOrEmpty(condition.Value))
                        {
                            parameter.ParameterName = field.ParameterName;
                            parameter.NpgsqlDbType  = NpgsqlDbType.Text;
                            parameter.Value         = DBNull.Value;
                            comm.Parameters.Add(parameter);
                            //comm.Parameters.Add(":" + field.ParameterName, DBNull.Value);
                        }
                        else
                        {
                            parameter.ParameterName = ":" + field.ParameterName;
                            parameter.NpgsqlDbType  = NpgsqlDbType.Text;
                            parameter.Value         = condition.Value.Decode(field);
                            comm.Parameters.Add(parameter);
                            //comm.Parameters.Add(":" + field.ParameterName, condition.Value.Decode(field));
                        }
                    }
                }
            }
        }