Пример #1
0
        public Response UploadListSFTP(DataExtensionImportParent dataExtensionImportParent)
        {
            var response = new Response { Success = true, Warning = false };
            try
            {
                const int port = 22;
                const string host = "ftp.s6.exacttarget.com";
                const string username = "******";
                const string password = "******";
                const string workingdirectory = "/Import//";

                using (var client = new SftpClient(host, port, username, password))
                {
                    client.Connect();
                    client.ChangeDirectory(workingdirectory);
                    foreach (var item in dataExtensionImportParent.DataExtensionImportList)
                    {
                        string extension = Path.GetExtension(item.Ruta);
                        string nombreArchivo = string.Format("{0}{1}",item.Nombre, extension);
                        using (var fileStream = new FileStream(item.Ruta, FileMode.Open))
                        {

                            client.BufferSize = 4 * 1024; // bypass Payload error large files
                            client.UploadFile(fileStream, nombreArchivo);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }
            return response;
        }
Пример #2
0
        public void CargarFileUpload(DataExtensionImportParent dataExtensionImportParent)
        {
            try
            {
                Controls.Clear();
                if(dataExtensionImportParent.DataExtensionImportList == null)
                {
                    return;
                }

                var alto = 0;
                foreach (var dataExtensionImport in dataExtensionImportParent.DataExtensionImportList)
                {
                    FileUpload fileUpload = new FileUpload {
                        IdDato = dataExtensionImport.Id,
                        Texto = dataExtensionImport.Nombre,
                        Top = alto
                    };

                    fileUpload.EventoClick += fileUpload_Click;

                    alto += 50;
                    Controls.Add(fileUpload);
                }

                Height = alto;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constantes.Mensaje, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }