EDN Admin
Well-known member
Hola, bueno le explico mi problema. Estoy trabajando con transactionScope ya requiero de realizar una transacion anidada. Les dejo el codigo para lo revisen.
El problema es que cuando trato de pasar a la siguiente funcion que me realiza un select para poder retornar algunos datos del cliente recientemente insertado, me sale el error "La comunicaciÃn con el administrador de transacciones subyacente ha fallado."
Les comento que ya configure el servicio de transacciones distribuidas en el servidor de BD y tbm lo configure en mi makina donde estoy desarrollando el sistema. Esta transaccion es para la creacion de una cuenta q se realiza por medio de una pagina.
Les agradeceria su consejo para optimizar mi codigo. Ya estoy desesperado. Ademas creo q voy a tener q modificar el codigo ya que investigando me comenta q el transactionscope consume muxos recursos y tampoco es recomendable realizar consultas dentro de
una transacion distribuida.
<div style="color:black; background-color:white
<pre><span style="color:blue using (TransactionScope ScopeGral =<span style="color:blue new TransactionScope())
{
<span style="color:blue using (TransactionScope Scope1 = <span style="color:blue new TransactionScope())
{
<span style="color:blue try
{
<span style="color:blue if (inc.CodDevice == <span style="color:#a31515 "7")
{
strId = intRandomInteger;
intBatchId = 112;
IvrSql.FnCustomerAdd(intRandomInteger, strFirst_Name, strLast_Name, strAddress1, strCity, strState_Region,
strPostal_Code, strCountry, strPhone, strFax, strEmail, strId, strPwd, strNote, inc.NomDevice, inc.MacAddress);
}
<span style="color:blue else
{
intBatchId = 0;
IvrSql.FnCustomerAdd(intRandomInteger, strFirst_Name, strLast_Name, strAddress1, strCity, strState_Region,
strPostal_Code, strCountry, strPhone, strFax, strEmail, strId, strPwd, strNote, inc.NomDevice, inc.MacAddress);
}
lvCodIntCustomer = IvrSql.GetCodIntCustomer(intRandomInteger);
IvrSql.FnAccountAdd(intRandomInteger, inc.ParentAccount, intAccountGroup,
intAccountType, <span style="color:#a31515 "", strToday, fltStartBalance, fltBalance, intCos, lvCodIntCustomer, intBatchId);
<span style="color:blue using (DataView dvlvacc = IvrSql.GetlvCodAccount(intRandomInteger))
{
<span style="color:blue if (dvlvacc.Count > 0)
{
lvCodAccount = Convert.ToInt32(dvlvacc[0][<span style="color:#a31515 "ACCOUNT_ID"]);
lvAccount = dvlvacc[0][<span style="color:#a31515 "ACCOUNT"].ToString();
lvCodParentAccount = Convert.ToInt32(dvlvacc[0][<span style="color:#a31515 "PARENT_ACCOUNT_ID"]);
lvAccountType = Convert.ToInt32(dvlvacc[0][<span style="color:#a31515 "ACCOUNT_TYPE"]);
}
<span style="color:blue else
{
lvCodAccount = 0;
lvAccount = <span style="color:#a31515 "0";
lvCodParentAccount = 0;
lvAccountType = 0;
}
}
strAccountPrm = intRandomInteger;
<span style="color:blue using (DataView dv = IvrSql.GetParentAcc(lvCodParentAccount))
{
<span style="color:blue if (dv.Count > 0)
{
lvParentAccount = dv[0].ToString();
}
<span style="color:blue else
{
lvParentAccount = <span style="color:#a31515 "0";
}
}
IvrSql.FnInsertGMTAcc(intRandomInteger, inc.CodGMT);
IvrSql.FnInsertBilling(inc.SessionId, intRandomInteger, intAccountGroup, strToday, fltBalance,
lvAccount, lvCodAccount, inc.CountryCode, lvParentAccount, lvCodParentAccount, lvAccountType);
<span style="color:blue if (intBatchId == 0)
{
IvrSql.FnAliasesAdd(strId, lvCodAccount);
}
<span style="color:blue if (inc.CodDevice != <span style="color:#a31515 "7")
{
IvrSql.FnAccReferencesAdd(strId, lvCodAccount);
}
IvrSql.FnCustomMacAdd(lvCodIntCustomer, inc.MacAddress, inc.CodDevice);
<span style="color:blue if (phone.dfCustomerId!= <span style="color:#a31515 "")
{
FnUSp_TabNumTlfSkyTel_UPD(lvCodIntCustomer, phone);
}
<span style="color:blue if (inc.Flag_Acc_Cap != <span style="color:#a31515 "1")
{
FnUSp_AccsAccCapAdd(inc.AmountForCap,
inc.Flag_Acc_Cap, inc.MasterFlagCap, inc.SesSky_Cod_Operator,
inc.SesAccount_ID);
}
statusTrans = <span style="color:blue true;
Scope1.Complete();
}
<span style="color:blue catch (Exception ex)
{
<span style="color:blue throw ex;
}
}
<span style="color:blue if (inc.valrbAccount == <span style="color:#a31515 "2")
{
<span style="color:blue using (TransactionScope Scope2 = <span style="color:blue new TransactionScope())
{
<span style="color:blue try
{
strPwd2 = GetIntRandom(4);
strNote = <span style="color:#a31515 "Pwd:" + strPwd2;
IvrSql.FnCustomerAdd(intRandomInteger2, strFirst_Name, strLast_Name, strAddress1, strCity, strState_Region,
strPostal_Code, strCountry, strPhone, strFax, strEmail, strId2, strPwd2, strNote, inc.NomDevice, inc.MacAddress);
<span style="color:green //Continua parte del codigo de arriba
statusTrans2 = <span style="color:blue true;
Scope2.Complete();
}
<span style="color:blue catch (Exception ex)
{
<span style="color:blue throw ex;
}
}
}
<span style="color:blue if (statusTrans == <span style="color:blue true)
{
<span style="color:blue if (statusTrans == <span style="color:blue true && statusTrans2 == <span style="color:blue true)
{
OutBE.MMAccount2 = strId2;
OutBE.MMPwd2 = strPwd2;
OutBE.MMPhone2 = strId2;
}
<span style="color:blue else
{
OutBE.MMAccount2 = <span style="color:#a31515 "";
OutBE.MMPwd2 = <span style="color:#a31515 "";
OutBE.MMPhone2 = <span style="color:#a31515 "";
}
<span style="color:blue if (inc.CodDevice == <span style="color:#a31515 "7")
{
OutBE.MMAccount = intRandomInteger;
}
<span style="color:blue else
{
OutBE.MMAccount = strId;
}
OutBE.MMPwd = strPwd;
OutBE.MMPhone = strId;
}
<span style="color:blue else
{
OutBE.MMAccount = <span style="color:#a31515 "";
OutBE.MMPwd = <span style="color:#a31515 "";
OutBE.MMPhone = <span style="color:#a31515 "";
OutBE.MMAccount2 = <span style="color:#a31515 "";
OutBE.MMPwd2 = <span style="color:#a31515 "";
OutBE.MMPhone2 = <span style="color:#a31515 "";
}
ScopeGral.Complete();
}
[/code]
<br/>
View the full article
El problema es que cuando trato de pasar a la siguiente funcion que me realiza un select para poder retornar algunos datos del cliente recientemente insertado, me sale el error "La comunicaciÃn con el administrador de transacciones subyacente ha fallado."
Les comento que ya configure el servicio de transacciones distribuidas en el servidor de BD y tbm lo configure en mi makina donde estoy desarrollando el sistema. Esta transaccion es para la creacion de una cuenta q se realiza por medio de una pagina.
Les agradeceria su consejo para optimizar mi codigo. Ya estoy desesperado. Ademas creo q voy a tener q modificar el codigo ya que investigando me comenta q el transactionscope consume muxos recursos y tampoco es recomendable realizar consultas dentro de
una transacion distribuida.
<div style="color:black; background-color:white
<pre><span style="color:blue using (TransactionScope ScopeGral =<span style="color:blue new TransactionScope())
{
<span style="color:blue using (TransactionScope Scope1 = <span style="color:blue new TransactionScope())
{
<span style="color:blue try
{
<span style="color:blue if (inc.CodDevice == <span style="color:#a31515 "7")
{
strId = intRandomInteger;
intBatchId = 112;
IvrSql.FnCustomerAdd(intRandomInteger, strFirst_Name, strLast_Name, strAddress1, strCity, strState_Region,
strPostal_Code, strCountry, strPhone, strFax, strEmail, strId, strPwd, strNote, inc.NomDevice, inc.MacAddress);
}
<span style="color:blue else
{
intBatchId = 0;
IvrSql.FnCustomerAdd(intRandomInteger, strFirst_Name, strLast_Name, strAddress1, strCity, strState_Region,
strPostal_Code, strCountry, strPhone, strFax, strEmail, strId, strPwd, strNote, inc.NomDevice, inc.MacAddress);
}
lvCodIntCustomer = IvrSql.GetCodIntCustomer(intRandomInteger);
IvrSql.FnAccountAdd(intRandomInteger, inc.ParentAccount, intAccountGroup,
intAccountType, <span style="color:#a31515 "", strToday, fltStartBalance, fltBalance, intCos, lvCodIntCustomer, intBatchId);
<span style="color:blue using (DataView dvlvacc = IvrSql.GetlvCodAccount(intRandomInteger))
{
<span style="color:blue if (dvlvacc.Count > 0)
{
lvCodAccount = Convert.ToInt32(dvlvacc[0][<span style="color:#a31515 "ACCOUNT_ID"]);
lvAccount = dvlvacc[0][<span style="color:#a31515 "ACCOUNT"].ToString();
lvCodParentAccount = Convert.ToInt32(dvlvacc[0][<span style="color:#a31515 "PARENT_ACCOUNT_ID"]);
lvAccountType = Convert.ToInt32(dvlvacc[0][<span style="color:#a31515 "ACCOUNT_TYPE"]);
}
<span style="color:blue else
{
lvCodAccount = 0;
lvAccount = <span style="color:#a31515 "0";
lvCodParentAccount = 0;
lvAccountType = 0;
}
}
strAccountPrm = intRandomInteger;
<span style="color:blue using (DataView dv = IvrSql.GetParentAcc(lvCodParentAccount))
{
<span style="color:blue if (dv.Count > 0)
{
lvParentAccount = dv[0].ToString();
}
<span style="color:blue else
{
lvParentAccount = <span style="color:#a31515 "0";
}
}
IvrSql.FnInsertGMTAcc(intRandomInteger, inc.CodGMT);
IvrSql.FnInsertBilling(inc.SessionId, intRandomInteger, intAccountGroup, strToday, fltBalance,
lvAccount, lvCodAccount, inc.CountryCode, lvParentAccount, lvCodParentAccount, lvAccountType);
<span style="color:blue if (intBatchId == 0)
{
IvrSql.FnAliasesAdd(strId, lvCodAccount);
}
<span style="color:blue if (inc.CodDevice != <span style="color:#a31515 "7")
{
IvrSql.FnAccReferencesAdd(strId, lvCodAccount);
}
IvrSql.FnCustomMacAdd(lvCodIntCustomer, inc.MacAddress, inc.CodDevice);
<span style="color:blue if (phone.dfCustomerId!= <span style="color:#a31515 "")
{
FnUSp_TabNumTlfSkyTel_UPD(lvCodIntCustomer, phone);
}
<span style="color:blue if (inc.Flag_Acc_Cap != <span style="color:#a31515 "1")
{
FnUSp_AccsAccCapAdd(inc.AmountForCap,
inc.Flag_Acc_Cap, inc.MasterFlagCap, inc.SesSky_Cod_Operator,
inc.SesAccount_ID);
}
statusTrans = <span style="color:blue true;
Scope1.Complete();
}
<span style="color:blue catch (Exception ex)
{
<span style="color:blue throw ex;
}
}
<span style="color:blue if (inc.valrbAccount == <span style="color:#a31515 "2")
{
<span style="color:blue using (TransactionScope Scope2 = <span style="color:blue new TransactionScope())
{
<span style="color:blue try
{
strPwd2 = GetIntRandom(4);
strNote = <span style="color:#a31515 "Pwd:" + strPwd2;
IvrSql.FnCustomerAdd(intRandomInteger2, strFirst_Name, strLast_Name, strAddress1, strCity, strState_Region,
strPostal_Code, strCountry, strPhone, strFax, strEmail, strId2, strPwd2, strNote, inc.NomDevice, inc.MacAddress);
<span style="color:green //Continua parte del codigo de arriba
statusTrans2 = <span style="color:blue true;
Scope2.Complete();
}
<span style="color:blue catch (Exception ex)
{
<span style="color:blue throw ex;
}
}
}
<span style="color:blue if (statusTrans == <span style="color:blue true)
{
<span style="color:blue if (statusTrans == <span style="color:blue true && statusTrans2 == <span style="color:blue true)
{
OutBE.MMAccount2 = strId2;
OutBE.MMPwd2 = strPwd2;
OutBE.MMPhone2 = strId2;
}
<span style="color:blue else
{
OutBE.MMAccount2 = <span style="color:#a31515 "";
OutBE.MMPwd2 = <span style="color:#a31515 "";
OutBE.MMPhone2 = <span style="color:#a31515 "";
}
<span style="color:blue if (inc.CodDevice == <span style="color:#a31515 "7")
{
OutBE.MMAccount = intRandomInteger;
}
<span style="color:blue else
{
OutBE.MMAccount = strId;
}
OutBE.MMPwd = strPwd;
OutBE.MMPhone = strId;
}
<span style="color:blue else
{
OutBE.MMAccount = <span style="color:#a31515 "";
OutBE.MMPwd = <span style="color:#a31515 "";
OutBE.MMPhone = <span style="color:#a31515 "";
OutBE.MMAccount2 = <span style="color:#a31515 "";
OutBE.MMPwd2 = <span style="color:#a31515 "";
OutBE.MMPhone2 = <span style="color:#a31515 "";
}
ScopeGral.Complete();
}
[/code]
<br/>
View the full article