|
@@ -5,11 +5,17 @@ using System.Net;
|
|
|
using System.Net.Http;
|
|
using System.Net.Http;
|
|
|
|
|
|
|
|
using ResfullApi.Models;
|
|
using ResfullApi.Models;
|
|
|
|
|
+using ResfullApi.Models.balance;
|
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json;
|
|
|
using System.Data;
|
|
using System.Data;
|
|
|
using System.IO;
|
|
using System.IO;
|
|
|
using System.Xml;
|
|
using System.Xml;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
+using Newtonsoft.Json.Linq;
|
|
|
|
|
+using Microsoft.Extensions.Caching.Memory;
|
|
|
|
|
+using CommonObj.common;
|
|
|
|
|
+using CommonObj.model;
|
|
|
|
|
+using StackExchange.Redis;
|
|
|
|
|
|
|
|
namespace ApiProcess.Controllers
|
|
namespace ApiProcess.Controllers
|
|
|
{
|
|
{
|
|
@@ -18,6 +24,11 @@ namespace ApiProcess.Controllers
|
|
|
public class systemApi : ControllerBase
|
|
public class systemApi : ControllerBase
|
|
|
{
|
|
{
|
|
|
static readonly log4net.ILog logger = log4net.LogManager.GetLogger(typeof(systemApi));
|
|
static readonly log4net.ILog logger = log4net.LogManager.GetLogger(typeof(systemApi));
|
|
|
|
|
+ private IMemoryCache memoryCache;
|
|
|
|
|
+ public systemApi(IMemoryCache memoryCache)
|
|
|
|
|
+ {
|
|
|
|
|
+ this.memoryCache = memoryCache;
|
|
|
|
|
+ }
|
|
|
// {"msisdn":"50940227941","serviceId":"23","money":"2000"}
|
|
// {"msisdn":"50940227941","serviceId":"23","money":"2000"}
|
|
|
[HttpPost]
|
|
[HttpPost]
|
|
|
public IActionResult systemCharge([FromBody] dynamic sendData)
|
|
public IActionResult systemCharge([FromBody] dynamic sendData)
|
|
@@ -195,8 +206,1568 @@ namespace ApiProcess.Controllers
|
|
|
return rp;
|
|
return rp;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // USER WEB CMS MANAGEMENT APIs
|
|
|
|
|
+ [HttpPost]
|
|
|
|
|
+ public IActionResult sysUserWebCmsGetList([FromBody] dynamic sendData)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("New request income sysUserWebCmsGetList :" + sendData.ToString());
|
|
|
|
|
+ userWebCmsObjList response = new userWebCmsObjList();
|
|
|
|
|
+ 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 username = Convert.ToString(userObj["username"]);
|
|
|
|
|
+ string role = Convert.ToString(userObj["role"]);
|
|
|
|
|
+ string isLock = Convert.ToString(userObj["isLock"]);
|
|
|
|
|
+ string order = Convert.ToString(userObj["order"]);
|
|
|
|
|
+ string rowsOnPage = Convert.ToString(userObj["rowsOnPage"]);
|
|
|
|
|
+ string seqPage = Convert.ToString(userObj["seqPage"]);
|
|
|
|
|
+
|
|
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(username)) username = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(role)) role = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(isLock)) isLock = "-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 = systemUserDataAccess.SYS_USER_WEB_CMS_GET_LIST(users, id, username, role, isLock, order, rowsOnPage, seqPage);
|
|
|
|
|
+ logger.Info("Call database SYS_USER_WEB_CMS_GET_LIST success:");
|
|
|
|
|
+
|
|
|
|
|
+ response.responseCode = "0";
|
|
|
|
|
+ response.responseMessage = "Success";
|
|
|
|
|
+
|
|
|
|
|
+ if (ds_regist != null && ds_regist.Tables.Count > 0 && 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 userWebCmsObj[ds_regist.Tables[0].Rows.Count];
|
|
|
|
|
+ for (int j = 0; j < ds_regist.Tables[0].Rows.Count; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ userWebCmsObj _obj = new userWebCmsObj();
|
|
|
|
|
+
|
|
|
|
|
+ _obj.id = ds_regist.Tables[0].Rows[j]["ID"].ToString();
|
|
|
|
|
+ _obj.username = ds_regist.Tables[0].Rows[j]["USERNAME"].ToString();
|
|
|
|
|
+ _obj.password = ds_regist.Tables[0].Rows[j]["PASSWORD"].ToString();
|
|
|
|
|
+ _obj.role = ds_regist.Tables[0].Rows[j]["ROLE"].ToString();
|
|
|
|
|
+ _obj.countryCode = 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("Response to web: " + response.ToString());
|
|
|
|
|
+ return Ok(response);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ [HttpPost]
|
|
|
|
|
+ public IActionResult sysUserWebCmsInsert([FromBody] dynamic sendData)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("New request income sysUserWebCmsInsert :" + 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 password = Convert.ToString(userObj["password"]);
|
|
|
|
|
+ string role = Convert.ToString(userObj["role"]);
|
|
|
|
|
+ string countryCode = Convert.ToString(userObj["countryCode"]);
|
|
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
|
|
+
|
|
|
|
|
+ if (string.IsNullOrEmpty(username)) username = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(password)) password = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(role)) role = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(countryCode)) countryCode = "-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 = systemUserDataAccess.SYS_USER_WEB_CMS_INSERT(username, password, role, countryCode, note, users);
|
|
|
|
|
+ logger.Info("Call database SYS_USER_WEB_CMS_INSERT success:");
|
|
|
|
|
+
|
|
|
|
|
+ if (ds_regist != null && ds_regist.Tables[0].Rows.Count > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString();
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ response.responseCode = "-1";
|
|
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
|
|
+ response.responseCode = "-2";
|
|
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
|
|
+ }
|
|
|
|
|
+ logger.Info("Response to web: " + response.ToString());
|
|
|
|
|
+ return Ok(response);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ [HttpPost]
|
|
|
|
|
+ public IActionResult sysUserWebCmsUpdate([FromBody] dynamic sendData)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("New request income sysUserWebCmsUpdate :" + 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 password = Convert.ToString(userObj["password"]);
|
|
|
|
|
+ string role = Convert.ToString(userObj["role"]);
|
|
|
|
|
+ string countryCode = Convert.ToString(userObj["countryCode"]);
|
|
|
|
|
+ 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(id)) id = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(username)) username = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(password)) password = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(role)) role = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(countryCode)) countryCode = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(isLock)) isLock = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(timeLock)) timeLock = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(totalFalse)) totalFalse = "-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 = systemUserDataAccess.SYS_USER_WEB_CMS_UPDATE(id, username, password, role, countryCode, isLock, timeLock, totalFalse, note, users);
|
|
|
|
|
+ logger.Info("Call database SYS_USER_WEB_CMS_UPDATE success:");
|
|
|
|
|
+
|
|
|
|
|
+ if (ds_regist != null && ds_regist.Tables[0].Rows.Count > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString();
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ response.responseCode = "-1";
|
|
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
|
|
+ response.responseCode = "-2";
|
|
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
|
|
+ }
|
|
|
|
|
+ logger.Info("Response to web: " + response.ToString());
|
|
|
|
|
+ return Ok(response);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // FUNCTION WEB CMS MANAGEMENT APIs
|
|
|
|
|
+ [HttpPost]
|
|
|
|
|
+ public IActionResult sysFunctionWebCmsGetList([FromBody] dynamic sendData)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("New request income sysFunctionWebCmsGetList :" + sendData.ToString());
|
|
|
|
|
+ functionWebCmsObjList response = new functionWebCmsObjList();
|
|
|
|
|
+ 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 role = Convert.ToString(userObj["role"]);
|
|
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
|
|
+ string link = Convert.ToString(userObj["link"]);
|
|
|
|
|
+ string order = Convert.ToString(userObj["order"]);
|
|
|
|
|
+ string rowsOnPage = Convert.ToString(userObj["rowsOnPage"]);
|
|
|
|
|
+ string seqPage = Convert.ToString(userObj["seqPage"]);
|
|
|
|
|
+
|
|
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(role)) role = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(link)) link = "-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 = systemUserDataAccess.SYS_FUNCTION_WEB_CMS_GET_LIST(users, id, role, name, link, order, rowsOnPage, seqPage);
|
|
|
|
|
+ logger.Info("Call database SYS_FUNCTION_WEB_CMS_GET_LIST success:");
|
|
|
|
|
+
|
|
|
|
|
+ response.responseCode = "0";
|
|
|
|
|
+ response.responseMessage = "Success";
|
|
|
|
|
+
|
|
|
|
|
+ if (ds_regist != null && ds_regist.Tables.Count > 0 && 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 functionWebCmsObj[ds_regist.Tables[0].Rows.Count];
|
|
|
|
|
+ for (int j = 0; j < ds_regist.Tables[0].Rows.Count; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ functionWebCmsObj _obj = new functionWebCmsObj();
|
|
|
|
|
+
|
|
|
|
|
+ _obj.id = ds_regist.Tables[0].Rows[j]["ID"].ToString();
|
|
|
|
|
+ _obj.role = ds_regist.Tables[0].Rows[j]["ROLE"].ToString();
|
|
|
|
|
+ _obj.name = ds_regist.Tables[0].Rows[j]["NAME"].ToString();
|
|
|
|
|
+ _obj.link = ds_regist.Tables[0].Rows[j]["LINK"].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("Response to web: " + response.ToString());
|
|
|
|
|
+ return Ok(response);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ [HttpPost]
|
|
|
|
|
+ public IActionResult sysFunctionWebCmsInsert([FromBody] dynamic sendData)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("New request income sysFunctionWebCmsInsert :" + sendData.ToString());
|
|
|
|
|
+ Response response = new Response();
|
|
|
|
|
+ response.responseCode = "-1";
|
|
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
|
|
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
|
|
+ string role = Convert.ToString(userObj["role"]);
|
|
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
|
|
+ string link = Convert.ToString(userObj["link"]);
|
|
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
|
|
+
|
|
|
|
|
+ if (string.IsNullOrEmpty(role)) role = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(link)) link = "-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 = systemUserDataAccess.SYS_FUNCTION_WEB_CMS_INSERT(role, name, link, note, users);
|
|
|
|
|
+ logger.Info("Call database SYS_FUNCTION_WEB_CMS_INSERT success:");
|
|
|
|
|
+
|
|
|
|
|
+ if (ds_regist != null && ds_regist.Tables[0].Rows.Count > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString();
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ response.responseCode = "-1";
|
|
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
|
|
+ response.responseCode = "-2";
|
|
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
|
|
+ }
|
|
|
|
|
+ logger.Info("Response to web: " + response.ToString());
|
|
|
|
|
+ return Ok(response);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ [HttpPost]
|
|
|
|
|
+ public IActionResult sysFunctionWebCmsUpdate([FromBody] dynamic sendData)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("New request income sysFunctionWebCmsUpdate :" + 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 role = Convert.ToString(userObj["role"]);
|
|
|
|
|
+ string name = Convert.ToString(userObj["name"]);
|
|
|
|
|
+ string link = Convert.ToString(userObj["link"]);
|
|
|
|
|
+ string note = Convert.ToString(userObj["note"]);
|
|
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
|
|
+
|
|
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(role)) role = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(name)) name = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(link)) link = "-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 = systemUserDataAccess.SYS_FUNCTION_WEB_CMS_UPDATE(id, role, name, link, note, users);
|
|
|
|
|
+ logger.Info("Call database SYS_FUNCTION_WEB_CMS_UPDATE success:");
|
|
|
|
|
+
|
|
|
|
|
+ if (ds_regist != null && ds_regist.Tables[0].Rows.Count > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ response.responseCode = ds_regist.Tables[0].Rows[0]["status"].ToString();
|
|
|
|
|
+ response.responseMessage = ds_regist.Tables[0].Rows[0]["msg"].ToString();
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ response.responseCode = "-1";
|
|
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
|
|
+ response.responseCode = "-2";
|
|
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
|
|
+ }
|
|
|
|
|
+ logger.Info("Response to web: " + response.ToString());
|
|
|
|
|
+ return Ok(response);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // REPORT COUNT DAILY MANAGEMENT APIs
|
|
|
|
|
+ [HttpPost]
|
|
|
|
|
+ public IActionResult sysReportCountDailyGetList([FromBody] dynamic sendData)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("New request income sysReportCountDailyGetList :" + sendData.ToString());
|
|
|
|
|
+ reportCountDailyObjList response = new reportCountDailyObjList();
|
|
|
|
|
+ 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 reportDate = Convert.ToString(userObj["reportDate"]);
|
|
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
|
|
+ string serviceId = Convert.ToString(userObj["serviceId"]);
|
|
|
|
|
+ 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(users)) users = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(id)) id = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(reportDate)) reportDate = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(serviceId)) serviceId = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(order)) order = "desc";
|
|
|
|
|
+ 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 = systemDataAccess.SYS_REPORT_COUNT_DAILY_GET_LIST(users, id, reportDate, campaignId, serviceId, fromDate, toDate, order, rowsOnPage, seqPage);
|
|
|
|
|
+ logger.Info("Call database SYS_REPORT_COUNT_DAILY_GET_LIST success:");
|
|
|
|
|
+
|
|
|
|
|
+ response.responseCode = "0";
|
|
|
|
|
+ response.responseMessage = "Success";
|
|
|
|
|
+
|
|
|
|
|
+ if (ds_regist != null && ds_regist.Tables.Count > 0 && 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 reportCountDailyObj[ds_regist.Tables[0].Rows.Count];
|
|
|
|
|
+ for (int j = 0; j < ds_regist.Tables[0].Rows.Count; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ reportCountDailyObj _obj = new reportCountDailyObj();
|
|
|
|
|
+
|
|
|
|
|
+ _obj.id = ds_regist.Tables[0].Rows[j]["ID"].ToString();
|
|
|
|
|
+ _obj.reportDate = ds_regist.Tables[0].Rows[j]["REPORT_DATE"] != DBNull.Value ? Convert.ToDateTime(ds_regist.Tables[0].Rows[j]["REPORT_DATE"]).ToString("dd/MM/yyyy") : "";
|
|
|
|
|
+ _obj.campaignId = ds_regist.Tables[0].Rows[j]["CAMPAIGN_ID"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["CAMPAIGN_ID"].ToString() : "";
|
|
|
|
|
+ _obj.campaignName = ds_regist.Tables[0].Rows[j]["CAMPAIGN_NAME"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["CAMPAIGN_NAME"].ToString() : "";
|
|
|
|
|
+ _obj.priority = ds_regist.Tables[0].Rows[j]["PRIORITY"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["PRIORITY"].ToString() : "";
|
|
|
|
|
+ _obj.isDefault = ds_regist.Tables[0].Rows[j]["IS_DEFAULT"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["IS_DEFAULT"].ToString() : "";
|
|
|
|
|
+ _obj.isMyService = ds_regist.Tables[0].Rows[j]["IS_MYSERVICE"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["IS_MYSERVICE"].ToString() : "";
|
|
|
|
|
+ _obj.addType = ds_regist.Tables[0].Rows[j]["ADD_TYPE"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["ADD_TYPE"].ToString() : "";
|
|
|
|
|
+ _obj.serviceId = ds_regist.Tables[0].Rows[j]["SERVICE_ID"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["SERVICE_ID"].ToString() : "";
|
|
|
|
|
+ _obj.serviceName = ds_regist.Tables[0].Rows[j]["SERVICE_NAME"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["SERVICE_NAME"].ToString() : "";
|
|
|
|
|
+ _obj.countSend1 = ds_regist.Tables[0].Rows[j]["COUNT_SEND_1"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["COUNT_SEND_1"].ToString() : "0";
|
|
|
|
|
+ _obj.countSuccess1 = ds_regist.Tables[0].Rows[j]["COUNT_SUCCESS_1"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["COUNT_SUCCESS_1"].ToString() : "0";
|
|
|
|
|
+ _obj.countFail1 = ds_regist.Tables[0].Rows[j]["COUNT_FAIL_1"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["COUNT_FAIL_1"].ToString() : "0";
|
|
|
|
|
+ _obj.countPress1 = ds_regist.Tables[0].Rows[j]["COUNT_PRESS_1"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["COUNT_PRESS_1"].ToString() : "0";
|
|
|
|
|
+ _obj.countSend2 = ds_regist.Tables[0].Rows[j]["COUNT_SEND_2"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["COUNT_SEND_2"].ToString() : "0";
|
|
|
|
|
+ _obj.countPress2 = ds_regist.Tables[0].Rows[j]["COUNT_PRESS_2"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["COUNT_PRESS_2"].ToString() : "0";
|
|
|
|
|
+ _obj.countRegSuccess = ds_regist.Tables[0].Rows[j]["COUNT_REG_SUCCESS"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["COUNT_REG_SUCCESS"].ToString() : "0";
|
|
|
|
|
+ _obj.countRegFail = ds_regist.Tables[0].Rows[j]["COUNT_REG_FAIL"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["COUNT_REG_FAIL"].ToString() : "0";
|
|
|
|
|
+ _obj.insertTime = ds_regist.Tables[0].Rows[j]["INSERT_TIME"] != DBNull.Value ? Convert.ToDateTime(ds_regist.Tables[0].Rows[j]["INSERT_TIME"]).ToString("dd/MM/yyyy HH:mm:ss") : "";
|
|
|
|
|
+
|
|
|
|
|
+ response.list[j] = _obj;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
|
|
+ response.responseCode = "-2";
|
|
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
|
|
+ }
|
|
|
|
|
+ logger.Info("Response to web: " + response.ToString());
|
|
|
|
|
+ return Ok(response);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // REPORT ERROR DAILY MANAGEMENT APIs
|
|
|
|
|
+ [HttpPost]
|
|
|
|
|
+ public IActionResult sysReportErrorDailyGetList([FromBody] dynamic sendData)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("New request income sysReportErrorDailyGetList :" + sendData.ToString());
|
|
|
|
|
+ reportErrorDailyObjList response = new reportErrorDailyObjList();
|
|
|
|
|
+ response.responseCode = "-1";
|
|
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
|
|
+
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
|
|
+ string reportDate = Convert.ToString(userObj["reportDate"]);
|
|
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
|
|
+ string serviceId = Convert.ToString(userObj["serviceId"]);
|
|
|
|
|
+
|
|
|
|
|
+ if (string.IsNullOrEmpty(users)) users = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(reportDate)) reportDate = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(serviceId)) serviceId = "-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 = systemDataAccess.SYS_REPORT_ERROR_DAILY_GET_LIST(users, reportDate, campaignId, serviceId);
|
|
|
|
|
+ logger.Info("Call database SYS_REPORT_ERROR_DAILY_GET_LIST success:");
|
|
|
|
|
+
|
|
|
|
|
+ response.responseCode = "0";
|
|
|
|
|
+ response.responseMessage = "Success";
|
|
|
|
|
+
|
|
|
|
|
+ if (ds_regist != null && ds_regist.Tables.Count > 0 && ds_regist.Tables[0].Rows.Count > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ response.list = new reportErrorDailyObj[ds_regist.Tables[0].Rows.Count];
|
|
|
|
|
+ for (int j = 0; j < ds_regist.Tables[0].Rows.Count; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ reportErrorDailyObj _obj = new reportErrorDailyObj();
|
|
|
|
|
+
|
|
|
|
|
+ _obj.id = ds_regist.Tables[0].Rows[j]["ID"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["ID"].ToString() : "";
|
|
|
|
|
+ _obj.reportDate = ds_regist.Tables[0].Rows[j]["REPORT_DATE"] != DBNull.Value ? Convert.ToDateTime(ds_regist.Tables[0].Rows[j]["REPORT_DATE"]).ToString("dd/MM/yyyy") : "";
|
|
|
|
|
+ _obj.campaignId = ds_regist.Tables[0].Rows[j]["CAMPAIGN_ID"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["CAMPAIGN_ID"].ToString() : "";
|
|
|
|
|
+ _obj.serviceId = ds_regist.Tables[0].Rows[j]["SERVICE_ID"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["SERVICE_ID"].ToString() : "";
|
|
|
|
|
+ _obj.errorCode = ds_regist.Tables[0].Rows[j]["ERROR_CODE"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["ERROR_CODE"].ToString() : "";
|
|
|
|
|
+ _obj.countNum = ds_regist.Tables[0].Rows[j]["COUNT_NUM"] != DBNull.Value ? ds_regist.Tables[0].Rows[j]["COUNT_NUM"].ToString() : "0";
|
|
|
|
|
+ _obj.insertTime = ds_regist.Tables[0].Rows[j]["INSERT_TIME"] != DBNull.Value ? Convert.ToDateTime(ds_regist.Tables[0].Rows[j]["INSERT_TIME"]).ToString("dd/MM/yyyy HH:mm:ss") : "";
|
|
|
|
|
+
|
|
|
|
|
+ response.list[j] = _obj;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ response.list = new reportErrorDailyObj[0];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
|
|
+ response.responseCode = "-2";
|
|
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
|
|
+ }
|
|
|
|
|
+ logger.Info("Response to web: " + response.ToString());
|
|
|
|
|
+ return Ok(response);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // HOURLY IMPRESSIONS API
|
|
|
|
|
+ [HttpPost]
|
|
|
|
|
+ public IActionResult sysHourlyImpressionsGetList([FromBody] dynamic sendData)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("New request income sysHourlyImpressionsGetList :" + sendData.ToString());
|
|
|
|
|
+ hourlyImpressionsObjList response = new hourlyImpressionsObjList();
|
|
|
|
|
+ response.responseCode = "-1";
|
|
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
|
|
+
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
|
|
+ string serviceId = Convert.ToString(userObj["serviceId"]);
|
|
|
|
|
+ string hours = Convert.ToString(userObj["hours"]);
|
|
|
|
|
+ string quickJump = Convert.ToString(userObj["quickJump"]);
|
|
|
|
|
+
|
|
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(serviceId)) serviceId = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(hours)) hours = "72h";
|
|
|
|
|
+ if (string.IsNullOrEmpty(quickJump)) quickJump = "-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("sysHourlyImpressionsGetList 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("sysHourlyImpressionsGetList response : " + response.ToString());
|
|
|
|
|
+ return Ok(response);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ DataSet ds = balanceDataAccess.GET_HOURLY_IMPRESSIONS(campaignId, serviceId, hours, quickJump);
|
|
|
|
|
+ logger.Info("Call database GET_HOURLY_IMPRESSIONS success:");
|
|
|
|
|
+
|
|
|
|
|
+ response.responseCode = "0";
|
|
|
|
|
+ response.responseMessage = "Success";
|
|
|
|
|
+
|
|
|
|
|
+ if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ response.list = new hourlyImpressionsObj[ds.Tables[0].Rows.Count];
|
|
|
|
|
+ for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ hourlyImpressionsObj _obj = new hourlyImpressionsObj();
|
|
|
|
|
+
|
|
|
|
|
+ _obj.hourLabel = ds.Tables[0].Rows[j]["HOUR_LABEL"] != DBNull.Value ? ds.Tables[0].Rows[j]["HOUR_LABEL"].ToString() : "";
|
|
|
|
|
+ _obj.hourValue = ds.Tables[0].Rows[j]["HOUR_VALUE"] != DBNull.Value ? ds.Tables[0].Rows[j]["HOUR_VALUE"].ToString() : "";
|
|
|
|
|
+ _obj.campaignId = ds.Tables[0].Rows[j]["CAMPAIGN_ID"] != DBNull.Value ? ds.Tables[0].Rows[j]["CAMPAIGN_ID"].ToString() : "";
|
|
|
|
|
+ _obj.campaignName = ds.Tables[0].Rows[j]["CAMPAIGN_NAME"] != DBNull.Value ? ds.Tables[0].Rows[j]["CAMPAIGN_NAME"].ToString() : "";
|
|
|
|
|
+ _obj.serviceId = ""; // No longer using service
|
|
|
|
|
+ _obj.serviceName = ""; // No longer using service
|
|
|
|
|
+ _obj.countImpressions = ds.Tables[0].Rows[j]["COUNT_IMPRESSED"] != DBNull.Value ? ds.Tables[0].Rows[j]["COUNT_IMPRESSED"].ToString() : "0";
|
|
|
|
|
+
|
|
|
|
|
+ response.list[j] = _obj;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
|
|
+ response.responseCode = "-2";
|
|
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
|
|
+ }
|
|
|
|
|
+ logger.Info("Response to web: " + response.ToString());
|
|
|
|
|
+ return Ok(response);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // DAILY IMPRESSIONS API
|
|
|
|
|
+ [HttpPost]
|
|
|
|
|
+ public IActionResult sysDailyImpressionsGetList([FromBody] dynamic sendData)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("New request income sysDailyImpressionsGetList :" + sendData.ToString());
|
|
|
|
|
+ hourlyImpressionsObjList response = new hourlyImpressionsObjList();
|
|
|
|
|
+ response.responseCode = "-1";
|
|
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
|
|
+
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
|
|
+
|
|
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-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("sysDailyImpressionsGetList 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("sysDailyImpressionsGetList response : " + response.ToString());
|
|
|
|
|
+ return Ok(response);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ DataSet ds = balanceDataAccess.GET_DAILY_IMPRESSIONS(campaignId, fromDate, toDate);
|
|
|
|
|
+ logger.Info("Call database GET_DAILY_IMPRESSIONS success:");
|
|
|
|
|
+
|
|
|
|
|
+ response.responseCode = "0";
|
|
|
|
|
+ response.responseMessage = "Success";
|
|
|
|
|
+
|
|
|
|
|
+ if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ response.list = new hourlyImpressionsObj[ds.Tables[0].Rows.Count];
|
|
|
|
|
+ for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ hourlyImpressionsObj _obj = new hourlyImpressionsObj();
|
|
|
|
|
+
|
|
|
|
|
+ _obj.hourLabel = ds.Tables[0].Rows[j]["DAY_LABEL"] != DBNull.Value ? ds.Tables[0].Rows[j]["DAY_LABEL"].ToString() : "";
|
|
|
|
|
+ _obj.hourValue = ds.Tables[0].Rows[j]["DAY_VALUE"] != DBNull.Value ? Convert.ToDateTime(ds.Tables[0].Rows[j]["DAY_VALUE"]).ToString("yyyy-MM-dd") : "";
|
|
|
|
|
+ _obj.campaignId = ds.Tables[0].Rows[j]["CAMPAIGN_ID"] != DBNull.Value ? ds.Tables[0].Rows[j]["CAMPAIGN_ID"].ToString() : "";
|
|
|
|
|
+ _obj.campaignName = ds.Tables[0].Rows[j]["CAMPAIGN_NAME"] != DBNull.Value ? ds.Tables[0].Rows[j]["CAMPAIGN_NAME"].ToString() : "";
|
|
|
|
|
+ _obj.serviceId = ""; // No longer using service
|
|
|
|
|
+ _obj.serviceName = ""; // No longer using service
|
|
|
|
|
+ _obj.countImpressions = ds.Tables[0].Rows[j]["COUNT_IMPRESSED"] != DBNull.Value ? ds.Tables[0].Rows[j]["COUNT_IMPRESSED"].ToString() : "0";
|
|
|
|
|
+
|
|
|
|
|
+ response.list[j] = _obj;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
|
|
+ response.responseCode = "-2";
|
|
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
|
|
+ }
|
|
|
|
|
+ logger.Info("Response to web: " + response.ToString());
|
|
|
|
|
+ return Ok(response);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ [HttpPost]
|
|
|
|
|
+ public IActionResult sysDailyUniqueImpressionsGetList([FromBody] dynamic sendData)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("New request income sysDailyUniqueImpressionsGetList :" + sendData.ToString());
|
|
|
|
|
+ hourlyImpressionsObjList response = new hourlyImpressionsObjList();
|
|
|
|
|
+ response.responseCode = "-1";
|
|
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
|
|
+
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
|
|
+ string serviceId = Convert.ToString(userObj["serviceId"]);
|
|
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
|
|
+
|
|
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(serviceId)) serviceId = "-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();
|
|
|
|
|
+
|
|
|
|
|
+ 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("sysDailyUniqueImpressionsGetList 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);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ 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("sysDailyUniqueImpressionsGetList response : " + response.ToString());
|
|
|
|
|
+ return Ok(response);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ DataSet ds = balanceDataAccess.GET_DAILY_UNIQUE_IMPRESSIONS(campaignId, serviceId, fromDate, toDate);
|
|
|
|
|
+ logger.Info("Call database GET_DAILY_UNIQUE_IMPRESSIONS success:");
|
|
|
|
|
+
|
|
|
|
|
+ response.responseCode = "0";
|
|
|
|
|
+ response.responseMessage = "Success";
|
|
|
|
|
+
|
|
|
|
|
+ if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ response.list = new hourlyImpressionsObj[ds.Tables[0].Rows.Count];
|
|
|
|
|
+ for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ hourlyImpressionsObj _obj = new hourlyImpressionsObj();
|
|
|
|
|
+
|
|
|
|
|
+ _obj.hourLabel = ds.Tables[0].Rows[j]["DAY_LABEL"] != DBNull.Value ? ds.Tables[0].Rows[j]["DAY_LABEL"].ToString() : "";
|
|
|
|
|
+ _obj.hourValue = ds.Tables[0].Rows[j]["DAY_VALUE"] != DBNull.Value ? Convert.ToDateTime(ds.Tables[0].Rows[j]["DAY_VALUE"]).ToString("yyyy-MM-dd") : "";
|
|
|
|
|
+ _obj.campaignId = ds.Tables[0].Rows[j]["CAMPAIGN_ID"] != DBNull.Value ? ds.Tables[0].Rows[j]["CAMPAIGN_ID"].ToString() : "";
|
|
|
|
|
+ _obj.campaignName = ds.Tables[0].Rows[j]["CAMPAIGN_NAME"] != DBNull.Value ? ds.Tables[0].Rows[j]["CAMPAIGN_NAME"].ToString() : "";
|
|
|
|
|
+ _obj.serviceId = "";
|
|
|
|
|
+ _obj.serviceName = "";
|
|
|
|
|
+ _obj.countImpressions = ds.Tables[0].Rows[j]["COUNT_IMPRESSED"] != DBNull.Value ? ds.Tables[0].Rows[j]["COUNT_IMPRESSED"].ToString() : "0";
|
|
|
|
|
+
|
|
|
|
|
+ response.list[j] = _obj;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
|
|
+ response.responseCode = "-2";
|
|
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
|
|
+ }
|
|
|
|
|
+ logger.Info("sysDailyUniqueImpressionsGetList response : " + response.ToString());
|
|
|
|
|
+ return Ok(response);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ [HttpPost]
|
|
|
|
|
+ public IActionResult sysDailyEngagedGetList([FromBody] dynamic sendData)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("New request income sysDailyEngagedGetList :" + sendData.ToString());
|
|
|
|
|
+ hourlyImpressionsObjList response = new hourlyImpressionsObjList();
|
|
|
|
|
+ response.responseCode = "-1";
|
|
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
|
|
+
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
|
|
+ string serviceId = Convert.ToString(userObj["serviceId"]);
|
|
|
|
|
+ string fromDate = Convert.ToString(userObj["fromDate"]);
|
|
|
|
|
+ string toDate = Convert.ToString(userObj["toDate"]);
|
|
|
|
|
+
|
|
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(serviceId)) serviceId = "-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();
|
|
|
|
|
+
|
|
|
|
|
+ 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("sysDailyEngagedGetList 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);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ 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("sysDailyEngagedGetList response : " + response.ToString());
|
|
|
|
|
+ return Ok(response);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ DataSet ds = balanceDataAccess.GET_DAILY_ENGAGED_USERS(campaignId, serviceId, fromDate, toDate);
|
|
|
|
|
+ logger.Info("Call database GET_DAILY_ENGAGED_USERS success:");
|
|
|
|
|
+
|
|
|
|
|
+ response.responseCode = "0";
|
|
|
|
|
+ response.responseMessage = "Success";
|
|
|
|
|
+
|
|
|
|
|
+ if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ response.list = new hourlyImpressionsObj[ds.Tables[0].Rows.Count];
|
|
|
|
|
+ for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ hourlyImpressionsObj _obj = new hourlyImpressionsObj();
|
|
|
|
|
+
|
|
|
|
|
+ _obj.hourLabel = ds.Tables[0].Rows[j]["DAY_LABEL"] != DBNull.Value ? ds.Tables[0].Rows[j]["DAY_LABEL"].ToString() : "";
|
|
|
|
|
+ _obj.hourValue = ds.Tables[0].Rows[j]["DAY_VALUE"] != DBNull.Value ? Convert.ToDateTime(ds.Tables[0].Rows[j]["DAY_VALUE"]).ToString("yyyy-MM-dd") : "";
|
|
|
|
|
+ _obj.campaignId = ds.Tables[0].Rows[j]["CAMPAIGN_ID"] != DBNull.Value ? ds.Tables[0].Rows[j]["CAMPAIGN_ID"].ToString() : "";
|
|
|
|
|
+ _obj.campaignName = ds.Tables[0].Rows[j]["CAMPAIGN_NAME"] != DBNull.Value ? ds.Tables[0].Rows[j]["CAMPAIGN_NAME"].ToString() : "";
|
|
|
|
|
+ _obj.serviceId = "";
|
|
|
|
|
+ _obj.serviceName = "";
|
|
|
|
|
+ _obj.countImpressions = ds.Tables[0].Rows[j]["COUNT_ENGAGED"] != DBNull.Value ? ds.Tables[0].Rows[j]["COUNT_ENGAGED"].ToString() : "0";
|
|
|
|
|
+
|
|
|
|
|
+ response.list[j] = _obj;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
|
|
+ response.responseCode = "-2";
|
|
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
|
|
+ }
|
|
|
|
|
+ logger.Info("sysDailyEngagedGetList response : " + response.ToString());
|
|
|
|
|
+ return Ok(response);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // PUSH USSD DETAIL REPORT
|
|
|
|
|
+ [HttpPost]
|
|
|
|
|
+ public IActionResult sysPushUssdDetailGetList([FromBody] dynamic sendData)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("New request income sysPushUssdDetailGetList :" + sendData.ToString());
|
|
|
|
|
+ pushUssdDetailObjList response = new pushUssdDetailObjList();
|
|
|
|
|
+ response.responseCode = "-1";
|
|
|
|
|
+ response.responseMessage = "Err unknow";
|
|
|
|
|
+
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ var userObj = JObject.Parse(sendData.ToString());
|
|
|
|
|
+ string users = Convert.ToString(userObj["users"]);
|
|
|
|
|
+ string campaignId = Convert.ToString(userObj["campaignId"]);
|
|
|
|
|
+ string serviceId = Convert.ToString(userObj["serviceId"]);
|
|
|
|
|
+ string msisdn = Convert.ToString(userObj["msisdn"]);
|
|
|
|
|
+ string sendStatus = Convert.ToString(userObj["sendStatus"]);
|
|
|
|
|
+ string isSuccess = Convert.ToString(userObj["isSuccess"]);
|
|
|
|
|
+ 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(users)) users = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(campaignId)) campaignId = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(serviceId)) serviceId = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(msisdn)) msisdn = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(sendStatus)) sendStatus = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(isSuccess)) isSuccess = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(fromDate)) fromDate = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(toDate)) toDate = "-1";
|
|
|
|
|
+ if (string.IsNullOrEmpty(order)) order = "desc";
|
|
|
|
|
+ if (string.IsNullOrEmpty(rowsOnPage)) rowsOnPage = "100";
|
|
|
|
|
+ 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();
|
|
|
|
|
+
|
|
|
|
|
+ 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("sysPushUssdDetailGetList 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);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ 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("sysPushUssdDetailGetList response : " + response.ToString());
|
|
|
|
|
+ return Ok(response);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ DataSet ds = systemDataAccess.SYS_PUSH_USSD_DETAIL_GET_LIST(users, campaignId, serviceId, msisdn, sendStatus, isSuccess, fromDate, toDate, order, rowsOnPage, seqPage);
|
|
|
|
|
+ logger.Info("Call database SYS_PUSH_USSD_DETAIL_GET_LIST success:");
|
|
|
|
|
+
|
|
|
|
|
+ response.responseCode = "0";
|
|
|
|
|
+ response.responseMessage = "Success";
|
|
|
|
|
+
|
|
|
|
|
+ if (ds != null && ds.Tables.Count > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ var dataTable = ds.Tables[0];
|
|
|
|
|
+ response.list = new pushUssdDetailObj[dataTable.Rows.Count];
|
|
|
|
|
+ for (int j = 0; j < dataTable.Rows.Count; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ var _obj = new pushUssdDetailObj();
|
|
|
|
|
+ _obj.id = dataTable.Rows[j]["ID"].ToString();
|
|
|
|
|
+ _obj.requestId = dataTable.Rows[j]["REQUEST_ID"].ToString();
|
|
|
|
|
+ _obj.campaignId = dataTable.Rows[j]["CAMPAIGN_ID"] != DBNull.Value ? dataTable.Rows[j]["CAMPAIGN_ID"].ToString() : "";
|
|
|
|
|
+ _obj.campaignName = dataTable.Rows[j].Table.Columns.Contains("CAMPAIGN_NAME") && dataTable.Rows[j]["CAMPAIGN_NAME"] != DBNull.Value ? dataTable.Rows[j]["CAMPAIGN_NAME"].ToString() : "";
|
|
|
|
|
+ _obj.serviceId = dataTable.Rows[j]["SERVICE_ID"] != DBNull.Value ? dataTable.Rows[j]["SERVICE_ID"].ToString() : "";
|
|
|
|
|
+ _obj.msisdn = dataTable.Rows[j]["MSISDN"].ToString();
|
|
|
|
|
+ _obj.sendTime = dataTable.Rows[j]["SEND_TIME"] != DBNull.Value ? Convert.ToDateTime(dataTable.Rows[j]["SEND_TIME"]).ToString("dd/MM/yyyy HH:mm:ss") : "";
|
|
|
|
|
+ _obj.sendStatus = dataTable.Rows[j]["SEND_STATUS"] != DBNull.Value ? dataTable.Rows[j]["SEND_STATUS"].ToString() : "";
|
|
|
|
|
+ _obj.totalStep = dataTable.Rows[j]["TOTAL_STEP"] != DBNull.Value ? dataTable.Rows[j]["TOTAL_STEP"].ToString() : "";
|
|
|
|
|
+ _obj.isStep1 = dataTable.Rows[j]["IS_STEP_1"] != DBNull.Value ? dataTable.Rows[j]["IS_STEP_1"].ToString() : "";
|
|
|
|
|
+ _obj.step1Time = dataTable.Rows[j]["STEP_1_TIME"] != DBNull.Value ? Convert.ToDateTime(dataTable.Rows[j]["STEP_1_TIME"]).ToString("dd/MM/yyyy HH:mm:ss") : "";
|
|
|
|
|
+ _obj.isStep2 = dataTable.Rows[j]["IS_STEP_2"] != DBNull.Value ? dataTable.Rows[j]["IS_STEP_2"].ToString() : "";
|
|
|
|
|
+ _obj.step2Time = dataTable.Rows[j]["STEP_2_TIME"] != DBNull.Value ? Convert.ToDateTime(dataTable.Rows[j]["STEP_2_TIME"]).ToString("dd/MM/yyyy HH:mm:ss") : "";
|
|
|
|
|
+ _obj.errorCode = dataTable.Rows[j]["ERROR_CODE"] != DBNull.Value ? dataTable.Rows[j]["ERROR_CODE"].ToString() : "";
|
|
|
|
|
+ _obj.isSuccess = dataTable.Rows[j]["IS_SUCCESS"] != DBNull.Value ? dataTable.Rows[j]["IS_SUCCESS"].ToString() : "";
|
|
|
|
|
+ _obj.insertTime = dataTable.Rows[j]["INSERT_TIME"] != DBNull.Value ? Convert.ToDateTime(dataTable.Rows[j]["INSERT_TIME"]).ToString("dd/MM/yyyy HH:mm:ss") : "";
|
|
|
|
|
+ _obj.lastUpdate = dataTable.Rows[j]["LAST_UPDATE"] != DBNull.Value ? Convert.ToDateTime(dataTable.Rows[j]["LAST_UPDATE"]).ToString("dd/MM/yyyy HH:mm:ss") : "";
|
|
|
|
|
+ response.list[j] = _obj;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ logger.Info("exception: " + ex.ToString());
|
|
|
|
|
+ response.responseCode = "-2";
|
|
|
|
|
+ response.responseMessage = "System upgrade";
|
|
|
|
|
+ }
|
|
|
|
|
+ logger.Info("sysPushUssdDetailGetList response : " + response.ToString());
|
|
|
|
|
+ return Ok(response);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|