// POST api/ExcuteOracle
        public string Post(ValueModelOracle value)
        {
            if (dicAppSet == null || dicAppSet.Count == 0)
            {
                general gn = new general();
                dicAppSet = gn.ReadAppseting();
                if (dicAppSet == null || dicAppSet.Count == 0)
                {
                    return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Đọc appsetting lỗi\"}]}");
                }
            }

            if (value == null || value.config == null)
            {
                return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại định dạng json đầu vào\"}]}");
            }

            Db_Access ac    = new Db_Access();
            var       check = ac.checkRequertLienTuc(HttpContext.Current, dicAppSet, value.config, value.para);

            if (!check)
            {
                return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Không cho phép request liên tục\"}]}");
            }

            var json = "";

            gnOracleXml orc = new gnOracleXml();

            json = orc.ExcuteStores(value.config, value.para, dicAppSet);

            return(json);
        }
Beispiel #2
0
        // POST: api/ExcuteText

        public string Post(ValueText value)
        {
            if (value == null || value.connstr == null || value.connstr == "" || value.sqltext == null)
            {
                return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại định dạng json đầu vào\"}]}");
            }

            general   gns       = new general();
            var       dicAppSet = gns.ReadAppseting();
            Db_Access ac        = new Db_Access();
            var       check     = ac.checkRequertLienTuc(HttpContext.Current, dicAppSet, value.sqltext, "");

            if (!check)
            {
                return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Không cho phép request liên tục\"}]}");
            }

            var dicConfig = new Dictionary <string, string>();

            dicConfig.Add("connstr", value.connstr);
            dicConfig.Add("namesql", value.sqltext);
            dicConfig.Add("commandtype", "Text");

            var json = "";

            gnOracle orc = new gnOracle();

            json = orc.ExcuteReturnJson(dicConfig, null);

            return(json);
        }
Beispiel #3
0
        // GET api/values
        public IEnumerable <string> Get()
        {
            general gn = new general();

            dicAppSet = gn.ReadAppseting();

            Db_Access ac = new Db_Access();

            var check = ac.checkRequertLienTuc(HttpContext.Current, dicAppSet, "test", "test");

            return(new string[] { "value1", (!check ? "Không được thực hiện lệnh liên tục trong " + dicAppSet["time_requestlientuc"] + " ms":"ok") });
        }
        public string Get(string config, string para)
        {
            try
            {
                string id = JsonConvert.DeserializeObject <Dictionary <string, string> >(para)["id"];
                if (id.Equals("id_user"))
                {
                    if (dicAppSet == null || dicAppSet.Count == 0)
                    {
                        general gn = new general();
                        dicAppSet = gn.ReadAppseting();
                        if (dicAppSet == null || dicAppSet.Count == 0)
                        {
                            return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Đọc appsetting lỗi\"}]}");
                        }
                    }

                    if (config == null || para == null)
                    {
                        return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại định dạng json đầu vào\"}]}");
                    }

                    Db_Access ac    = new Db_Access();
                    var       check = ac.checkRequertLienTuc(HttpContext.Current, dicAppSet, config, para);
                    if (!check)
                    {
                        return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Không cho phép request liên tục\"}]}");
                    }

                    gnOracle orc  = new gnOracle();
                    var      json = orc.ExcuteStores(config, para, dicAppSet);
                    return(json);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        // POST api/BulkcopyOracle
        public string Post(paraBulkTable value)
        {
            try
            {
                Dictionary <string, string> dicAppSet;
                Dictionary <string, string> dicProce;

                general gn = new general();
                dicAppSet = gn.ReadAppseting();

                var json      = "";
                var dicConfig = gn.ConfigConvertToDicConfig(value.config);
                if (dicConfig == null)
                {
                    return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại định dạng json đầu vào\"}]}");
                }
                var para = JObject.Parse(value.table);
                if (para == null)
                {
                    return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại định dạng json đầu vào\"}]}");
                }

                Db_Access ac    = new Db_Access();
                var       check = ac.checkRequertLienTuc(HttpContext.Current, dicAppSet, value.config, "");
                if (!check)
                {
                    return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Không cho phép request liên tục\"}]}");
                }

                foreach (var val in para)
                {
                    var dt = gn.ConvertJsonToDataTable(val.Value.ToString(), val.Key);
                    gnBulkCopyOracle or = new gnBulkCopyOracle();
                    json = or.BulkCopyToOracle(dt, dicConfig);
                }
                return(json);
            }
            catch (Exception ex)
            {
                return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"" + ex.Message.Replace("\n", "") + "\"}]}");
            }
        }
Beispiel #6
0
        // POST api/ExcuteOracle
        public string Post(ValueModelOracle value)
        {
            if (dicAppSet == null || dicAppSet.Count == 0)
            {
                general gn = new general();
                dicAppSet = gn.ReadAppseting();
                if (dicAppSet == null || dicAppSet.Count == 0)
                {
                    return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Đọc appsetting lỗi\"}]}");
                }
            }

            if (value == null || value.config == null)
            {
                return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại định dạng json đầu vào\"}]}");
            }

            Db_Access ac    = new Db_Access();
            var       check = ac.checkRequertLienTuc(HttpContext.Current, dicAppSet, value.config, value.para);

            if (!check)
            {
                return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Không cho phép request liên tục\"}]}");
            }
            //Db_Access_Cookie cook = new Db_Access_Cookie();
            //HttpCookie cookie = HttpContext.Current.Request.Cookies["Cookie"];
            //var checkCook = cook.checkCookie(cookie, dicAppSet, value.config);

            //var json = "";
            //if (checkCook == "ERROR")
            //{
            //    return "{\"result\":\"CookieError\",\"data\":[]}";
            //}
            //else
            //{
            gnOracle orc  = new gnOracle();
            var      json = orc.ExcuteStores(value.config, value.para, dicAppSet);

            //  }
            return(json);
        }
        // POST: api/BulkCopySql
        public string Post(paraBulkTableSql value)
        {
            try
            {
                general gn        = new general();
                var     dicAppSet = gn.ReadAppseting();
                var     json      = "";
                var     dicConfig = gn.ConfigConvertToDicConfig(value.config);
                if (dicConfig == null)
                {
                    return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại định dạng json đầu vào\"}]}");
                }
                var table = JObject.Parse(value.table);
                if (table == null)
                {
                    return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại định dạng json đầu vào\"}]}");
                }

                Db_Access ac    = new Db_Access();
                var       check = ac.checkRequertLienTuc(HttpContext.Current, dicAppSet, value.config, "");
                if (!check)
                {
                    return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Không cho phép request liên tục\"}]}");
                }

                gnSqlNomal gns  = new gnSqlNomal();
                var        para = gns.convertParaToDic(value.para);

                foreach (var val in table)
                {
                    var   dt  = gn.ConvertJsonToDataTable(val.Value.ToString(), val.Key);
                    gnSql sql = new gnSql();
                    json = sql.BulkCopyToSql(dt, dicConfig, para);
                }
                return(json);
            }
            catch (Exception ex)
            {
                return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"" + ex.Message.Replace("\n", "") + "\"}]}");
            }
        }
Beispiel #8
0
        // POST api/sqlnomal
        public string Post(ValueNomal value)
        {
            gnSqlNomal gn        = new gnSqlNomal();
            general    gns       = new general();
            var        dicAppSet = gns.ReadAppseting();

            if (value == null || value.config == null)
            {
                return("{\"result\":\"ERROR\",\"data\":\"Kiểm tra lại định dạng json đầu vào\"}");
            }

            Db_Access ac    = new Db_Access();
            var       check = ac.checkRequertLienTuc(HttpContext.Current, dicAppSet, value.config, value.para);

            if (!check)
            {
                return("{\"result\":\"ERROR\",\"data\":\"Không cho phép request liên tục\"}");
            }

            var config = gn.convertConfigToDic(value.config);
            var para   = gn.convertParaToDic(value.para);

            return(gn.ExecuteSqlDataset(config, para));
        }