public static DevExpress.DashboardCommon.Dashboard CreateDashBoard(this IDashboardDefinition template, IObjectSpace objectSpace, FilterEnabled filterEnabled) { var dashboard = new DevExpress.DashboardCommon.Dashboard(); try { if (!string.IsNullOrEmpty(template.Xml)) { dashboard = LoadFromXml(template); dashboard.ApplyModel(filterEnabled, template, objectSpace); } foreach (var typeWrapper in template.DashboardTypes.Select(wrapper => new { wrapper.Type, Caption = GetCaption(wrapper) })) { var wrapper = typeWrapper; var dsource = dashboard.DataSources.FirstOrDefault(source => source.Name.Equals(wrapper.Caption)); var objects = objectSpace.CreateDashboardDataSource(wrapper.Type); if (dsource != null) { dsource.Data = objects; } else if (!dashboard.DataSources.Contains(ds => ds.Name.Equals(wrapper.Caption))) { dashboard.AddDataSource(typeWrapper.Caption, objects); } } } catch (Exception e) { dashboard.Dispose(); Tracing.Tracer.LogError(e); } return(dashboard); }
private void btnKaydet_ItemClick(object sender, ItemClickEventArgs e) { DevExpress.DashboardCommon.Dashboard rep = new DevExpress.DashboardCommon.Dashboard(); int iEkleyenID = 0; iEkleyenID = Genel.AktifKullaniciID; DashboardParameter prmUser = new DashboardParameter(); prmUser.Name = "EkleyenID"; prmUser.Type = typeof(System.Int32); prmUser.Value = iEkleyenID; prmUser.Description = "EkleyenID"; prmUser.Visible = false; rep.Parameters.Add(prmUser); MemoryStream stream = new MemoryStream(); rep.SaveToXml(stream); stream.Position = 0; byte[] RaporData = Genel.StreamToByteArray(stream); var IslemEkle = data.IUD_Evraklar(1, -1, RaporData, txtAdi.Text, txtAdi.Text, -1, -1, true, false, -1, -1, true, Genel.AktifKullaniciID).ToList(); if (IslemEkle != null && IslemEkle.FirstOrDefault().ID > 0) { //Ayar.InfoMesajGoster(Genel.DilGetirMesaj(1017), Ayar.MesajTipi.Bilgi, this); } }
public static DevExpress.DashboardCommon.Dashboard CreateDashBoard(this IDashboardDefinition template, IObjectSpace objectSpace, FilterEnabled filterEnabled) { var dashboard = new DevExpress.DashboardCommon.Dashboard(); try { if (!string.IsNullOrEmpty(template.Xml)) { dashboard = LoadFromXml(template); dashboard.ApplyModel(filterEnabled, template, objectSpace); } foreach (var typeWrapper in template.DashboardTypes.Select(wrapper => new { wrapper.Type, Caption = GetCaption(wrapper) })) { var wrapper = typeWrapper; var dsource = dashboard.DataSources.FirstOrDefault(source => source.Name.Equals(wrapper.Caption)); var objects = objectSpace.CreateDashboardDataSource(wrapper.Type); if (dsource != null) { dsource.Data = objects; } else if (!dashboard.DataSources.Contains(ds => ds.Name.Equals(wrapper.Caption))) { dashboard.AddDataSource(typeWrapper.Caption, objects); } } } catch (Exception e) { dashboard.Dispose(); Tracing.Tracer.LogError(e); } return dashboard; }
public static void ApplyModel(this DevExpress.DashboardCommon.Dashboard dashboard, RuleMode ruleMode, IDashboardDefinition template, IModelApplication model) { var dataSources = GetDataSources(dashboard, ruleMode, template, model); foreach (var adapter in dataSources) { if (adapter.ModelDataSource is IModelDashboardDataSourceFilter filter) { var criteria = ApplyFilter(filter.Filter, adapter.DataSource.Filter); adapter.DataSource.Filter = criteria?.ToString(); if (adapter.DataSource is DashboardSqlDataSource dashboardSqlDataSource) { foreach (var selectQuery in dashboardSqlDataSource.Queries.OfType <SelectQuery>().Where(query => Regex.IsMatch(query.Name, filter.TableName))) { if (filter.TopReturnedRecords > 0) { selectQuery.Top = filter.TopReturnedRecords; } selectQuery.FilterString = criteria?.ToString(); } } } else if (adapter.ModelDataSource is IModelDashboardDataSourceParameter parameter) { parameter.ApplyValue(dashboard.Parameters[parameter.ParameterName]); } } }
private static void MigrateDatasourceTypes(DevExpress.DashboardCommon.Dashboard dashboard) { var objectDataSources = dashboard.DataSources.OfType <DashboardObjectDataSource>().ToArray(); foreach (var objectDataSource in objectDataSources) { var dashboardItems = dashboard.Items.OfType <DataDashboardItem>() .Where(item => item.DataSource == objectDataSource).ToArray(); if (objectDataSource.Constructor != null) { var typeName = objectDataSource.Constructor.Parameters.First().Value; var dataSource = new DashboardObjectDataSource { DataSourceType = XafTypesInfo.Instance.FindTypeInfo($"{typeName}").Type, Name = objectDataSource.Name, ComponentName = objectDataSource.ComponentName }; dashboard.DataSources.Remove(objectDataSource); dashboard.DataSources.Add(dataSource); foreach (var dataDashboardItem in dashboardItems) { dataDashboardItem.DataSource = dataSource; } } } }
static void Filter(IDashboardDefinition template, DevExpress.DashboardCommon.Dashboard dashboard) { //var types = template.DashboardTypes.Select(tw => tw.Caption).ToArray(); //for (int i = dashboard.DataSources.Count - 1; i >= 0; i--) // if (!types.Contains(dashboard.DataSources[i].Name)) // dashboard.DataSources.RemoveAt(i); }
public static DevExpress.DashboardCommon.Dashboard CreateDashBoard(this IDashboardDefinition template, IObjectSpace objectSpace, bool filter) { var dashboard = new DevExpress.DashboardCommon.Dashboard(); try { LoadFromXml(template.Xml, dashboard); foreach (ITypeWrapper typeWrapper in template.DashboardTypes) { ITypeWrapper wrapper = typeWrapper; if (dashboard.DataSources.Contains(ds => ds.Name.Equals(wrapper.Caption))) { Type dashBoardObjectType = DashBoardObjectType(template, dashboard, typeWrapper); if (dashBoardObjectType != null) { ITypeWrapper wrapper1 = typeWrapper; var dataSource = dashboard.DataSources.First(ds => ds.Name.Equals(wrapper1.Caption)); dataSource.Data = GetObjects(objectSpace, dashBoardObjectType); } } else if (!dashboard.DataSources.Contains(ds => ds.Name.Equals(wrapper.Caption))) dashboard.DataSources.Add(new DashboardObjectDataSource(typeWrapper.Caption, GetObjects(objectSpace, typeWrapper.Type))); } if (filter) Filter(template, dashboard); } catch (Exception e) { dashboard.Dispose(); Tracing.Tracer.LogError(e); } return dashboard; }
static IEnumerable <DataSourceAdapter> GetDataSources(DevExpress.DashboardCommon.Dashboard dashboard, FilterEnabled filterEnabled, IDashboardDefinition template, IObjectSpace objectSpace) { var modelDashboardModule = ((IModelApplicationDashboardModule)ApplicationHelper.Instance.Application.Model).DashboardModule; return(modelDashboardModule.DataSources.Where(source => source.NodeEnabled && CanApply(source, filterEnabled, template, objectSpace)).Select(modelDataSource => { var dataSource = dashboard.DataSources.FirstOrDefault(source => String.Equals(source.Name.Trim(), modelDataSource.DataSourceName.Trim(), StringComparison.CurrentCultureIgnoreCase)); return new DataSourceAdapter(dataSource, modelDataSource); }).Where(adapter => adapter.ModelDataSource != null)); }
void Form1_Load(object sender, EventArgs e) { Dashboard dashboard = new DevExpress.DashboardCommon.Dashboard(); dashboard.LoadFromXml(@"Data\CustomerSupport.xml"); dashboard.DataSources[0].Data = new CustomerSupportData( DataLoader.LoadCustomerSupport(), DataLoader.LoadEmployees() ).CustomerSupport; dashboardViewer1.Dashboard = dashboard; }
public static void SynchronizeModel(this DevExpress.DashboardCommon.Dashboard dashboard, IObjectSpace objectSpace, IDashboardDefinition template) { var dataSources = GetDataSources(dashboard, FilterEnabled.Always, template, objectSpace); foreach (var dataSource in dataSources) { var filter = dataSource.ModelDataSource as IModelDashboardDataSourceFilter; if (filter != null) { dataSource.DataSource.Filter = filter.SynchronizeFilter(dataSource.DataSource.Filter); } } }
static DevExpress.DashboardCommon.Dashboard LoadFromXml(IDashboardDefinition dashboardDefinition) { var dashboard = new DevExpress.DashboardCommon.Dashboard(); using (var me = new MemoryStream()) { var sw = new StreamWriter(me); sw.Write(dashboardDefinition.Xml); sw.Flush(); me.Seek(0, SeekOrigin.Begin); dashboard.LoadFromXml(me); sw.Close(); me.Close(); } return dashboard; }
static void LoadFromXml(string xml, DevExpress.DashboardCommon.Dashboard dashboard) { if (xml != null) { using (var me = new MemoryStream()) { var sw = new StreamWriter(me); sw.Write(xml); sw.Flush(); me.Seek(0, SeekOrigin.Begin); dashboard.LoadFromXml(me); sw.Close(); me.Close(); } } }
static DevExpress.DashboardCommon.Dashboard LoadFromXml(IDashboardDefinition dashboardDefinition) { var dashboard = new DevExpress.DashboardCommon.Dashboard(); using (var me = new MemoryStream()) { var sw = new StreamWriter(me); sw.Write(dashboardDefinition.Xml); sw.Flush(); me.Seek(0, SeekOrigin.Begin); dashboard.LoadFromXml(me); sw.Close(); me.Close(); } return(dashboard); }
public S_Evraklar_Result Evrak = new S_Evraklar_Result(); //Model.S_Evraklar_Result Evrak = new Model.S_Evraklar_Result(); public void Datagetir() { //açınca ekran kitleniyor. incelemek lazım. //SplashScreenManager.ShowForm(this, typeof(BarduckCRM.Bekleyiniz), true, true); //SplashScreenManager.CloseForm(); Evrak = data.S_Evraklar(DashboardID, true, 1).FirstOrDefault(); //Genel.PrmDb.S_Evraklar(DashboardID, true, Genel.DilID).FirstOrDefault(); var DosyaYolu = data.S_AyarKarakter(2, 1).FirstOrDefault().Deger; //Genel.PrmDb.S_AyarKarakter(2, Genel.DilID).FirstOrDefault().Deger; DosyaYolu += Evrak.DosyaAdi + ".xml"; byte[] bytearry = data.S_DosyaGet(DosyaYolu).FirstOrDefault(); if (bytearry == null) { //Ayar.InfoMesajGoster(Genel.DilGetirMesaj(0), Ayar.MesajTipi.Hata, this); return; } Stream RepData = Genel.ByteArrayToStream(bytearry); DevExpress.DashboardCommon.Dashboard dasboard = new DevExpress.DashboardCommon.Dashboard(); dasboard.BeginUpdateLayout(); dasboard.LoadFromXml(RepData); dasboard.DataLoading += dasboard_DataLoading; dasboard.EndUpdateLayout(); // DataSet datasourcelist = Ayar.DsGetir(DashboardID, MusteriID, ProjeID, AktiviteID, Parametre4, Parametre5, Parametre6, Parametre7, Parametre8, Parametre9, Parametre10); //// dasboard.DataSources.Clear(); // foreach (DataTable item in datasourcelist.Tables) // { // dasboard.AddDataSource(item.TableName, item); // //if (dasboard.DataSources.Where(z => z.Name == item.TableName).FirstOrDefault() == null) // //{ // // dasboard.AddDataSource(item.TableName, item); // //} // } if (dasboard != null) { dashboardViewer1.Dashboard = dasboard; // dashboardViewer1.PopulateUnusedDataSources = true; // dashboardViewer1.ReloadData(); } }
public static void ApplyModel(this DevExpress.DashboardCommon.Dashboard dashboard, FilterEnabled filterEnabled, IDashboardDefinition template, IObjectSpace objectSpace) { var dataSources = GetDataSources(dashboard, filterEnabled, template, objectSpace); foreach (var adapter in dataSources) { var filter = adapter.ModelDataSource as IModelDashboardDataSourceFilter; if (filter != null) { adapter.DataSource.Filter = filter.ApplyFilter(adapter.DataSource.Filter); } var parameter = adapter.ModelDataSource as IModelDashboardDataSourceParameter; if (parameter != null) { parameter.ApplyValue(dashboard.Parameters[parameter.ParameterName]); } } }
public static DevExpress.DashboardCommon.Dashboard ToDashboard(this IDashboardDefinition dashboardDefinition) { var dashboard = new DevExpress.DashboardCommon.Dashboard(); if (!string.IsNullOrWhiteSpace(dashboardDefinition.Xml)) { using (var me = new MemoryStream()){ var sw = new StreamWriter(me); var xml = dashboardDefinition.Xml; xml = Regex.Replace(xml, $"({typeof(ParameterLessProxyCollection).FullName}, {typeof(ParameterLessProxyCollection).Namespace}, Version=)([^,]*)", "${1}" + XpandAssemblyInfo.Version, RegexOptions.IgnoreCase); sw.Write(xml); sw.Flush(); me.Seek(0, SeekOrigin.Begin); dashboard.LoadFromXml(me); sw.Close(); me.Close(); } } return(dashboard); }
private ASPxDashboard GetASPxDashboardDesigner() { _dashboardDesigner = new ASPxDashboard { Width = Unit.Percentage(100), AllowOpenDashboard = false, AllowCreateNewDashboard = false, IncludeDashboardIdToUrl = false, IncludeDashboardStateToUrl = false, WorkingMode = GetWorkingMode(), MobileLayoutEnabled = ((IModelDashboardModuleASPxDashboard)((IModelApplicationDashboardModule)Model.Application).DashboardModule).MobileLayoutEnabled }; var xpandDashboardDataProvider = ((XpandDashboardDataProvider)DashboardsModule.DataProvider); var dashboardCollectionDataSourceFillService = (IXpandDashboardDataSourceFillService)AttachService(xpandDashboardDataProvider); dashboardCollectionDataSourceFillService.FillService.LoadBeforeParameters += (sender, args) => args.Handled = new[] { RuleMode.Always, RuleMode.DesignTime }.Contains(Definition.EditParameters); _dashboard = Definition.GetDashboard(_application, RuleMode.DesignTime, dashboardCollectionDataSourceFillService, editParameters: dashboard1 => { _dashboardHasParameters = dashboard1.Parameters.Any(); }); _dashboardDesigner.DashboardId = _dashboard.Title.Text; var dashboardStorage = new XpandDataSourceStorage(_application.Model); _dashboardDesigner.SetDataSourceStorage(dashboardStorage); _dashboardDesigner.CustomJSProperties += DashboardDesigner_CustomJSProperties; _dashboardDesigner.ClientSideEvents.DashboardInitialized = @"function(dashboardControl, e) { if (dashboardControl.cpDashboardHasParameters) dashboardControl.ShowParametersDialog(); }"; _dashboardDesigner.DashboardAdding += DashboardAdding; _dashboardDesigner.DashboardLoading += DashboardLoading; _dashboardDesigner.DashboardSaving += DashboardSaving; return(_dashboardDesigner); }
public static DashboardDatasourceFilterList CreateDashboardDatasourceFilterList( this DevExpress.DashboardCommon.Dashboard dashboard, IDashboardDefinition dashboardDefinition, RuleMode ruleMode, XafApplication application) { var objectSpace = application.CreateObjectSpace(typeof(DashboardDatasourceFilter)); var dashboardDatasourceFilterList = new DashboardDatasourceFilterList(); var dataSources = dashboard.GetDataSources(ruleMode, dashboardDefinition, application.Model); foreach (var item in dataSources.OrderBy(tuple => tuple.ModelDataSource.Index)) { if (item.ModelDataSource is IModelDashboardDataSourceFilter modelFilter && modelFilter.ShowInPopupView) { var filter = objectSpace.CreateObject <DashboardDatasourceFilter>(); filter.ID = item.ModelDataSource.Id(); filter.Filter = modelFilter.Filter; filter.DataSourceName = item.DataSource.Name; filter.TopReturnedRecords = modelFilter.TopReturnedRecords; filter.ShowPersistentMembersOnly = modelFilter.ShowPersistentMembersOnly; dashboardDatasourceFilterList.Filters.Add(filter); } } return(dashboardDatasourceFilterList); }
public static DevExpress.DashboardCommon.Dashboard CreateDashBoard(this IDashboardDefinition template, IObjectSpace objectSpace, bool filter) { var dashboard = new DevExpress.DashboardCommon.Dashboard(); try { LoadFromXml(template.Xml, dashboard); foreach (ITypeWrapper typeWrapper in template.DashboardTypes) { ITypeWrapper wrapper = typeWrapper; if (dashboard.DataSources.Contains(ds => ds.Name.Equals(wrapper.Caption))) { Type dashBoardObjectType = DashBoardObjectType(template, dashboard, typeWrapper); if (dashBoardObjectType != null) { ITypeWrapper wrapper1 = typeWrapper; var dataSource = dashboard.DataSources.First(ds => ds.Name.Equals(wrapper1.Caption)); dataSource.Data = GetObjects(objectSpace, dashBoardObjectType); } } else if (!dashboard.DataSources.Contains(ds => ds.Name.Equals(wrapper.Caption))) { dashboard.DataSources.Add(new DashboardObjectDataSource(typeWrapper.Caption, GetObjects(objectSpace, typeWrapper.Type))); } } if (filter) { Filter(template, dashboard); } } catch (Exception e) { dashboard.Dispose(); Tracing.Tracer.LogError(e); } return(dashboard); }
static Type DashBoardObjectType(IDashboardDefinition template, DevExpress.DashboardCommon.Dashboard dashboard, ITypeWrapper typeWrapper) { var wrapper = template.DashboardTypes.FirstOrDefault(type => type.Caption.Equals(dashboard.DataSources.First(ds => ds.Name.Equals(typeWrapper.Caption)).Name)); return(wrapper != null ? wrapper.Type : null); }
private static void AddNewDataSources(IDashboardDefinition dashboardDefinition, DevExpress.DashboardCommon.Dashboard dashboard) { foreach (var typeWrapper in dashboardDefinition.DashboardTypes) { var exists = dashboard.DataSources.OfType <DashboardObjectDataSource>() .Any(source => Equals(source.DataSource, typeWrapper.Type)); if (!exists) { var dataSource = new DashboardObjectDataSource { DataSourceType = typeWrapper.Type, Name = CaptionHelper.GetClassCaption(typeWrapper.Type.FullName), ComponentName = typeWrapper.Type.Name }; dashboard.DataSources.Add(dataSource); } } }
private static void AddNewDataSources(IDashboardDefinition dashboardDefinition, DevExpress.DashboardCommon.Dashboard dashboard) { var dashboardTypesCount = dashboardDefinition.DashboardTypes.Count; if (dashboardTypesCount > 1) { throw new UserFriendlyException($"{dashboardDefinition.Name} contains {dashboardTypesCount} dashboard types. Only one dashboard type is supported."); } var wrapper = dashboardDefinition.DashboardTypes.First(); var dataSource = new DashboardObjectDataSource { DataSourceType = wrapper.Type, Name = nameof(DashboardObjectDataSource), ComponentName = nameof(DashboardObjectDataSource) }; dashboard.DataSources.Add(dataSource); }
public static IEnumerable <(IDashboardDataSource DataSource, IModelDashboardDataSource ModelDataSource)> GetDataSources(this DevExpress.DashboardCommon.Dashboard dashboard, RuleMode ruleMode, IDashboardDefinition template, IModelApplication model) { var modelDashboardModule = ((IModelDashboardModuleDataSources)((IModelApplicationDashboardModule)model).DashboardModule); return(modelDashboardModule.DataSources .Where(source => source.NodeEnabled && CanApply(source, ruleMode, template)).Select(modelDataSource => { var dataSource = dashboard.DataSources.FirstOrDefault(source => Regex.IsMatch(source.Name, modelDataSource.DataSourceName, RegexOptions.IgnoreCase) && Regex.IsMatch(source.GetType().Name, modelDataSource.DatasourceType, RegexOptions.IgnoreCase)); return (DataSource: dataSource, ModelDataSource: modelDataSource); }).Where(tuple => tuple.DataSource != null && tuple.ModelDataSource != null)); }
private static void ConfigureDashboard(IDashboardDefinition dashboardDefinition, RuleMode ruleMode, IXpandDashboardDataSourceFillService dashboardCollectionDataSourceFillService, DataSourceOptionsContainer options, Action <DevExpress.DashboardCommon.Dashboard> editParameters, DashboardDatasourceFilterList datasourceFilterList, DevExpress.DashboardCommon.Dashboard dashboard) { var canEditParameters = new[] { ruleMode, RuleMode.Always }.Contains(dashboardDefinition.EditParameters); if (canEditParameters) { editParameters(dashboard); } dashboardCollectionDataSourceFillService.FillService.DatasourceCreating += (sender, args) => { var filter = datasourceFilterList.Filters.LastOrDefault(_ => _.DataSourceName == args.TargetType.Name); if (filter != null) { dashboardCollectionDataSourceFillService.TopReturnedRecords = filter.TopReturnedRecords; dashboardCollectionDataSourceFillService.ShowPersistentMembersOnly = filter.ShowPersistentMembersOnly; } }; if (options != null) { options.ObjectDataSourceLoadingBehavior = DocumentLoadingBehavior.LoadAsIs; } }
public static void SaveDashboard(this IObjectSpace objectSpace, DevExpress.DashboardCommon.Dashboard dashboard, IDashboardDefinition template, MemoryStream memoryStream) { dashboard.SynchronizeModel(objectSpace, template); dashboard.SaveToXml(memoryStream); dashboard.ApplyModel(FilterEnabled.Always, template, objectSpace); }
private void btnTasarim_ItemClick(object sender, ItemClickEventArgs e) { //DevExpress.DashboardCommon.Dashboard dasboard = new DevExpress.DashboardCommon.Dashboard(); //var DosyaYolu = data.S_AyarKarakter(2, 1).ToList().FirstOrDefault().Deger + "dash.xml";//gv.GetRowCellValue(iRowID, "DosyaAdi").ToString() + ".xml"; //if (DosyaYolu == null) // return; //byte[] bytearry = data.S_DosyaGet(DosyaYolu).FirstOrDefault(); //if (bytearry != null) //{ // Stream RepData = Genel.ByteArrayToStream(bytearry); // dasboard.LoadFromXml(RepData); //} ////DataSet datasourcelist = Ayar.DsGetir(iSelectedReportID, 1, 1, 1, 1, 1, 1, 1, 1, 1, 99, true); //////dasboard.DataSources.Clear(); ////foreach (DataTable item in datasourcelist.Tables) ////{ //// if (dasboard.DataSources.Where(z => z.Name == item.TableName).FirstOrDefault() == null) //// { //// dasboard.AddDataSource(item.TableName, item); //// } ////} ////dasboard.DataLoading += dasboard_DataLoading; //DashboardTasarim frm = new DashboardTasarim(dasboard); //frm.Show(); #region Dashboard var DosyaYolu = data.S_AyarKarakter(2, 1).FirstOrDefault().Deger + DosyaAdi + ".xml"; byte[] bytearry = data.S_DosyaGet(DosyaYolu).FirstOrDefault(); if (bytearry != null) { Stream RepData = Genel.ByteArrayToStream(bytearry); DevExpress.DashboardCommon.Dashboard dasboard = new DevExpress.DashboardCommon.Dashboard(); dasboard.LoadFromXml(RepData); DataSet datasourcelist = Genel.DsGetir(DashboardID, true); //dasboard.DataSources.Clear(); foreach (DataTable item in datasourcelist.Tables) { if (dasboard.DataSources.Where(z => z.Name == item.TableName).FirstOrDefault() == null) { dasboard.AddDataSource(item.TableName, item); } } dasboard.DataLoading += dasboard_DataLoading; DashboardTasarim rep = new DashboardTasarim(dasboard); rep.ShowDialog(); if (rep.SaveDashboard) { MemoryStream stream = new MemoryStream(); rep.Dashboard.SaveToXml(stream); stream.Position = 0; byte[] RaporData = Genel.StreamToByteArray(stream); data.IUD_Evraklar(4, DashboardID, RaporData, null, null, null, null, null, null, null, null, true, Genel.AktifKullaniciID); } } #endregion }
public DashboardTasarim(DevExpress.DashboardCommon.Dashboard dashboard) { InitializeComponent(); dashboardDesigner1.Dashboard = dashboard; }