private void EliminaDestinoDeTFT()
    {
        Configuration config           = WebConfigurationManager.OpenWebConfiguration("~");
        KeyValueConfigurationElement s = config.AppSettings.Settings["Sistema"];

        ServiciosCD40.DestinosExternosSector drs = new ServiciosCD40.DestinosExternosSector();
        drs.IdSistema = s.Value;
        drs.IdDestino = TBDestino.Text;

        // Eliminar de todos los TFT el destino
        ServiceServiciosCD40.DeleteSQL(drs);
    }
    private bool DestinoLCENAsignadoPanelLC(string strSistema, string strDestino, uint idPrefijo, ref System.Text.StringBuilder strMsg)
    {
        //Devuelve true si el destino LCEN está asignado a algún destino en el panel de LC
        //En principio, sólo puede estar asignado a destinos ATS
        bool bExiste = false;

        try
        {
            ServiciosCD40.DestinosExternosSector dExtSec = new ServiciosCD40.DestinosExternosSector();
            dExtSec.IdSistema            = strSistema;
            dExtSec.IdDestinoLCEN        = strDestino;
            dExtSec.IdPrefijoDestinoLCEN = idPrefijo;
            dExtSec.TipoAcceso           = "IA"; //Panel de LC

            ServiciosCD40.Tablas[] lista = ServiceServiciosCD40.ListSelectSQL(dExtSec);

            if (lista != null && lista.Length > 0)
            {
                bExiste = true;
                string strDestinoATS = ((ServiciosCD40.DestinosExternosSector)lista[0]).IdDestino;
                string strSector     = ((ServiciosCD40.DestinosExternosSector)lista[0]).IdSector;

                //Componemos el mensaje  a mostrar en pantalla
                System.Text.StringBuilder strMsgFormato = new System.Text.StringBuilder();

                if (GetGlobalResourceObject("Espaniol", "DestinoLCENAsignadoEnPanelLC") != null)
                {
                    strMsgFormato.Append((string)GetGlobalResourceObject("Espaniol", "DestinoLCENAsignadoEnPanelLC"));
                }
                else
                {
                    strMsgFormato.Append("El destino de línea caliente externa {0} se encuentra asignado al destino ATS {1} en el panel de línea caliente del sector {2}. Por favor, libere el destino {0} antes de eliminarlo");
                }

                if (strMsg.Length > 0)
                {
                    strMsg.Clear();
                }

                strMsg.AppendFormat(strMsgFormato.ToString(), strDestino, strDestinoATS, strSector);
                strMsgFormato.Clear();
            }
        }
        catch (Exception)
        {
        }

        return(bExiste);
    }
    private bool DestinoAsignadoATft(string strSistema, string destino)
    {
        ServiciosCD40.DestinosExternosSector drs = new ServiciosCD40.DestinosExternosSector();
        drs.IdSistema = strSistema;
        drs.IdDestino = destino;

        ServiciosCD40.Tablas[] lista = ServiceServiciosCD40.ListSelectSQL(drs);

        if (lista != null && lista.Length > 0)
        {
            return(true);
        }

        return(false);
    }
Esempio n. 4
0
    private void MuestraParametrosPosicion()
    {
        uint posicionPulsada = UInt16.Parse(((string)ViewState["IdBoton"]).Replace("Button", ""));

        if (!PermisoSegunPerfil)
        {
            BtAceptar.Enabled = TBoxLiteral.Enabled = DListPrioridadSIP.Enabled = DListPrioridadTecla.Enabled = false;
        }

        if (posicionPulsada <= 0)
        {
            return;
        }

        if (prefijosPosiciones[posicionPulsada] == PREFIJO_DESTINO_LCE || prefijosPosiciones[posicionPulsada] == PREFIJO_DESTINO_ATS ||
            prefijosPosiciones[posicionPulsada] == PREFIJO_DESTINO_ATS_BIS)     //línea caliente externa=1 ó ATS=3
        {
            ServiciosCD40.DestinosExternosSector t = new ServiciosCD40.DestinosExternosSector();
            t.IdSistema  = (string)Session["idsistema"];
            t.IdNucleo   = (string)Session["idnucleo"];
            t.IdSector   = (string)Session["NombreSector"];
            t.IdPrefijo  = prefijosPosiciones[posicionPulsada];
            t.PosHMI     = posicionPulsada;
            t.TipoAcceso = "IA";

            try
            {
                DataSet ds = ServicioCD40.DataSetSelectSQL(t);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    DataRow dExterno = ds.Tables[0].Rows[0];
                    TBoxLiteral.Text = (string)dExterno["Literal"];
                    // DListPrioridadSIP.SelectedIndex = (int)((uint)dExterno["PrioridadSIP"] - 1);
                    DListPrioridadSIP.SelectedValue   = Convert.ToString(((uint)dExterno["PrioridadSIP"]));
                    DListPrioridadTecla.SelectedIndex = (int)((uint)dExterno["Prioridad"] - 1);
                    PrioridadTecla = (int)((uint)dExterno["Prioridad"]);

                    ViewState["IdDestino"] = (string)dExterno["IdDestino"];
                    ViewState["IdPrefijo"] = prefijosPosiciones[posicionPulsada].ToString();

                    if (prefijosPosiciones[posicionPulsada] == PREFIJO_DESTINO_ATS || prefijosPosiciones[posicionPulsada] == PREFIJO_DESTINO_ATS_BIS)
                    {
                        //Si es un destino ATS
                        DListDestinosLCEN.Visible = true;
                        LbDestinoLCEN.Visible     = true;
                        //Se carga la lista de Destinos LCEN libres en el sistema
                        CargaDestinosLCEN_Libres();

                        //Obtenemos si es un Destino ATS con un numero de abonado dentro de un encaminamieno IP
                        bEsDestinoATS_IP = ServicioCD40.DestinoATS_ConCentralIP((string)Session["idsistema"], (string)ViewState["IdDestino"]);

                        if (null != dExterno["IdDestinoLCEN"])
                        {
                            string strDestinoLCEN = dExterno["IdDestinoLCEN"].ToString();

                            if (!string.IsNullOrEmpty(strDestinoLCEN))
                            {
                                if (DListDestinosLCEN.Items.FindByText(strDestinoLCEN) != null)
                                {
                                    DListDestinosLCEN.Items.FindByText(strDestinoLCEN).Selected = true;
                                }
                                else
                                {
                                    //Se añade el destino que tiene actualmente asignado, porque no estará en la lista
                                    DListDestinosLCEN.Items.Add(strDestinoLCEN);
                                    DListDestinosLCEN.Items.FindByText(strDestinoLCEN).Selected = true;
                                }
                            }
                        }
                        else
                        {
                            //Se selecciona el primer elemento que corresponde a "Ningún Destino Seleccionado"
                            DListDestinosLCEN.SelectedIndex = 0;
                        }
                    }
                    else
                    {
                        //Si es no es un destino ATS
                        if (DListDestinosLCEN.Items.Count > 0)
                        {
                            DListDestinosLCEN.Items.Clear();
                        }

                        DListDestinosLCEN.Visible = false;
                        LbDestinoLCEN.Visible     = false;
                    }
                }
            }
            catch (Exception ex)
            {
                logDebugView.Error("(TFTTelefonia-MuestraParametrosPosicion): ", ex);
            }
        }
        else                                    //línea caliente interna
        {
            if (DListDestinosLCEN.Items.Count > 0)
            {
                DListDestinosLCEN.Items.Clear();
            }

            DListDestinosLCEN.Visible = false;
            LbDestinoLCEN.Visible     = false;

            ServiciosCD40.DestinosInternosSector t = new ServiciosCD40.DestinosInternosSector();

            t.IdSistema = (string)Session["idsistema"];
            t.IdNucleo  = (string)Session["idnucleo"];
            t.IdSector  = (string)Session["NombreSector"];
            t.IdPrefijo = PREFIJO_DESTINO_LCI;
            t.PosHMI    = posicionPulsada;

            try
            {
                DataSet ds = ServicioCD40.DataSetSelectSQL(t);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    DataRow dInterno = ds.Tables[0].Rows[0];
                    TBoxLiteral.Text = (string)dInterno["Literal"];
                    //DListPrioridadSIP.SelectedIndex = (int)((uint)dInterno["PrioridadSIP"] - 1);
                    DListPrioridadSIP.SelectedValue   = Convert.ToString(((uint)dInterno["PrioridadSIP"]));
                    DListPrioridadTecla.SelectedIndex = (int)((uint)dInterno["Prioridad"] - 1);
                    PrioridadTecla = (int)((uint)dInterno["Prioridad"]);

                    ViewState["IdDestino"] = (string)dInterno["IdDestino"];
                    ViewState["IdPrefijo"] = prefijosPosiciones[posicionPulsada].ToString();
                }
            }
            catch (Exception ex)
            {
                logDebugView.Error("(TFTTelefonia-MuestraParametrosPosicion): ", ex);
            }
        }
    }
Esempio n. 5
0
    private void GuardarNuevaPosicionEnBD(string idDest, string literal, uint idPref, uint prioridad, uint prioSip, string idDestinoLCEN)
    {
        if (Session["idsistema"] != null && Session["NombreSector"] != null && Session["idnucleo"] != null)
        {
            try
            {
                if (idPref == PREFIJO_DESTINO_LCE || idPref == PREFIJO_DESTINO_ATS || idPref == PREFIJO_DESTINO_ATS_BIS) //telefonia externa LC (prefijo=1) o Destino ATS(prefijo=3)
                {
                    ServiciosCD40.DestinosExternosSector t = new ServiciosCD40.DestinosExternosSector();
                    t.IdSistema    = (string)Session["idsistema"];
                    t.IdSector     = (string)Session["NombreSector"];
                    t.OrigenR2     = (string)Session["NombreSector"];
                    t.IdNucleo     = (string)Session["idnucleo"];
                    t.IdDestino    = idDest;
                    t.PosHMI       = UInt16.Parse(((string)ViewState["IdBoton"]).Replace("Button", ""));
                    t.IdPrefijo    = idPref;
                    t.TipoDestino  = 1;
                    t.Literal      = literal;
                    t.Prioridad    = prioridad;
                    t.PrioridadSIP = prioSip;
                    t.TipoAcceso   = "IA";

                    if (!string.IsNullOrEmpty(idDestinoLCEN))
                    {
                        //Se ha asignado un recurso LCEN al Destino ATS
                        t.IdPrefijoDestinoLCEN = PREFIJO_DESTINO_LCE;
                        t.IdDestinoLCEN        = idDestinoLCEN;
                    }
                    else
                    {
                        t.IdPrefijoDestinoLCEN = null;
                        t.IdDestinoLCEN        = null;
                    }

                    if (!Modificando && ServicioCD40.InsertSQL(t) < 0)
                    {
                        logDebugView.Warn("(TFTLC-GuardarNuevaPosicionEnBD): No se ha guardado la posicion de telefonia externa");
                    }
                    else if (!Modificando)
                    {
                        #region Sincronizar CD30
                        Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
                        KeyValueConfigurationElement sincronizar = config.AppSettings.Settings["SincronizaCD30"];
                        if ((sincronizar != null) && (Int32.Parse(sincronizar.Value) == 1))
                        {
                            SincronizaCD30.SincronizaCD30 sincro = new SincronizaCD30.SincronizaCD30();

                            switch (sincro.AltaColateralTelefonia(t.IdNucleo, t.IdSector, t.PosHMI + 56, t.Literal, t.IdDestino, 2, t.OrigenR2, t.Prioridad))
                            {
                            case 127:
                                cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod127"));
                                break;

                            case 128:
                                cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod128"));
                                break;

                            default:
                                break;
                            }
                        }
                        #endregion
                    }
                    if (Modificando && ServicioCD40.UpdateSQL(t) < 0)
                    {
                        logDebugView.Warn("(TFTTelefonia-GuardarNuevaPosicionEnBD): fallo en update de telefonia externa");
                    }
                    else if (Modificando)
                    {
                        #region Sincronizar CD30
                        Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
                        KeyValueConfigurationElement sincronizar = config.AppSettings.Settings["SincronizaCD30"];
                        if ((sincronizar != null) && (Int32.Parse(sincronizar.Value) == 1))
                        {
                            SincronizaCD30.SincronizaCD30 sincro = new SincronizaCD30.SincronizaCD30();

                            switch (sincro.ModificaColateralTelefonia(t.IdNucleo, t.IdSector, t.PosHMI + 56, t.Literal, t.Prioridad))
                            {
                            case 127:
                                cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod127"));
                                break;

                            case 128:
                                cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod128"));
                                break;

                            default:
                                break;
                            }
                        }
                        #endregion
                    }
                }
                else
                if (idPref == PREFIJO_DESTINO_LCI)    //telefonia interna
                {
                    ServiciosCD40.DestinosInternosSector t = new ServiciosCD40.DestinosInternosSector();
                    t.IdSistema    = (string)Session["idsistema"];
                    t.IdSector     = (string)Session["NombreSector"];
                    t.OrigenR2     = (string)Session["NombreSector"];
                    t.IdNucleo     = (string)Session["idnucleo"];
                    t.IdDestino    = idDest;
                    t.PosHMI       = UInt16.Parse(((string)ViewState["IdBoton"]).Replace("Button", ""));
                    t.IdPrefijo    = idPref;
                    t.TipoDestino  = 2;
                    t.Literal      = literal;
                    t.Prioridad    = prioridad;
                    t.PrioridadSIP = prioSip;
                    t.TipoAcceso   = "IA";


                    if (!Modificando)
                    {
                        ServiciosCD40.DestinosInternosSector d = t;
                        if (ServicioCD40.InsertaColateralEnUsuarioReciproco(ref d, (int)NumPosicionesPag))
                        {
                            if (ServicioCD40.InsertSQL(t) < 0)
                            {
                                ServicioCD40.EliminaColateralEnUsuarioReciproco(ref d);
                                logDebugView.Warn("(TFTLC-GuardarNuevaPosicionEnBD): No se ha guardado la posicion de telefonia interna");

                                return;
                            }

                            #region Sincronizar CD30
                            Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
                            KeyValueConfigurationElement sincronizar = config.AppSettings.Settings["SincronizaCD30"];
                            if ((sincronizar != null) && (Int32.Parse(sincronizar.Value) == 1))
                            {
                                SincronizaCD30.SincronizaCD30 sincro = new SincronizaCD30.SincronizaCD30();

                                sincro.AltaColateralTelefonia(d.IdNucleo, d.IdSector, d.PosHMI + 56, d.Literal, d.IdDestino, 7, d.OrigenR2, d.Prioridad);
                            }
                            #endregion

                            #region Sincronizar CD30
                            //Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
                            //KeyValueConfigurationElement sincronizar = config.AppSettings.Settings["SincronizaCD30"];
                            if ((sincronizar != null) && (Int32.Parse(sincronizar.Value) == 1))
                            {
                                SincronizaCD30.SincronizaCD30 sincro = new SincronizaCD30.SincronizaCD30();

                                switch (sincro.AltaColateralTelefonia(t.IdNucleo, t.IdSector, t.PosHMI + 56, t.Literal, t.IdDestino, 7, t.OrigenR2, t.Prioridad))
                                {
                                case 127:
                                    cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod127"));
                                    break;

                                case 128:
                                    cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod128"));
                                    break;

                                default:
                                    break;
                                }
                            }
                            #endregion
                        }
                        else
                        {
                            cMsg.alert((string)GetGlobalResourceObject("Espaniol", "PanelLcCompleto"));
                        }

                        return;
                    }
                    else
                    {
                        ServiciosCD40.DestinosInternosSector d = t;
                        if (ServicioCD40.UpdateSQL(t) < 0)
                        {
                            logDebugView.Warn("(TFTTelefonia-GuardarNuevaPosicionEnBD): fallo en update de telefonia externa");
                        }
                        else
                        {
                            if (ServicioCD40.EliminaColateralEnUsuarioReciproco(ref d))
                            {
                                d = t;
                                if (ServicioCD40.InsertaColateralEnUsuarioReciproco(ref d, (int)NumPosicionesPag))
                                {
                                    #region Sincronizar CD30
                                    Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
                                    KeyValueConfigurationElement sincronizar = config.AppSettings.Settings["SincronizaCD30"];
                                    if ((sincronizar != null) && (Int32.Parse(sincronizar.Value) == 1))
                                    {
                                        SincronizaCD30.SincronizaCD30 sincro = new SincronizaCD30.SincronizaCD30();

                                        sincro.AltaColateralTelefonia(d.IdNucleo, d.IdSector, d.PosHMI + 56, d.Literal, d.IdDestino, 7, d.OrigenR2, d.Prioridad);
                                    }
                                    #endregion

                                    #region Sincronizar CD30
                                    if ((sincronizar != null) && (Int32.Parse(sincronizar.Value) == 1))
                                    {
                                        SincronizaCD30.SincronizaCD30 sincro = new SincronizaCD30.SincronizaCD30();

                                        switch (sincro.ModificaColateralTelefonia(t.IdNucleo, t.IdSector, t.PosHMI + 56, t.Literal, t.Prioridad))
                                        {
                                        case 127:
                                            cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod127"));
                                            break;

                                        case 128:
                                            cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod128"));
                                            break;

                                        default:
                                            break;
                                        }
                                    }
                                    #endregion
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logDebugView.Error("(TFTLC-GuardarNuevaPosicionEnBD): ", ex);
            }
        }
    }
    private void MuestraParametrosPosicion()
    {
        UInt16 buttonIndex     = UInt16.Parse(((string)ViewState["IdBoton"]).Replace("Button", ""));
        uint   posicionPulsada = CalculatePosHmi(buttonIndex);

        if (posicionPulsada <= 0)
        {
            return;
        }
        //20201007 #4576
        TBoxLiteral.Enabled = false;

        if (!PermisoSegunPerfil)
        {
            BtAceptar.Enabled = DListPrioridadSIP.Enabled = DListPrioridadTecla.Enabled = false;
        }

        if (prefijosPosiciones[posicionPulsada] > 2)        //telefonia externa
        {
            ServiciosCD40.DestinosExternosSector t = new ServiciosCD40.DestinosExternosSector();
            t.IdSistema  = (string)Session["idsistema"];
            t.IdNucleo   = (string)Session["idnucleo"];
            t.IdSector   = (string)Session["NombreSector"];
            t.IdPrefijo  = prefijosPosiciones[posicionPulsada];
            t.PosHMI     = CalculatePosHmi(buttonIndex);
            t.TipoAcceso = "DA";

            try
            {
                DataSet ds = ServicioCD40.DataSetSelectSQL(t);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    DataRow dExterno = ds.Tables[0].Rows[0];
                    TBoxLiteral.Text = (string)dExterno["Literal"];
                    //DListPrioridadSIP.SelectedIndex = (int)((uint)dExterno["PrioridadSIP"] - 1);
                    DListPrioridadSIP.SelectedValue   = Convert.ToString(((uint)dExterno["PrioridadSIP"]));
                    DListPrioridadTecla.SelectedIndex = (int)((uint)dExterno["Prioridad"] - 1);

                    ViewState["IdDestino"] = (string)dExterno["IdDestino"];
                    ViewState["IdPrefijo"] = prefijosPosiciones[posicionPulsada].ToString();
                }
            }
            catch (Exception ex)
            {
                logDebugView.Error("(TFTTelefonia-MuestraParametrosPosicion): ", ex);
            }
        }
        else if (prefijosPosiciones[posicionPulsada] == 2)        //telefonia interna
        {
            ServiciosCD40.DestinosInternosSector t = new ServiciosCD40.DestinosInternosSector();

            t.IdSistema  = (string)Session["idsistema"];
            t.IdNucleo   = (string)Session["idnucleo"];
            t.IdSector   = (string)Session["NombreSector"];
            t.IdPrefijo  = 2;
            t.PosHMI     = CalculatePosHmi(buttonIndex);
            t.TipoAcceso = "DA";

            try
            {
                DataSet ds = ServicioCD40.DataSetSelectSQL(t);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    DataRow dInterno = ds.Tables[0].Rows[0];
                    TBoxLiteral.Text = (string)dInterno["Literal"];
                    //DListPrioridadSIP.SelectedIndex = (int)((uint)dInterno["PrioridadSIP"] - 1);
                    DListPrioridadSIP.SelectedValue   = Convert.ToString(((uint)dInterno["PrioridadSIP"]));
                    DListPrioridadTecla.SelectedIndex = (int)((uint)dInterno["Prioridad"] - 1);

                    ViewState["IdDestino"] = (string)dInterno["IdDestino"];
                    ViewState["IdPrefijo"] = prefijosPosiciones[posicionPulsada].ToString();
                }
            }
            catch (Exception ex)
            {
                logDebugView.Error("(TFTTelefonia-MuestraParametrosPosicion): ", ex);
            }
        }
    }
    private void GuardarNuevaPosicionEnBD(string idDest, string literal, uint idPref, uint prioridad, uint prioSip)
    {
        if (Session["idsistema"] != null && Session["NombreSector"] != null && Session["idnucleo"] != null)
        {
            try
            {
                UInt16 buttonIndex = UInt16.Parse(((string)ViewState["IdBoton"]).Replace("Button", ""));
                uint   posHmi      = CalculatePosHmi(buttonIndex);
                // TextBox tbox = (TextBox)TEnlacesInternos.FindControl("TextBox" + ((string)ViewState["IdBoton"]).Replace("Button", ""));
                if (idPref > 2)//telefonia externa
                {
                    ServiciosCD40.DestinosExternosSector t = new ServiciosCD40.DestinosExternosSector();
                    t.IdSistema    = (string)Session["idsistema"];
                    t.IdSector     = (string)Session["NombreSector"];
                    t.OrigenR2     = (string)Session["NombreSector"];
                    t.IdNucleo     = (string)Session["idnucleo"];
                    t.IdDestino    = idDest;
                    t.PosHMI       = posHmi;
                    t.IdPrefijo    = idPref;
                    t.TipoDestino  = 1;
                    t.Literal      = literal;
                    t.Prioridad    = prioridad;
                    t.PrioridadSIP = prioSip;
                    t.TipoAcceso   = "DA";

                    if (!Modificando && ServicioCD40.InsertSQL(t) < 0)
                    {
                        logDebugView.Warn("(TFTTelefonia-GuardarNuevaPosicionEnBD): fallo en insert de telefonia externa");
                    }
                    else if (!Modificando)
                    {
                        #region Sincronizar CD30
                        Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
                        KeyValueConfigurationElement sincronizar = config.AppSettings.Settings["SincronizaCD30"];
                        if ((sincronizar != null) && (Int32.Parse(sincronizar.Value) == 1))
                        {
                            SincronizaCD30.SincronizaCD30 sincro = new SincronizaCD30.SincronizaCD30();

                            switch (sincro.AltaColateralTelefonia(t.IdNucleo, t.IdSector, t.PosHMI, t.Literal, t.IdDestino, t.IdPrefijo, t.OrigenR2, t.Prioridad))
                            {
                            case 127:
                                cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod127"));
                                break;

                            case 128:
                                cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod128"));
                                break;

                            default:
                                break;
                            }
                        }
                        #endregion
                    }
                    if (Modificando && ServicioCD40.UpdateSQL(t) < 0)
                    {
                        logDebugView.Warn("(TFTTelefonia-GuardarNuevaPosicionEnBD): fallo en update de telefonia externa");
                    }
                    else if (Modificando)
                    {
                        #region Sincronizar CD30
                        Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
                        KeyValueConfigurationElement sincronizar = config.AppSettings.Settings["SincronizaCD30"];
                        if ((sincronizar != null) && (Int32.Parse(sincronizar.Value) == 1))
                        {
                            SincronizaCD30.SincronizaCD30 sincro = new SincronizaCD30.SincronizaCD30();

                            switch (sincro.ModificaColateralTelefonia(t.IdNucleo, t.IdSector, t.PosHMI, t.Literal, t.Prioridad))
                            {
                            case 127:
                                cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod127"));
                                break;

                            case 128:
                                cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod128"));
                                break;

                            default:
                                break;
                            }
                        }
                        #endregion
                    }
                }
                else
                if (idPref == 2)    //telefonia interna
                {
                    ServiciosCD40.DestinosInternosSector t = new ServiciosCD40.DestinosInternosSector();
                    t.IdSistema    = (string)Session["idsistema"];
                    t.IdSector     = (string)Session["NombreSector"];
                    t.OrigenR2     = (string)Session["NombreSector"];
                    t.IdNucleo     = (string)Session["idnucleo"];
                    t.IdDestino    = idDest;
                    t.PosHMI       = posHmi;
                    t.IdPrefijo    = idPref;
                    t.TipoDestino  = 2;
                    t.Literal      = literal;
                    t.Prioridad    = prioridad;
                    t.PrioridadSIP = prioSip;
                    t.TipoAcceso   = "DA";
                    if (!Modificando && ServicioCD40.InsertSQL(t) < 0)
                    {
                        logDebugView.Warn("(TFTTelefonia-GuardarNuevaPosicionEnBD): fallo en insert de telefonia interna");
                    }
                    else if (!Modificando)
                    {
                        #region Sincronizar CD30
                        Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
                        KeyValueConfigurationElement sincronizar = config.AppSettings.Settings["SincronizaCD30"];
                        if ((sincronizar != null) && (Int32.Parse(sincronizar.Value) == 1))
                        {
                            SincronizaCD30.SincronizaCD30 sincro = new SincronizaCD30.SincronizaCD30();

                            switch (sincro.AltaColateralTelefonia(t.IdNucleo, t.IdSector, t.PosHMI, t.Literal, t.IdDestino, 1, t.OrigenR2, t.Prioridad))
                            {
                            case 127:
                                cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod127"));
                                break;

                            case 128:
                                cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod128"));
                                break;

                            default:
                                break;
                            }
                        }
                        #endregion
                    }
                    if (Modificando && ServicioCD40.UpdateSQL(t) < 0)
                    {
                        logDebugView.Warn("(TFTTelefonia-GuardarNuevaPosicionEnBD): fallo en update de telefonia interna");
                    }
                    else if (Modificando)
                    {
                        #region Sincronizar CD30
                        Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
                        KeyValueConfigurationElement sincronizar = config.AppSettings.Settings["SincronizaCD30"];
                        if ((sincronizar != null) && (Int32.Parse(sincronizar.Value) == 1))
                        {
                            SincronizaCD30.SincronizaCD30 sincro = new SincronizaCD30.SincronizaCD30();

                            switch (sincro.ModificaColateralTelefonia(t.IdNucleo, t.IdSector, t.PosHMI, t.Literal, t.Prioridad))
                            {
                            case 127:
                                cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod127"));
                                break;

                            case 128:
                                cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod128"));
                                break;

                            default:
                                break;
                            }
                        }
                        #endregion
                    }

                    if (!Modificando)
                    {
                        // Dar de baja el colatarel en el usuario recíproco
                        if (ServicioCD40.InsertaColateralEnUsuarioReciproco(ref t, (int)NumPosicionesPag))
                        {
                            #region Sincronizar CD30
                            Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
                            KeyValueConfigurationElement sincronizar = config.AppSettings.Settings["SincronizaCD30"];
                            if ((sincronizar != null) && (Int32.Parse(sincronizar.Value) == 1))
                            {
                                SincronizaCD30.SincronizaCD30 sincro = new SincronizaCD30.SincronizaCD30();

                                switch (sincro.AltaColateralTelefonia(t.IdNucleo, t.IdSector, t.PosHMI, t.Literal, t.IdDestino, 1, t.OrigenR2, t.Prioridad))
                                {
                                case 127:
                                    cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod127"));
                                    break;

                                case 128:
                                    cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod128"));
                                    break;

                                default:
                                    break;
                                }
                            }
                            #endregion
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logDebugView.Error("(TFTTelefonia-GuardarNuevaPosicionEnBD): ", ex);
            }
        }
    }