if (Context.Parameters["ClassName"] == null ||
Context.Parameters["ClassName"] != "ActionForReports")
return;
base.Install(stateSaver);
try
{
// Récupération du chemin complet de l'assembly
string assemblyPath = Context.Parameters["assemblypath"];
string[] splitPath = assemblyPath.Split(new string[] { @"\" }, StringSplitOptions.None);
// Récupération du répertoire d'installation
string assemblyFile = splitPath[splitPath.Length - 1];
string installFolder = assemblyPath.Substring(0, assemblyPath.LastIndexOf(
string.Format(@"\{0}", assemblyFile)));
FrmReportCustomInstaller connexionForm = new FrmReportCustomInstaller(installFolder);
if (DialogResult.OK != connexionForm.ShowDialog())
throw new InstallException("Erreur lors de l'installation");
}
catch (InstallException ex)
throw ex;
catch (Exception ex)
// Création du répertoire
if (this.CheckExist(ItemTypeEnum.Folder, "/", "ArticleReportProject") == false)
rs.CreateFolder("ArticleReportProject", "/", null);
if (this.CheckExist(ItemTypeEnum.Folder, "/", "Data Sources") == false)
rs.CreateFolder("Data Sources", "/", null);
DataSourceDefinition dsAdv = new DataSourceDefinition();
dsAdv.CredentialRetrieval = CredentialRetrievalEnum.Store;
dsAdv.ConnectString = String.Format(
@"Data Source={0};Initial Catalog=AdventureWorks", txtRSReportServer.Text.Trim());
dsAdv.Enabled = true;
dsAdv.OriginalConnectStringExpressionBased = false;
dsAdv.WindowsCredentials = false;
dsAdv.ImpersonateUser = false;
dsAdv.Extension = "SQL";
dsAdv.Prompt = null;
dsAdv.UserName = "sa";
dsAdv.Password = "MonMotDePasse";
rs.CreateDataSource("AdvDataSource ", "/Data Sources", true, dsAdv, null);
DirectoryInfo di = new DirectoryInfo(this.folderName);
FileInfo[] rapports = di.GetFiles("*.rdl");
Byte[] reportDefinition = null;
System.IO.FileStream stream = System.IO.File.OpenRead(f.FullName);
reportDefinition = new Byte[stream.Length];
stream.Read(reportDefinition, 0, (int)stream.Length);
stream.Close();
Warning[] warnings = rs.CreateReport(normalName, "/ArticleReportProject", true, reportDefinition, null);
XmlDocument doc = new XmlDocument();
MemoryStream memoryStream = new MemoryStream(reportDefinition);
doc.Load(memoryStream);
// Récupération des DataSources incluses dans le document XML
XmlNodeList listXmlDataSources = doc.GetElementsByTagName("DataSource");
ArrayList lstDataSources = new ArrayList();
foreach (XmlNode xmlDs in listXmlDataSources)
// Récupération de la DataSourceReference
String dataSourceReference = xmlDs.FirstChild.InnerText;
string dataSourceName = xmlDs.Attributes["Name"].Value;
DataSource newDS = new DataSource();
DataSourceReference dsRef = new DataSourceReference();
dsRef.Reference = string.Format("/Data Sources/{0}", dataSourceReference);
newDS.Item = dsRef;
newDS.Name = dataSourceName;
lstDataSources.Add(newDS);
DataSource[] newDataSources = (DataSource[])lstDataSources.ToArray(typeof(DataSource));
rs.SetItemDataSources(String.Format("/ArticleReportProject/{0}", normalName), newDataSources);