private void AddValues(IOrderedDictionary values) { //the settings property holds either MSMQ or FTP settings //and as it is a "special" property we need to help the databinding a little MultiView multiView = GetControl <MultiView>("MultiViewSettings", PageFormView); ConnectionSettings connectionSettings; if ( (Integration.Connection.ChannelTypeEnum)Enum.Parse(typeof(Integration.Connection.ChannelTypeEnum), GetControl <DropDownList>("DropDownListChannel", PageFormView).SelectedValue) == Integration.Connection.ChannelTypeEnum.MSMQ) { connectionSettings = new MSMQConnectionSettings(); ((MSMQConnectionSettings)connectionSettings).QueueName = GetControl <DropDownList>("DropDownListQueues", multiView).Text; } else { connectionSettings = new FTPConnectionSettings(); ((FTPConnectionSettings)connectionSettings).Port = Convert.ToInt32(GetControl <TextBox>("TextBoxPort", multiView).Text); ((FTPConnectionSettings)connectionSettings).IpAddress = GetControl <TextBox>("TextBoxIPAddress", multiView).Text; ((FTPConnectionSettings)connectionSettings).Password = GetControl <TextBox>("TextBoxPassword", multiView).Text; ((FTPConnectionSettings)connectionSettings).Username = GetControl <TextBox>("TextBoxUserName", multiView).Text; ((FTPConnectionSettings)connectionSettings).ErrorCount = Convert.ToInt32(GetControl <TextBox>("TextBoxErrorCount", multiView).Text); } values.Add("Settings", connectionSettings); }
public MainForm() { InitializeComponent(); this.Icon = Properties.Resources.Hard_Disk_Server_icon1; OpenedExcelFile = null; btnQuickLoad.Enabled = FTPConnectionSettings.LoadSettings() != null; FTPConnectionSettings.FTPSettingsChanged += FTPConnectionSettings_FTPSettingsChanged; }
private void btnSettingsFTP_Click(object sender, EventArgs e) { FTPConnectionSettings ftp = FTPConnectionSettings.LoadSettings(); using (FTPSettingsDialog dlg = new FTPSettingsDialog(ftp)) { if (dlg.ShowDialog() == DialogResult.OK) { FTPConnectionSettings.SaveSettings(dlg.FTPSettings); } } }
protected void OpCoFormView_DataBound(object sender, EventArgs e) { if (PageFormView.DataItem != null && (PageFormView.CurrentMode == FormViewMode.ReadOnly || PageFormView.CurrentMode == FormViewMode.Edit)) { //make sure the correct view is shown and therefor the correct connection settings MultiView multiView = GetControl <MultiView>("MultiViewSettings", PageFormView); Integration.Connection connection = (Integration.Connection)PageFormView.DataItem; Integration.Connection.ChannelTypeEnum channelTypeEnum = (connection.ChannelType); multiView.ActiveViewIndex = Convert.ToInt32(channelTypeEnum); if (PageFormView.CurrentMode == FormViewMode.ReadOnly) { if (channelTypeEnum == Integration.Connection.ChannelTypeEnum.FTP) { FTPConnectionSettings ftpConnection = (FTPConnectionSettings)connection.Settings; GetControl <Label>("LabelIPAddress", multiView).Text = ftpConnection.IpAddress; GetControl <Label>("LabelPort", multiView).Text = ftpConnection.Port.ToString(); GetControl <Label>("LabelUserName", multiView).Text = ftpConnection.Username; GetControl <Label>("LabelErrorCount", multiView).Text = ftpConnection.ErrorCount.ToString(); } else { MSMQConnectionSettings msmqConnection = (MSMQConnectionSettings)connection.Settings; GetControl <Label>("LabelQueueName", multiView).Text = msmqConnection.QueueName; } } else { if (channelTypeEnum == Integration.Connection.ChannelTypeEnum.FTP) { FTPConnectionSettings ftpConnection = (FTPConnectionSettings)connection.Settings; GetControl <TextBox>("TextBoxIPAddress", multiView).Text = ftpConnection.IpAddress; GetControl <TextBox>("TextBoxPort", multiView).Text = ftpConnection.Port.ToString(); GetControl <TextBox>("TextBoxUserName", multiView).Text = ftpConnection.Username; GetControl <TextBox>("TextBoxPassword", multiView).Text = ftpConnection.Password; GetControl <TextBox>("TextBoxErrorCount", multiView).Text = ftpConnection.ErrorCount.ToString(); } else { MSMQConnectionSettings msmqConnection = (MSMQConnectionSettings)connection.Settings; GetControl <DropDownList>("DropDownListQueues", multiView).Text = msmqConnection.QueueName; } } } }
private void FileUploader_DoWork(object sender, DoWorkEventArgs e) { FTPConnectionSettings ftp = FTPConnectionSettings.LoadSettings(); if (ftp == null) { throw new Exception("Не указаны параметры подключения к FTP"); } Uploaders.UploaderFTP uploader = new Uploaders.UploaderFTP(ftp, "quickUploads"); uploader.Initialize(); ImageResizer.ImageInfo image = e.Argument as ImageResizer.ImageInfo; string pictureName = $"{Guid.NewGuid()}.{image.SourceExtention}"; Uri result = uploader.SaveImage(image.SourceBitmap, pictureName); e.Result = result; }
public IUploader Build(UploadDirection direction) { if (direction == UploadDirection.LOCAL) { return(new UploaderLocal(this.DirectoryName)); } else if (direction == UploadDirection.FTP) { FTPConnectionSettings ftp = FTPConnectionSettings.LoadSettings(); if (ftp == null) { throw new Exception("Не указаны параметры подключения к FTP"); } return(new UploaderFTP(ftp, this.DirectoryName)); } else { throw new Exception("Ошибка создания загрузчика."); } }
private void FTPConnectionSettings_FTPSettingsChanged(FTPConnectionSettings settings) { btnQuickLoad.Enabled = settings != null; }
internal UploaderFTP(FTPConnectionSettings ftpsettings, string uploadFolder) : base(uploadFolder) { this.FTPSettings = ftpsettings; }