예제 #1
0
        public async Task <ActionResult> DeleteModule(string store, [FromBody] List <ModuleFieldInfo> fieldsInfos)
        {
            var outPut = new RestOutput <string>();

            try
            {
                var m_Client = new CoreController(_configuration);
                var cm       = new WebApiCore.CommonFunction();
                //var lst = new List<string>();
                //var param = m_Client.DiscoveryParameters(store);
                ////cm.GetSQLServerParameterValues(out lst, store, param, fieldsInfos);
                //cm.GetNpgsqlParameterValues(param, fieldsInfos);
                //var userName = GetUserName();
                //var dataStore = m_Client.RunStore(store, lst, userName);


                var param = m_Client.DiscoveryParameters(store.IndexOf(".") > 0 ? store : _Schema + "." + store);
                cm.GetNpgsqlParameterValues(param, fieldsInfos);
                var userName  = GetUserName();
                var dataStore = m_Client.RunFunction(store, param);

                outPut.Data       = dataStore;
                outPut.ResultCode = 1;
                return(Ok(outPut));
            }
            catch (Exception ex)
            {
                outPut.ResultCode = -1;
                outPut.Message    = ex.ToString();
            }
            return(Ok(outPut));
        }
예제 #2
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));
        }
예제 #3
0
        public async Task <ActionResult> LoadMainTainModule(string modId, string subModId, string parram, [FromBody] List <ModuleFieldInfo> fieldsInfos)
        {
            var outPut = new RestOutput <object>();

            try
            {
                var m_Client = new CoreController(_configuration);
                var data     = m_Client.LoadMainTainModule(modId);
                MaintainModuleInfo modMaintain = null;
                var store = "";
                if (data.Any())
                {
                    modMaintain = data.First();
                    store       = CommonFunction.GetStoreRunModMaintain(modMaintain, subModId ?? ESubMod.MVW.ToString());
                }
                var fields = CommonFunction.GetModuleFields(fieldsInfos, modId, FLDGROUP.PARAMETER);
                var cm     = new WebApiCore.CommonFunction();
                var lst    = new List <string>();
                if (!string.IsNullOrEmpty(store))
                {
                    var param = m_Client.DiscoveryParameters(store.IndexOf(".") > 0 ? store : store);
                    cm.GetNpgsqlParameterValues(param, fields);
                    var dataStore = m_Client.RunStoreToDataTable(store, param);
                    outPut.Data = JsonConvert.SerializeObject(dataStore);
                    return(Ok(outPut));
                }
                return(Ok(outPut));
            }
            catch (Exception ex)
            {
                outPut.ResultCode = -1;
                outPut.Message    = ex.ToString();
                return(Ok(outPut));
            }
        }
예제 #4
0
        public async Task <ActionResult> InsertLog([FromBody] LOG log)
        {
            var           outPut   = new RestOutput <int>();
            var           m_Client = new CoreController(_configuration);
            SqlConnection conn     = new SqlConnection(m_Client.ConnectionString);

            try
            {
                var cm         = new WebApiCore.CommonFunction();
                var lst        = new List <string>();
                var store      = "sp_LOG_INS";
                var param      = m_Client.DiscoveryParameters(store);
                var fieldInfos = new List <SqlParameter>();
                fieldInfos.Add(new SqlParameter("@ModId", log.ModId));
                fieldInfos.Add(new SqlParameter("@Type", log.Type));
                fieldInfos.Add(new SqlParameter("@ActionError", log.ActionError));
                fieldInfos.Add(new SqlParameter("@Note", log.Note));
                var userName = GetUserName();
                fieldInfos.Add(new SqlParameter("@UserName", userName));
                fieldInfos.Add(new SqlParameter("@Ip", log.Ip));
                conn.Open();
                var comm = new SqlCommand(store, conn);
                comm.CommandType = CommandType.StoredProcedure;
                comm.Parameters.AddRange(fieldInfos.ToArray());
                comm.ExecuteNonQuery();
                return(Ok(outPut));
            }
            catch (Exception ex)
            {
                outPut.ResultCode = -1;
                outPut.Message    = ex.ToString();
                return(Ok(outPut));
            }
            finally
            {
                conn.Close();
            }
        }
예제 #5
0
        public async Task <ActionResult> LoadDefModByTypeValue([FromBody] List <CodeInfoParram> codeInfos)
        {
            var outPut     = new RestOutput <List <CodeInfoModel> >();
            var outPutData = new List <CodeInfoModel>();

            try
            {
                var m_Client = new CoreController(_configuration);
                foreach (var item in codeInfos)
                {
                    try
                    {
                        if (item.ListSource == null)
                        {
                            continue;
                        }
                        if (item.ListSource.Contains(":"))
                        {
                            var codeInfoModel = new CodeInfoModel
                            {
                                Name      = item.Name,
                                CodeInfos = m_Client.LoadDefModByTypeValue(item.ListSource)
                            };
                            outPutData.Add(codeInfoModel);
                        }
                        else
                        {
                            var parram = new List <string>();
                            if (!string.IsNullOrEmpty(item.Parrams))
                            {
                                parram.Add(item.Parrams);
                            }
                            var param     = new List <SqlParameter>();
                            var storeName = item.ListSource;
                            if (!(item.ListSource.IndexOf("(") < 0 && item.ListSource.IndexOf(")") < 0))
                            {
                                storeName = item.ListSource.Substring(0, item.ListSource.IndexOf("("));
                                var strParr = item.ListSource.Substring(item.ListSource.IndexOf("(") + 1, item.ListSource.IndexOf(")") - item.ListSource.IndexOf("(") - 1);
                                if (!string.IsNullOrEmpty(strParr))
                                {
                                    parram.AddRange(strParr.Split(','));
                                }
                            }

                            param = m_Client.DiscoveryParameters(storeName);
                            int index = 0;
                            foreach (var pr in param)
                            {
                                //if (pr.NpgsqlDbType != NpgsqlTypes.NpgsqlDbType.Refcursor)
                                //{
                                pr.Value = parram[index];
                                index++;
                                //}
                            }
                            var data = new DataTable();

                            data = (DataTable)m_Client.RunStoreToDataTable(storeName, param);


                            if (data != null)
                            {
                                if (data.Columns.Contains("VALUE"))//Trường hợp load các Listsource không phải callback
                                {
                                    if (item.CtrlType != EControlType.SCL.ToString())
                                    {
                                        var codeInfoControls = (from p in data.AsEnumerable() select new CodeInfo {
                                            CodeValue = p["VALUE"].ToString(), CodeValueName = p["TEXT"].ToString()
                                        }).ToList();
                                        var codeInfoModel    = new CodeInfoModel
                                        {
                                            ControlType = item.CtrlType,
                                            Name        = item.Name,
                                            CodeInfos   = codeInfoControls
                                        };
                                        outPutData.Add(codeInfoModel);
                                    }
                                    else
                                    {
                                        var scheduleControl = (from p in data.AsEnumerable() select new ScheduleControlModel {
                                            id = p["id"].ToString(), title = p["title"].ToString(), className = p["className"].ToString(), end = p["end"].ToString(), start = p["start"].ToString(), url = p["url"].ToString(), modId = p["modId"].ToString()
                                        }).ToList();
                                        var codeInfoModel   = new CodeInfoModel
                                        {
                                            ControlType      = item.CtrlType,
                                            Name             = item.Name,
                                            ScheduleControls = scheduleControl
                                        };
                                        outPutData.Add(codeInfoModel);
                                    }
                                }
                                else//Trường hợp load các Listsource  callback
                                {
                                    var dataCallBack  = JsonConvert.SerializeObject(data);
                                    var codeInfoModel = new CodeInfoModel
                                    {
                                        ControlType  = item.CtrlType,
                                        Name         = item.Name,
                                        DataCallBack = dataCallBack
                                    };
                                    outPutData.Add(codeInfoModel);
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                    }
                }
                outPut.Data       = outPutData;
                outPut.ResultCode = 1;
                return(Ok(outPut));
            }
            catch (Exception ex)
            {
                outPut.ResultCode = -1;
                outPut.Message    = ex.ToString();
                return(Ok(outPut));
            }
            return(Ok(outPut));
        }