예제 #1
0
        static async Task Main(string[] args)
        {
            var fotoatt    = new FotoAttachDal();
            var listaFotos = fotoatt.GetList();

            for (int i = 0; i < listaFotos.Count; i++)
            {
                Console.WriteLine(".............................................");
                await SendFiles(listaFotos[i].archivo, listaFotos[i].noar, listaFotos[i].idar, listaFotos[i].idfotoar);

                Console.WriteLine("...................................");
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            GetAppSettingsFile();
            var foto       = new FotoAttachDal(_iconfiguration);
            var listaFotos = foto.GetList();

            /*
             * listaFotos.ForEach(async item =>
             * {
             *  await SendFiles(item.archivo, item.noar, item.idar);
             *  Console.WriteLine(item.archivo);
             * });*/
            foto.insertDatos("Se ejecuto la aplicacion", "-1", 0, "k");
            Console.ReadKey();
        }
예제 #3
0
        static async Task <bool> SendFiles(string name, string noar, int idar)
        {
            var        foto               = new FotoAttachDal(_iconfiguration);
            bool       respuesta          = false;
            HttpClient client             = new HttpClient();
            MultipartFormDataContent form = new MultipartFormDataContent();
            HttpContent content           = new StringContent("fileToUpload");
            HttpContent contentNoar       = new StringContent(noar);

            form.Add(content, "fileToUpload");
            form.Add(contentNoar, "noar");

            var stream = new FileStream("C:\\inetpub\\wwwroot\\MIC3\\UPLOADER\\ARCHIVOS\\" + name, FileMode.Open);

            content = new StreamContent(stream);
            content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
            {
                Name     = "archivos",
                FileName = name
            };

            form.Add(content);

            HttpResponseMessage response = null;

            try
            {
                response  = (await client.PostAsync("http://sgse.microformas.com.mx:8093/api/files/ODT", form));
                respuesta = true;
            }
            catch (Exception ex)
            {
                foto.insertDatos(name, noar, idar, "A OCURRIDO UN ERROR INTERNO EN EL PROGRAMA 'MigracionToElavon' AL ENVIAR EL ARCHIVO: " + ex.ToString());
                Console.WriteLine(ex.Message);
            }

            var k = response.Content.ReadAsStringAsync().Result;

            foto.insertDatos(name, noar, idar, k);
            return(respuesta);
        }
예제 #4
0
        static async Task SendFiles(string name, string noar, int idar, int id_foto_ar)
        {
            var foto = new FotoAttachDal();

            try
            {
                HttpClient client             = new HttpClient();
                MultipartFormDataContent form = new MultipartFormDataContent();
                HttpContent content           = new StringContent("fileToUpload");
                HttpContent contentNoar       = new StringContent(noar);
                form.Add(content, "fileToUpload");
                form.Add(contentNoar, "noar");
                Console.WriteLine("Tomando Imagen: " + name);
                var stream = new FileStream("C:\\inetpub\\wwwroot\\MIC3\\UPLOADER\\ARCHIVOS\\" + name, FileMode.Open);
                content = new StreamContent(stream);
                content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
                {
                    Name     = "archivos",
                    FileName = name
                };

                form.Add(content);

                HttpResponseMessage response = null;
                Console.WriteLine("Iniciando Envio de Imagen: " + name);
                response = (await client.PostAsync("http://sgse.microformas.com.mx/ELAVON/MigracionArchivosApi/api/files/ODT", form));
                var k = response.Content.ReadAsStringAsync().Result;

                if (response.StatusCode != HttpStatusCode.OK)
                {
                    foto.insertDatos(name, noar, idar, k, id_foto_ar, 0);
                }

                foto.insertDatos(name, noar, idar, k, id_foto_ar, 1);
            }
            catch (Exception ex)
            {
                foto.insertDatos(name, noar, idar, "A OCURRIDO UN ERROR INTERNO EN EL PROGRAMA MigracionArchivosSgsElavon AL ENVIAR EL ARCHIVO  " + ex.StackTrace, id_foto_ar, 0);
            }
        }