示例#1
0
        public async static Task <JObject> GetTable_SP_Dic(AppSettings appSettings, string guidRequest, QueryBody queryBody)
        {
            string methodName = "GetTable_SP_Dic";

            try
            {
                DataTable table = new DataTable();
                if (queryBody.table.Count == 0)
                {
                    return(DapperPostgresHelper.ToJObject(null));
                }
                var columnNames = queryBody.table.SelectMany(dict => dict.Keys).Distinct();
                table.Columns.AddRange(columnNames.Select(c => new DataColumn(c)).ToArray());
                queryBody.table.ForEach(x =>
                {
                    var row = table.NewRow();
                    foreach (var k in x.Keys)
                    {
                        row[k] = x[k];
                    }
                    table.Rows.Add(row);
                });
                queryBody.parameters.Add("p_table", JsonConvert.SerializeObject(table));
                var result = await DapperPostgresHelper.ExecuteSP_SingleDictionary <dynamic>(appSettings, guidRequest, queryBody.method, queryBody.parameters);

                return(DapperPostgresHelper.ToJObject(result));
            }
            catch (Exception e)
            {
                Log.Write(appSettings, LogEnum.ERROR.ToString(), label, className, methodName, $"ERROR: {JsonConvert.SerializeObject(queryBody)}");
                Log.Write(appSettings, LogEnum.ERROR.ToString(), label, className, methodName, $"ERROR: {e.Source + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace}");
                throw e;
            }
        }
示例#2
0
        public async static Task <List <JObject> > GetCollection_SP_Dic_Free(AppSettings appSettings, string guidRequest, QueryBody queryBody)
        {
            string methodName = "GetCollection_SP_Dic_Free";

            try
            {
                var result = await DapperPostgresHelper.ExecuteSP_MultipleDictionaryFree <dynamic>(appSettings, guidRequest, queryBody.method, queryBody.parameters);

                return(DapperPostgresHelper.ToJObjectList(result));
            }
            catch (Exception e)
            {
                Log.Write(appSettings, LogEnum.ERROR.ToString(), label, className, methodName, $"ERROR: {JsonConvert.SerializeObject(queryBody)}");
                Log.Write(appSettings, LogEnum.ERROR.ToString(), label, className, methodName, $"ERROR: {e.Source + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace}");
                throw e;
            }
        }