Ejemplo n.º 1
0
        public async Task <string> LoadQueryModule([FromBody] ParramModuleQuery query)
        {
            var outPut = new RestOutput <string>();

            try
            {
                var m_Client = new CoreController(_configuration);
                var ds       = m_Client.LoadProcedure(query.Store, query.Parram);
                if (ds != null)
                {
                    //Newtonsoft.Json.JsonSerializer json = new Newtonsoft.Json.JsonSerializer();
                    //json.Converters.Add(new DataSetConverter());
                    //(((DataSet)ds).Tables[0])
                    outPut.Data = JsonConvert.SerializeObject(((DataSet)ds).Tables[0], Formatting.Indented, new JsonSerializerSettings {
                        Converters = new[] { new DataSetConverter() }
                    });
                    //string json = JsonConvert.SerializeObject(dataSet, Formatting.Indented, new JsonSerializerSettings { Converters = new[] { new Newtonsoft.Json.Converters.DataSetConverter() } });
                    outPut.ResultCode = 1;
                    outPut.Message    = "";
                    return(JsonConvert.SerializeObject(outPut));
                }
            }
            catch (Exception ex)
            {
                outPut.ResultCode = -1;
                outPut.Message    = ex.ToString();
                return(JsonConvert.SerializeObject(outPut));
            }
            return(null);
        }
Ejemplo n.º 2
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));
            }
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
0
        public async Task <string> SearchModSearch([FromBody] SearchModSearch searchModSearch)
        {
            var outPut = new RestOutput <string>();

            try
            {
                var m_Client       = new CoreController(_configuration);
                var whereExtension = string.Empty;
                var query          = BuildQuerySearch.BuildSearchCondition(searchModSearch.ModInfo, ref whereExtension, null, searchModSearch.StaticConditionInstances.First());

                //var ds = m_Client.LoadProcedure(query.Store, query.Parram);
                //if (ds != null)
                //{
                //    //Newtonsoft.Json.JsonSerializer json = new Newtonsoft.Json.JsonSerializer();
                //    //json.Converters.Add(new DataSetConverter());
                //    //(((DataSet)ds).Tables[0])
                //    outPut.Data = JsonConvert.SerializeObject(((DataSet)ds).Tables[0], Formatting.Indented, new JsonSerializerSettings { Converters = new[] { new DataSetConverter() } });
                //    //string json = JsonConvert.SerializeObject(dataSet, Formatting.Indented, new JsonSerializerSettings { Converters = new[] { new Newtonsoft.Json.Converters.DataSetConverter() } });
                //    outPut.ResultCode = 1;
                //    outPut.Message = "";
                //    return JsonConvert.SerializeObject(outPut);
                //}
            }
            catch (Exception ex)
            {
                outPut.ResultCode = -1;
                outPut.Message    = ex.ToString();
                return(JsonConvert.SerializeObject(outPut));
            }
            return(null);
        }
Ejemplo n.º 5
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.º 6
0
        //Dongpv:15/06/2020
        //public async Task<List<dynamic>> getQuery(ParramModuleQuery parram)
        public async Task <List <dynamic> > getQuery(Message msg) //ParramModuleQuery parram ModalParameters
        {
            try
            {
                //var json = JsonConvert.SerializeObject(obj);
                //var  json = JsonConvert.DeserializeObject<string>(apiResponse);
                //ArrayList Body = new ArrayList(); Body.Add("pv_UserId"); Body.Add(userId);
                //1. Convert obj to arraylist
                //foreach (ParramModuleQuery moduleFieldInfo in  parram)
                //{
                //    if (moduleFieldInfo.Value != null)
                //    {
                //        Body.Add(moduleFieldInfo.FieldName); Body.Add(moduleFieldInfo.Value);
                //        enity = moduleFieldInfo.Entity;
                //    }
                //}

                var json = JsonConvert.SerializeObject(msg);

                //2. CALL HOST
                var result = await SendMessage(json);

                DataTable tb = new DataTable();
                if (!string.IsNullOrEmpty(result) && result != "null")
                {
                    tb = SysUtils.Json2Table(result);
                }

                //DataTable tb = SysUtils.Json2Table(data);

                //var moduleds = JsonConvert.DeserializeObject<string> (data);
                //var moduleds = JsonConvert.DeserializeObject<RestOutput<string>>(data);
                //DataTable dt = (DataTable)JsonConvert.DeserializeObject(moduleds.Data, (typeof(DataTable)));
                //var moduledData = JsonConvert.DeserializeObject<List<dynamic>>(moduleds.Data);
                //var moduledData = JsonConvert.DeserializeObject<List<dynamic>>(moduleds);
                // return moduledData;
                //DataTable dt = (DataTable)JsonConvert.DeserializeObject(data, (typeof(DataTable)));
                var outPut = new RestOutput <string>();
                outPut.Data = JsonConvert.SerializeObject(tb, Formatting.Indented, new JsonSerializerSettings {
                    Converters = new[] { new DataSetConverter() }
                });
                //string json = JsonConvert.SerializeObject(dataSet, Formatting.Indented, new JsonSerializerSettings { Converters = new[] { new Newtonsoft.Json.Converters.DataSetConverter() } });
                outPut.ResultCode = 1;
                outPut.Message    = "";
                //return JsonConvert.SerializeObject(outPut);

                var       moduleds    = JsonConvert.DeserializeObject <RestOutput <string> >(JsonConvert.SerializeObject(outPut));
                DataTable dt          = (DataTable)JsonConvert.DeserializeObject(moduleds.Data, (typeof(DataTable)));
                var       moduledData = JsonConvert.DeserializeObject <List <dynamic> >(moduleds.Data);

                return(moduledData);

                //return data;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 7
0
        public async Task <RestOutput <string> > UpdateData(string modId, string enity, string keyEdit, List <ModuleFieldInfo> fieldEdits)
        {
            try
            {
                //var json = JsonConvert.SerializeObject(obj);
                //var  json = JsonConvert.DeserializeObject<string>(apiResponse);
                //ArrayList Body = new ArrayList(); Body.Add("pv_UserId"); Body.Add(userId);

                //1. Convert obj to arraylist
                //ArrayList Body = new ArrayList();
                //foreach (ModuleFieldInfo moduleFieldInfo in fieldEdits)
                //{
                //    Body.Add(moduleFieldInfo.FieldName); Body.Add(moduleFieldInfo.Value);
                //}

                var order = new {
                    UserID     = "0000",
                    IP         = "00000",
                    BranchID   = "000",
                    ModuleID   = modId,
                    ObjectName = enity,
                    MsgType    = Constants.MSG_MNT_TYPE,
                    MsgAction  = Constants.MSG_UPDATE_ACTION,
                    Body       = fieldEdits
                };

                var json = JsonConvert.SerializeObject(order);

                var result = await SendMessage(json);

                DataTable tb = new DataTable();
                if (!string.IsNullOrEmpty(result) && result != "null")
                {
                    tb = SysUtils.Json2Table(result);
                }

                //var moduleds = JsonConvert.DeserializeObject<RestOutput<string>>(data);
                var outPut = new RestOutput <string>();
                outPut.Data = JsonConvert.SerializeObject(tb, Formatting.Indented, new JsonSerializerSettings {
                    Converters = new[] { new DataSetConverter() }
                });
                outPut.ResultCode = 1;
                outPut.Message    = "";

                var       moduleds    = JsonConvert.DeserializeObject <RestOutput <string> >(JsonConvert.SerializeObject(outPut));
                DataTable dt          = (DataTable)JsonConvert.DeserializeObject(moduleds.Data, (typeof(DataTable)));
                var       moduledData = JsonConvert.DeserializeObject <List <dynamic> >(moduleds.Data);

                return(moduleds);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 8
0
        public async Task Save()
        {
            //HomeBus homeBus = new HomeBus(moduleService, iConfiguration, distributedCache);
            var    excute  = new RestOutput <string>();
            string store   = "";
            string modId   = "";
            string keyEdit = "";

            //Dongpv:
            excute = (await moduleService.UpdateData(modId, store, keyEdit, Conver2FieldInfos(ContractModel)));
        }
Ejemplo n.º 9
0
        public async Task <ActionResult> Get(string moduleName)
        {
            var outPut     = new RestOutput <ModuleInfoViewModel>();
            var moduleInfo = new ModuleInfoViewModel();

            try
            {
                var modulesInfo      = new List <ModuleInfo>();
                var fieldsInfo       = new List <ModuleFieldInfo>();
                var buttonsInfo      = new List <ButtonInfo>();
                var buttonParamsInfo = new List <ButtonParamInfo>();
                var languageInfo     = new List <LanguageInfo>();
                var oracleParamsInfo = new List <OracleParam>();
                var m_Client         = new CoreController(_configuration);
                m_Client.ForceLoadModule(out modulesInfo, out fieldsInfo, out buttonsInfo, out buttonParamsInfo, out languageInfo, out oracleParamsInfo, moduleName);
                var fields    = fieldsInfo.Where(x => String.IsNullOrEmpty(x.ParentId)).ToList();
                var parentIds = fieldsInfo.Where(x => !String.IsNullOrEmpty(x.ParentId)).Select(x => x.ParentId).Distinct().ToList();
                if (parentIds != null)
                {
                    foreach (var parentId in parentIds)
                    {
                        var field = fields.Where(x => x.FieldID == parentId);
                        if (field != null && field.Any())
                        {
                            field.First().FieldChilds = fieldsInfo.Where(x => x.ParentId == parentId).ToList();
                        }
                    }
                }
                //var dicFieldInfo = new Dictionary<ModuleFieldInfo, string>();
                moduleInfo = new ModuleInfoViewModel
                {
                    ButtonParamsInfo = buttonParamsInfo,
                    ButtonsInfo      = buttonsInfo,
                    FieldsInfo       = fields,
                    LanguageInfo     = languageInfo,
                    ModulesInfo      = modulesInfo,
                    OracleParamsInfo = oracleParamsInfo
                };
                outPut.Data = moduleInfo;
                return(Ok(outPut));
            }
            catch (Exception ex)
            {
                outPut.ResultCode = -1;
                outPut.Message    = ex.ToString();
                return(Ok(outPut));
            }
            return(Ok(outPut));
        }
Ejemplo n.º 10
0
        private Task StartRestWriter(BlockingCollection <Wrapper <OutputBase> > output)
        {
            return(Task.Factory.StartNew(() =>
            {
                var objectCount = 0;

                using (var client = new WebClient())
                {
                    client.Headers.Add("content-type", "application/json");
                    client.Headers.Add("Accept", "application/json; charset=UTF-8");
                    client.Headers.Add("Authorization", _options.GetEncodedUserPass());

                    var coll = new RestOutput();
                    var serializer = new JavaScriptSerializer();

                    foreach (var obj in output.GetConsumingEnumerable())
                    {
                        var item = obj.Item;

                        if (item is DomainTrust temp)
                        {
                            foreach (var x in temp.ToMultipleParam())
                            {
                                coll.AddNewData(temp.TypeHash(), x);
                            }
                        }
                        else
                        {
                            coll.AddNewData(item.TypeHash(), item.ToParam());
                        }

                        obj.Item = null;
                        objectCount++;

                        if (objectCount % 500 != 0)
                        {
                            continue;
                        }
                        var data = serializer.Serialize(coll.GetStatements());
                        client.UploadData(_options.GetURI(), "POST", Encoding.Default.GetBytes(data));
                        coll.Reset();
                    }
                    var remainingData = serializer.Serialize(coll.GetStatements());
                    var responseArray = client.UploadData(_options.GetURI(), "POST", Encoding.Default.GetBytes(remainingData));
                    //Console.WriteLine(Encoding.ASCII.GetString(responseArray));
                }
            }, TaskCreationOptions.LongRunning));
        }
Ejemplo n.º 11
0
        public async Task <ActionResult> GetAllCodeInfo()
        {
            var outPut = new RestOutput <List <CodeInfo> >();

            try
            {
                var m_Client = new CoreController(_configuration);
                var data     = m_Client.GetAllCodeInfo();
                outPut.Data = data;
                return(Ok(outPut));
            }
            catch (Exception ex)
            {
            }
            return(Ok(outPut));
        }
Ejemplo n.º 12
0
        public async Task <ActionResult> LoadModMaintainByModId(string modId)
        {
            var outPut = new RestOutput <List <MaintainModuleInfo> >();

            try
            {
                var m_Client = new CoreController(_configuration);
                var data     = m_Client.LoadMainTainModule(modId);
                outPut.Data = data;
                return(Ok(outPut));
            }
            catch (Exception ex)
            {
            }
            return(Ok(outPut));
        }
Ejemplo n.º 13
0
        public async Task <RestOutput <string> > DeleteModule(string store, List <ModuleFieldInfo> fieldDels)
        {
            try
            {
                var url  = string.Format("Module/DeleteModule?store={0}", store);
                var data = await PostApi(url, fieldDels);

                var moduleds = JsonConvert.DeserializeObject <RestOutput <string> >(data);
                return(moduleds);
            }
            catch (Exception ex)
            {
                var outPut = new RestOutput <string>();
                outPut.Data = ex.Message;
                return(outPut);
            }
        }
Ejemplo n.º 14
0
        public async Task <ActionResult> LoadModSearchByModId(string modId)
        {
            var outPut = new RestOutput <List <SearchModuleInfo> >();

            try
            {
                var m_Client = new CoreController(_configuration);
                var data     = m_Client.LoadModSearchByModId(modId);
                outPut.Data = data;
                return(Ok(outPut));
            }
            catch (Exception ex)
            {
                outPut.ResultCode = -1;
                outPut.Message    = ex.ToString();
            }
            return(Ok(null));
        }
Ejemplo n.º 15
0
        public async Task <ActionResult> LoadDefModByTypeValue(string parameter)
        {
            var outPut = new RestOutput <List <CodeInfo> >();

            try
            {
                var m_Client   = new CoreController(_configuration);
                var outPutData = m_Client.LoadDefModByTypeValue(parameter);
                outPut.Data = outPutData;
                return(Ok(outPut));
            }
            catch (Exception ex)
            {
                outPut.ResultCode = -1;
                outPut.Message    = ex.ToString();
                return(Ok(outPut));
            }
            return(Ok(outPut));
        }
Ejemplo n.º 16
0
 public async Task <ActionResult> GetGroupModByUserId(string userId)
 {
     try
     {
         var outPut = new RestOutput <List <GroupMod> >();
         try
         {
             var m_Client = new CoreController(_configuration);
             var data     = m_Client.GetGroupModByUserId(userId);
             outPut.Data = data;
             return(Ok(outPut));
         }
         catch (Exception ex)
         {
         }
         return(Ok(outPut));
     }
     catch (Exception ex)
     {
     }
     return(Ok(null));
 }
Ejemplo n.º 17
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();
            }
        }
Ejemplo n.º 18
0
        public async Task <ActionResult> GetAllIcon()
        {
            var outPut = new RestOutput <List <LanguageInfo> >();

            try
            {
                var m_Client = new CoreController(_configuration);
                var menu     = m_Client.GetAllLanguageIcon();
                if (!menu.Any())
                {
                    outPut.Data = null;
                    return(Ok(outPut));
                }
                outPut.Data = menu;
                return(Ok(outPut));
            }
            catch (Exception ex)
            {
                outPut.ResultCode = -1;
                outPut.Message    = ex.ToString();
                return(Ok(outPut));
            }
        }
Ejemplo n.º 19
0
        public async Task <ActionResult> GetUserLogin(string userName, string password)
        {
            var outPut = new RestOutput <User>();

            try
            {
                var m_Client = new CoreController(_configuration);
                var users    = m_Client.GetUserByUserNamePassword(userName, password);
                if (!users.Any())
                {
                    outPut.Data = null;
                    return(Ok(outPut));
                }
                outPut.Data = users.First();
                return(Ok(outPut));
            }
            catch (Exception ex)
            {
                outPut.ResultCode = -1;
                outPut.Message    = ex.ToString();
                return(Ok(outPut));
            }
        }
Ejemplo n.º 20
0
        public async Task <ActionResult> GetAllSysVar()
        {
            var outPut = new RestOutput <List <SysVar> >();

            try
            {
                var m_Client = new CoreController(_configuration);
                var sysVar   = m_Client.GetAllSysVar();
                if (!sysVar.Any())
                {
                    outPut.Data = null;
                    return(Ok(outPut));
                }
                outPut.Data = sysVar;
                return(Ok(outPut));
            }
            catch (Exception ex)
            {
                outPut.ResultCode = -1;
                outPut.Message    = ex.ToString();
                return(Ok(outPut));
            }
        }
Ejemplo n.º 21
0
        public async Task Save()
        {
            //Dongpv:FIX TO RUN
            //ErrorValidate = new List<string>();
            //foreach (var item in moduleFieldInfo)
            //{
            //    var validator = new Common.FluentValidation();

            //    var rsErr = validator.Validate(item);
            //    if (!rsErr.IsValid)
            //    {
            //        ErrorValidate.AddRange(rsErr.Errors.Select(x => x.ErrorMessage));
            //    }
            //}
            //if (ErrorValidate.Any())
            //{
            //    return;
            //}
            //Dongpv:FIX TO RUN

            HomeBus homeBus = new HomeBus(moduleService, iConfiguration, distributedCache);

            string validate = "";

            var modMaintain = await homeBus.LoadMaintainModuleInfo(modId);

            var store = "";

            //Dongpv:
            var excute = new RestOutput <string>();

            if (string.IsNullOrEmpty(keyEdit))
            {
                store = modMaintain.AddInsertStore;
                //Dongpv:
                excute = (await moduleService.SaveData(modId, store, keyEdit, moduleFieldInfo));
            }
            else
            {
                store = modMaintain.EditUpdateStore;
                //Dongpv:
                excute = (await moduleService.UpdateData(modId, store, keyEdit, moduleFieldInfo));
            }


            //var excute = (await moduleService.SaveEditModule(modId, store, keyEdit, fieldEdits));
            //Dongpv:
            //var excute = (await moduleService.SaveEditModule(modId, store, keyEdit, moduleFieldInfo));
            //Dongpv:

            if (excute.Data != "success" && excute.ResultCode != 1)
            {
                var err             = excute.Data.GetError();
                var redrectToSearch = string.IsNullOrEmpty(parram) ? modMaintain.AddRepeatInput : modMaintain.EditRepeatInput;
                JSRuntime.InvokeAsync <string>("bb_alert", excute.Data, DotNetObjectReference.Create(this), "AlertCallBack", redrectToSearch);
            }
            else
            {
                if (modMaintain.ShowSuccess == "Y" || excute.ResultCode == 1)
                {
                    var title = "Lưu dữ liệu thành công";
                    JSRuntime.InvokeAsync <string>("bb_alert", title, DotNetObjectReference.Create(this), "AlertCallBack");
                    //Modal.Show<Pages.Edit>(moduleInfoModel.ModulesInfo.ModuleName.GetLanguageTitle(moduleInfoModel.LanguageInfo), parameters);
                }
            }
        }
Ejemplo n.º 22
0
        public async Task <List <dynamic> > getDetail(string modId, string modSearchId, List <ModuleFieldInfo> fieldEdits) //ParramModuleQuery parram ModalParameters
        {
            try
            {
                //var json = JsonConvert.SerializeObject(obj);
                //var  json = JsonConvert.DeserializeObject<string>(apiResponse);
                //ArrayList Body = new ArrayList(); Body.Add("pv_UserId"); Body.Add(userId);
                //1. Convert obj to arraylist

                var order = new {
                    UserID     = "0000",
                    MsgIP      = "00000",
                    BranchID   = "000",
                    ModId      = modId,
                    ObjectName = Constants.OBJ_DETAIL,
                    MsgType    = Constants.MSG_MISC_TYPE,
                    MsgAction  = Constants.MSG_SEARCH,
                    Body       = fieldEdits
                };

                var json = JsonConvert.SerializeObject(order);

                //2. CALL HOST
                var result = await SendMessage(json);

                DataTable tb = new DataTable();
                if (!string.IsNullOrEmpty(result) && result != "null")
                {
                    tb = SysUtils.Json2Table(result);
                }

                //DataTable tb = SysUtils.Json2Table(data);
                //var moduleds = JsonConvert.DeserializeObject<string> (data);
                //var moduleds = JsonConvert.DeserializeObject<RestOutput<string>>(data);
                //DataTable dt = (DataTable)JsonConvert.DeserializeObject(moduleds.Data, (typeof(DataTable)));
                //var moduledData = JsonConvert.DeserializeObject<List<dynamic>>(moduleds.Data);
                //var moduledData = JsonConvert.DeserializeObject<List<dynamic>>(moduleds);
                // return moduledData;
                //DataTable dt = (DataTable)JsonConvert.DeserializeObject(data, (typeof(DataTable)));
                var outPut = new RestOutput <string>();
                outPut.Data = JsonConvert.SerializeObject(tb, Formatting.Indented, new JsonSerializerSettings {
                    Converters = new[] { new DataSetConverter() }
                });
                //string json = JsonConvert.SerializeObject(dataSet, Formatting.Indented, new JsonSerializerSettings { Converters = new[] { new Newtonsoft.Json.Converters.DataSetConverter() } });
                outPut.ResultCode = 1;
                outPut.Message    = "";
                //return JsonConvert.SerializeObject(outPut);

                var       moduleds    = JsonConvert.DeserializeObject <RestOutput <string> >(JsonConvert.SerializeObject(outPut));
                DataTable dt          = (DataTable)JsonConvert.DeserializeObject(moduleds.Data, (typeof(DataTable)));
                var       moduledData = JsonConvert.DeserializeObject <List <dynamic> >(moduleds.Data);

                return(moduledData);

                //return data;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 23
0
        public async Task <RestOutput <string> > SaveData(string modId, string enity, string keyEdit, List <ModuleFieldInfo> fieldEdits)
        {
            try
            {
                //var json = JsonConvert.SerializeObject(obj);
                //var  json = JsonConvert.DeserializeObject<string>(apiResponse);
                //ArrayList Body = new ArrayList(); Body.Add("pv_UserId"); Body.Add(userId);
                //1. Convert obj to arraylist
                //ArrayList Body = new ArrayList();
                //foreach (ModuleFieldInfo moduleFieldInfo in fieldEdits)
                //{
                //    if (moduleFieldInfo.Value != null)
                //    {
                //        if(string.IsNullOrEmpty(enity)) enity = moduleFieldInfo.Entity;

                //        string controlType = moduleFieldInfo.ControlType;
                //        string fileName = moduleFieldInfo.FieldName.Trim();
                //        object value = moduleFieldInfo.Value;

                //        if (controlType == "GE")
                //        {
                //            ArrayList arrDetail = new ArrayList();
                //            SysUtils.String2ArrayList(ref arrDetail, value.ToString().Replace("[", "").Replace("]", "").Replace("{", "").Replace("}", "").Replace("\r\n", "").Replace("\"", ""), ",", ":");
                //            value = arrDetail;
                //        }

                //       Body.Add(fileName); Body.Add(value);
                //    }
                //}

                var message = new {
                    UserID     = "0000",
                    IP         = "00000",
                    BranchID   = "000",
                    ModuleID   = modId,
                    ModId      = modId,
                    ObjectName = enity,
                    MsgType    = Constants.MSG_MNT_TYPE,
                    MsgAction  = Constants.MSG_ADD_ACTION,
                    Body       = fieldEdits
                };

                var json = JsonConvert.SerializeObject(message);

                var result = await SendMessage(json);

                DataTable tb = new DataTable();
                if (!string.IsNullOrEmpty(result) && result != "null")
                {
                    tb = SysUtils.Json2Table(result);
                }

                var outPut = new RestOutput <string>();
                outPut.Data = JsonConvert.SerializeObject(tb, Formatting.Indented, new JsonSerializerSettings {
                    Converters = new[] { new DataSetConverter() }
                });
                //string json = JsonConvert.SerializeObject(dataSet, Formatting.Indented, new JsonSerializerSettings { Converters = new[] { new Newtonsoft.Json.Converters.DataSetConverter() } });
                outPut.ResultCode = 1;
                outPut.Message    = "";

                //var moduleds = JsonConvert.DeserializeObject<RestOutput<string>>(data);
                var       moduleds    = JsonConvert.DeserializeObject <RestOutput <string> >(JsonConvert.SerializeObject(outPut));
                DataTable dt          = (DataTable)JsonConvert.DeserializeObject(moduleds.Data, (typeof(DataTable)));
                var       moduledData = JsonConvert.DeserializeObject <List <dynamic> >(moduleds.Data);

                return(moduleds);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 24
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));
        }