예제 #1
0
        public void DeleteProfile(Profile profile)
        {
            bool wasActive = profile.Active;

            Profiles.Remove(profile);

            (
                from p in XmlConfig.Elements("profile")
                where (string)p.Element("profileId") == profile.ProfileId
                select p
            ).FirstOrDefault().Remove();


            if (wasActive)
            {
                if (Profiles.Count > 0)
                {
                    Profile newCurrent = Profiles[0];
                    DefaultProfileId = newCurrent.ProfileId;
                    CurrentProfile   = newCurrent;
                }
                else
                {
                    DefaultProfileId = null;
                    CurrentProfile   = null;
                }
            }

            XmlConfig.Save(PROFILES_XML);
        }
예제 #2
0
        private void LoadProfiles()
        {
            string defaultProfileId = DefaultProfileId;

            Profiles = new List <Profile>();
            Profiles.AddRange(
                from p in XmlConfig.Elements("profile")
                select new Profile {
                ProfileXml = p
            });
            foreach (Profile p in Profiles)
            {
                if (defaultProfileId != null && p.ProfileId == defaultProfileId)
                {
                    p.Active       = true;
                    CurrentProfile = p;
                }
            }
        }
예제 #3
0
        private Dictionary <string, object> ProcessDynamicParams(SqlParams sqlParams, ref string reportsql, ref string prepareSql, ref string totalSql)
        {
            var parameters = new Dictionary <string, object>();
            var elements   = XmlConfig.Elements("Dynamic");

            if (XmlConfig.Attribute("BaseType") != null)
            {
                var baseConfig = AllReportConfig.Elements("Rep").FirstOrDefault(q => q.Attribute("key").Value == XmlConfig.Attribute("BaseType").Value);
                if (baseConfig != null)
                {
                    foreach (var item in baseConfig.Elements("Dynamic"))
                    {
                        var property = elements.FirstOrDefault(p => p.Attribute("property").Value == item.Attribute("property").Value);
                        if (property != null)
                        {
                            property.Add(item.Elements());
                        }
                    }
                }
            }

            foreach (var itemEle in elements)
            {
                Dictionary <string, object> dataRes;
                List <ReportWhereEntity>    list = FillReportWhereEntity(itemEle);
                string dynamicStr = GetDynamicStr(list, sqlParams.Where, out dataRes);
                string dyProperty = itemEle.Attribute("property").Value;

                if (!string.IsNullOrEmpty(reportsql))
                {
                    reportsql = reportsql.Replace(dyProperty, dynamicStr);
                }
                //if (!string.IsNullOrEmpty(footerSql))
                //    footerSql = footerSql.Replace(dyProperty, dynamicStr);
                if (!string.IsNullOrEmpty(prepareSql))
                {
                    prepareSql = prepareSql.Replace(dyProperty, dynamicStr);
                }
                if (!string.IsNullOrEmpty(totalSql))
                {
                    totalSql = totalSql.Replace(dyProperty, dynamicStr);
                }

                if (dataRes != null)
                {
                    foreach (var item in dataRes)
                    {
                        if (parameters.All(p => p.Key != item.Key.ToLower()))
                        {
                            parameters.Add(item.Key.ToLower(), item.Value);
                        }
                    }
                }
            }

            foreach (var item in sqlParams.Where)
            {
                if (parameters.All(p => p.Key != item.Key.ToLower()))
                {
                    parameters.Add(item.Key.ToLower(), item.Value);
                }
            }
            return(parameters);
        }