private void RecargarTabla()
        {
            conn = new SqlConnection(stringConexion);
            conn.Open();

            cmd             = new SqlCommand("Truncate Table SecuenciaScripts");
            cmd.Connection  = conn;
            cmd.CommandType = CommandType.Text;
            cmd.ExecuteNonQuery();



            int     contador = 1;
            EScript PV       = default(EScript);

            while ((contador <= ListaScripts.Count))
            {
                PV = ListaScripts.Find(x => x.IdScript == contador);
                if ((PV == null))
                {
                    contador = contador + 1;
                    continue;
                }
                cmd             = new SqlCommand("Insert into SecuenciaScripts (NombreScripts,Motor,TipoBorrado,OrdenBorrado,AplicaMigracion,NombreSP) values('" + PV.NombreScript + "','" + PV.Motor + "'," + PV.TipoBorrado.ToString() + "," + PV.OrdenBorrado.ToString() + ",'" + PV.AplicaMigracion + "','" + PV.NombreSP + "')");
                cmd.Connection  = conn;
                cmd.CommandType = CommandType.Text;
                cmd.ExecuteNonQuery();
                contador = contador + 1;
            }
        }
        private void CargaDiccionario()
        {
            SqlDataAdapter adp    = default(SqlDataAdapter);
            DataTable      tbl    = new DataTable("Scripts");
            SqlDataReader  reader = default(SqlDataReader);
            EScript        pivote = default(EScript);

            ListaScripts = new List <EScript>();


            conn = new SqlConnection(stringConexion);
            conn.Open();

            cmd             = new SqlCommand("Select IdScript,NombreScripts,Motor,case when TipoBorrado = 0 then 'Delete' when TipoBorrado = 1 then 'Truncate' else 'No aplica' end as 'TipoBorrado',OrdenBorrado,AplicaMigracion,NombreSP from SecuenciaScripts");
            cmd.Connection  = conn;
            cmd.CommandType = CommandType.Text;

            reader = cmd.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    pivote                 = new EScript();
                    pivote.IdScript        = reader.GetInt32(0);
                    pivote.NombreScript    = reader.GetString(1);
                    pivote.Motor           = reader.GetString(2);
                    pivote.TipoBorrado     = reader.GetString(3) == "Delete" ? 0 : reader.GetString(3) == "Truncate" ? 1 : 2;
                    pivote.OrdenBorrado    = reader.GetInt32(4);
                    pivote.AplicaMigracion = reader.GetString(5);
                    pivote.NombreSP        = reader.GetString(6);
                    ListaScripts.Add(pivote);
                }
            }
        }
Exemple #3
0
    /// <summary>
    /// this method is to get list of selected script(s) in the grid.
    /// </summary>
    /// <returns></returns>
    private EScript[] GetSelectedScript()
    {
        System.Collections.ArrayList ListScript = new ArrayList();

        for (int i = 0; i < grdScript.Rows.Count; i++)
        {
            HtmlInputCheckBox chkScriptSelecter = new HtmlInputCheckBox();
            chkScriptSelecter = (HtmlInputCheckBox)grdScript.Rows[i].FindControl("chkRowChild");
            if (chkScriptSelecter.Checked == true)
            {
                EScript script = new EScript();
                script.ScriptID = Convert.ToInt32(((DataTable)(ViewState["DSGRID"])).Rows[grdScript.Rows[i].DataItemIndex]["ScriptID"]);
                ListScript.Add(script);
            }
        }

        EScript[] Scripts = new EScript[ListScript.Count];
        for (int i = 0; i < ListScript.Count; i++)
        {
            Scripts[i] = new EScript();
            Scripts[i] = (EScript)ListScript[i];
        }

        return(Scripts);
    }
        private void ActualizarOrdenBorrado()
        {
            //Hago una copia del elemento al que se le va a cambiar el IndiceBorrado
            EScript pv  = default(EScript);
            int     idx = 0;

            pv  = ListaOrdenBorrado.Find(x => x.IdScript == IdScriptRecBorrado);
            idx = pv.OrdenBorrado;
            if ((idx == IndiceBorrado.Value))
            {
                return;
            }
            //Remuevo el elemento de la lista de borrado
            ListaOrdenBorrado.Remove(pv);
            //Reedito la copia para que tenga el nuevo indice de borrado
            pv.OrdenBorrado = Convert.ToInt32(IndiceBorrado.Value);



            if ((idx > IndiceBorrado.Value))
            {
                foreach (EScript sr in ListaOrdenBorrado)
                {
                    if ((sr.OrdenBorrado < IndiceBorrado.Value))
                    {
                        continue;
                    }
                    sr.OrdenBorrado = sr.OrdenBorrado + 1;
                }
            }

            if ((idx < IndiceBorrado.Value))
            {
                foreach (EScript sr in ListaOrdenBorrado)
                {
                    if ((sr.OrdenBorrado > idx & sr.OrdenBorrado <= IndiceBorrado.Value))
                    {
                        sr.OrdenBorrado = sr.OrdenBorrado - 1;
                    }
                }
            }

            ListaOrdenBorrado.Add(pv);
            ListaOrdenBorrado.Sort((EScript a, EScript b) => { return(a.OrdenBorrado.CompareTo(b.OrdenBorrado)); });
        }
        private void CambioScripts()
        {
            EScript PVAnt   = default(EScript);
            EScript PVDes   = default(EScript);
            int     Antes   = 0;
            int     Despues = 0;

            Antes   = Convert.ToInt32(TxtIdScript.Text);
            Despues = Convert.ToInt32(TxtCambio.Text);

            if ((ListaScripts.Exists(x => x.IdScript == Despues)))
            {
                PVAnt          = ListaScripts.Find(x => x.IdScript == Antes);
                PVDes          = ListaScripts.Find(x => x.IdScript == Despues);
                PVAnt.IdScript = Despues;
                PVDes.IdScript = Antes;
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("No existe el indice de script indicado, favor verificar");
                TxtCambio.Text = "";
                TxtCambio.Focus();
                return;
            }

            RecargarTabla();
            Metodo2();

            TxtCambio.Text    = "";
            TxtCambio.Visible = false;
            CheckBox1.Checked = false;

            TxtIdScript.Enabled = false;
            TxtScript.Enabled   = false;
            CheckBox1.Visible   = true;
            TxtIdScript.Focus();
            DataGridView1.FirstDisplayedScrollingRowIndex = DataGridView1.RowCount - 1;
            DataGridView1.ClearSelection();
            DataGridView1.Rows[DataGridView1.RowCount - 1].Selected = true;
            TxtIdScript.Text = DataGridView1.Rows[DataGridView1.RowCount - 1].Cells[0].Value.ToString();
            TxtScript.Text   = DataGridView1.Rows[DataGridView1.RowCount - 1].Cells[1].Value.ToString();
            BtnNuevo.Text    = "Incorporar";
        }
Exemple #6
0
    /// <summary>
    /// this method is used for adding new and updating the information regarding the script which is
    /// called on clicking save button.
    /// </summary>
    private void UpdateScript()
    {
        var script = new EScript();

        script.Description = txtDescription.Text;
        script.Name        = txtName.Text;
        script.Active      = true;
        script.Default     = chkIsDefault.Checked;
        script.ScriptText  = Server.HtmlDecode(txtScriptText.Text);
        var scripttype = new EScriptType();

        scripttype.ScriptTypeID = Convert.ToInt32(ddlscripttype.SelectedValue);

        script.ScriptType = scripttype;
        Int64 returnresult;

        var callCenterDal = new CallCenterDAL();

        if (hfScriptID.Value.Equals(""))
        {
            returnresult = callCenterDal.SaveScript(script, Convert.ToInt32(EOperationMode.Insert));
            if (returnresult == 0)
            {
                returnresult = 9999990;
            }
        }
        else
        {
            script.ScriptID = Convert.ToInt32(((DataTable)(ViewState["DSGRID"])).Rows[grdScript.Rows[Convert.ToInt32(hfScriptID.Value)].DataItemIndex]["ScriptID"]);
            returnresult    = callCenterDal.SaveScript(script, Convert.ToInt32(EOperationMode.Update));
            if (returnresult == 0)
            {
                returnresult = 9999991;
            }
        }
        errordiv.InnerHtml = (String)GetGlobalResourceObject("Resource", "msgDatabaseResult" + returnresult.ToString());
        errordiv.Visible   = true;
        hfScriptID.Value   = "";
        GetScript();
    }
        private void ReacomodarScript()
        {
            string IdScript  = "";
            int    nIdScript = -1;
            int    maximo    = 0;

            if (ListaScripts.Count <= 0)
            {
                return;
            }

            nIdScript = Convert.ToInt32(TxtIdScript.Text.Trim());
            maximo    = ListaScripts.Count;

            if ((nIdScript > maximo))
            {
                // Tabla.Add(TxtIdScript.Text.Trim, TxtScript.Text.Trim)
                ListaScripts.Add(new EScript
                {
                    IdScript        = Convert.ToInt32(TxtIdScript.Text.Trim()),
                    NombreScript    = TxtScript.Text.Trim(),
                    Motor           = ComboBox1.Text.Trim(),
                    TipoBorrado     = CbxTipoBorrado.SelectedIndex,
                    OrdenBorrado    = Convert.ToInt32(IndiceBorrado.Value),
                    AplicaMigracion = chkAplicaM.Checked ? "S" : "N",
                    NombreSP        = "PROC_" + TxtScript.Text.Trim().Substring(0, TxtScript.Text.Trim().Length - 4).ToUpper()
                });

                return;
            }


            if ((ListaScripts.Exists(x => x.IdScript == Convert.ToInt32(TxtIdScript.Text.Trim()))))
            {
                EScript pv = default(EScript);



                while ((maximo >= nIdScript))
                {
                    IdScript = Convert.ToString(maximo);

                    pv = ListaScripts.Find(x => x.IdScript == maximo);

                    if ((pv == null))
                    {
                        maximo = maximo - 1;
                        continue;
                    }

                    pv.IdScript = maximo + 1;


                    //Tabla(IdScript) = Convert.ToString(maximo + 1)
                    maximo = maximo - 1;
                }

                ListaScripts.Add(new EScript
                {
                    IdScript        = Convert.ToInt32(TxtIdScript.Text.Trim()),
                    NombreScript    = TxtScript.Text.Trim(),
                    Motor           = ComboBox1.Text.Trim(),
                    TipoBorrado     = CbxTipoBorrado.SelectedIndex,
                    OrdenBorrado    = Convert.ToInt32(IndiceBorrado.Value),
                    AplicaMigracion = chkAplicaM.Checked ? "S" : "N",
                    NombreSP        = "PROC_" + TxtScript.Text.Trim().Substring(0, TxtScript.Text.Trim().Length - 4).ToUpper()
                });
            }
        }
        private void ReacomodarScript2()
        {
            if (Convert.ToInt32(TxtCambio.Text) == Convert.ToInt32(TxtIdScript.Text))
            {
                System.Windows.Forms.MessageBox.Show("El indice de script a reubicar es el mismo, favor verificar");
                return;
            }


            if (Convert.ToInt32(TxtCambio.Text) < Convert.ToInt32(TxtIdScript.Text))
            {
                int inc = Convert.ToInt32(TxtIdScript.Text) - 1;

                EScript pv    = default(EScript);
                EScript pvAux = new EScript
                {
                    IdScript        = Convert.ToInt32(TxtCambio.Text),
                    NombreScript    = TxtScript.Text.Trim(),
                    Motor           = ComboBox1.Text.Trim(),
                    TipoBorrado     = CbxTipoBorrado.SelectedIndex,
                    OrdenBorrado    = Convert.ToInt32(IndiceBorrado.Value),
                    AplicaMigracion = chkAplicaM.Checked ? "S" : "N",
                    NombreSP        = "PROC_" + TxtScript.Text.Trim().Substring(0, TxtScript.Text.Trim().Length - 4).ToUpper()
                };

                pv = ListaScripts.Find(x => x.IdScript == Convert.ToInt32(TxtIdScript.Text.Trim()));
                ListaScripts.Remove(pv);


                while ((inc >= Convert.ToInt32(TxtCambio.Text)))
                {
                    pv = ListaScripts.Find(x => x.IdScript == inc);

                    if ((pv == null))
                    {
                        inc = inc - 1;
                        continue;
                    }

                    pv.IdScript = inc + 1;


                    //Tabla(IdScript) = Convert.ToString(maximo + 1)
                    inc = inc - 1;
                }

                ListaScripts.Add(pvAux);
            }


            if (Convert.ToInt32(TxtCambio.Text) > Convert.ToInt32(TxtIdScript.Text))
            {
                int inc = Convert.ToInt32(TxtIdScript.Text) + 1;

                EScript pv    = default(EScript);
                EScript pvAux = new EScript
                {
                    IdScript     = Convert.ToInt32(TxtCambio.Text),
                    NombreScript = TxtScript.Text.Trim(),
                    Motor        = ComboBox1.Text.Trim(),
                    TipoBorrado  = CbxTipoBorrado.SelectedIndex,
                    OrdenBorrado = Convert.ToInt32(IndiceBorrado.Value)
                };

                pv = ListaScripts.Find(x => x.IdScript == Convert.ToInt32(TxtIdScript.Text.Trim()));
                ListaScripts.Remove(pv);


                while ((inc <= Convert.ToInt32(TxtCambio.Text)))
                {
                    pv = ListaScripts.Find(x => x.IdScript == inc);

                    if ((pv == null))
                    {
                        inc = inc - 1;
                        continue;
                    }

                    pv.IdScript = inc - 1;


                    //Tabla(IdScript) = Convert.ToString(maximo + 1)
                    inc = inc + 1;
                }

                ListaScripts.Add(pvAux);
            }
        }
Exemple #9
0
 private void Awake()
 {
     instance = this;
 }