From 05312b65a5585f2aec9e4cb948f42cab4a2a1a8c Mon Sep 17 00:00:00 2001 From: dwkim Date: Sat, 26 Mar 2016 06:34:05 +0900 Subject: [PATCH] changed CBSelLoginIDDupeCheckController added CBComInsMemberGameInfoStagesController added CBComInsMemberItemController --- CloudBread.csproj | 12 +- .../CBComInsMemberGameInfoStagesController.cs | 170 ++++++++++++++++++ Controllers/CBComInsMemberItemController.cs | 153 ++++++++++++++++ .../CBSelLoginIDDupeCheckController.cs | 3 +- Models/ComInsMemberGameInfoStages.cs | 40 +++++ Models/ComInsMemberItem.cs | 27 +++ Models/SelLoginIDDupeCheck.cs | 2 + 7 files changed, 405 insertions(+), 2 deletions(-) create mode 100644 Controllers/CBComInsMemberGameInfoStagesController.cs create mode 100644 Controllers/CBComInsMemberItemController.cs create mode 100644 Models/ComInsMemberGameInfoStages.cs create mode 100644 Models/ComInsMemberItem.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index 0942677..0418729 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -239,6 +239,8 @@ + + @@ -288,6 +290,8 @@ + + @@ -329,7 +333,13 @@ - + + Designer + + + + + diff --git a/Controllers/CBComInsMemberGameInfoStagesController.cs b/Controllers/CBComInsMemberGameInfoStagesController.cs new file mode 100644 index 0000000..ae2f82a --- /dev/null +++ b/Controllers/CBComInsMemberGameInfoStagesController.cs @@ -0,0 +1,170 @@ +/** +* @file CBComInsMemberGameInfoStagesController.cs +* @brief Common API for a game stage insert on MemberGameInfoStages table. \n +* @author Dae Woo Kim +* @param MemberGameInfoStages object +* @return string "1" - affected rows +* @see uspComInsMemberGameInfoStages SP, BehaviorID : B109 +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using Microsoft.Azure.Mobile.Server; +using Microsoft.Azure.Mobile.Server.Config; + +using System.Threading.Tasks; +using System.Diagnostics; +using Logger.Logging; +using CloudBread.globals; +using CloudBreadLib.BAL.Crypto; +using System.Data; +using System.Data.Sql; +using System.Data.SqlClient; +using Newtonsoft.Json; +using CloudBreadAuth; +using System.Security.Claims; +using Microsoft.Practices.TransientFaultHandling; +using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; + +namespace CloudBread.Controllers +{ + [MobileAppController] + public class CBComInsMemberGameInfoStagesController : ApiController + { + public HttpResponseMessage Post(ComInsMemberGameInfoStagesInputParams p) + { + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } + + // Get the sid or memberID of the current user. + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); + p.MemberID = sid; + + Logging.CBLoggers logMessage = new Logging.CBLoggers(); + string jsonParam = JsonConvert.SerializeObject(p); + + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); + RowcountResult rowcountResult = new RowcountResult(); + + try + { + // task start log + //logMessage.memberID = p.MemberID; + //logMessage.Level = "INFO"; + //logMessage.Logger = "CBComInsMemberGameInfoStagesController"; + //logMessage.Message = jsonParam; + //Logging.RunLog(logMessage); + + /// Database connection retry policy + RetryPolicy retryPolicy = new RetryPolicy(globalVal.conRetryCount, TimeSpan.FromSeconds(globalVal.conRetryFromSeconds)); + using (SqlConnection connection = new SqlConnection(globalVal.DBConnectionString)) + { + using (SqlCommand command = new SqlCommand("uspComInsMemberGameInfoStages", connection)) + { + command.CommandType = CommandType.StoredProcedure; + command.Parameters.Add("@MemberGameInfoStageID", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoStageID; + command.Parameters.Add("@MemberID", SqlDbType.NVarChar, -1).Value = p.MemberID; + command.Parameters.Add("@StageName", SqlDbType.NVarChar, -1).Value = p.StageName; + command.Parameters.Add("@StageStatus", SqlDbType.NVarChar, -1).Value = p.StageStatus; + command.Parameters.Add("@Category1", SqlDbType.NVarChar, -1).Value = p.Category1; + command.Parameters.Add("@Category2", SqlDbType.NVarChar, -1).Value = p.Category2; + command.Parameters.Add("@Category3", SqlDbType.NVarChar, -1).Value = p.Category3; + command.Parameters.Add("@Mission1", SqlDbType.NVarChar, -1).Value = p.Mission1; + command.Parameters.Add("@Mission2", SqlDbType.NVarChar, -1).Value = p.Mission2; + command.Parameters.Add("@Mission3", SqlDbType.NVarChar, -1).Value = p.Mission3; + command.Parameters.Add("@Mission4", SqlDbType.NVarChar, -1).Value = p.Mission4; + command.Parameters.Add("@Mission5", SqlDbType.NVarChar, -1).Value = p.Mission5; + command.Parameters.Add("@Points", SqlDbType.NVarChar, -1).Value = p.Points; + command.Parameters.Add("@StageStat1", SqlDbType.NVarChar, -1).Value = p.StageStat1; + command.Parameters.Add("@StageStat2", SqlDbType.NVarChar, -1).Value = p.StageStat2; + command.Parameters.Add("@StageStat3", SqlDbType.NVarChar, -1).Value = p.StageStat3; + command.Parameters.Add("@StageStat4", SqlDbType.NVarChar, -1).Value = p.StageStat4; + command.Parameters.Add("@StageStat5", SqlDbType.NVarChar, -1).Value = p.StageStat5; + command.Parameters.Add("@sCol1", SqlDbType.NVarChar, -1).Value = p.sCol1; + command.Parameters.Add("@sCol2", SqlDbType.NVarChar, -1).Value = p.sCol2; + command.Parameters.Add("@sCol3", SqlDbType.NVarChar, -1).Value = p.sCol3; + command.Parameters.Add("@sCol4", SqlDbType.NVarChar, -1).Value = p.sCol4; + command.Parameters.Add("@sCol5", SqlDbType.NVarChar, -1).Value = p.sCol5; + command.Parameters.Add("@sCol6", SqlDbType.NVarChar, -1).Value = p.sCol6; + command.Parameters.Add("@sCol7", SqlDbType.NVarChar, -1).Value = p.sCol7; + command.Parameters.Add("@sCol8", SqlDbType.NVarChar, -1).Value = p.sCol8; + command.Parameters.Add("@sCol9", SqlDbType.NVarChar, -1).Value = p.sCol9; + command.Parameters.Add("@sCol10", SqlDbType.NVarChar, -1).Value = p.sCol10; + + connection.OpenWithRetry(retryPolicy); + using (SqlDataReader dreader = command.ExecuteReaderWithRetry(retryPolicy)) + { + while (dreader.Read()) + { + rowcountResult.result = dreader[0].ToString(); + } + dreader.Close(); + } + connection.Close(); + + // task end log + logMessage.memberID = p.MemberID; + logMessage.Level = "INFO"; + logMessage.Logger = "CBComInsMemberGameInfoStagesController"; + logMessage.Message = jsonParam; + Logging.RunLog(logMessage); + + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(rowcountResult), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, rowcountResult); + return response; + } + + } + } + + catch (Exception ex) + { + // error log + logMessage.memberID = p.MemberID; + logMessage.Level = "ERROR"; + logMessage.Logger = "CBComInsMemberGameInfoStagesController"; + logMessage.Message = jsonParam; + logMessage.Exception = ex.ToString(); + Logging.RunLog(logMessage); + + throw; + } + } + + } +} + + diff --git a/Controllers/CBComInsMemberItemController.cs b/Controllers/CBComInsMemberItemController.cs new file mode 100644 index 0000000..5d756b7 --- /dev/null +++ b/Controllers/CBComInsMemberItemController.cs @@ -0,0 +1,153 @@ +/** +* @file CBComInsMemberItemController +* @brief Common API for a MemberItem Insert on MemberItems table. \n +* @author Dae Woo Kim +* @param MemberItem object +* @return string "1" - affected rows +* @see uspComInsMemberItem SP, BehaviorID : B108 +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using Microsoft.Azure.Mobile.Server; +using Microsoft.Azure.Mobile.Server.Config; + +using System.Threading.Tasks; +using System.Diagnostics; +using Logger.Logging; +using CloudBread.globals; +using CloudBreadLib.BAL.Crypto; +using System.Data; +using System.Data.Sql; +using System.Data.SqlClient; +using Newtonsoft.Json; +using CloudBreadAuth; +using System.Security.Claims; +using Microsoft.Practices.TransientFaultHandling; +using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; + +namespace CloudBread.Controllers +{ + [MobileAppController] + public class CBComInsMemberItemController : ApiController + { + public HttpResponseMessage Post(ComInsMemberItemInputParams p) + { + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } + + // Get the sid or memberID of the current user. + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); + p.MemberID = sid; + + Logging.CBLoggers logMessage = new Logging.CBLoggers(); + string jsonParam = JsonConvert.SerializeObject(p); + + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); + RowcountResult rowcountResult = new RowcountResult(); + + try + { + // task start log + //logMessage.memberID = p.MemberID; + //logMessage.Level = "INFO"; + //logMessage.Logger = "CBComInsMemberItemController"; + //logMessage.Message = jsonParam; + //Logging.RunLog(logMessage); + + /// Database connection retry policy + RetryPolicy retryPolicy = new RetryPolicy(globalVal.conRetryCount, TimeSpan.FromSeconds(globalVal.conRetryFromSeconds)); + using (SqlConnection connection = new SqlConnection(globalVal.DBConnectionString)) + { + using (SqlCommand command = new SqlCommand("uspComInsMemberItem", connection)) + { + command.CommandType = CommandType.StoredProcedure; + command.Parameters.Add("@MemberItemID ", SqlDbType.NVarChar, -1).Value = p.MemberItemID; + command.Parameters.Add("@MemberID ", SqlDbType.NVarChar, -1).Value = p.MemberID; + command.Parameters.Add("@ItemListID ", SqlDbType.NVarChar, -1).Value = p.ItemListID; + command.Parameters.Add("@ItemCount ", SqlDbType.NVarChar, -1).Value = p.ItemCount; + command.Parameters.Add("@ItemStatus ", SqlDbType.NVarChar, -1).Value = p.ItemStatus; + command.Parameters.Add("@sCol1 ", SqlDbType.NVarChar, -1).Value = p.sCol1; + command.Parameters.Add("@sCol2 ", SqlDbType.NVarChar, -1).Value = p.sCol2; + command.Parameters.Add("@sCol3 ", SqlDbType.NVarChar, -1).Value = p.sCol3; + command.Parameters.Add("@sCol4 ", SqlDbType.NVarChar, -1).Value = p.sCol4; + command.Parameters.Add("@sCol5 ", SqlDbType.NVarChar, -1).Value = p.sCol5; + command.Parameters.Add("@sCol6 ", SqlDbType.NVarChar, -1).Value = p.sCol6; + command.Parameters.Add("@sCol7 ", SqlDbType.NVarChar, -1).Value = p.sCol7; + command.Parameters.Add("@sCol8 ", SqlDbType.NVarChar, -1).Value = p.sCol8; + command.Parameters.Add("@sCol9 ", SqlDbType.NVarChar, -1).Value = p.sCol9; + command.Parameters.Add("@sCol10 ", SqlDbType.NVarChar, -1).Value = p.sCol10; + + connection.OpenWithRetry(retryPolicy); + using (SqlDataReader dreader = command.ExecuteReaderWithRetry(retryPolicy)) + { + while (dreader.Read()) + { + rowcountResult.result = dreader[0].ToString(); + } + dreader.Close(); + } + connection.Close(); + + // task end log + logMessage.memberID = p.MemberID; + logMessage.Level = "INFO"; + logMessage.Logger = "CBComInsMemberItemController"; + logMessage.Message = jsonParam; + Logging.RunLog(logMessage); + + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(rowcountResult), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, rowcountResult); + return response; + } + } + } + + catch (Exception ex) + { + //에러로그 + logMessage.memberID = p.MemberID; + logMessage.Level = "ERROR"; + logMessage.Logger = "CBComInsMemberItemController"; + logMessage.Message = jsonParam; + logMessage.Exception = ex.ToString(); + Logging.RunLog(logMessage); + + throw; + } + } + } +} diff --git a/Controllers/CBSelLoginIDDupeCheckController.cs b/Controllers/CBSelLoginIDDupeCheckController.cs index d6b74db..14b0653 100644 --- a/Controllers/CBSelLoginIDDupeCheckController.cs +++ b/Controllers/CBSelLoginIDDupeCheckController.cs @@ -75,7 +75,8 @@ public HttpResponseMessage Post(SelLoginIDDupeCheckInputParams p) using(SqlCommand command = new SqlCommand("uspSelLoginIDDupeCheck", connection)) { command.CommandType = CommandType.StoredProcedure; - command.Parameters.Add("@MemberID", SqlDbType.NVarChar, -1).Value = p.memberID; + command.Parameters.Add("@FindID", SqlDbType.NVarChar, -1).Value = p.findID; + command.Parameters.Add("@Category", SqlDbType.NVarChar, -1).Value = p.category; connection.OpenWithRetry(retryPolicy); using(SqlDataReader dreader = command.ExecuteReaderWithRetry(retryPolicy)) { diff --git a/Models/ComInsMemberGameInfoStages.cs b/Models/ComInsMemberGameInfoStages.cs new file mode 100644 index 0000000..66180cb --- /dev/null +++ b/Models/ComInsMemberGameInfoStages.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class ComInsMemberGameInfoStagesInputParams + { + public string MemberGameInfoStageID { get; set; } + public string MemberID { get; set; } + public string StageName { get; set; } + public string StageStatus { get; set; } + public string Category1 { get; set; } + public string Category2 { get; set; } + public string Category3 { get; set; } + public string Mission1 { get; set; } + public string Mission2 { get; set; } + public string Mission3 { get; set; } + public string Mission4 { get; set; } + public string Mission5 { get; set; } + public string Points { get; set; } + public string StageStat1 { get; set; } + public string StageStat2 { get; set; } + public string StageStat3 { get; set; } + public string StageStat4 { get; set; } + public string StageStat5 { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + public string token { get; set; } + } +} \ No newline at end of file diff --git a/Models/ComInsMemberItem.cs b/Models/ComInsMemberItem.cs new file mode 100644 index 0000000..61dddb9 --- /dev/null +++ b/Models/ComInsMemberItem.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class ComInsMemberItemInputParams + { + public string MemberItemID { get; set; } + public string MemberID { get; set; } + public string ItemListID { get; set; } + public string ItemCount { get; set; } + public string ItemStatus { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + public string token { get; set; } + } +} \ No newline at end of file diff --git a/Models/SelLoginIDDupeCheck.cs b/Models/SelLoginIDDupeCheck.cs index cbe93d0..fb3efbb 100644 --- a/Models/SelLoginIDDupeCheck.cs +++ b/Models/SelLoginIDDupeCheck.cs @@ -8,6 +8,8 @@ namespace CloudBread.Models public class SelLoginIDDupeCheckInputParams { public string memberID { get; set; } + public string findID { get; set; } + public string category { get; set; } public string token { get; set; } }