예제 #1
0
        private ControlBusiness.Business.CommonB CreateProductosBL()
        {
            ControlEntities ctx = new ControlEntities();
            var             mockControlRepository = new MockControlRepository(ctx);
            //  var inventBL = new InventarioB();
            //var inventBL = new InventarioB(mockControlRepository);
            var commB = new CommonB(mockControlRepository);

            commB.CreateEntity(new Producto()
            {
                IdProducto  = 0,
                Codigo      = "First Producto code",
                Descripcion = "Descrip 1",
                Proveedore  = new Proveedore()
                {
                    IdProveedor = 0,
                    Descripcion = "Proveedor One",
                    Telefono    = "Tel 1"
                }
            });
            commB.CreateEntity(new Producto()
            {
                IdProducto  = 1,
                Codigo      = "Second Producto code",
                Descripcion = "Descrip 2",
                Proveedore  = new Proveedore()
                {
                    IdProveedor = 1,
                    Descripcion = "Proveedor 2",
                    Telefono    = "Tel 2"
                }
            });
            commB.CreateEntity(new Producto()
            {
                IdProducto  = 2,
                Codigo      = "Third Producto code",
                Descripcion = "Descrip 3",
                Proveedore  = new Proveedore()
                {
                    IdProveedor = 2,
                    Descripcion = "Proveedor 3",
                    Telefono    = "Tel 3"
                }
            });
            return(commB);
        }
예제 #2
0
        static void Main(string[] args)
        {
            //respaldos como tarea de windows
            // para probarlo solo debe ejecutarse y

            /* task scheduler de windows
             * y si quiere que caiga en error, poner breakpoint línea:
             * DirectoryInfo df = new DirectoryInfo(rutaFinal); y alterar el valor del
             * directorio destino del backup
             * get cadena de conexion
             */
            CommonB biz  = new CommonB();
            var     conn = biz.GetConnection();
            // get parametros
            var cursosParams = biz.GetList <Parametro>().FirstOrDefault();
            // get ruta de parametros
            var parameterRutaSistema = cursosParams.RutaSistema;

            // get config for email
            port                  = cursosParams.PortCorreo;
            timeout               = cursosParams.TimeOutCorreo;
            host                  = cursosParams.HostCorreo;
            fromEmail             = cursosParams.FromCorreo;
            displayName           = cursosParams.DisplayNameCorreo;
            userName              = cursosParams.UserNameCorreo;
            password              = cursosParams.PasswordCorreo;
            destinoCorreoRespaldo = cursosParams.CorreoContactoRespaldos;
            var rutaFinal = "";

            if (!string.IsNullOrWhiteSpace(parameterRutaSistema))
            {
                rutaFinal = parameterRutaSistema.Trim();
            }
            else
            {
                rutaFinal = Path.GetDirectoryName(Directory.GetCurrentDirectory());
            }
            //verficiar que exista ruta
            var strBackup = "BACKUP DATABASE [Cursos] TO  DISK = N'" +
                            rutaFinal.Trim() + "\\Cursos.bak' WITH NOFORMAT, INIT,  NAME = N'Cursos-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10";

            if (!string.IsNullOrWhiteSpace(rutaFinal))
            {
                DirectoryInfo df = new DirectoryInfo(rutaFinal);
                try
                {
                    if (df.Exists)
                    {
                        // send backup
                        // usuario de bases de datos debe tener permisos db backupoperator, on user mapping, database role memebership
                        //int count = AdoDataMethods.ExecuteSql(commB.GetConnection(), strBackup);
                        Console.WriteLine("Haciendo respaldo...");
                        int count = AdoDataMethods.ExecuteSql(conn.Trim(), strBackup);
                        //int count = commB.ExecuteSql(strBackup);
                        //MessageBox.Show("Respaldo realizado!", "Backup", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                    }
                    else
                    {
                        Console.WriteLine("Error en respaldo, intentanto enviar correo...");
                        SendErrorEmail("El folder seleccionado: " + rutaFinal +
                                       " para hacer los respaldos es inaccesible o no existe, " +
                                       "por favor verifique los parámetros.");

                        //MessageBox.Show("El folder seleccionado es inaccesible o no existe!", "Backup", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    }
                }
                catch (Exception ex)
                {
                    SendErrorEmail("No se puede hacer el respaldo de la base de datos" +
                                   "Cursos. Mensaje: " + ex.Message + System.Environment.NewLine +
                                   "Inner Exception: " + ex.InnerException + Environment.NewLine +
                                   "Stack: " + ex.StackTrace + Environment.NewLine +
                                   "por favor verifique la configuración en la base de datos.");
                    //General.LogInfo(ex, "Control", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                }
            }
            //for (int i = 1; i <= 100; i++)
            //{
            //    if (i % 5 == 0 && i % 3 == 0)
            //    {
            //        Console.WriteLine("FizzBuzz");
            //    }
            //    else
            //    {
            //        if (i % 5 == 0)
            //        {
            //            Console.WriteLine("Buzz");
            //        }
            //        else
            //        {
            //            if (i % 3 == 0)
            //            {
            //                Console.WriteLine("Fizz");
            //            }
            //            else
            //            {
            //                Console.WriteLine(i);
            //            }
            //        }
            //    }
            //}

            //string p = "FINISHED FILES ARE THE RE- SULT OF YEARS OF SCIENTIF- IC STUDY COMBINED WITH THE EXPERIENCE OF YEARS ";
            //int total = 0;
            //for (var item=0;item < p.Length; item++)
            //{
            //    if (p[item].Equals("F")) total++;
            //}
            //Console.WriteLine(total);
            // From Data out

            //var oCustomers = obj.GetUsuario("Admin", "2");
            //Console.WriteLine(oCustomers.FirstOrDefault().Nombre);
            // Data in

            //GeneralB obj2 = new GeneralB();
            //obj2.CustomerCode = "c001";
            //obj2.CustomerName = "Shivprasad";
            //Console.ReadLine();

            /// test wcf host
            //RunService();


            ///// test wcf client
            //TestService();

            // create xml
            //ExecuteXmlTest1();
            //ExecuteXmlTest2();
            //Console.ReadLine();
        }
        private void ExistenciasForm_Load(object sender, EventArgs e)
        {
            CommonB commB = new CommonB();

            gridExistencias.DataSource = commB.GetList <Existencia>();
        }