|
|
@@ -0,0 +1,9052 @@
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Data;
|
|
|
+using System.Linq;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using System.Xml.Linq;
|
|
|
+using ApiProcess.Models.balance;
|
|
|
+using ApiProcessToken.Models.banlance;
|
|
|
+using CommonObj.common;
|
|
|
+using CommonObj.model;
|
|
|
+using Microsoft.AspNetCore.Http;
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
+using Microsoft.AspNetCore.Server.IISIntegration;
|
|
|
+using Microsoft.Extensions.Caching.Memory;
|
|
|
+using Newtonsoft.Json;
|
|
|
+using Newtonsoft.Json.Linq;
|
|
|
+using ResfullApi.Models;
|
|
|
+using ResfullApi.Models.balance;
|
|
|
+using StackExchange.Redis;
|
|
|
+
|
|
|
+namespace ApiProcess.Controllers
|
|
|
+{
|
|
|
+ [Route("api/[controller]/[action]/data")]
|
|
|
+ [ApiController]
|
|
|
+ public class balance : ControllerBase
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ static readonly log4net.ILog logger = log4net.LogManager.GetLogger(typeof(balance));
|
|
|
+
|
|
|
+ private IMemoryCache memoryCache;
|
|
|
+ public balance(IMemoryCache memoryCache)
|
|
|
+ {
|
|
|
+ this.memoryCache = memoryCache;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // {"users":"123","pass":"123"}
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult usersAdminLogin([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+ ////log4net.ILog logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
+ ////log4net.Config.XmlConfigurator.Configure();
|
|
|
+ ///
|
|
|
+ logger.Info("New request income admin Login :" + sendData.ToString());
|
|
|
+ responseObjLogin response = new responseObjLogin();
|
|
|
+ response.status = "-1";
|
|
|
+ response.message = "Err unknow";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string pass = Convert.ToString(userObj["pass"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "0";
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "1";
|
|
|
+ if (string.IsNullOrEmpty(pass)) pass = "-1";
|
|
|
+ if (string.IsNullOrEmpty(channel)) channel = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass"); var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.status = "-2";
|
|
|
+ response.message = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+
|
|
|
+ if (users == "-1" || pass == "-1" || channel == "-1")
|
|
|
+ {
|
|
|
+ logger.Info("Authen false");
|
|
|
+ response.status = "35";
|
|
|
+ response.message = CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.status, "");// "Check Authen false";
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.ADMIN_USERS_INFO(users, ResfullApi.Models.CustomEncryption.Encrypt(pass));
|
|
|
+ logger.Info("Call database ADMIN_USERS_INFO success:");
|
|
|
+
|
|
|
+ if (ds_regist == null || ds_regist.Tables[0].Rows.Count == 0)
|
|
|
+ {
|
|
|
+ response.status = "1";
|
|
|
+ response.message = "Login false";
|
|
|
+ response.role = "";
|
|
|
+ response.token = "";
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string status = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ if (status == "0")
|
|
|
+ {
|
|
|
+ //Tiep tuc lay danh sach chu nang cua Role
|
|
|
+ DataSet ds = balanceDataAccess.ADMIN_USERS_FUNCTION(ds_regist.Tables[0].Rows[0]["role"].ToString());
|
|
|
+ if (ds == null || ds.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ response.function = new adminFunctionObj[ds.Tables[0].Rows.Count];
|
|
|
+ for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
|
|
|
+ {
|
|
|
+ adminFunctionObj _obj = new adminFunctionObj();
|
|
|
+ _obj.id = ds.Tables[0].Rows[j]["id"].ToString();
|
|
|
+ _obj.role = ds.Tables[0].Rows[j]["ROLE"].ToString();
|
|
|
+ _obj.name = ds.Tables[0].Rows[j]["NAME"].ToString();
|
|
|
+ _obj.link = ds.Tables[0].Rows[j]["LINK"].ToString();
|
|
|
+ _obj.note = ds.Tables[0].Rows[j]["NOTE"].ToString();
|
|
|
+ response.function[j] = _obj;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ tokenObj _token = CommonFunction.createToken(_redis, users, pass, channel, "LOGIN_ADMIN", "", ds_regist.Tables[0].Rows[0]["role"].ToString());
|
|
|
+ response.status = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.message = ds_regist.Tables[0].Rows[0]["message"].ToString();
|
|
|
+ response.role = ds_regist.Tables[0].Rows[0]["role"].ToString();
|
|
|
+ response.token = _token.token;
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ response.status = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.message = ds_regist.Tables[0].Rows[0]["message"].ToString();
|
|
|
+ response.role = ds_regist.Tables[0].Rows[0]["role"].ToString();
|
|
|
+ response.token = "";
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("Err:" + ex.ToString());
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //{"id":"2","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult companyGetList([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income companyGetList :" + sendData.ToString());
|
|
|
+ companyList response = new companyList();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+
|
|
|
+ string order = Convert.ToString(userObj["order"]);
|
|
|
+ string rowsOnPage = Convert.ToString(userObj["rowsOnPage"]);
|
|
|
+ string seqPage = Convert.ToString(userObj["seqPage"]);
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(order)) order = "asc";
|
|
|
+ if (string.IsNullOrEmpty(rowsOnPage)) rowsOnPage = "1000000000000";
|
|
|
+ if (string.IsNullOrEmpty(seqPage)) seqPage = "1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+ /*
|
|
|
+ if (string.IsNullOrEmpty(requestId)) requestId = "";
|
|
|
+ if (string.IsNullOrEmpty(transIdByTicket)) transIdByTicket = "";
|
|
|
+ if (string.IsNullOrEmpty(paymentCode)) paymentCode = "";
|
|
|
+ if (string.IsNullOrEmpty(token)) token = "";
|
|
|
+ */
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.comGetList(id,users, name, code, fromDate, toDate, order, rowsOnPage, seqPage);
|
|
|
+ logger.Info("Call database comGetList success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+
|
|
|
+ response.rowsOnPage = ds_regist.Tables[0].Rows[0]["ROW_ON_PAGE"].ToString();
|
|
|
+ response.seqPage = ds_regist.Tables[0].Rows[0]["SEQ_PAGE"].ToString();
|
|
|
+ response.totalPage = ds_regist.Tables[0].Rows[0]["TOTAL_PAGE"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response.list = new company[ds_regist.Tables[0].Rows.Count];
|
|
|
+ for (int j = 0; j < ds_regist.Tables[0].Rows.Count; j++)
|
|
|
+ {
|
|
|
+ company _obj = new company();
|
|
|
+
|
|
|
+ _obj.id = ds_regist.Tables[0].Rows[j]["id"].ToString();
|
|
|
+ _obj.code = ds_regist.Tables[0].Rows[j]["code"].ToString();
|
|
|
+ _obj.name = ds_regist.Tables[0].Rows[j]["name"].ToString();
|
|
|
+ _obj.phone = ds_regist.Tables[0].Rows[j]["phone"].ToString();
|
|
|
+ _obj.email = ds_regist.Tables[0].Rows[j]["EMAIL"].ToString();
|
|
|
+ _obj.address = ds_regist.Tables[0].Rows[j]["ADDRESS"].ToString();
|
|
|
+ _obj.desciption = ds_regist.Tables[0].Rows[j]["DESCRIPTION"].ToString();
|
|
|
+ _obj.note = ds_regist.Tables[0].Rows[j]["NOTE"].ToString();
|
|
|
+ _obj.usersCreated = ds_regist.Tables[0].Rows[j]["USERS_CREATED"].ToString();
|
|
|
+ _obj.dateCreated = ds_regist.Tables[0].Rows[j]["DATE_CREATED"].ToString();
|
|
|
+ _obj.usersUpdate = ds_regist.Tables[0].Rows[j]["USERS_UPDATE"].ToString();
|
|
|
+ _obj.dateUpdate = ds_regist.Tables[0].Rows[j]["DATE_UPDATE"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response.list[j] = _obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"code":"124","phone":"0961423229","name":"Cty Viettech 1","email":"quangbh@gmail.com","description":"Mo ta","note":"note 1","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+
|
|
|
+ */
|
|
|
+
|
|
|
+ public IActionResult companyInsert([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income companyInsert :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string phone = Convert.ToString(userObj["phone"]);
|
|
|
+ string email = Convert.ToString(userObj["email"]);
|
|
|
+ string address = Convert.ToString(userObj["address"]);
|
|
|
+ string description = Convert.ToString(userObj["description"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
+ if (string.IsNullOrEmpty(phone)) phone = "-1";
|
|
|
+ if (string.IsNullOrEmpty(email)) email = "-1";
|
|
|
+ if (string.IsNullOrEmpty(address)) address = "-1";
|
|
|
+ if (string.IsNullOrEmpty(description)) description = "-1";
|
|
|
+ if (string.IsNullOrEmpty(note)) note = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+ /*
|
|
|
+ if (string.IsNullOrEmpty(requestId)) requestId = "";
|
|
|
+ if (string.IsNullOrEmpty(transIdByTicket)) transIdByTicket = "";
|
|
|
+ if (string.IsNullOrEmpty(paymentCode)) paymentCode = "";
|
|
|
+ if (string.IsNullOrEmpty(token)) token = "";
|
|
|
+ */
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.comInsert(code,name,phone,email,address,description,note,users);
|
|
|
+ logger.Info("Call database comInsert success:");
|
|
|
+
|
|
|
+
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success comInsert not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success comInsert is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"id":"2","code":"124","phone":"0961423229","name":"Cty Viettech New","email":"quangbh@gmail.com","description":"Mo ta","note":"note 1","type":"0","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+
|
|
|
+
|
|
|
+ */
|
|
|
+
|
|
|
+ public IActionResult companyUpdate([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income companyUpdate :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string phone = Convert.ToString(userObj["phone"]);
|
|
|
+ string email = Convert.ToString(userObj["email"]);
|
|
|
+ string address = Convert.ToString(userObj["address"]);
|
|
|
+ string description = Convert.ToString(userObj["description"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+ string type = Convert.ToString(userObj["type"]);
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
+ if (string.IsNullOrEmpty(phone)) phone = "-1";
|
|
|
+ if (string.IsNullOrEmpty(email)) email = "-1";
|
|
|
+ if (string.IsNullOrEmpty(address)) address = "-1";
|
|
|
+ if (string.IsNullOrEmpty(description)) description = "-1";
|
|
|
+ if (string.IsNullOrEmpty(note)) note = "-1";
|
|
|
+ if (string.IsNullOrEmpty(type)) type = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+ /*
|
|
|
+ if (string.IsNullOrEmpty(requestId)) requestId = "";
|
|
|
+ if (string.IsNullOrEmpty(transIdByTicket)) transIdByTicket = "";
|
|
|
+ if (string.IsNullOrEmpty(paymentCode)) paymentCode = "";
|
|
|
+ if (string.IsNullOrEmpty(token)) token = "";
|
|
|
+ */
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.comUpdate(id,code, name, phone, email, address, description, note, users,type);
|
|
|
+ logger.Info("Call database comUpdate success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success comUpdate not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success comUpdate is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //{"id":"2","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult listSubGetList([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income listSubGetList :" + sendData.ToString());
|
|
|
+ listSubList response = new listSubList();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string subType = Convert.ToString(userObj["subType"]);
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+
|
|
|
+
|
|
|
+ string isActive = Convert.ToString(userObj["isActive"]);
|
|
|
+ if (string.IsNullOrEmpty(isActive)) isActive = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string order = Convert.ToString(userObj["order"]);
|
|
|
+ string rowsOnPage = Convert.ToString(userObj["rowsOnPage"]);
|
|
|
+ string seqPage = Convert.ToString(userObj["seqPage"]);
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(order)) order = "asc";
|
|
|
+ if (string.IsNullOrEmpty(rowsOnPage)) rowsOnPage = "1000000000000";
|
|
|
+ if (string.IsNullOrEmpty(seqPage)) seqPage = "1";
|
|
|
+ if (string.IsNullOrEmpty(subType)) subType = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+ /*
|
|
|
+ if (string.IsNullOrEmpty(requestId)) requestId = "";
|
|
|
+ if (string.IsNullOrEmpty(transIdByTicket)) transIdByTicket = "";
|
|
|
+ if (string.IsNullOrEmpty(paymentCode)) paymentCode = "";
|
|
|
+ if (string.IsNullOrEmpty(token)) token = "";
|
|
|
+ */
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.listSubGetList(id, users, subType, name, code, fromDate, toDate, order, rowsOnPage, seqPage,isActive);
|
|
|
+
|
|
|
+ logger.Info("Call database listSubGetList success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response.rowsOnPage = ds_regist.Tables[0].Rows[0]["ROW_ON_PAGE"].ToString();
|
|
|
+ response.seqPage = ds_regist.Tables[0].Rows[0]["SEQ_PAGE"].ToString();
|
|
|
+ response.totalPage = ds_regist.Tables[0].Rows[0]["TOTAL_PAGE"].ToString();
|
|
|
+
|
|
|
+ response.list = new listSubObj[ds_regist.Tables[0].Rows.Count];
|
|
|
+ for (int j = 0; j < ds_regist.Tables[0].Rows.Count; j++)
|
|
|
+ {
|
|
|
+ listSubObj _obj = new listSubObj();
|
|
|
+
|
|
|
+ _obj.id = ds_regist.Tables[0].Rows[j]["id"].ToString();
|
|
|
+ _obj.code = ds_regist.Tables[0].Rows[j]["code"].ToString();
|
|
|
+ _obj.name = ds_regist.Tables[0].Rows[j]["name"].ToString();
|
|
|
+
|
|
|
+ _obj.listType = ds_regist.Tables[0].Rows[j]["LIST_TYPE"].ToString();
|
|
|
+ _obj.status = ds_regist.Tables[0].Rows[j]["STATUS"].ToString();
|
|
|
+ _obj.totalFile = ds_regist.Tables[0].Rows[j]["TOTAL_FILE"].ToString();
|
|
|
+ _obj.totalRecord = ds_regist.Tables[0].Rows[j]["TOTAL_RECORD"].ToString();
|
|
|
+ _obj.totalSuccess = ds_regist.Tables[0].Rows[j]["TOTAL_SUCCESS"].ToString();
|
|
|
+ _obj.totalFalse = ds_regist.Tables[0].Rows[j]["TOTAL_FALSE"].ToString();
|
|
|
+ _obj.isDelete = ds_regist.Tables[0].Rows[j]["IS_DELETE"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ _obj.note = ds_regist.Tables[0].Rows[j]["NOTE"].ToString();
|
|
|
+ _obj.usersCreated = ds_regist.Tables[0].Rows[j]["USERS_CREATED"].ToString();
|
|
|
+ _obj.dateCreated = ds_regist.Tables[0].Rows[j]["DATE_CREATED"].ToString();
|
|
|
+ _obj.usersUpdate = ds_regist.Tables[0].Rows[j]["USERS_UPDATE"].ToString();
|
|
|
+ _obj.dateUpdate = ds_regist.Tables[0].Rows[j]["DATE_UPDATE"].ToString();
|
|
|
+
|
|
|
+ _obj.isActive = ds_regist.Tables[0].Rows[j]["IS_ACTIVE"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response.list[j] = _obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"code":"124","name":"Cty Viettech 1","min":"0","max":"5","note":"note 1","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ */
|
|
|
+
|
|
|
+ public IActionResult listSubInsert([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income listSubInsert :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string subType = Convert.ToString(userObj["subType"]);
|
|
|
+
|
|
|
+
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
+ if (string.IsNullOrEmpty(subType)) subType = "2";
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(note)) note = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.blistSubInsert(code, name, note, users,subType);
|
|
|
+ logger.Info("Call database blistSubInsert success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success blistSubInsert not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success blistSubInsert is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"id":"3","code":"124","name":"Goi thu 1","min":"6","max":"10","note":"note 1","type":"0","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+
|
|
|
+ */
|
|
|
+
|
|
|
+ public IActionResult listSubUpdate([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income balanceUpdate :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string subType = Convert.ToString(userObj["subType"]);
|
|
|
+
|
|
|
+
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+ string type = Convert.ToString(userObj["type"]);
|
|
|
+ string status = Convert.ToString(userObj["status"]);
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
+ if (string.IsNullOrEmpty(subType)) subType = "1";
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(note)) note = "-1";
|
|
|
+ if (string.IsNullOrEmpty(type)) type = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.blistSubUpdate(id, code, name, subType, note, users, type,status);
|
|
|
+ logger.Info("Call database blistSubUpdate success:");
|
|
|
+
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success blistSubUpdate not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success blistSubUpdate is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //{"id":"2","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult listSubFileGetList([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income listSubFileGetList :" + sendData.ToString());
|
|
|
+ listSubFileList response = new listSubFileList();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string subId = Convert.ToString(userObj["subId"]);
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+
|
|
|
+ string order = Convert.ToString(userObj["order"]);
|
|
|
+ string rowsOnPage = Convert.ToString(userObj["rowsOnPage"]);
|
|
|
+ string seqPage = Convert.ToString(userObj["seqPage"]);
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(order)) order = "asc";
|
|
|
+ if (string.IsNullOrEmpty(rowsOnPage)) rowsOnPage = "1000000000000";
|
|
|
+ if (string.IsNullOrEmpty(seqPage)) seqPage = "1";
|
|
|
+ if (string.IsNullOrEmpty(subId)) subId = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+ /*
|
|
|
+ if (string.IsNullOrEmpty(requestId)) requestId = "";
|
|
|
+ if (string.IsNullOrEmpty(transIdByTicket)) transIdByTicket = "";
|
|
|
+ if (string.IsNullOrEmpty(paymentCode)) paymentCode = "";
|
|
|
+ if (string.IsNullOrEmpty(token)) token = "";
|
|
|
+ */
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.listSubFileGetList(id, users, subId, name, code, fromDate, toDate, order, rowsOnPage, seqPage);
|
|
|
+
|
|
|
+ logger.Info("Call database listSubFileGetList success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response.rowsOnPage = ds_regist.Tables[0].Rows[0]["ROW_ON_PAGE"].ToString();
|
|
|
+ response.seqPage = ds_regist.Tables[0].Rows[0]["SEQ_PAGE"].ToString();
|
|
|
+ response.totalPage = ds_regist.Tables[0].Rows[0]["TOTAL_PAGE"].ToString();
|
|
|
+
|
|
|
+ response.list = new listSubFileObj[ds_regist.Tables[0].Rows.Count];
|
|
|
+ for (int j = 0; j < ds_regist.Tables[0].Rows.Count; j++)
|
|
|
+ {
|
|
|
+ listSubFileObj _obj = new listSubFileObj();
|
|
|
+
|
|
|
+ _obj.id = ds_regist.Tables[0].Rows[j]["id"].ToString();
|
|
|
+ _obj.code = ds_regist.Tables[0].Rows[j]["code"].ToString();
|
|
|
+ _obj.name = ds_regist.Tables[0].Rows[j]["name"].ToString();
|
|
|
+
|
|
|
+ _obj.fileId = ds_regist.Tables[0].Rows[j]["FILE_ID"].ToString();
|
|
|
+ _obj.fileName = ds_regist.Tables[0].Rows[j]["FILE_NAME"].ToString();
|
|
|
+
|
|
|
+ _obj.status = ds_regist.Tables[0].Rows[j]["STATUS"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+ _obj.totalRecord = ds_regist.Tables[0].Rows[j]["TOTAL_RECORD"].ToString();
|
|
|
+ _obj.totalSuccess = ds_regist.Tables[0].Rows[j]["TOTAL_SUCCESS"].ToString();
|
|
|
+ _obj.totalFalse = ds_regist.Tables[0].Rows[j]["TOTAL_FALSE"].ToString();
|
|
|
+
|
|
|
+ _obj.isDelete = ds_regist.Tables[0].Rows[j]["IS_DELETE"].ToString();
|
|
|
+ _obj.startDate = ds_regist.Tables[0].Rows[j]["START_DATE"].ToString();
|
|
|
+ _obj.endDate = ds_regist.Tables[0].Rows[j]["END_DATE"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+ _obj.note = ds_regist.Tables[0].Rows[j]["NOTE"].ToString();
|
|
|
+ _obj.usersCreated = ds_regist.Tables[0].Rows[j]["USERS_CREATED"].ToString();
|
|
|
+ _obj.dateCreated = ds_regist.Tables[0].Rows[j]["DATE_CREATED"].ToString();
|
|
|
+ _obj.usersUpdate = ds_regist.Tables[0].Rows[j]["USERS_UPDATE"].ToString();
|
|
|
+ _obj.dateUpdate = ds_regist.Tables[0].Rows[j]["DATE_UPDATE"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response.list[j] = _obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"code":"124","name":"Cty Viettech 1","min":"0","max":"5","note":"note 1","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ */
|
|
|
+
|
|
|
+ public IActionResult listSubFileInsert([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income listSubFileInsert :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string subId = Convert.ToString(userObj["subId"]);
|
|
|
+ string fileId = Convert.ToString(userObj["fileId"]);
|
|
|
+ string fileName = Convert.ToString(userObj["fileName"]);
|
|
|
+
|
|
|
+
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
+ if (string.IsNullOrEmpty(subId)) subId = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(note)) note = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.blistSubFileInsert(code, name, note, users, subId, fileId,fileName);
|
|
|
+ logger.Info("Call database listSubFileInsert success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success listSubFileInsert not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success listSubFileInsert is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"id":"3","code":"124","name":"Goi thu 1","min":"6","max":"10","note":"note 1","type":"0","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+
|
|
|
+ */
|
|
|
+
|
|
|
+ public IActionResult listSubFileUpdate([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income listSubFileUpdate :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string subId = Convert.ToString(userObj["subId"]);
|
|
|
+
|
|
|
+ string status = Convert.ToString(userObj["status"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+ string type = Convert.ToString(userObj["type"]);
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
+ if (string.IsNullOrEmpty(subId)) subId = "1";
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(note)) note = "-1";
|
|
|
+ if (string.IsNullOrEmpty(type)) type = "-1";
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(status)) status = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.blistSubFileUpdate(id, code, name, subId, note, users, type,status);
|
|
|
+ logger.Info("Call database blistSubFileUpdate success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success blistSubFileUpdate not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success blistSubFileUpdate is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult shortCodeGetList([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income shortCodeGetList :" + sendData.ToString());
|
|
|
+ shortCodeList response = new shortCodeList();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+ string type = Convert.ToString(userObj["type"]);
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+ /*
|
|
|
+ if (string.IsNullOrEmpty(requestId)) requestId = "";
|
|
|
+ if (string.IsNullOrEmpty(transIdByTicket)) transIdByTicket = "";
|
|
|
+ if (string.IsNullOrEmpty(paymentCode)) paymentCode = "";
|
|
|
+ if (string.IsNullOrEmpty(token)) token = "";
|
|
|
+ */
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.sortCodeGetList( type,users);
|
|
|
+
|
|
|
+ logger.Info("Call database shortCodeGetList success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response.list = new shortCodeObj[ds_regist.Tables[0].Rows.Count];
|
|
|
+ for (int j = 0; j < ds_regist.Tables[0].Rows.Count; j++)
|
|
|
+ {
|
|
|
+ shortCodeObj _obj = new shortCodeObj();
|
|
|
+
|
|
|
+ _obj.id = ds_regist.Tables[0].Rows[j]["id"].ToString();
|
|
|
+ _obj.name = ds_regist.Tables[0].Rows[j]["name"].ToString();
|
|
|
+ response.list[j] = _obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult changeStatus([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income changeStatus :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+ string type = Convert.ToString(userObj["type"]);
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+ if (string.IsNullOrEmpty(id)) users = "-1";
|
|
|
+
|
|
|
+ string status = Convert.ToString(userObj["status"]);
|
|
|
+ if (string.IsNullOrEmpty(users)) status = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+ /*
|
|
|
+ if (string.IsNullOrEmpty(requestId)) requestId = "";
|
|
|
+ if (string.IsNullOrEmpty(transIdByTicket)) transIdByTicket = "";
|
|
|
+ if (string.IsNullOrEmpty(paymentCode)) paymentCode = "";
|
|
|
+ if (string.IsNullOrEmpty(token)) token = "";
|
|
|
+ */
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.changeStatus(type,id,status,users);
|
|
|
+
|
|
|
+ logger.Info("Call database changeStatus success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success changeStatus not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success changeStatus is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //{"id":"2","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult balanceGetList([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income balanceGetList :" + sendData.ToString());
|
|
|
+ balanceList response = new balanceList();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+
|
|
|
+
|
|
|
+ string isActive = Convert.ToString(userObj["isActive"]);
|
|
|
+ if (string.IsNullOrEmpty(isActive)) isActive = "-1";
|
|
|
+
|
|
|
+ string order = Convert.ToString(userObj["order"]);
|
|
|
+ string rowsOnPage = Convert.ToString(userObj["rowsOnPage"]);
|
|
|
+ string seqPage = Convert.ToString(userObj["seqPage"]);
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(order)) order = "asc";
|
|
|
+ if (string.IsNullOrEmpty(rowsOnPage)) rowsOnPage = "1000000000000";
|
|
|
+ if (string.IsNullOrEmpty(seqPage)) seqPage = "1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+ /*
|
|
|
+ if (string.IsNullOrEmpty(requestId)) requestId = "";
|
|
|
+ if (string.IsNullOrEmpty(transIdByTicket)) transIdByTicket = "";
|
|
|
+ if (string.IsNullOrEmpty(paymentCode)) paymentCode = "";
|
|
|
+ if (string.IsNullOrEmpty(token)) token = "";
|
|
|
+ */
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.balGetList(id, users,name,code,fromDate,toDate,order,rowsOnPage,seqPage, isActive);
|
|
|
+
|
|
|
+ logger.Info("Call database balGetList success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response.rowsOnPage = ds_regist.Tables[0].Rows[0]["ROW_ON_PAGE"].ToString();
|
|
|
+ response.seqPage = ds_regist.Tables[0].Rows[0]["SEQ_PAGE"].ToString();
|
|
|
+ response.totalPage = ds_regist.Tables[0].Rows[0]["TOTAL_PAGE"].ToString();
|
|
|
+
|
|
|
+ response.list = new balanceObj[ds_regist.Tables[0].Rows.Count];
|
|
|
+ for (int j = 0; j < ds_regist.Tables[0].Rows.Count; j++)
|
|
|
+ {
|
|
|
+ balanceObj _obj = new balanceObj();
|
|
|
+
|
|
|
+ _obj.id = ds_regist.Tables[0].Rows[j]["id"].ToString();
|
|
|
+ _obj.code = ds_regist.Tables[0].Rows[j]["code"].ToString();
|
|
|
+ _obj.name = ds_regist.Tables[0].Rows[j]["name"].ToString();
|
|
|
+ _obj.min = ds_regist.Tables[0].Rows[j]["v_min"].ToString();
|
|
|
+ _obj.max = ds_regist.Tables[0].Rows[j]["v_max"].ToString();
|
|
|
+ _obj.isActive = ds_regist.Tables[0].Rows[j]["IS_ACTIVE"].ToString();
|
|
|
+
|
|
|
+ _obj.note = ds_regist.Tables[0].Rows[j]["NOTE"].ToString();
|
|
|
+ _obj.usersCreated = ds_regist.Tables[0].Rows[j]["USERS_CREATED"].ToString();
|
|
|
+ _obj.dateCreated = ds_regist.Tables[0].Rows[j]["DATE_CREATED"].ToString();
|
|
|
+ _obj.usersUpdate = ds_regist.Tables[0].Rows[j]["USERS_UPDATE"].ToString();
|
|
|
+ _obj.dateUpdate = ds_regist.Tables[0].Rows[j]["DATE_UPDATE"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response.list[j] = _obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"code":"124","name":"Cty Viettech 1","min":"0","max":"5","note":"note 1","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ */
|
|
|
+
|
|
|
+ public IActionResult balanceInsert([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income balanceInsert :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string min = Convert.ToString(userObj["min"]);
|
|
|
+ string max = Convert.ToString(userObj["max"]);
|
|
|
+
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
+ if (string.IsNullOrEmpty(min)) min = "-1";
|
|
|
+ if (string.IsNullOrEmpty(max)) max = "-1";
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(note)) note = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.balInsert(code, name, min, max, note, users);
|
|
|
+ logger.Info("Call database balInsert success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success balInsert not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success balInsert is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"id":"3","code":"124","name":"Goi thu 1","min":"6","max":"10","note":"note 1","type":"0","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+
|
|
|
+ */
|
|
|
+
|
|
|
+ public IActionResult balanceUpdate([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income balanceUpdate :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string min = Convert.ToString(userObj["min"]);
|
|
|
+ string max = Convert.ToString(userObj["max"]);
|
|
|
+
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+ string type = Convert.ToString(userObj["type"]);
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
+ if (string.IsNullOrEmpty(min)) min = "-1";
|
|
|
+ if (string.IsNullOrEmpty(max)) max = "-1";
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(note)) note = "-1";
|
|
|
+ if (string.IsNullOrEmpty(type)) type = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.balUpdate(id, code, name, min, max, note, users, type);
|
|
|
+ logger.Info("Call database balUpdate success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success balUpdate not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success balUpdate is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //{"id":"2","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult expGetList([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income balanceGetList :" + sendData.ToString());
|
|
|
+ expireDateList response = new expireDateList();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+ string isActive = Convert.ToString(userObj["isActive"]);
|
|
|
+ if (string.IsNullOrEmpty(isActive)) isActive = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+
|
|
|
+ string order = Convert.ToString(userObj["order"]);
|
|
|
+ string rowsOnPage = Convert.ToString(userObj["rowsOnPage"]);
|
|
|
+ string seqPage = Convert.ToString(userObj["seqPage"]);
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(order)) order = "asc";
|
|
|
+ if (string.IsNullOrEmpty(rowsOnPage)) rowsOnPage = "1000000000000";
|
|
|
+ if (string.IsNullOrEmpty(seqPage)) seqPage = "1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.expGetList(id, users, name, code, fromDate, toDate, order, rowsOnPage, seqPage,isActive);
|
|
|
+ logger.Info("Call database balGetList success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+
|
|
|
+ response.rowsOnPage = ds_regist.Tables[0].Rows[0]["ROW_ON_PAGE"].ToString();
|
|
|
+ response.seqPage = ds_regist.Tables[0].Rows[0]["SEQ_PAGE"].ToString();
|
|
|
+ response.totalPage = ds_regist.Tables[0].Rows[0]["TOTAL_PAGE"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response.list = new expireDate[ds_regist.Tables[0].Rows.Count];
|
|
|
+ for (int j = 0; j < ds_regist.Tables[0].Rows.Count; j++)
|
|
|
+ {
|
|
|
+ expireDate _obj = new expireDate();
|
|
|
+
|
|
|
+ _obj.id = ds_regist.Tables[0].Rows[j]["id"].ToString();
|
|
|
+ _obj.code = ds_regist.Tables[0].Rows[j]["code"].ToString();
|
|
|
+ _obj.name = ds_regist.Tables[0].Rows[j]["name"].ToString();
|
|
|
+ _obj.totalDay = ds_regist.Tables[0].Rows[j]["TOTAL_DAY_USE"].ToString();
|
|
|
+
|
|
|
+ _obj.min = ds_regist.Tables[0].Rows[j]["V_MIN"].ToString();
|
|
|
+ _obj.max = ds_regist.Tables[0].Rows[j]["V_MAX"].ToString();
|
|
|
+
|
|
|
+ _obj.note = ds_regist.Tables[0].Rows[j]["NOTE"].ToString();
|
|
|
+ _obj.usersCreated = ds_regist.Tables[0].Rows[j]["USERS_CREATED"].ToString();
|
|
|
+ _obj.dateCreated = ds_regist.Tables[0].Rows[j]["DATE_CREATED"].ToString();
|
|
|
+ _obj.usersUpdate = ds_regist.Tables[0].Rows[j]["USERS_UPDATE"].ToString();
|
|
|
+ _obj.dateUpdate = ds_regist.Tables[0].Rows[j]["DATE_UPDATE"].ToString();
|
|
|
+
|
|
|
+ _obj.isActive = ds_regist.Tables[0].Rows[j]["IS_ACTIVE"].ToString();
|
|
|
+
|
|
|
+ response.list[j] = _obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"code":"124","name":"Cty Viettech 1","totalDay":"0","note":"note 1","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ */
|
|
|
+ public IActionResult expInsert([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income balanceInsert :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string totalDay = Convert.ToString(userObj["totalDay"]);
|
|
|
+ string min = Convert.ToString(userObj["min"]);
|
|
|
+ string max = Convert.ToString(userObj["max"]);
|
|
|
+
|
|
|
+
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(min)) min = "0";
|
|
|
+ if (string.IsNullOrEmpty(max)) max = "100000";
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(totalDay)) totalDay = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(note)) note = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.expInsert(code, name, totalDay, note, users,min,max);
|
|
|
+ logger.Info("Call database expInsert success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success expInsert not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success expInsert is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"id":"2","code":"124","name":"Gkaka","totalDay":"6","note":"note 1","type":"0","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+
|
|
|
+ */
|
|
|
+
|
|
|
+ public IActionResult expUpdate([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income companyGetList :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string totalDay = Convert.ToString(userObj["totalDay"]);
|
|
|
+
|
|
|
+ string min = Convert.ToString(userObj["min"]);
|
|
|
+ string max = Convert.ToString(userObj["max"]);
|
|
|
+
|
|
|
+
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+ string type = Convert.ToString(userObj["type"]);
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
+ if (string.IsNullOrEmpty(totalDay)) totalDay = "-1";
|
|
|
+ if (string.IsNullOrEmpty(min)) min = "0";
|
|
|
+ if (string.IsNullOrEmpty(max)) max = "100000";
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(note)) note = "-1";
|
|
|
+ if (string.IsNullOrEmpty(type)) type = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.expUpdate(id, code, name, totalDay, note, users, type, min, max);
|
|
|
+ logger.Info("Call database expUpdate success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success expUpdate not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success expUpdate is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //{"id":"1","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult paramGetList([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income balanceGetList :" + sendData.ToString());
|
|
|
+ ApiProcess.Models.balance.paramObjList response = new ApiProcess.Models.balance.paramObjList();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.paramGetList(id, users);
|
|
|
+ logger.Info("Call database balGetList success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response.list = new ApiProcess.Models.balance.paramObj[ds_regist.Tables[0].Rows.Count];
|
|
|
+ for (int j = 0; j < ds_regist.Tables[0].Rows.Count; j++)
|
|
|
+ {
|
|
|
+ ApiProcess.Models.balance.paramObj _obj = new ApiProcess.Models.balance.paramObj();
|
|
|
+
|
|
|
+ _obj.id = ds_regist.Tables[0].Rows[j]["ID"].ToString();
|
|
|
+ _obj.code = ds_regist.Tables[0].Rows[j]["CODE"].ToString();
|
|
|
+ _obj.values = ds_regist.Tables[0].Rows[j]["SVALUES"].ToString();
|
|
|
+ _obj.note = ds_regist.Tables[0].Rows[j]["NOTE"].ToString();
|
|
|
+ _obj.status = ds_regist.Tables[0].Rows[j]["STATUS"].ToString();
|
|
|
+ _obj.codeGroup = ds_regist.Tables[0].Rows[j]["CODE_GROUP"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+ _obj.display0 = ds_regist.Tables[0].Rows[j]["DISPLAY0"].ToString();
|
|
|
+ _obj.display1 = ds_regist.Tables[0].Rows[j]["DISPLAY1"].ToString();
|
|
|
+ _obj.display2 = ds_regist.Tables[0].Rows[j]["DISPLAY2"].ToString();
|
|
|
+ _obj.display3 = ds_regist.Tables[0].Rows[j]["DISPLAY3"].ToString();
|
|
|
+ _obj.display4 = ds_regist.Tables[0].Rows[j]["DISPLAY4"].ToString();
|
|
|
+ _obj.display5 = ds_regist.Tables[0].Rows[j]["DISPLAY5"].ToString();
|
|
|
+
|
|
|
+ _obj.gameId = ds_regist.Tables[0].Rows[j]["GAME_ID"].ToString();
|
|
|
+ _obj.channel = ds_regist.Tables[0].Rows[j]["CHANNEL"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response.list[j] = _obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"code":"124","values":"Cty Viettech 1","note":"0","status":"1","codeGroup":"quangbh","display0":"display0","display1":"display1","display2":"display2","display3":"display3","display4":"display4","display5":"display5","gameId":"1","channel":"channel","users":"haha","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ */
|
|
|
+ public IActionResult paramInsert([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income balanceInsert :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string values = Convert.ToString(userObj["values"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+ string status = Convert.ToString(userObj["status"]);
|
|
|
+ string codeGroup = Convert.ToString(userObj["codeGroup"]);
|
|
|
+
|
|
|
+ string display0 = Convert.ToString(userObj["display0"]);
|
|
|
+ string display1 = Convert.ToString(userObj["display1"]);
|
|
|
+ string display2 = Convert.ToString(userObj["display2"]);
|
|
|
+ string display3 = Convert.ToString(userObj["display3"]);
|
|
|
+ string display4 = Convert.ToString(userObj["display4"]);
|
|
|
+ string display5 = Convert.ToString(userObj["display5"]);
|
|
|
+
|
|
|
+ string gameId = Convert.ToString(userObj["gameId"]);
|
|
|
+ string channelParam = Convert.ToString(userObj["channelParam"]);
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(codeGroup)) codeGroup = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.paramInsert(code,values,note,status,codeGroup,display0,display1,
|
|
|
+ display2,display3,display4,display5,gameId, channelParam, users);
|
|
|
+ logger.Info("Call database paramInsert success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success paramInsert not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success paramInsert is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"id":"1","code":"124","values":"Cty Viettech 1","note":"0","status":"1","codeGroup":"quangbh","display0":"display0","display1":"display1","display2":"displayso 3","display3":"display3","display4":"display4","display5":"display5","gameId":"1","channel":"channel","type":"0","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+
|
|
|
+ */
|
|
|
+
|
|
|
+ public IActionResult paramUpdate([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income companyGetList :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string values = Convert.ToString(userObj["values"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+ string status = Convert.ToString(userObj["status"]);
|
|
|
+ string codeGroup = Convert.ToString(userObj["codeGroup"]);
|
|
|
+
|
|
|
+ string display0 = Convert.ToString(userObj["display0"]);
|
|
|
+ string display1 = Convert.ToString(userObj["display1"]);
|
|
|
+ string display2 = Convert.ToString(userObj["display2"]);
|
|
|
+ string display3 = Convert.ToString(userObj["display3"]);
|
|
|
+ string display4 = Convert.ToString(userObj["display4"]);
|
|
|
+ string display5 = Convert.ToString(userObj["display5"]);
|
|
|
+
|
|
|
+ string gameId = Convert.ToString(userObj["gameId"]);
|
|
|
+ string channelParam = Convert.ToString(userObj["channelParam"]);
|
|
|
+
|
|
|
+ string type = Convert.ToString(userObj["type"]);
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+ if (string.IsNullOrEmpty(type)) type = "0";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.paramUpdate(id, code, values, note, status, codeGroup, display0, display1,
|
|
|
+ display2, display3, display4, display5, gameId, channelParam, users, type);
|
|
|
+ logger.Info("Call database paramUpdate success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success paramUpdate not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success paramUpdate is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //{"id":"1","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult svGetList([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income balanceGetList :" + sendData.ToString());
|
|
|
+ serviceObjList response = new serviceObjList();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+
|
|
|
+ string order = Convert.ToString(userObj["order"]);
|
|
|
+ string rowsOnPage = Convert.ToString(userObj["rowsOnPage"]);
|
|
|
+ string seqPage = Convert.ToString(userObj["seqPage"]);
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(order)) order = "asc";
|
|
|
+ if (string.IsNullOrEmpty(rowsOnPage)) rowsOnPage = "1000000000000";
|
|
|
+ if (string.IsNullOrEmpty(seqPage)) seqPage = "1";
|
|
|
+ string isActive = Convert.ToString(userObj["isActive"]);
|
|
|
+ if (string.IsNullOrEmpty(isActive)) isActive = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.svGetList(id, users, name, code, fromDate, toDate, order, rowsOnPage, seqPage, isActive);
|
|
|
+ logger.Info("Call database balGetList success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ response.rowsOnPage = ds_regist.Tables[0].Rows[0]["ROW_ON_PAGE"].ToString();
|
|
|
+ response.seqPage = ds_regist.Tables[0].Rows[0]["SEQ_PAGE"].ToString();
|
|
|
+ response.totalPage = ds_regist.Tables[0].Rows[0]["TOTAL_PAGE"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+ response.list = new serviceObj[ds_regist.Tables[0].Rows.Count];
|
|
|
+ for (int j = 0; j < ds_regist.Tables[0].Rows.Count; j++)
|
|
|
+ {
|
|
|
+ serviceObj _obj = new serviceObj();
|
|
|
+
|
|
|
+ _obj.id = ds_regist.Tables[0].Rows[j]["ID"].ToString();
|
|
|
+ _obj.code = ds_regist.Tables[0].Rows[j]["CODE"].ToString();
|
|
|
+ _obj.name = ds_regist.Tables[0].Rows[j]["NAME"].ToString();
|
|
|
+ _obj.description = ds_regist.Tables[0].Rows[j]["DESCRIPTION"].ToString();
|
|
|
+ _obj.shortCode = ds_regist.Tables[0].Rows[j]["SHORT_CODE"].ToString();
|
|
|
+ _obj.command = ds_regist.Tables[0].Rows[j]["COMMAND_REGISTER"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+ _obj.contentEn = ds_regist.Tables[0].Rows[j]["CONTENT_EN"].ToString();
|
|
|
+ _obj.contentFr = ds_regist.Tables[0].Rows[j]["CONTENT_FR"].ToString();
|
|
|
+ _obj.contentLc = ds_regist.Tables[0].Rows[j]["CONTENT_LC"].ToString();
|
|
|
+ _obj.note = ds_regist.Tables[0].Rows[j]["NOTE"].ToString();
|
|
|
+ _obj.companyId = ds_regist.Tables[0].Rows[j]["COMPANY_ID"].ToString();
|
|
|
+
|
|
|
+ _obj.usersCreated = ds_regist.Tables[0].Rows[j]["USERS_CREATED"].ToString();
|
|
|
+ _obj.dateCreated = ds_regist.Tables[0].Rows[j]["DATE_CREATED"].ToString();
|
|
|
+ _obj.usersUpdate = ds_regist.Tables[0].Rows[j]["USERS_UPDATE"].ToString();
|
|
|
+ _obj.dateUpdate = ds_regist.Tables[0].Rows[j]["DATE_UPDATE"].ToString();
|
|
|
+
|
|
|
+ _obj.dateUpdate = ds_regist.Tables[0].Rows[j]["DATE_UPDATE"].ToString();
|
|
|
+
|
|
|
+ _obj.msgRegisterSuccess = ds_regist.Tables[0].Rows[j]["USSD_MSG_REGISTER_SUC"].ToString();
|
|
|
+ _obj.msgRegisterFlase = ds_regist.Tables[0].Rows[j]["USSD_MSG_REGISTER_FAIL"].ToString();
|
|
|
+ _obj.msgConfirm = ds_regist.Tables[0].Rows[j]["USSD_CONFIRM"].ToString();
|
|
|
+
|
|
|
+ _obj.isActive = ds_regist.Tables[0].Rows[j]["IS_ACTIVE"].ToString();
|
|
|
+ _obj.isMyService = ds_regist.Tables[0].Rows[j]["IS_MYSERVICE"].ToString();
|
|
|
+
|
|
|
+ response.list[j] = _obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"code":"124","name":"Cty Viettech 1","description":"0","shortCode":"12345","command":"ON 123","contentEn":"contentEn","contentFr":"contentFr","contentLc":"contentLc","note":"note","companyId":"1","users":"haha","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ */
|
|
|
+ public IActionResult svInsert([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income balanceInsert :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string description = Convert.ToString(userObj["description"]);
|
|
|
+ string shortCode = Convert.ToString(userObj["shortCode"]);
|
|
|
+ string command = Convert.ToString(userObj["command"]);
|
|
|
+
|
|
|
+ string contentEn = Convert.ToString(userObj["contentEn"]);
|
|
|
+ string contentFr = Convert.ToString(userObj["contentFr"]);
|
|
|
+ string contentLc = Convert.ToString(userObj["contentLc"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+ string companyId = Convert.ToString(userObj["companyId"]);
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string msgRegisterSuccess = Convert.ToString(userObj["msgRegisterSuccess"]);
|
|
|
+ string msgRegisterFlase = Convert.ToString(userObj["msgRegisterFlase"]);
|
|
|
+ string msgConfirm = Convert.ToString(userObj["msgConfirm"]);
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(msgRegisterSuccess)) msgRegisterSuccess = "-1";
|
|
|
+ if (string.IsNullOrEmpty(msgRegisterFlase)) msgRegisterFlase = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(companyId)) companyId = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.svInsert(code, name, description, shortCode, command, contentEn, contentFr,
|
|
|
+ contentLc,note, companyId, users, msgRegisterSuccess, msgRegisterFlase, msgConfirm);
|
|
|
+ logger.Info("Call database svInsert success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success svInsert not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success svInsert is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"id":"2","code":"124","name":"name1","description":"123","shortCode":"123456","command":"ON 1231","contentEn":"contentEn","contentFr":"contentFr","contentLc":"contentLc","note":"note","companyId":"1","type":"0","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ */
|
|
|
+
|
|
|
+ public IActionResult svUpdate([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income companyGetList :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string description = Convert.ToString(userObj["description"]);
|
|
|
+ string shortCode = Convert.ToString(userObj["shortCode"]);
|
|
|
+ string command = Convert.ToString(userObj["command"]);
|
|
|
+
|
|
|
+ string contentEn = Convert.ToString(userObj["contentEn"]);
|
|
|
+ string contentFr = Convert.ToString(userObj["contentFr"]);
|
|
|
+ string contentLc = Convert.ToString(userObj["contentLc"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+ string companyId = Convert.ToString(userObj["companyId"]);
|
|
|
+
|
|
|
+ string type = Convert.ToString(userObj["type"]);
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string msgRegisterSuccess = Convert.ToString(userObj["msgRegisterSuccess"]);
|
|
|
+ string msgRegisterFlase = Convert.ToString(userObj["msgRegisterFlase"]);
|
|
|
+ string msgConfirm = Convert.ToString(userObj["msgConfirm"]);
|
|
|
+ if (string.IsNullOrEmpty(msgRegisterSuccess)) msgRegisterSuccess = "-1";
|
|
|
+ if (string.IsNullOrEmpty(msgRegisterFlase)) msgRegisterFlase = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+ if (string.IsNullOrEmpty(type)) type = "0";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.svUpdate(id, code, name, description, shortCode, command, contentEn, contentFr,
|
|
|
+ contentLc, note, companyId, users, type, msgRegisterSuccess, msgRegisterFlase, msgConfirm);
|
|
|
+ logger.Info("Call database svUpdate success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success svUpdate not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success svUpdate is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //************************ HIEN TAI KHONG DU SUNG PHAN SERVICE ADD
|
|
|
+
|
|
|
+ //{"id":"2","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult svAddGetList([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income balanceGetList :" + sendData.ToString());
|
|
|
+ serviceAddObjList response = new serviceAddObjList();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+
|
|
|
+ string order = Convert.ToString(userObj["order"]);
|
|
|
+ string rowsOnPage = Convert.ToString(userObj["rowsOnPage"]);
|
|
|
+ string seqPage = Convert.ToString(userObj["seqPage"]);
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(order)) order = "asc";
|
|
|
+ if (string.IsNullOrEmpty(rowsOnPage)) rowsOnPage = "1000000000000";
|
|
|
+ if (string.IsNullOrEmpty(seqPage)) seqPage = "1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.svAddGetList(id, users, name, code, fromDate, toDate, order, rowsOnPage, seqPage);
|
|
|
+ logger.Info("Call database balGetList success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+
|
|
|
+ response.rowsOnPage = ds_regist.Tables[0].Rows[0]["ROW_ON_PAGE"].ToString();
|
|
|
+ response.seqPage = ds_regist.Tables[0].Rows[0]["SEQ_PAGE"].ToString();
|
|
|
+ response.totalPage = ds_regist.Tables[0].Rows[0]["TOTAL_PAGE"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response.list = new serviceAddObj[ds_regist.Tables[0].Rows.Count];
|
|
|
+ for (int j = 0; j < ds_regist.Tables[0].Rows.Count; j++)
|
|
|
+ {
|
|
|
+ serviceAddObj _obj = new serviceAddObj();
|
|
|
+
|
|
|
+ _obj.id = ds_regist.Tables[0].Rows[j]["ID"].ToString();
|
|
|
+ _obj.code = ds_regist.Tables[0].Rows[j]["CODE"].ToString();
|
|
|
+ _obj.name = ds_regist.Tables[0].Rows[j]["NAME"].ToString();
|
|
|
+ _obj.addType = ds_regist.Tables[0].Rows[j]["ADD_TYPE"].ToString();
|
|
|
+ _obj.numberDisplay = ds_regist.Tables[0].Rows[j]["NUMBER_DISPLAY"].ToString();
|
|
|
+ _obj.priority = ds_regist.Tables[0].Rows[j]["PRIORITY"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+ _obj.serviceId = ds_regist.Tables[0].Rows[j]["SERVICE_ID"].ToString();
|
|
|
+ _obj.note = ds_regist.Tables[0].Rows[j]["NOTE"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+ _obj.usersCreated = ds_regist.Tables[0].Rows[j]["USERS_CREATED"].ToString();
|
|
|
+ _obj.dateCreated = ds_regist.Tables[0].Rows[j]["DATE_CREATED"].ToString();
|
|
|
+ _obj.usersUpdate = ds_regist.Tables[0].Rows[j]["USERS_UPDATE"].ToString();
|
|
|
+ _obj.dateUpdate = ds_regist.Tables[0].Rows[j]["DATE_UPDATE"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+ response.list[j] = _obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"code":"124","name":"Cty Viettech 1","addType":"0","shortCode":"12345","numberDisplay":"1","priority":"0","serviceId":"1","note":"note","users":"haha","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ */
|
|
|
+ public IActionResult svAddInsert([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income balanceInsert :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string addType = Convert.ToString(userObj["addType"]);
|
|
|
+ string numberDisplay = Convert.ToString(userObj["numberDisplay"]);
|
|
|
+ string priority = Convert.ToString(userObj["priority"]);
|
|
|
+
|
|
|
+ string serviceId = Convert.ToString(userObj["serviceId"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.svAddInsert(code, name, addType, numberDisplay, priority, serviceId, note, users);
|
|
|
+ logger.Info("Call database svAddInsert success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success svAddInsert not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success svAddInsert is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"id":"2","code":"124","name":"quangbh","addType":"0","shortCode":"12345","numberDisplay":"1","priority":"0","serviceId":"1","note":"note","type":"0","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ */
|
|
|
+
|
|
|
+ public IActionResult svAddUpdate([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income companyGetList :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string addType = Convert.ToString(userObj["addType"]);
|
|
|
+ string numberDisplay = Convert.ToString(userObj["numberDisplay"]);
|
|
|
+ string priority = Convert.ToString(userObj["priority"]);
|
|
|
+
|
|
|
+ string serviceId = Convert.ToString(userObj["serviceId"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+ string type = Convert.ToString(userObj["type"]);
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+ if (string.IsNullOrEmpty(type)) type = "0";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.svAddUpdate(id, code, name, addType, numberDisplay, priority, serviceId, note, users, type);
|
|
|
+ logger.Info("Call database comInsert success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success svAddUpdate not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success svAddUpdate is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //************************ KET THUC PHAN KHONG DU SUNG PHAN SERVICE ADD
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //{"id":"2","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult camGetList([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income camGetList :" + sendData.ToString());
|
|
|
+ campaignObjList response = new campaignObjList();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+ string isDefault = Convert.ToString(userObj["isDefault"]);
|
|
|
+ string isMyservice = Convert.ToString(userObj["isMyservice"]);
|
|
|
+
|
|
|
+
|
|
|
+ string status = Convert.ToString(userObj["status"]);
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+
|
|
|
+ string order = Convert.ToString(userObj["order"]);
|
|
|
+ string rowsOnPage = Convert.ToString(userObj["rowsOnPage"]);
|
|
|
+ string seqPage = Convert.ToString(userObj["seqPage"]);
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(order)) order = "asc";
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(rowsOnPage)) rowsOnPage = "1000000000000";
|
|
|
+ if (string.IsNullOrEmpty(seqPage)) seqPage = "1";
|
|
|
+ if (string.IsNullOrEmpty(isDefault)) isDefault = "-1";
|
|
|
+ if (string.IsNullOrEmpty(isMyservice)) isMyservice = "-1";
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(status)) status = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string _rowsOnPage, _seqPage, _totalPage;
|
|
|
+ List<campaignObj> _listBalanceOfCam = getListCommon.getListCam(id, users, name, code, fromDate, toDate, order, rowsOnPage, seqPage, status
|
|
|
+ , out _rowsOnPage, out _seqPage, out _totalPage, isDefault, isMyservice);
|
|
|
+
|
|
|
+ logger.Info("Call database balGetList success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ response.rowsOnPage = _rowsOnPage;
|
|
|
+ response.seqPage = _seqPage;
|
|
|
+ response.totalPage = _totalPage;
|
|
|
+
|
|
|
+ response.list = _listBalanceOfCam;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"code":"124","name":"Cty Viettech 1","fromDate":"01/11/2021 00:00:00","toDate":"01/11/2022 00:00:00","fromHour":"08:08:09","toHour":"01:09:08","rule":"1","priority":"1","balanceId":"1","expireDateId":"1","status":"1","note":"123456","users":"haha","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ */
|
|
|
+ public IActionResult camInsert([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income balanceInsert :" + sendData.ToString());
|
|
|
+ campaignInsert response = new campaignInsert();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+ string fromHour = Convert.ToString(userObj["fromHour"]);
|
|
|
+
|
|
|
+ string toHour = Convert.ToString(userObj["toHour"]);
|
|
|
+ string rule = Convert.ToString(userObj["rule"]);
|
|
|
+ string priority = Convert.ToString(userObj["priority"]);
|
|
|
+ string balanceId = Convert.ToString(userObj["balanceId"]);
|
|
|
+ string expireDateId = Convert.ToString(userObj["expireDateId"]);
|
|
|
+ string status = Convert.ToString(userObj["status"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+ string numberDisplay = Convert.ToString(userObj["numberDisplay"]);
|
|
|
+
|
|
|
+ string addType = Convert.ToString(userObj["addType"]);
|
|
|
+ string title = Convert.ToString(userObj["title"]);
|
|
|
+
|
|
|
+ string isDefault = Convert.ToString(userObj["isDefault"]);
|
|
|
+ string isMyservice = Convert.ToString(userObj["isMyservice"]);
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(code)) code = "-1";
|
|
|
+ if (string.IsNullOrEmpty(numberDisplay)) numberDisplay = "1";
|
|
|
+ if (string.IsNullOrEmpty(addType)) addType = "1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.camInsert(code, name, fromDate, toDate, fromHour, toHour, rule,
|
|
|
+ priority, balanceId, expireDateId, status, note, users, numberDisplay, addType, title, isDefault, isMyservice);
|
|
|
+ logger.Info("Call database balInsert success:");
|
|
|
+
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success ds_regist not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString();
|
|
|
+ response.id= ds_regist.Tables[0].Rows[0]["id"].ToString();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success ds_regist is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"id":"5","code":"124","name":"Cty 1","fromDate":"01/11/2021 00:00:00","toDate":"01/11/2022 00:00:00","fromHour":"08:08:09","toHour":"01:09:08","rule":"1","priority":"1","balanceId":"1","expireDateId":"1","status":"1","note":"123456","type":"0","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ */
|
|
|
+
|
|
|
+ public IActionResult camUpdate([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income companyGetList :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+ string code = Convert.ToString(userObj["code"]);
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+ string fromHour = Convert.ToString(userObj["fromHour"]);
|
|
|
+
|
|
|
+ string toHour = Convert.ToString(userObj["toHour"]);
|
|
|
+ string rule = Convert.ToString(userObj["rule"]);
|
|
|
+ string priority = Convert.ToString(userObj["priority"]);
|
|
|
+ string balanceId = Convert.ToString(userObj["balanceId"]);
|
|
|
+ string expireDateId = Convert.ToString(userObj["expireDateId"]);
|
|
|
+ string status = Convert.ToString(userObj["status"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+
|
|
|
+ string type = Convert.ToString(userObj["type"]);
|
|
|
+ string numberDisplay = Convert.ToString(userObj["numberDisplay"]);
|
|
|
+ string addType = Convert.ToString(userObj["addType"]);
|
|
|
+
|
|
|
+ string title = Convert.ToString(userObj["title"]);
|
|
|
+ string isDefault = Convert.ToString(userObj["isDefault"]);
|
|
|
+ string isMyservice = Convert.ToString(userObj["isMyservice"]);
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+ if (string.IsNullOrEmpty(type)) type = "0";
|
|
|
+ if (string.IsNullOrEmpty(numberDisplay)) numberDisplay = "1";
|
|
|
+ if (string.IsNullOrEmpty(addType)) addType = "1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.camUpdate(id, code, name, fromDate, toDate, fromHour, toHour, rule,
|
|
|
+ priority, balanceId, expireDateId, status, note, users, type, numberDisplay, addType,title,isDefault,isMyservice);
|
|
|
+ logger.Info("Call database comInsert success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success ds_regist not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success ds_regist is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public IActionResult camCopy([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income camCopy :" + sendData.ToString());
|
|
|
+ campaignInsert response = new campaignInsert();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.camCopy(id);
|
|
|
+ logger.Info("Call database camCopy success:");
|
|
|
+
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success ds_regist not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString();
|
|
|
+ response.id = ds_regist.Tables[0].Rows[0]["id"].ToString();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success ds_regist is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //{"id":"2","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult camBalanceGetList([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income camBalanceGetList :" + sendData.ToString());
|
|
|
+ campaignBalObjList response = new campaignBalObjList();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
+
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+
|
|
|
+ string order = Convert.ToString(userObj["order"]);
|
|
|
+ string rowsOnPage = Convert.ToString(userObj["rowsOnPage"]);
|
|
|
+ string seqPage = Convert.ToString(userObj["seqPage"]);
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(order)) order = "asc";
|
|
|
+ if (string.IsNullOrEmpty(rowsOnPage)) rowsOnPage = "1000000000000";
|
|
|
+ if (string.IsNullOrEmpty(seqPage)) seqPage = "1";
|
|
|
+
|
|
|
+ string _keyConfig = Common.GetValuesAppSetting("webConfig", "key");
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ string _rowsOnPage, _seqPage, _totalPage;
|
|
|
+ List<campaignBalObj> _listBalanceOfCam =getListCommon.getListBalanceOfCam(id, users, campaignId, fromDate, toDate, order, rowsOnPage, seqPage, channel, language
|
|
|
+ ,out _rowsOnPage,out _seqPage,out _totalPage);
|
|
|
+
|
|
|
+ logger.Info("Call database balGetList success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ response.rowsOnPage = _rowsOnPage;
|
|
|
+ response.seqPage = _seqPage;
|
|
|
+ response.totalPage = _totalPage;
|
|
|
+
|
|
|
+ response.list = _listBalanceOfCam;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ ////{"id":"2","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ //[HttpPost]
|
|
|
+ //public IActionResult camBalanceGetListBk([FromBody] dynamic sendData)
|
|
|
+ //{
|
|
|
+
|
|
|
+ // logger.Info("New request income camBalanceGetList :" + sendData.ToString());
|
|
|
+ // campaignBalObjList response = new campaignBalObjList();
|
|
|
+ // response.responseCode = "-1";
|
|
|
+ // response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ // try
|
|
|
+ // {
|
|
|
+
|
|
|
+ // var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ // string users = Convert.ToString(userObj["users"]);
|
|
|
+ // string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+
|
|
|
+ // string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
+
|
|
|
+ // string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ // string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+
|
|
|
+ // string order = Convert.ToString(userObj["order"]);
|
|
|
+ // string rowsOnPage = Convert.ToString(userObj["rowsOnPage"]);
|
|
|
+ // string seqPage = Convert.ToString(userObj["seqPage"]);
|
|
|
+ // if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
+
|
|
|
+ // if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
+ // if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
+ // if (string.IsNullOrEmpty(order)) order = "asc";
|
|
|
+ // if (string.IsNullOrEmpty(rowsOnPage)) rowsOnPage = "1000000000000";
|
|
|
+ // if (string.IsNullOrEmpty(seqPage)) seqPage = "1";
|
|
|
+
|
|
|
+ // string _keyConfig = Common.GetValuesAppSetting("webConfig", "key");
|
|
|
+ // if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ // if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // string token = Convert.ToString(userObj["token"]);
|
|
|
+ // string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ // string language = Convert.ToString(userObj["language"]);
|
|
|
+ // if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ // string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ // string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ // string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ // var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ // //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ // redisConnection _redis;
|
|
|
+ // memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ // if (_redis == null)
|
|
|
+ // {
|
|
|
+ // var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ // {
|
|
|
+ // AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ // Priority = CacheItemPriority.High,
|
|
|
+ // SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ // Size = 1024,
|
|
|
+ // };
|
|
|
+ // _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ // _redis.connet();
|
|
|
+ // memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ // }
|
|
|
+ // if (!_redis.isConnet())
|
|
|
+ // {
|
|
|
+ // if (!_redis.connet())
|
|
|
+ // {
|
|
|
+ // logger.Info("Connect to redis false");
|
|
|
+ // response.responseCode = "-2";
|
|
|
+ // response.responseMessage = "System Update";
|
|
|
+ // logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ // return Ok(response);
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ // {
|
|
|
+ // AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ // Priority = CacheItemPriority.High,
|
|
|
+ // SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ // Size = 1024,
|
|
|
+ // };
|
|
|
+ // memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ // tokenObj _tokenObj = null;
|
|
|
+ // if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ // {
|
|
|
+ // logger.Info("Authen token false");
|
|
|
+ // response.responseCode = "35";
|
|
|
+ // response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ // logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ // return Ok(response);
|
|
|
+ // }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // DataSet ds_regist = balanceDataAccess.camBalGetList(id, users, campaignId, fromDate, toDate, order, rowsOnPage, seqPage, channel, language);
|
|
|
+ // logger.Info("Call database balGetList success:");
|
|
|
+ // response.responseCode = "0";
|
|
|
+ // response.responseMessage = "Success";
|
|
|
+ // if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ // {
|
|
|
+
|
|
|
+
|
|
|
+ // response.rowsOnPage = ds_regist.Tables[0].Rows[0]["ROW_ON_PAGE"].ToString();
|
|
|
+ // response.seqPage = ds_regist.Tables[0].Rows[0]["SEQ_PAGE"].ToString();
|
|
|
+ // response.totalPage = ds_regist.Tables[0].Rows[0]["TOTAL_PAGE"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+ // response.list = new campaignBalObj[ds_regist.Tables[0].Rows.Count];
|
|
|
+ // for (int j = 0; j < ds_regist.Tables[0].Rows.Count; j++)
|
|
|
+ // {
|
|
|
+ // campaignBalObj _obj = new campaignBalObj();
|
|
|
+
|
|
|
+ // _obj.id = ds_regist.Tables[0].Rows[j]["ID"].ToString();
|
|
|
+ // _obj.campaignId = ds_regist.Tables[0].Rows[j]["CAMPAIGN_ID"].ToString();
|
|
|
+ // _obj.balanceId = ds_regist.Tables[0].Rows[j]["REF_ID"].ToString();
|
|
|
+ // _obj.isDelete = ds_regist.Tables[0].Rows[j]["IS_DELETE"].ToString();
|
|
|
+ // _obj.note = ds_regist.Tables[0].Rows[j]["NOTE"].ToString();
|
|
|
+
|
|
|
+ // _obj.usersCreated = ds_regist.Tables[0].Rows[j]["USERS_CREATED"].ToString();
|
|
|
+ // _obj.dateCreated = ds_regist.Tables[0].Rows[j]["DATE_CREATED"].ToString();
|
|
|
+ // _obj.usersUpdate = ds_regist.Tables[0].Rows[j]["USERS_UPDATE"].ToString();
|
|
|
+ // _obj.dateUpdate = ds_regist.Tables[0].Rows[j]["DATE_UPDATE"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // response.list[j] = _obj;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // }
|
|
|
+ // catch (Exception ex)
|
|
|
+ // {
|
|
|
+ // logger.Info("exception: " + ex.ToString());
|
|
|
+ // response.responseCode = "-2";
|
|
|
+ // response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ // }
|
|
|
+ // logger.Info("Responase to web: " + response.ToString());
|
|
|
+ // return Ok(response);
|
|
|
+ //}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"code":"124","name":"Cty Viettech 1","fromDate":"01/11/2021 00:00:00","toDate":"01/11/2022 00:00:00","fromHour":"08:08:09","toHour":"01:09:08","rule":"1","priority":"1","balanceId":"1","expireDateId":"1","status":"1","note":"123456","users":"haha","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ */
|
|
|
+ public IActionResult camBalanceInsert([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income camBalanceInsert :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
+ string refId = Convert.ToString(userObj["balanceId"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
+ if (string.IsNullOrEmpty(refId)) refId = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.camBalInsert(campaignId,refId, note, users,
|
|
|
+ channel, language);
|
|
|
+ logger.Info("Call database camBalInsert success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success camBalInsert not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success ds_regist is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public IActionResult camBalanceUpdate([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income camBalanceUpdate :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string type = Convert.ToString(userObj["type"]);
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
+ string refId = Convert.ToString(userObj["balanceId"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
+ if (string.IsNullOrEmpty(refId)) refId = "-1";
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+ if (string.IsNullOrEmpty(type)) type = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.camBalUpdate(campaignId, refId, note, users,
|
|
|
+ channel, language,id,type);
|
|
|
+ logger.Info("Call database camBalanceUpdate success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success camBalanceUpdate not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success ds_regist is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult camSubGetList([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income camSubGetList :" + sendData.ToString());
|
|
|
+ campaignSubObjList response = new campaignSubObjList();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
+
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+
|
|
|
+ string order = Convert.ToString(userObj["order"]);
|
|
|
+ string rowsOnPage = Convert.ToString(userObj["rowsOnPage"]);
|
|
|
+ string seqPage = Convert.ToString(userObj["seqPage"]);
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(order)) order = "asc";
|
|
|
+ if (string.IsNullOrEmpty(rowsOnPage)) rowsOnPage = "1000000000000";
|
|
|
+ if (string.IsNullOrEmpty(seqPage)) seqPage = "1";
|
|
|
+
|
|
|
+ string _keyConfig = Common.GetValuesAppSetting("webConfig", "key");
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string _rowsOnPage, _seqPage, _totalPage;
|
|
|
+ List<campaignSubObj> _listBalanceOfCam = getListCommon.getListSubOfCam(id, users, campaignId, fromDate, toDate, order, rowsOnPage, seqPage, channel, language
|
|
|
+ , out _rowsOnPage, out _seqPage, out _totalPage);
|
|
|
+
|
|
|
+ logger.Info("Call database balGetList success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ response.rowsOnPage = _rowsOnPage;
|
|
|
+ response.seqPage = _seqPage;
|
|
|
+ response.totalPage = _totalPage;
|
|
|
+
|
|
|
+ response.list = _listBalanceOfCam;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //[HttpPost]
|
|
|
+ //public IActionResult camSubGetListbk([FromBody] dynamic sendData)
|
|
|
+ //{
|
|
|
+
|
|
|
+ // logger.Info("New request income camSubGetList :" + sendData.ToString());
|
|
|
+ // campaignSubObjList response = new campaignSubObjList();
|
|
|
+ // response.responseCode = "-1";
|
|
|
+ // response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ // try
|
|
|
+ // {
|
|
|
+
|
|
|
+ // var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ // string users = Convert.ToString(userObj["users"]);
|
|
|
+ // string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+
|
|
|
+ // string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
+
|
|
|
+ // string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ // string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+
|
|
|
+ // string order = Convert.ToString(userObj["order"]);
|
|
|
+ // string rowsOnPage = Convert.ToString(userObj["rowsOnPage"]);
|
|
|
+ // string seqPage = Convert.ToString(userObj["seqPage"]);
|
|
|
+ // if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
+
|
|
|
+ // if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
+ // if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
+ // if (string.IsNullOrEmpty(order)) order = "asc";
|
|
|
+ // if (string.IsNullOrEmpty(rowsOnPage)) rowsOnPage = "1000000000000";
|
|
|
+ // if (string.IsNullOrEmpty(seqPage)) seqPage = "1";
|
|
|
+
|
|
|
+ // string _keyConfig = Common.GetValuesAppSetting("webConfig", "key");
|
|
|
+ // if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ // if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // string token = Convert.ToString(userObj["token"]);
|
|
|
+ // string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ // string language = Convert.ToString(userObj["language"]);
|
|
|
+ // if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ // string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ // string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ // string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ // var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ // //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ // redisConnection _redis;
|
|
|
+ // memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ // if (_redis == null)
|
|
|
+ // {
|
|
|
+ // var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ // {
|
|
|
+ // AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ // Priority = CacheItemPriority.High,
|
|
|
+ // SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ // Size = 1024,
|
|
|
+ // };
|
|
|
+ // _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ // _redis.connet();
|
|
|
+ // memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ // }
|
|
|
+ // if (!_redis.isConnet())
|
|
|
+ // {
|
|
|
+ // if (!_redis.connet())
|
|
|
+ // {
|
|
|
+ // logger.Info("Connect to redis false");
|
|
|
+ // response.responseCode = "-2";
|
|
|
+ // response.responseMessage = "System Update";
|
|
|
+ // logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ // return Ok(response);
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ // {
|
|
|
+ // AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ // Priority = CacheItemPriority.High,
|
|
|
+ // SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ // Size = 1024,
|
|
|
+ // };
|
|
|
+ // memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ // tokenObj _tokenObj = null;
|
|
|
+ // if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ // {
|
|
|
+ // logger.Info("Authen token false");
|
|
|
+ // response.responseCode = "35";
|
|
|
+ // response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ // logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ // return Ok(response);
|
|
|
+ // }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // DataSet ds_regist = balanceDataAccess.camSubGetList(id, users, campaignId, fromDate, toDate, order, rowsOnPage, seqPage, channel, language);
|
|
|
+ // logger.Info("Call database camSubGetList success:");
|
|
|
+ // response.responseCode = "0";
|
|
|
+ // response.responseMessage = "Success";
|
|
|
+ // if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ // {
|
|
|
+
|
|
|
+
|
|
|
+ // response.rowsOnPage = ds_regist.Tables[0].Rows[0]["ROW_ON_PAGE"].ToString();
|
|
|
+ // response.seqPage = ds_regist.Tables[0].Rows[0]["SEQ_PAGE"].ToString();
|
|
|
+ // response.totalPage = ds_regist.Tables[0].Rows[0]["TOTAL_PAGE"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+ // response.list = new List<campaignSubObj>[ds_regist.Tables[0].Rows.Count];
|
|
|
+ // for (int j = 0; j < ds_regist.Tables[0].Rows.Count; j++)
|
|
|
+ // {
|
|
|
+ // campaignBalObj _obj = new campaignBalObj();
|
|
|
+
|
|
|
+ // _obj.id = ds_regist.Tables[0].Rows[j]["ID"].ToString();
|
|
|
+ // _obj.campaignId = ds_regist.Tables[0].Rows[j]["CAMPAIGN_ID"].ToString();
|
|
|
+ // _obj.balanceId = ds_regist.Tables[0].Rows[j]["REF_ID"].ToString();
|
|
|
+ // _obj.isDelete = ds_regist.Tables[0].Rows[j]["IS_DELETE"].ToString();
|
|
|
+ // _obj.note = ds_regist.Tables[0].Rows[j]["NOTE"].ToString();
|
|
|
+
|
|
|
+ // _obj.usersCreated = ds_regist.Tables[0].Rows[j]["USERS_CREATED"].ToString();
|
|
|
+ // _obj.dateCreated = ds_regist.Tables[0].Rows[j]["DATE_CREATED"].ToString();
|
|
|
+ // _obj.usersUpdate = ds_regist.Tables[0].Rows[j]["USERS_UPDATE"].ToString();
|
|
|
+ // _obj.dateUpdate = ds_regist.Tables[0].Rows[j]["DATE_UPDATE"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // response.list[j] = _obj;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // }
|
|
|
+ // catch (Exception ex)
|
|
|
+ // {
|
|
|
+ // logger.Info("exception: " + ex.ToString());
|
|
|
+ // response.responseCode = "-2";
|
|
|
+ // response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ // }
|
|
|
+ // logger.Info("Responase to web: " + response.ToString());
|
|
|
+ // return Ok(response);
|
|
|
+ //}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"code":"124","name":"Cty Viettech 1","fromDate":"01/11/2021 00:00:00","toDate":"01/11/2022 00:00:00","fromHour":"08:08:09","toHour":"01:09:08","rule":"1","priority":"1","balanceId":"1","expireDateId":"1","status":"1","note":"123456","users":"haha","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ */
|
|
|
+ public IActionResult camSubInsert([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income camSubInsert :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
+ string refId = Convert.ToString(userObj["subId"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
+ if (string.IsNullOrEmpty(refId)) refId = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.camSubInsert(campaignId, refId, note, users,
|
|
|
+ channel, language);
|
|
|
+ logger.Info("Call database camSubInsert success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success camSubInsert not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success ds_regist is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public IActionResult camSubUpdate([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income camSubUpdate :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string type = Convert.ToString(userObj["type"]);
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
+ string refId = Convert.ToString(userObj["subId"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
+ if (string.IsNullOrEmpty(refId)) refId = "-1";
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+ if (string.IsNullOrEmpty(type)) type = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.camSubUpdate(campaignId, refId, note, users,
|
|
|
+ channel, language, id, type);
|
|
|
+ logger.Info("Call database camBalanceUpdate success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success camBalanceUpdate not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success ds_regist is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public IActionResult camExpireGetList([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income camExpireGetList :" + sendData.ToString());
|
|
|
+ campaignExpObjList response = new campaignExpObjList();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
+
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+
|
|
|
+ string order = Convert.ToString(userObj["order"]);
|
|
|
+ string rowsOnPage = Convert.ToString(userObj["rowsOnPage"]);
|
|
|
+ string seqPage = Convert.ToString(userObj["seqPage"]);
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(order)) order = "asc";
|
|
|
+ if (string.IsNullOrEmpty(rowsOnPage)) rowsOnPage = "1000000000000";
|
|
|
+ if (string.IsNullOrEmpty(seqPage)) seqPage = "1";
|
|
|
+
|
|
|
+ string _keyConfig = Common.GetValuesAppSetting("webConfig", "key");
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ string _rowsOnPage, _seqPage, _totalPage;
|
|
|
+ List<campaignExpObj> _listBalanceOfCam = getListCommon.getListExpireOfCam(id, users, campaignId, fromDate, toDate, order, rowsOnPage, seqPage, channel, language
|
|
|
+ , out _rowsOnPage, out _seqPage, out _totalPage);
|
|
|
+
|
|
|
+ logger.Info("Call database balGetList success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ response.rowsOnPage = _rowsOnPage;
|
|
|
+ response.seqPage = _seqPage;
|
|
|
+ response.totalPage = _totalPage;
|
|
|
+
|
|
|
+ response.list = _listBalanceOfCam;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"code":"124","name":"Cty Viettech 1","fromDate":"01/11/2021 00:00:00","toDate":"01/11/2022 00:00:00","fromHour":"08:08:09","toHour":"01:09:08","rule":"1","priority":"1","balanceId":"1","expireDateId":"1","status":"1","note":"123456","users":"haha","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ */
|
|
|
+ public IActionResult camExpireInsert([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income camExpireInsert :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
+ string refId = Convert.ToString(userObj["expireId"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
+ if (string.IsNullOrEmpty(refId)) refId = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.camExpInsert(campaignId, refId, note, users,
|
|
|
+ channel, language);
|
|
|
+ logger.Info("Call database camExpireInsert success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success camExpireInsert not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success ds_regist is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public IActionResult camExpireUpdate([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income camExpireUpdate :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string type = Convert.ToString(userObj["type"]);
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
+ string refId = Convert.ToString(userObj["expireId"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
+ if (string.IsNullOrEmpty(refId)) refId = "-1";
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+ if (string.IsNullOrEmpty(type)) type = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.camExpUpdate(campaignId, refId, note, users,
|
|
|
+ channel, language, id, type);
|
|
|
+ logger.Info("Call database camExpireUpdate success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success camExpireUpdate not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success ds_regist is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public IActionResult caShortCodeGetList([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income caShortCodeGetList :" + sendData.ToString());
|
|
|
+ campaignScObjList response = new campaignScObjList();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
+
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+
|
|
|
+ string order = Convert.ToString(userObj["order"]);
|
|
|
+ string rowsOnPage = Convert.ToString(userObj["rowsOnPage"]);
|
|
|
+ string seqPage = Convert.ToString(userObj["seqPage"]);
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(order)) order = "asc";
|
|
|
+ if (string.IsNullOrEmpty(rowsOnPage)) rowsOnPage = "1000000000000";
|
|
|
+ if (string.IsNullOrEmpty(seqPage)) seqPage = "1";
|
|
|
+
|
|
|
+ string _keyConfig = Common.GetValuesAppSetting("webConfig", "key");
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ string _rowsOnPage, _seqPage, _totalPage;
|
|
|
+ List<campaignScObj> _listBalanceOfCam = getListCommon.getListShortCodeOfCam(id, users, campaignId, fromDate, toDate, order, rowsOnPage, seqPage, channel, language
|
|
|
+ , out _rowsOnPage, out _seqPage, out _totalPage);
|
|
|
+
|
|
|
+ logger.Info("Call database balGetList success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ response.rowsOnPage = _rowsOnPage;
|
|
|
+ response.seqPage = _seqPage;
|
|
|
+ response.totalPage = _totalPage;
|
|
|
+
|
|
|
+ response.list = _listBalanceOfCam;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"code":"124","name":"Cty Viettech 1","fromDate":"01/11/2021 00:00:00","toDate":"01/11/2022 00:00:00","fromHour":"08:08:09","toHour":"01:09:08","rule":"1","priority":"1","balanceId":"1","expireDateId":"1","status":"1","note":"123456","users":"haha","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ */
|
|
|
+ public IActionResult camShortCodeInsert([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income camShortCodeInsert :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
+ string refId = Convert.ToString(userObj["shortCodeId"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
+ if (string.IsNullOrEmpty(refId)) refId = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.camScInsert(campaignId, refId, note, users,
|
|
|
+ channel, language);
|
|
|
+ logger.Info("Call database camShortCodeInsert success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success camShortCodeInsert not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success ds_regist is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public IActionResult camShortCodeUpdate([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income camShortCodeUpdate :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string type = Convert.ToString(userObj["type"]);
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
+ string refId = Convert.ToString(userObj["shortCodeId"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
+ if (string.IsNullOrEmpty(refId)) refId = "-1";
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+ if (string.IsNullOrEmpty(type)) type = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.camScUpdate(campaignId, refId, note, users,
|
|
|
+ channel, language, id, type);
|
|
|
+ logger.Info("Call database camShortCodeUpdate success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success camShortCodeUpdate not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success camShortCodeUpdate is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //{"id":"2","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult camAddGetList([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income balanceGetList :" + sendData.ToString());
|
|
|
+ campaignAddObjList response = new campaignAddObjList();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
+
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+
|
|
|
+ string order = Convert.ToString(userObj["order"]);
|
|
|
+ string rowsOnPage = Convert.ToString(userObj["rowsOnPage"]);
|
|
|
+ string seqPage = Convert.ToString(userObj["seqPage"]);
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
+ logger.Info("order truc" + order);
|
|
|
+ if (string.IsNullOrEmpty(order)) order = "asc";
|
|
|
+ logger.Info("order sau"+ order);
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(rowsOnPage)) rowsOnPage = "1000000000000";
|
|
|
+ if (string.IsNullOrEmpty(seqPage)) seqPage = "1";
|
|
|
+
|
|
|
+ string _keyConfig = Common.GetValuesAppSetting("webConfig", "key");
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ string _rowsOnPage, _seqPage, _totalPage;
|
|
|
+ List<campaignAddObj> _listOfCam = getListCommon.getListServiceOfCam(id, users, campaignId, fromDate, toDate, order, rowsOnPage, seqPage, channel, language
|
|
|
+ , out _rowsOnPage, out _seqPage, out _totalPage);
|
|
|
+
|
|
|
+ logger.Info("Call database balGetList success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ response.rowsOnPage = _rowsOnPage;
|
|
|
+ response.seqPage = _seqPage;
|
|
|
+ response.totalPage = _totalPage;
|
|
|
+
|
|
|
+ response.list = _listOfCam;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"code":"124","name":"Cty Viettech 1","fromDate":"01/11/2021 00:00:00","toDate":"01/11/2022 00:00:00","fromHour":"08:08:09","toHour":"01:09:08","rule":"1","priority":"1","balanceId":"1","expireDateId":"1","status":"1","note":"123456","users":"haha","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ */
|
|
|
+ public IActionResult camAddInsert([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income balanceInsert :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
+ string serviceAddId = Convert.ToString(userObj["serviceId"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+ string ussdDisplay = Convert.ToString(userObj["ussdDisplay"]);
|
|
|
+ string keyRegister = Convert.ToString(userObj["keyRegister"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
+ if (string.IsNullOrEmpty(serviceAddId)) serviceAddId = "-1";
|
|
|
+ if (string.IsNullOrEmpty(ussdDisplay)) ussdDisplay = "-1";
|
|
|
+ if (string.IsNullOrEmpty(keyRegister)) keyRegister = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.camAddInsert(campaignId, serviceAddId, note, users,
|
|
|
+ ussdDisplay, keyRegister);
|
|
|
+ logger.Info("Call database balInsert success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success ds_regist not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success ds_regist is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"id":"5","code":"124","name":"Cty 1","fromDate":"01/11/2021 00:00:00","toDate":"01/11/2022 00:00:00","fromHour":"08:08:09","toHour":"01:09:08","rule":"1","priority":"1","balanceId":"1","expireDateId":"1","status":"1","note":"123456","type":"0","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ */
|
|
|
+
|
|
|
+ public IActionResult camAddUpdate([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income companyGetList :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
+ string serviceAddId = Convert.ToString(userObj["serviceAddId"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+
|
|
|
+ string type = Convert.ToString(userObj["type"]);
|
|
|
+
|
|
|
+ string keyRegister = Convert.ToString(userObj["keyRegister"]);
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string ussdDisplay = Convert.ToString(userObj["ussdDisplay"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+ if (string.IsNullOrEmpty(keyRegister)) keyRegister = "-1";
|
|
|
+ if (string.IsNullOrEmpty(type)) type = "0";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(ussdDisplay)) ussdDisplay = "-1";
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.camAddUpdate(id, campaignId, serviceAddId, note, users, type, ussdDisplay, keyRegister);
|
|
|
+ logger.Info("Call database comInsert success:");
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+ logger.Info("Call database success ds_regist not null");
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString(); ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ logger.Info("Call database success ds_regist is null");
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //{"id":"1","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult usersGetList([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income balanceGetList :" + sendData.ToString());
|
|
|
+ usersObjList response = new usersObjList();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.usersGetList(id, users);
|
|
|
+ logger.Info("Call database balGetList success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response.list = new usersObj[ds_regist.Tables[0].Rows.Count];
|
|
|
+ for (int j = 0; j < ds_regist.Tables[0].Rows.Count; j++)
|
|
|
+ {
|
|
|
+ usersObj _obj = new usersObj();
|
|
|
+
|
|
|
+ _obj.id = ds_regist.Tables[0].Rows[j]["ID"].ToString();
|
|
|
+ _obj.userName = ds_regist.Tables[0].Rows[j]["USERNAME"].ToString();
|
|
|
+ _obj.pasword =ResfullApi.Models.CustomEncryption.Decrypt(ds_regist.Tables[0].Rows[j]["PASSWORD"].ToString());
|
|
|
+ _obj.role = ds_regist.Tables[0].Rows[j]["ROLE"].ToString();
|
|
|
+ _obj.contryCode = ds_regist.Tables[0].Rows[j]["COUNTRY_CODE"].ToString();
|
|
|
+ _obj.isLock = ds_regist.Tables[0].Rows[j]["IS_LOCK"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+ _obj.totalFalse = ds_regist.Tables[0].Rows[j]["TOTAL_FALSE"].ToString();
|
|
|
+ _obj.timeLock = ds_regist.Tables[0].Rows[j]["TIME_LOCK"].ToString();
|
|
|
+ _obj.note = ds_regist.Tables[0].Rows[j]["NOTE"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+ response.list[j] = _obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"code":"124","values":"Cty Viettech 1","note":"0","status":"1","codeGroup":"quangbh","display0":"display0","display1":"display1","display2":"display2","display3":"display3","display4":"display4","display5":"display5","gameId":"1","channel":"channel","users":"haha","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ */
|
|
|
+ public IActionResult usersInsert([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income balanceInsert :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string userName = Convert.ToString(userObj["userName"]);
|
|
|
+ string pasword = ResfullApi.Models.CustomEncryption.Encrypt(Convert.ToString(userObj["pasword"]));
|
|
|
+ string role = Convert.ToString(userObj["role"]);
|
|
|
+ string contryCode = Convert.ToString(userObj["contryCode"]);
|
|
|
+ string isLock = Convert.ToString(userObj["isLock"]);
|
|
|
+ string timeLock = Convert.ToString(userObj["timeLock"]);
|
|
|
+ string totalFalse = Convert.ToString(userObj["totalFalse"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(userName)) userName = "-1";
|
|
|
+ if (string.IsNullOrEmpty(isLock)) isLock = "0";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.usersInsert(userName, pasword, role, contryCode, isLock, totalFalse, timeLock, note, users);
|
|
|
+ logger.Info("Call database balInsert success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"id":"1","code":"124","values":"Cty Viettech 1","note":"0","status":"1","codeGroup":"quangbh","display0":"display0","display1":"display1","display2":"displayso 3","display3":"display3","display4":"display4","display5":"display5","gameId":"1","channel":"channel","type":"0","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+
|
|
|
+ */
|
|
|
+
|
|
|
+ public IActionResult usersUpdate([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income companyGetList :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+ string userName = Convert.ToString(userObj["userName"]);
|
|
|
+ string pasword = ResfullApi.Models.CustomEncryption.Encrypt(Convert.ToString(userObj["pasword"]));
|
|
|
+ string role = Convert.ToString(userObj["role"]);
|
|
|
+ string contryCode = Convert.ToString(userObj["contryCode"]);
|
|
|
+ string isLock = Convert.ToString(userObj["isLock"]);
|
|
|
+ string timeLock = Convert.ToString(userObj["timeLock"]);
|
|
|
+ string totalFalse = Convert.ToString(userObj["totalFalse"]);
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
+
|
|
|
+
|
|
|
+ string type = Convert.ToString(userObj["type"]);
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+ if (string.IsNullOrEmpty(type)) type = "0";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.usersUpdate(id, userName, pasword, role, contryCode, isLock, totalFalse, timeLock, note, users, type);
|
|
|
+ logger.Info("Call database comInsert success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //{"id":"1","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult ngamGetList([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income balanceGetList :" + sendData.ToString());
|
|
|
+ ngamObjList response = new ngamObjList();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+ string serviceAddId = Convert.ToString(userObj["serviceAddId"]);
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+ if (string.IsNullOrEmpty(serviceAddId)) serviceAddId = "-1";
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.ngamGetList(id, users);
|
|
|
+ //DataSet ds_regist = balanceDataAccess.ngamGetList(serviceAddId, users);
|
|
|
+
|
|
|
+ logger.Info("Call database balGetList success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response.list = new ngamObj[ds_regist.Tables[0].Rows.Count];
|
|
|
+ for (int j = 0; j < ds_regist.Tables[0].Rows.Count; j++)
|
|
|
+ {
|
|
|
+ ngamObj _obj = new ngamObj();
|
|
|
+
|
|
|
+ _obj.id = ds_regist.Tables[0].Rows[j]["ID"].ToString();
|
|
|
+ _obj.name = ds_regist.Tables[0].Rows[j]["NAME"].ToString();
|
|
|
+ _obj.serviceId = ds_regist.Tables[0].Rows[j]["SV"].ToString();
|
|
|
+ _obj.message = ds_regist.Tables[0].Rows[j]["MSG"].ToString();
|
|
|
+ _obj.fromDate = ds_regist.Tables[0].Rows[j]["FD"].ToString();
|
|
|
+ _obj.toDate = ds_regist.Tables[0].Rows[j]["TD"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+ _obj.percent = ds_regist.Tables[0].Rows[j]["PC"].ToString();
|
|
|
+ _obj.addType = ds_regist.Tables[0].Rows[j]["ADD_TYPE"].ToString();
|
|
|
+ _obj.sysdate = ds_regist.Tables[0].Rows[j]["VSYSDATE"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+ response.list[j] = _obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"code":"124","values":"Cty Viettech 1","note":"0","status":"1","codeGroup":"quangbh","display0":"display0","display1":"display1","display2":"display2","display3":"display3","display4":"display4","display5":"display5","gameId":"1","channel":"channel","users":"haha","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ */
|
|
|
+ public IActionResult ngamInsert([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income balanceInsert :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string serviceId = Convert.ToString(userObj["serviceId"]);
|
|
|
+ string serviceAddId = Convert.ToString(userObj["serviceAddId"]);
|
|
|
+ string message = Convert.ToString(userObj["message"]);
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+ string percent = Convert.ToString(userObj["percent"]);
|
|
|
+ string addType = Convert.ToString(userObj["addType"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(serviceId)) serviceId = "-1";
|
|
|
+ if (string.IsNullOrEmpty(serviceAddId)) serviceAddId = "-1";
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(message)) message = "0";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //DataSet ds_regist = balanceDataAccess.ngamInsert(name, serviceId, message, fromDate, toDate, percent, addType, users);
|
|
|
+ DataSet ds_regist = balanceDataAccess.ngamInsert(name, serviceAddId, message, fromDate, toDate, percent, addType, users);
|
|
|
+
|
|
|
+ logger.Info("Call database balInsert success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"id":"1","code":"124","values":"Cty Viettech 1","note":"0","status":"1","codeGroup":"quangbh","display0":"display0","display1":"display1","display2":"displayso 3","display3":"display3","display4":"display4","display5":"display5","gameId":"1","channel":"channel","type":"0","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+
|
|
|
+ */
|
|
|
+
|
|
|
+ public IActionResult gamUpdate([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income companyGetList :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string id = Convert.ToString(userObj["id"]);
|
|
|
+
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
+ string serviceId = Convert.ToString(userObj["serviceId"]);
|
|
|
+ string serviceAddId = Convert.ToString(userObj["serviceAddId"]);
|
|
|
+ string message = Convert.ToString(userObj["message"]);
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+ string percent = Convert.ToString(userObj["percent"]);
|
|
|
+ string addType = Convert.ToString(userObj["addType"]);
|
|
|
+ string sysdate = Convert.ToString(userObj["sysdate"]);
|
|
|
+
|
|
|
+
|
|
|
+ string type = Convert.ToString(userObj["type"]);
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
+ if (string.IsNullOrEmpty(serviceAddId)) serviceAddId = "-1";
|
|
|
+ if (string.IsNullOrEmpty(type)) type = "0";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //DataSet ds_regist = balanceDataAccess.ngamUpdate(id, name, serviceId, message, fromDate, toDate, percent, addType, users, type);
|
|
|
+ DataSet ds_regist = balanceDataAccess.ngamUpdate(id, name, serviceAddId, message, fromDate, toDate, percent, addType, users, type);
|
|
|
+ logger.Info("Call database comInsert success:");
|
|
|
+
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //{"id":"1","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult blacklistGetList([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income blacklistGetList :" + sendData.ToString());
|
|
|
+ blackListGetListArr response = new blackListGetListArr();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+
|
|
|
+ string msisdn = Convert.ToString(userObj["msisdn"]);
|
|
|
+ string type = Convert.ToString(userObj["type"]);
|
|
|
+ string serviceId = Convert.ToString(userObj["serviceId"]);
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(msisdn)) msisdn = "-1";
|
|
|
+ if (string.IsNullOrEmpty(type)) type = "-1";
|
|
|
+ if (string.IsNullOrEmpty(serviceId)) serviceId = "-1";
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //DataSet ds_regist = balanceDataAccess.blackGettList(msisdn, type, serviceId, users);
|
|
|
+ DataSet ds_regist = balanceDataAccess.blackGettList(msisdn, type, campaignId, users);
|
|
|
+ logger.Info("Call database blackGettList success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response.list = new blackListGetList[ds_regist.Tables[0].Rows.Count];
|
|
|
+ for (int j = 0; j < ds_regist.Tables[0].Rows.Count; j++)
|
|
|
+ {
|
|
|
+ blackListGetList _obj = new blackListGetList();
|
|
|
+
|
|
|
+ _obj.id = ds_regist.Tables[0].Rows[j]["ID"].ToString();
|
|
|
+ _obj.msisdn = ds_regist.Tables[0].Rows[j]["msisdn"].ToString();
|
|
|
+ _obj.type = ds_regist.Tables[0].Rows[j]["type"].ToString();
|
|
|
+ //_obj.serviceId = ds_regist.Tables[0].Rows[j]["SV_ID"].ToString();
|
|
|
+ _obj.campaignId = ds_regist.Tables[0].Rows[j]["SV_ID"].ToString();
|
|
|
+ _obj.sysdate = ds_regist.Tables[0].Rows[j]["VSYSDATE"].ToString();
|
|
|
+ _obj.users = ds_regist.Tables[0].Rows[j]["USERS"].ToString();
|
|
|
+ _obj.campaignName = ds_regist.Tables[0].Rows[j]["campaign_name"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response.list[j] = _obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //Import data vao Export
|
|
|
+ //--;
|
|
|
+
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult blacklistInsertData([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ logger.Info("Request from UI blacklistInsertData: " + sendData.ToString());
|
|
|
+
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ blackImportDataList _data = JsonConvert.DeserializeObject<blackImportDataList>(sendData.ToString());
|
|
|
+ if (string.IsNullOrEmpty(_data.type)) _data.type = "-1";
|
|
|
+ if (string.IsNullOrEmpty(_data.serviceId)) _data.serviceId = "-1";
|
|
|
+ if (string.IsNullOrEmpty(_data.campaignId)) _data.campaignId = "-1";
|
|
|
+ if (string.IsNullOrEmpty(_data.users)) _data.users = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //Check key for authencation
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ List<List<string>> DataColumms = new List<List<string>>();
|
|
|
+ var LIST_MSISDN = new List<string>();
|
|
|
+ var LIST_TYPE = new List<string>();
|
|
|
+ var LIST_SVID = new List<string>();
|
|
|
+ var LIST_ACTION = new List<string>();
|
|
|
+ var LIST_USERS = new List<string>();
|
|
|
+
|
|
|
+
|
|
|
+ foreach (blackListObj eachData in _data.data)
|
|
|
+ {
|
|
|
+
|
|
|
+ LIST_TYPE.Add(_data.type);
|
|
|
+ //LIST_SVID.Add(_data.serviceId);
|
|
|
+ LIST_SVID.Add(_data.campaignId);
|
|
|
+ LIST_USERS.Add(_data.users);
|
|
|
+
|
|
|
+ LIST_MSISDN.Add(eachData.msisdn);
|
|
|
+ LIST_ACTION.Add(eachData.action);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ DataColumms.Add(LIST_MSISDN);
|
|
|
+ DataColumms.Add(LIST_TYPE);
|
|
|
+ DataColumms.Add(LIST_SVID);
|
|
|
+ DataColumms.Add(LIST_ACTION);
|
|
|
+ DataColumms.Add(LIST_USERS);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ balanceDataAccess.InsertBulkBlackList("BALANCE_PKG.BLACK_INSERT", DataColumms);
|
|
|
+
|
|
|
+ logger.Info("Call database export_created success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("getResultOfTerm exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(response);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public IActionResult reload([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income reload :" + sendData.ToString());
|
|
|
+ Response response = new Response();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string type = Convert.ToString(userObj["type"]);
|
|
|
+
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(type)) type = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.reload(type, users);
|
|
|
+ logger.Info("Call database reload success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //Khong dung ham hany
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult reportByCampaign_kodung([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income reportByCampaign :" + sendData.ToString());
|
|
|
+ reportByCampaignList response = new reportByCampaignList();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string status = Convert.ToString(userObj["status"]);
|
|
|
+
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(status)) status = "-1";
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.reportByCampaign( users, status, fromDate, toDate);
|
|
|
+ logger.Info("Call database reportByCampaign success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response.list = new reportByCampaign[ds_regist.Tables[0].Rows.Count];
|
|
|
+ for (int j = 0; j < ds_regist.Tables[0].Rows.Count; j++)
|
|
|
+ {
|
|
|
+ reportByCampaign _obj = new reportByCampaign();
|
|
|
+
|
|
|
+ _obj.seq = ds_regist.Tables[0].Rows[j]["SEQ"].ToString();
|
|
|
+ _obj.code = ds_regist.Tables[0].Rows[j]["CAM_CODE"].ToString();
|
|
|
+ _obj.name = ds_regist.Tables[0].Rows[j]["CAM_NAME"].ToString();
|
|
|
+ _obj.priority = ds_regist.Tables[0].Rows[j]["CAM_PRIORITY"].ToString();
|
|
|
+
|
|
|
+ _obj.ruleAdd = ds_regist.Tables[0].Rows[j]["CAM_RULE_ADD"].ToString();
|
|
|
+ _obj.addType = ds_regist.Tables[0].Rows[j]["CAM_ADD_TYPE"].ToString();
|
|
|
+
|
|
|
+ _obj.createDate = ds_regist.Tables[0].Rows[j]["CAM_DATE_CREATED"].ToString();
|
|
|
+ _obj.fromDate = ds_regist.Tables[0].Rows[j]["CAM_FROM_DATE"].ToString();
|
|
|
+ _obj.toDate = ds_regist.Tables[0].Rows[j]["CAM_TO_DATE"].ToString();
|
|
|
+ _obj.status = ds_regist.Tables[0].Rows[j]["CAM_STATUS"].ToString();
|
|
|
+ _obj.serviceCode = ds_regist.Tables[0].Rows[j]["S_CODE"].ToString();
|
|
|
+ _obj.serviceName = ds_regist.Tables[0].Rows[j]["S_NAME"].ToString();
|
|
|
+
|
|
|
+ _obj.totalView = ds_regist.Tables[0].Rows[j]["TOTAL_VIEW"].ToString();
|
|
|
+ _obj.activation = ds_regist.Tables[0].Rows[j]["ACTIVATION"].ToString();
|
|
|
+ _obj.success = ds_regist.Tables[0].Rows[j]["REGIST_SUCCESS"].ToString();
|
|
|
+ _obj.fail = ds_regist.Tables[0].Rows[j]["REGIST_FAIL"].ToString();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response.list[j] = _obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //{"id":"2","users":"quangbh","key":"jqB3Vi1fIlu+9a2ODQs65w=="}
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult calendarGetList([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income calendarGetList :" + sendData.ToString());
|
|
|
+ campaignCalebdarResponse response = new campaignCalebdarResponse();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string status = Convert.ToString(userObj["status"]);
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(status)) status = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DateTime startDate=new DateTime();
|
|
|
+ DateTime endDate=new DateTime();
|
|
|
+
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ startDate = DateTime.ParseExact(fromDate, "dd/MM/yyyy", null);
|
|
|
+ endDate = DateTime.ParseExact(toDate, "dd/MM/yyyy", null);
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception convert date: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+ }
|
|
|
+ TimeSpan ts = endDate - startDate;
|
|
|
+
|
|
|
+ int totalDay = ((int)ts.TotalDays);
|
|
|
+ List<campaignCalebdarObj> _listCalendar=new List<campaignCalebdarObj>();
|
|
|
+ for(int i=0;i<totalDay;i++)
|
|
|
+ {
|
|
|
+ string now = startDate.AddDays(i).ToString("dd/MM/yyyy");
|
|
|
+
|
|
|
+ List<campaignObj> _listCam = getListCommon.getListCamCalendar(users, now, now,status);
|
|
|
+ campaignCalebdarObj _objCalendar = new campaignCalebdarObj();
|
|
|
+ _objCalendar.date = now;
|
|
|
+ _objCalendar.list = _listCam;
|
|
|
+ _listCalendar.Add(_objCalendar);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ logger.Info("Call database balGetList success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+
|
|
|
+
|
|
|
+ response.list = _listCalendar;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult reportByCampaign([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income reportByCampaign :" + sendData.ToString());
|
|
|
+ reportTotalByCampaignList response = new reportTotalByCampaignList();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string status = Convert.ToString(userObj["status"]);
|
|
|
+ string isDefault = Convert.ToString(userObj["isDefault"]);
|
|
|
+
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(status)) status = "-1";
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(isDefault)) isDefault = "-1";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataSet ds_regist = balanceDataAccess.reportTotalByCampaign(users, fromDate, toDate, status,isDefault);
|
|
|
+ logger.Info("Call database reportTotalByCampaign success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+ if (ds_regist != null & ds_regist.Tables[0].Rows.Count > 0)
|
|
|
+ {
|
|
|
+
|
|
|
+ List<reportTotalByCampaign> _l = new List<reportTotalByCampaign>();
|
|
|
+ for (int j = 0; j < ds_regist.Tables[0].Rows.Count; j++)
|
|
|
+ {
|
|
|
+ reportTotalByCampaign _obj = new reportTotalByCampaign();
|
|
|
+ _obj.seq = ds_regist.Tables[0].Rows[j]["SEQ"].ToString();
|
|
|
+ _obj.campaignId = ds_regist.Tables[0].Rows[j]["CAMPAIGN_ID"].ToString();
|
|
|
+ _obj.campaignName = ds_regist.Tables[0].Rows[j]["CAMPAIGN_NAME"].ToString();
|
|
|
+ _obj.priority = ds_regist.Tables[0].Rows[j]["PRIORITY"].ToString();
|
|
|
+
|
|
|
+ _obj.campaignType = ds_regist.Tables[0].Rows[j]["CAMPAIGN_TYPE"].ToString();
|
|
|
+ _obj.serviceType = ds_regist.Tables[0].Rows[j]["SERVICE_TYPE"].ToString();
|
|
|
+
|
|
|
+ _obj.serviceName = ds_regist.Tables[0].Rows[j]["SERVICE_NAME"].ToString();
|
|
|
+ _obj.totalView1 = ds_regist.Tables[0].Rows[j]["VIEW1"].ToString();
|
|
|
+ _obj.activation1 = ds_regist.Tables[0].Rows[j]["ACTIVATION1"].ToString();
|
|
|
+ _obj.totalView2 = ds_regist.Tables[0].Rows[j]["VIEW2"].ToString();
|
|
|
+ _obj.activation2 = ds_regist.Tables[0].Rows[j]["ACTIVATION2"].ToString();
|
|
|
+ _obj.success = ds_regist.Tables[0].Rows[j]["TOTAL_SUCCESS"].ToString();
|
|
|
+
|
|
|
+ _obj.fail = ds_regist.Tables[0].Rows[j]["TOTAL_FALISE"].ToString();
|
|
|
+
|
|
|
+ _l.Add( _obj );
|
|
|
+ }
|
|
|
+ response.list = _l;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult reportTotalGetList([FromBody] dynamic sendData)
|
|
|
+ {
|
|
|
+
|
|
|
+ logger.Info("New request income reportTotalGetList :" + sendData.ToString());
|
|
|
+ campaignCalebdarResponse response = new campaignCalebdarResponse();
|
|
|
+ response.responseCode = "-1";
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
+
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
+ string status = Convert.ToString(userObj["status"]);
|
|
|
+ string isDefault = Convert.ToString(userObj["isDefault"]);
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
+
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
+ if (string.IsNullOrEmpty(status)) status = "-1";
|
|
|
+ if (string.IsNullOrEmpty(isDefault)) status = "-1";
|
|
|
+
|
|
|
+
|
|
|
+ string token = Convert.ToString(userObj["token"]);
|
|
|
+ string channel = Convert.ToString(userObj["channel"]);
|
|
|
+ string language = Convert.ToString(userObj["language"]);
|
|
|
+ if (string.IsNullOrEmpty(language)) language = "-1";
|
|
|
+
|
|
|
+ string RedisIp = Common.GetValuesAppSetting("webConfig", "RedisIp");
|
|
|
+ string RedisPort = Common.GetValuesAppSetting("webConfig", "RedisPort");
|
|
|
+ string RedisPass = Common.GetValuesAppSetting("webConfig", "RedisPass");
|
|
|
+ var clientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------Lay ra va luu mot redis tu cache-----------------------------
|
|
|
+ redisConnection _redis;
|
|
|
+ memoryCache.TryGetValue("redis", out _redis);
|
|
|
+ if (_redis == null)
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ _redis = new redisConnection(RedisIp, RedisPort, RedisPass);
|
|
|
+ _redis.connet();
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+ }
|
|
|
+ if (!_redis.isConnet())
|
|
|
+ {
|
|
|
+ if (!_redis.connet())
|
|
|
+ {
|
|
|
+ logger.Info("Connect to redis false");
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System Update";
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cacheExpiryOptions = new MemoryCacheEntryOptions
|
|
|
+ {
|
|
|
+ AbsoluteExpiration = DateTime.Now.AddMonths(12),
|
|
|
+ Priority = CacheItemPriority.High,
|
|
|
+ SlidingExpiration = TimeSpan.FromMinutes(2),
|
|
|
+ Size = 1024,
|
|
|
+ };
|
|
|
+ memoryCache.Set("redis", _redis, cacheExpiryOptions);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //----------------------Ket thuc lay redis tu cache -------------------------------------
|
|
|
+
|
|
|
+ tokenObj _tokenObj = null;
|
|
|
+ if (!CommonFunction.checkToken(clientIp, token, channel, _redis, logger, out _tokenObj))
|
|
|
+ {
|
|
|
+ logger.Info("Authen token false");
|
|
|
+ response.responseCode = "35";
|
|
|
+ response.responseMessage = CommonObj.common.CommonFunction.getErrCodeObjFromRedis(_redis, channel, response.responseCode, language);
|
|
|
+ logger.Info("confirmTicket response : " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DateTime startDate = new DateTime();
|
|
|
+ DateTime endDate = new DateTime();
|
|
|
+
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ startDate = DateTime.ParseExact(fromDate, "dd/MM/yyyy", null);
|
|
|
+ endDate = DateTime.ParseExact(toDate, "dd/MM/yyyy", null);
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception convert date: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+ }
|
|
|
+ TimeSpan ts = endDate - startDate;
|
|
|
+
|
|
|
+ int totalDay = ((int)ts.TotalDays);
|
|
|
+ List<campaignCalebdarObj> _listCalendar = new List<campaignCalebdarObj>();
|
|
|
+ for (int i = 0; i < totalDay; i++)
|
|
|
+ {
|
|
|
+ string now = startDate.AddDays(i).ToString("dd/MM/yyyy");
|
|
|
+
|
|
|
+ List<campaignObj> _listCam = getListCommon.getListCamCalendar(users, now, now, status);
|
|
|
+ campaignCalebdarObj _objCalendar = new campaignCalebdarObj();
|
|
|
+ _objCalendar.date = now;
|
|
|
+ _objCalendar.list = _listCam;
|
|
|
+ _listCalendar.Add(_objCalendar);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ logger.Info("Call database balGetList success:");
|
|
|
+ response.responseCode = "0";
|
|
|
+ response.responseMessage = "Success";
|
|
|
+
|
|
|
+
|
|
|
+ response.list = _listCalendar;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
+ response.responseCode = "-2";
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
+
|
|
|
+ }
|
|
|
+ logger.Info("Responase to web: " + response.ToString());
|
|
|
+ return Ok(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+}
|