void GetDataFromString(string customPropertyValue)
 {
     if (!string.IsNullOrEmpty(customPropertyValue))
     {
         var xmlStateEl = XDocument.Parse(customPropertyValue);
         state.LoadFromXml(xmlStateEl);
     }
 }
Exemple #2
0
        DashboardState GetDataFromString(string customPropertyValue)
        {
            DashboardState dState = new DashboardState();

            if (!string.IsNullOrEmpty(customPropertyValue))
            {
                var xmlStateEl = XDocument.Parse(customPropertyValue);
                dState.LoadFromXml(xmlStateEl);
            }
            return(dState);
        }
        DashboardState GetStateFromCustomProperty()
        {
            var            customPropertyValue = dashboardViewer1.Dashboard.CustomProperties.GetValue(PropertyName);
            DashboardState state = new DashboardState();

            if (!string.IsNullOrEmpty(customPropertyValue))
            {
                var xmlStateEl = XDocument.Parse(customPropertyValue);
                state.LoadFromXml(xmlStateEl);
            }
            return(state);
        }
Exemple #4
0
        private void dashboardControl_DashboardLoaded(object sender, DevExpress.DashboardWpf.DashboardLoadedEventArgs e)
        {
            XElement data = e.Dashboard.UserData;

            if (data != null)
            {
                if (data.Element("DashboardState") != null)
                {
                    XDocument dStateDocument = XDocument.Parse(data.Element("DashboardState").Value);
                    dState.LoadFromXml(XDocument.Parse(data.Element("DashboardState").Value));
                }
            }
        }
        private void DashboardViewerUniconta_DashboardLoaded(object sender, DevExpress.DashboardWpf.DashboardLoadedEventArgs e)
        {
            Dashboard dasdboard = e.Dashboard;

            foreach (var item in dasdboard?.Items)
            {
                var name = dasdboard?.CustomProperties.GetValue(item.ComponentName);
                if (name != null)
                {
                    if (name[0] == '&')
                    {
                        item.Name = Uniconta.ClientTools.Localization.lookup(name.Substring(1));
                    }
                    ;
                }
            }

            if (!dasdboard.Title.ShowMasterFilterState)
            {
                rowFilter.Visibility = Visibility.Collapsed;
            }

            XElement data = e.Dashboard.UserData;

            if (data != null)
            {
                var state = data.Element("DashboardState");
                if (state != null)
                {
                    dState.LoadFromXml(XDocument.Parse(state.Value));
                }

                var fixedComps = data.Element("FixedCompanies");
                if (fixedComps != null)
                {
                    fixedCompanies = null;
                    var rootelement = XElement.Parse(fixedComps.ToString());
                    foreach (var el in rootelement.Elements())
                    {
                        var fxdComps = XDocument.Parse(el.ToString()).Elements("FixedCompany")
                                       .Select(p => new FixedCompany
                        {
                            CompanyId      = int.Parse(p.Element("CompanyId").Value),
                            DatasourceName = p.Element("DatasourceName").Value
                        }).ToList();
                        if (fixedCompanies != null)
                        {
                            fixedCompanies.AddRange(fxdComps);
                        }
                        else
                        {
                            fixedCompanies = fxdComps;
                        }
                    }

                    if (fixedCompanies != null)
                    {
                        for (int i = 0; i < fixedCompanies.Count; i++)
                        {
                            var comp     = CWDefaultCompany.loadedCompanies.FirstOrDefault(x => x.CompanyId == fixedCompanies[i].CompanyId) as Company;
                            var openComp = OpenFixedCompany(comp).GetAwaiter().GetResult();
                            if (openComp != null)
                            {
                                openComp.GenerateUserType();
                                LoadListOfTableTypes(openComp);
                            }
                            else
                            {
                                UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("UserNoAccessToCompany"), Uniconta.ClientTools.Localization.lookup("Information"));
                            }
                        }
                    }
                }

                var ldOnOpn = data.Element("LoadOnOpen");
                if (ldOnOpn != null)
                {
                    LoadOnOpen = bool.Parse(ldOnOpn.Value);
                }

                var userId = data.Element("LogedInUserIdFilter");
                if (userId != null)
                {
                    UserIdPropName = userId.Value;
                }

                var filters = data.Element("Filters");
                if (filters != null)
                {
                    var filtersBytes = Convert.FromBase64String(filters.Value);
                    var r            = StreamingManagerReuse.Create(filtersBytes);
                    int version      = r.readByte();
                    if (version != 0)
                    {
                        if (version < 3 && r.readBoolean())
                        {
                            int filterCount = (int)StreamingManager.readNum(r);
                            for (int i = 0; i < filterCount; i++)
                            {
                                var key = r.readString();
                                List <PropValuePair> propVal = new List <PropValuePair>();
                                var arrpropval = (PropValuePair[])r.ToArray(typeof(PropValuePair));
                                propVal = arrpropval.ToList();
                                lstOfFilters.Add(key, arrpropval);
                            }
                        }
                        else
                        {
                            int filterCount = (int)StreamingManager.readNum(r);
                            for (int i = 0; i < filterCount; i++)
                            {
                                var key       = r.readString();
                                var arrFilter = (FilterProperties[])r.ToArray(typeof(FilterProperties));
                                lstOfNewFilters.Add(key, arrFilter.ToList());
                            }
                        }
                    }
                    if (r.readBoolean())
                    {
                        if (version < 3)
                        {
                            int sortCount = (int)r.readNum();
                            for (int i = 0; i < sortCount; i++)
                            {
                                var          key      = r.readString();
                                var          arrSort  = (SortingProperties[])r.ToArray(typeof(SortingProperties));
                                FilterSorter propSort = new FilterSorter(arrSort);
                                lstOfSorters.Add(key, propSort);
                            }
                        }
                    }
                    r.Release();
                }
            }
            else
            {
                LoadOnOpen = true;  // for old saved dashboards
            }
            if (LoadOnOpen)
            {
                foreach (var ds in e.Dashboard.DataSources)
                {
                    dataSourceLoadingParams.Add(ds.ComponentName);
                }
            }
        }
        private void DashboardViewerUniconta_DashboardLoaded(object sender, DevExpress.DashboardWpf.DashboardLoadedEventArgs e)
        {
            Dashboard dasdboard = e.Dashboard;

            foreach (var item in dasdboard?.Items)
            {
                var name = dasdboard?.CustomProperties.GetValue(item.ComponentName);
                if (name != null)
                {
                    if (name[0] == '&')
                    {
                        item.Name = Uniconta.ClientTools.Localization.lookup(name.Substring(1));
                    }
                    ;
                }
            }

            if (!dasdboard.Title.ShowMasterFilterState)
            {
                rowFilter.Visibility = Visibility.Collapsed;
            }

            XElement data = e.Dashboard.UserData;

            if (data != null)
            {
                var state = data.Element("DashboardState");
                if (state != null)
                {
                    dState.LoadFromXml(XDocument.Parse(state.Value));
                }

                var fixedComps = data.Element("FixedCompanies");
                if (fixedComps != null)
                {
                    fixedCompanies = null;
                    var rootelement = XElement.Parse(fixedComps.ToString());
                    foreach (var el in rootelement.Elements())
                    {
                        var fxdComps = XDocument.Parse(el.ToString()).Elements("FixedCompany")
                                       .Select(p => new FixedCompany
                        {
                            CompanyId      = int.Parse(p.Element("CompanyId").Value),
                            DatasourceName = p.Element("DatasourceName").Value
                        }).ToList();
                        if (fixedCompanies != null)
                        {
                            fixedCompanies.AddRange(fxdComps);
                        }
                        else
                        {
                            fixedCompanies = fxdComps;
                        }
                    }

                    if (fixedCompanies != null)
                    {
                        for (int i = 0; i < fixedCompanies.Count; i++)
                        {
                            var comp     = CWDefaultCompany.loadedCompanies.FirstOrDefault(x => x.CompanyId == fixedCompanies[i].CompanyId) as Company;
                            var openComp = OpenFixedCompany(comp).GetAwaiter().GetResult();
                            if (openComp != null)
                            {
                                LoadListOfTableTypes(openComp);
                            }
                            else
                            {
                                UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("UserNoAccessToCompany"), Uniconta.ClientTools.Localization.lookup("Information"));
                            }
                        }
                    }
                }

                var ldOnOpn = data.Element("LoadOnOpen");
                if (ldOnOpn != null)
                {
                    LoadOnOpen = bool.Parse(ldOnOpn.Value);
                }

                var userId = data.Element("LogedInUserIdFilter");
                if (userId != null)
                {
                    UserIdPropName = userId.Value;
                }

                #region Dashboard user fields

                var dshbdUserFls = data.Element("DashboardUserFields");
                if (dshbdUserFls != null)
                {
                    var nodes = dshbdUserFls.Nodes();
                    dashboardUserFields = new Dictionary <string, List <DashboardUserField> >();
                    foreach (var node in nodes)
                    {
                        if (node is XElement)
                        {
                            var name    = ((XElement)node).Name;
                            var rt      = XElement.Parse(node.ToString());
                            var userLst = new List <DashboardUserField>();
                            foreach (var el in rt.Elements())
                            {
                                var xml      = el.ToString();
                                var fxdComps = XDocument.Parse(xml).Elements("DashboardUserField")
                                               .Select(p => new DashboardUserField
                                {
                                    FieldName = p.Element("FieldName").Value,
                                    Value     = p.Element("Value").Value,
                                    DataType  = (byte)(p.Element("DataType") != null ? Convert.ToByte(p.Element("DataType").Value) : 0)
                                }).ToList();
                                userLst.AddRange(fxdComps);
                            }
                            dashboardUserFields.Add(name.ToString(), userLst);
                        }
                    }
                }
                #endregion
            }
            else
            {
                LoadOnOpen = true;  // for old saved dashboards
            }
            if (LoadOnOpen)
            {
                foreach (var ds in e.Dashboard.DataSources)
                {
                    dataSourceLoadingParams.Add(ds.ComponentName);
                }
            }
        }