|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
drop table tempdb; if exists ( select * from sysobjects where name = 'tempdb' and xtype = 'U' ) create table cars111 ( Name0 varchar(64) not null, Name1 varchar(64) not null, Name2 varchar(64) not null ); select * from INFORMATION_SCHEMA.COLUMNS where table_name = 'cars111' and column_name = 'Name0'; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
static internal ProtoBufRES doInsert(ProtoBufASK r_ask) { try { var res = new ProtoBufRES(); Mapper.Instance().BeginTransaction(); res.nRet = Mapper.Instance().QueryForObject < int > ("QueryInsert", r_ask); // Insert시에 SELECT SCOPE_IDENTITY()로 키값을 가져오는 방향으로 Mapper.Instance().CommitTransaction(); if (0 >= nRet) { res.m_eResult = ENUM_RESULT.ENUM_NOINSERT; res.m_strMessage = "처리되지 않았습니다."; return res; } else { res.m_eResult = ENUM_RESULT.ENUM_OK; return res; } } catch (Exception ex) { Mapper.Instance().RollBackTransaction(); throw new Exception(ex.Message); } } |
Test
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
static private readonly ILog s_thelog = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); #if DEBUG static public ServiceReference_Solution.ServiceTaxiClient proxy = new ServiceReference_Solution.ServiceTaxiClient(); #else static public ServiceReference_Staging.ServiceTaxiClient proxy = new ServiceReference_Staging.ServiceTaxiClient(); #endif private ProtoBufRES _function(ProtoBufASK r_ask) { s_thelog.Info("> " + GetType().FullName + "." + MethodBase.GetCurrentMethod().Name); var btask = ProtoBuffHelper.Serialize(r_ask); var btres = proxy.function(btask); var res = ProtoBuffHelper.Deserialize < ProtoBufRES > (btres); s_thelog.Debug(string.Format(" {0, -25} : {1}", "m_eResult", res.m_eResult)); if (ENUM_RESULT.ENUM_EXCEPTION == res.m_eResult) { s_thelog.Error(res.m_strMessage); } return res; } [TestMethod] public void function () { var ask = new ProtoBufASK { m_nMemberID = 1, m_nMemberFriendID = 2 }; var res = _function(ask); Assert.AreNotEqual(ENUM_RESULT.ENUM_EXCEPTION, res.m_eResult); } |
Services
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
static public byte[] function (byte[] r_bAsk) { try { var ask = ProtoBuffHelper.Deserialize < ProtoBufASK > (r_bAsk); var res = daoCommunity.doReceiveDeny(ask); return ProtoBuffHelper.Serialize(res); } catch (Exception ex) { var exres = new ProtoBufRES { m_eResult = ENUM_RESULT.ENUM_EXCEPTION, m_strMessage = string.Format("tException function : {0}nt{1}n", Convert.ToBase64String(r_bAsk), ex.Message) }; CCommon.s_thelog(exres.m_strMessage); return ProtoBuffHelper.Serialize(exres); } } |
DAO – insert
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
static internal ProtoBufRES doInsert(ProtoBufASK r_ask) { try { var res = new ProtoBufRES(); Mapper.Instance().BeginTransaction(); res.nRet = Mapper.Instance().QueryForObject < int > ("QueryInsert", r_ask); // Insert시에 SELECT SCOPE_IDENTITY()로 키값을 가져오는 방향으로 Mapper.Instance().CommitTransaction(); if (0 >= nRet) { res.m_eResult = ENUM_RESULT.ENUM_NOINSERT; res.m_strMessage = "처리되지 않았습니다."; return res; } else { res.m_eResult = ENUM_RESULT.ENUM_OK; return res; } } catch (Exception ex) { Mapper.Instance().RollBackTransaction(); throw new Exception(ex.Message); } } |
DAO – update delete
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
static internal ProtoBufRES doUpdate(ProtoBufASK r_ask) { try { var res = new ProtoBufRES(); Mapper.Instance().BeginTransaction(); res.nRet = Mapper.Instance().Delete("QueryDelete", r_ask); Mapper.Instance().CommitTransaction(); if (0 >= nRet) { res.m_eResult = ENUM_RESULT.ENUM_NOUPDATE; res.m_strMessage = "데이터가 처리되지 않았습니다."; return res; } else { res.m_eResult = ENUM_RESULT.ENUM_OK; return res; } } catch (Exception ex) { Mapper.Instance().RollBackTransaction(); throw new Exception(ex.Message); } } |
DAO – select
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
static internal ProtoBufRES doSelect(ProtoBufASK r_ask) { try { var res = Mapper.Instance().QueryForObject < ProtoBufRES > ("QuerySelect", r_ask); if (0 >= res.nRet) { res.m_eResult = ENUM_RESULT.ENUM_NORESULT; res.m_strMessage = "res에 데이터가 없습니다."; return res; } var listMine = Mapper.Instance().QueryForList < ProtoBuf > ("QuerySelect", r_ask); if (0 >= listMine.Count) { res.m_eResult = ENUM_RESULT.ENUM_NORESULT; res.m_strMessage = "list 내에 데이터가 없습니다."; return res; } else { foreach(var itemMine in listMine) { res.m_listMine.Add(itemMine); } res.m_eResult = ENUM_RESULT.ENUM_OK; return res; } } catch (Exception ex) { throw new Exception(ex.Message); } } |
|
protoc.exe --proto_path=. --cpp_out=. a.proto protogen -i:ProtocolLogin.proto -o:ProtocolLogin.cs |
|
링크
|