Skip to content

Commit

Permalink
changed CBSelLoginIDDupeCheckController
Browse files Browse the repository at this point in the history
added CBComInsMemberGameInfoStagesController
added CBComInsMemberItemController
  • Loading branch information
CloudBreadPaPa committed Mar 25, 2016
1 parent 1064505 commit 05312b6
Show file tree
Hide file tree
Showing 7 changed files with 405 additions and 2 deletions.
12 changes: 11 additions & 1 deletion CloudBread.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@
<Compile Include="CBRedis.cs" />
<Compile Include="Controllers\CBAddMemberItemPurchaseController.cs" />
<Compile Include="Controllers\CBAddUseMemberItemController.cs" />
<Compile Include="Controllers\CBComInsMemberGameInfoStagesController.cs" />
<Compile Include="Controllers\CBComInsMemberItemController.cs" />
<Compile Include="Controllers\CBComInsMemberItemPurchaseControllerController.cs" />
<Compile Include="Controllers\CBComSelCouponController.cs" />
<Compile Include="Controllers\CBComSelGiftDepositoryController.cs" />
Expand Down Expand Up @@ -288,6 +290,8 @@
</Compile>
<Compile Include="Models\AddMemberItemPurchase.cs" />
<Compile Include="Models\AddUseMemberItem.cs" />
<Compile Include="Models\ComInsMemberGameInfoStages.cs" />
<Compile Include="Models\ComInsMemberItem.cs" />
<Compile Include="Models\ComInsMemberItemPurchase.cs" />
<Compile Include="Models\ComSelCoupon.cs" />
<Compile Include="Models\ComSelGiftDepository.cs" />
Expand Down Expand Up @@ -329,7 +333,13 @@
<ItemGroup>
<Content Include="CloudBreadLib.dll" />
<Content Include="Global.asax" />
<Content Include="web.config" />
<Content Include="web.config">
<SubType>Designer</SubType>
</Content>
<None Include="Properties\PublishProfiles\cb2-auth-crypt-demo - Web Deploy.pubxml" />
<None Include="Properties\PublishProfiles\cb2-auth-demo - Web Deploy.pubxml" />
<None Include="Properties\PublishProfiles\cb2-crypt-demo - Web Deploy.pubxml" />
<None Include="Properties\PublishProfiles\cb2-demo - Web Deploy.pubxml" />
<None Include="Properties\PublishProfiles\dw-cloudbread-ys - Web Deploy.pubxml" />
<None Include="Properties\PublishProfiles\jh-mobileapp-dev-01 - Web Deploy.pubxml" />
<None Include="Properties\PublishProfiles\jhmobileApp - Web Deploy.pubxml" />
Expand Down
170 changes: 170 additions & 0 deletions Controllers/CBComInsMemberGameInfoStagesController.cs
Original file line number Diff line number Diff line change
@@ -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<ComInsMemberGameInfoStagesInputParams>(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<SqlAzureTransientErrorDetectionStrategy>(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;
}
}

}
}


153 changes: 153 additions & 0 deletions Controllers/CBComInsMemberItemController.cs
Original file line number Diff line number Diff line change
@@ -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<ComInsMemberItemInputParams>(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<SqlAzureTransientErrorDetectionStrategy>(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;
}
}
}
}
3 changes: 2 additions & 1 deletion Controllers/CBSelLoginIDDupeCheckController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
Loading

0 comments on commit 05312b6

Please sign in to comment.