private void ShowReport(Report report) { report.Parameters.Clear(); foreach (var ctrl in this.ReportParameterSearch) { if (ctrl.HasValue) ctrl.Set(report.Parameters); } foreach (DataSource ds in report.DataSources) { SelectSql sql = new SelectSql(); sql.Custom(ds.ReportSql.ToQuery()); foreach (var ctrl in this.FieldSearchControls) { if (!ctrl.AllowNull && ctrl.Value.IsNull()) { base.RadAlert(String.Format("Lütfen {0} Alanı için Veri Giriniz.", ctrl.Label)); return; } if (String.Equals(ctrl.DataSourceName, ds.DataSourceName)) ctrl.Set(sql); else { if (!String.IsNullOrEmpty(ctrl.AlsoAvailableFor)) { string[] arr = ctrl.AlsoAvailableFor.Split(','); foreach(string dsName in arr) { if (String.Equals(dsName, ds.DataSourceName, StringComparison.OrdinalIgnoreCase)) { ctrl.Set(sql); } } } } } SqlQuery query = sql.ToQuery();//Düzeltme (İç İçe Sorgu Yazlılmasın Diye) Eğer Sıkıntı Çıkarırısa Select * from (...) dene. foreach(var par in query.Parameters) { if (par.ParameterName.Contains(".")) { string orginal = "@" + par.ParameterName; par.ParameterName = par.ParameterName.Replace(".", "");//Düzeltme query.Text.Replace(orginal, "@" + par.ParameterName); } } ds.ReportSelectQuery = query; string sqlString = ds.ReportSelectQuery.Text.ToString(); foreach (var ctrl in this.SqlParameterSearch) { if (ctrl.Value.IsNull()) { base.RadAlert(String.Format("Lütfen {0} Alanı için Veri Giriniz.", ctrl.ParameterName)); return; } if (ctrl.AlsoAddAsReportParameter) report.Parameters.Add(ctrl.ParameterName, ctrl.Value); if (sqlString.Contains(ctrl.ParameterName)) ctrl.Set(ds.ReportSelectQuery); } } switch(Sessions.ShowType) { case ShowReportType.PopUp: ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "ShowReport", "ShowReportPage();", true); break; case ShowReportType.Redirect: base.Response.Redirect("~/Pages/ShowReportPagePopup.aspx"); break; default: throw new NotSupportedException(Sessions.ShowType.ToString()); } // ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "ShowReport", "ShowReportPage();", true); }
protected void OnTransferReport(object sender, EventArgs e) { if (this.beReport.Entity == null) { base.RadAlert("Lütfen Aktarılcak Raporu Seçiniz"); return; } if (this.cbxConnection.Value.IsNull()) { base.RadAlert("Aktarılacak Raporu Seçmediniz"); return; } Connection destConnection = base.Cmd.SelectById<Connection>(this.cbxConnection.Value.ConvertTo<int>()); Report report = base.Cmd.SelectById<Report>(this.beReport.Value); Module module = base.Cmd.SelectById<Module>(report.ModuleId); if (null == module) { base.RadAlert("Rapor için Modül Belirtilmemiş, Aktarma İşlemi Sonlandırıldı"); return; } IEnumerable<DataSource> dataSources = Fluent.Select<DataSource>().SelectAll().Where().Equals(d => d.ReportId, report.Id) .AsSelect().Query(base.Cmd); if (dataSources.IsEmptyList()) { base.RadAlert("Rapor için Veri Kaynağı Belirtilmemiş, Aktarma İşlemi Sonlandırıldı"); return; } using (DbConnection conn = DataUtils.CreateEmptyConnection(DbType.SqlServer)) { conn.ConnectionString = destConnection.ConnectionString; conn.Open(); using (ITransactionalDbAccess dataAccess = DataUtils.CreatTransactionalDataAccess(conn)) { //Öncelikle Modül Gerekli. ICommandAdapter destCmd = DataUtils.CreateCommandAdapter(dataAccess); Module destModule = Fluent.Select<Module>().SelectAll().Where().Equals(m => m.Name, module.Name).AsSelect().QuerySingle(destCmd); if (destModule == null) { destModule = new Module(); destModule.CopyPropertiesFrom(module); destCmd.Insert(destModule); } Report reportDest =Fluent.Select<Report>().SelectAll().Where().Equals(r => r.ReportName, report.ReportName).AsSelect() .QuerySingle(destCmd); if (reportDest == null) { reportDest = new Report(); reportDest.CopyPropertiesFrom(report); reportDest.ModuleId = destModule.Id; destCmd.Insert(reportDest); } foreach (DataSource ds in report.DataSources) { Connection sourceConn = destCmd.SelectById<Connection>(ds.ConnectionId); Connection destConn = Fluent.Select<Connection>().SelectAll().Where().Equals(c => c.Name, sourceConn.Name).AsSelect().QuerySingle(destCmd); if (destConn == null) { destConn = new Connection(); destConn.CopyPropertiesFrom(sourceConn); destCmd.Insert(destConn); } DataSource destDs = Fluent.Select<DataSource>().SelectAll().Where().Equals(d => d.DataSourceName, ds.DataSourceName) .And().Equals(d => d.ReportId, reportDest.Id).AsSelect().QuerySingle(Cmd); if (destDs == null) { destDs = new DataSource(); destDs.CopyPropertiesFrom(ds); destDs.ConnectionId = destConn.Id; destCmd.Insert(destDs); } } } } }