/SSRS 2005 FTP Delivery Extension/Secure.FTPDeliveryExtension/DeliveryExtension/SubscriptionData.cs
# · C# · 346 lines · 279 code · 34 blank · 33 comment · 1 complexity · 88a459a0998608281346dbaa46378b0f MD5 · raw file
- /*
- * Copyright (c) 2008-2009, Genox Software Ltd.
- * All rights reserved.
- *
- * Author : Toby Riley - 2009
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Genox Software Ltd. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Genox Software Ltd. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL Genox Software Ltd. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Text;
- using Microsoft.ReportingServices.Interfaces;
-
- namespace Secure.FTPDeliveryExtension
- {
-
- internal class SubscriptionData
- {
- // Fields
- private string _CSVTextDelimiter = string.Empty;
- private string _CSVTextQualifier = string.Empty;
- private string _FileNameFormat = string.Empty;
- private string _ftpFolder = string.Empty;
- private string _ftpPassword = string.Empty;
- private string _ftpPort = string.Empty;
- private string _ftpUrl = string.Empty;
- private string _ftpUsername = string.Empty;
- private string _IsDeliveryEncrypted = string.Empty;
- private string _PGPPublicKeyUID = string.Empty;
-
- // Methods
- private Setting CreateSetting(string name, string val)
- {
- Setting setting = new Setting();
- setting.Name = name;
- setting.Value = val;
- return setting;
- }
-
- public void FromSettings(Setting[] settings)
- {
- foreach (Setting setting in settings)
- {
- switch (setting.Name)
- {
- case "FTPUrl":
- FTPUrl = setting.Value;
- break;
-
- case "FTPFolder":
- FTPFolder = setting.Value;
- break;
-
- case "FTP Username":
- FTPUsername = setting.Value;
- break;
-
- case "FTP Password":
- FTPPassword = setting.Value;
- break;
-
- case "FTPPort":
- FTPPort = setting.Value;
- break;
-
- case "IsDeliveryEncrypted":
- IsDeliveryEncrypted = setting.Value;
- break;
-
- case "PGPPublicKeyUID":
- PGPPublicKeyUID = setting.Value;
- break;
-
- case "FileNameFormat":
- FileNameFormat = setting.Value;
- break;
-
- case "CSVTextDelimiter: ":
- CSVTextDelimiter = setting.Value;
- break;
-
- case "CSVTextQualifier: ":
- CSVTextQualifier = setting.Value;
- break;
- }
- }
- }
-
- public Setting[] ToSettingArray()
- {
- ArrayList list = new ArrayList();
- list.Add(CreateSetting("FTPUrl", FTPUrl));
- list.Add(CreateSetting("FTPFolder", FTPFolder));
- list.Add(CreateSetting("FTP Username", FTPUsername));
- list.Add(CreateSetting("FTP Password", FTPPassword));
- list.Add(CreateSetting("FTPPort", FTPPort));
- list.Add(CreateSetting("IsDeliveryEncrypted", IsDeliveryEncrypted));
- list.Add(CreateSetting("PGPPublicKeyUID", PGPPublicKeyUID));
- list.Add(CreateSetting("FileNameFormat", FileNameFormat));
- list.Add(CreateSetting("CSVTextQualifier: ", CSVTextQualifier));
- list.Add(CreateSetting("CSVTextDelimiter: ", CSVTextDelimiter));
- return (list.ToArray(typeof(Setting)) as Setting[]);
- }
-
- public Setting[] Validate(Setting[] settings)
- {
- return settings;
- }
-
- // Properties
- public string CSVTextDelimiter
- {
- get
- {
- return _CSVTextDelimiter;
- }
- set
- {
- _CSVTextDelimiter = value;
- }
- }
-
- public string CSVTextQualifier
- {
- get
- {
- return _CSVTextQualifier;
- }
- set
- {
- _CSVTextQualifier = value;
- }
- }
-
- internal static Setting[] ExtensionSettings
- {
- get
- {
- Setting[] extensionSettings = new Setting[10];
- extensionSettings = new Setting[10];
- extensionSettings[0] = new Setting();
- extensionSettings[0].Name = "FTP Url";
- extensionSettings[0].ReadOnly = false;
- extensionSettings[0].Required = true;
- extensionSettings[0].Encrypted = false;
- extensionSettings[1] = new Setting();
- extensionSettings[1].Name = "FTPFolder";
- extensionSettings[1].ReadOnly = false;
- extensionSettings[1].Required = false;
- extensionSettings[1].Encrypted = false;
- extensionSettings[2] = new Setting();
- extensionSettings[2].Name = "FTP Username";
- extensionSettings[2].ReadOnly = false;
- extensionSettings[2].Required = true;
- extensionSettings[2].Encrypted = false;
- extensionSettings[3] = new Setting();
- extensionSettings[3].Name = "FTP Password";
- extensionSettings[3].ReadOnly = false;
- extensionSettings[3].Required = true;
- extensionSettings[3].IsPassword = true;
- extensionSettings[3].Encrypted = true;
- extensionSettings[4] = new Setting();
- extensionSettings[4].Name = "FTP Port";
- extensionSettings[4].ReadOnly = false;
- extensionSettings[4].Required = false;
- extensionSettings[4].Encrypted = false;
- extensionSettings[5] = new Setting();
- extensionSettings[5].Name = "Encrypt Delivery";
- extensionSettings[5].ReadOnly = false;
- extensionSettings[5].Required = false;
- extensionSettings[5].Encrypted = false;
- extensionSettings[6] = new Setting();
- extensionSettings[6].Name = "PGP Public Key";
- extensionSettings[6].ReadOnly = false;
- extensionSettings[6].Required = false;
- extensionSettings[6].Encrypted = true;
- extensionSettings[7] = new Setting();
- extensionSettings[7].Name = "File Name Format";
- extensionSettings[7].ReadOnly = false;
- extensionSettings[7].Required = true;
- extensionSettings[7].Encrypted = false;
- extensionSettings[8] = new Setting();
- extensionSettings[8].Name = "CSV Text Delimiter";
- extensionSettings[8].ReadOnly = false;
- extensionSettings[8].Required = true;
- extensionSettings[8].Encrypted = false;
- extensionSettings[9] = new Setting();
- extensionSettings[9].Name = "CSV Text Qualifier";
- extensionSettings[9].ReadOnly = false;
- extensionSettings[9].Required = true;
- extensionSettings[9].Encrypted = false;
- return extensionSettings;
- }
- }
-
- public string FileNameFormat
- {
- get
- {
- return _FileNameFormat;
- }
- set
- {
- _FileNameFormat = value;
- }
- }
-
- public string FTPFolder
- {
- get
- {
- return _ftpFolder;
- }
- set
- {
- _ftpFolder = value;
- }
- }
-
- public string FTPPassword
- {
- get
- {
- return _ftpPassword;
- }
- set
- {
- _ftpPassword = value;
- }
- }
-
- public string FTPPort
- {
- get
- {
- return _ftpPort;
- }
- set
- {
- _ftpPort = value;
- }
- }
-
- public string FTPUrl
- {
- get
- {
- return _ftpUrl;
- }
- set
- {
- _ftpUrl = value;
- }
- }
-
- public string FTPUsername
- {
- get
- {
- return _ftpUsername;
- }
- set
- {
- _ftpUsername = value;
- }
- }
-
- public string IsDeliveryEncrypted
- {
- get
- {
- return _IsDeliveryEncrypted;
- }
- set
- {
- _IsDeliveryEncrypted = value;
- }
- }
-
- public string PGPPublicKeyUID
- {
- get
- {
- return _PGPPublicKeyUID;
- }
- set
- {
- _PGPPublicKeyUID = value;
- }
- }
-
- // Nested Types
- internal class Strings
- {
- // Fields
- internal const string CSVTextDelimiter = "CSVTextDelimiter: ";
- internal const string CSVTextDelimiterName = "CSV Text Delimiter";
- internal const string CSVTextQualifier = "CSVTextQualifier: ";
- internal const string CSVTextQualifierName = "CSV Text Qualifier";
- internal const string FileNameFormat = "FileNameFormat";
- internal const string FileNameFormatName = "File Name Format";
- internal const string FTPFolder = "FTPFolder";
- internal const string FTPFolderName = "FTP Folder";
- internal const string FTPPassword = "FTP Password";
- internal const string FTPPasswordName = "FTP Password";
- internal const string FTPPort = "FTPPort";
- internal const string FTPPortName = "FTP Port";
- internal const string FTPUrl = "FTPUrl";
- internal const string FTPUrlName = "FTP Url";
- internal const string FTPUsername = "FTP Username";
- internal const string FTPUsernameName = "FTP Username";
- internal const string IsDeliveryEncrypted = "IsDeliveryEncrypted";
- internal const string IsDeliveryEncryptedName = "Encrypt Delivery";
- internal const string PGPPublicKeyUID = "PGPPublicKeyUID";
- internal const string PGPPublicKeyUIDName = "PGP Public Key";
-
- }
-
- }
-
- }