Example #1
0
        /// <summary>
        /// Save queries to file
        /// </summary>
        /// <param name="fileName">Xml-file name</param>
        /// <param name="queries">Collection of queries</param>
        public static void SaveToXml(string fileName, List <QueryInfo> queries)
        {
            LoaderRootWrapper wrapper = new LoaderRootWrapper();

            wrapper.SqlInfos = new List <LoaderMSSQLQueryWrapper>
            {
                ReadLoaderQueryWrapper(queries, QuerySource.MSSQL),
                ReadLoaderQueryWrapper(queries, QuerySource.TDSQL),
                ReadLoaderQueryWrapper(queries, QuerySource.SQLite),
                ReadLoaderQueryWrapper(queries, QuerySource.SQLiteExternal),
                ReadLoaderQueryWrapper(queries, QuerySource.ActiveDirectory),
                ReadLoaderQueryWrapper(queries, QuerySource.EventLog),
                ReadLoaderQueryWrapper(queries, QuerySource.NetworkInformation)
            };

            XmlSerializer serializer = new XmlSerializer(typeof(LoaderRootWrapper));

            using (FileStream writer = new FileStream(fileName, FileMode.Create))
            {
                using (XmlWriter xmlWriter = XmlWriter.Create(writer, XmlUtils.GetXmlWriterSettings()))
                {
                    serializer.Serialize(xmlWriter, wrapper);
                }
            }
        }
Example #2
0
        private static IEnumerable <QueryInfo> GetQueries(LoaderRootWrapper wrapper, QuerySource querySource)
        {
            List <QueryInfo> queryInfos = wrapper.GetQueriesOfType(querySource).SelectMany(w => w.Infos).ToList();

            queryInfos.ForEach(q =>
            {
                q.OnDesialized();
                q.Source = querySource;
            });

            return(queryInfos);
        }
Example #3
0
        private static List <QueryInfo> GetQueries(LoaderRootWrapper wrapper)
        {
            List <QueryInfo> queries = new List <QueryInfo>();

            queries.AddRange(GetQueries(wrapper, QuerySource.MSSQL));
            queries.AddRange(GetQueries(wrapper, QuerySource.TDSQL));
            queries.AddRange(GetQueries(wrapper, QuerySource.SQLite));
            queries.AddRange(GetQueries(wrapper, QuerySource.SQLiteExternal));
            queries.AddRange(GetQueries(wrapper, QuerySource.ActiveDirectory));
            queries.AddRange(GetQueries(wrapper, QuerySource.EventLog));
            queries.AddRange(GetQueries(wrapper, QuerySource.NetworkInformation));

            return(queries);
        }
        /// <summary>
        /// Save layout to XML.
        /// </summary>
        /// <param name="fileName">File name.</param>
        /// <param name="settings">Settings.</param>
        public static void SaveLayoutToXml(string fileName, LayoutSettings settings)
        {
            var wrapper = new LoaderRootWrapper <LayoutSettings> {
                Settings = settings
            };

            var serializer = new XmlSerializer(typeof(LoaderRootWrapper <LayoutSettings>));

            using (var stream = new FileStream(fileName, FileMode.Create))
            {
                using (var xmlWriter = XmlWriter.Create(stream, XmlUtils.GetXmlWriterSettings()))
                {
                    serializer.Serialize(xmlWriter, wrapper);
                }
            }
        }
        /// <summary>
        /// Save settings to file
        /// </summary>
        /// <param name="fileName">Xml-file name</param>
        /// <param name="settings">Settings to be saved</param>
        public static void SaveToXml <T>(string fileName, T settings) where T : SettingsBase
        {
            EnsureDirectoryExists(fileName);

            var wrapper = new LoaderRootWrapper <T> {
                Settings = settings
            };
            var serializer = new XmlSerializer(typeof(LoaderRootWrapper <T>));

            using (var stream = new FileStream(fileName, FileMode.Create))
            {
                using (var xmlWriter = XmlWriter.Create(stream, XmlUtils.GetXmlWriterSettings()))
                {
                    serializer.Serialize(xmlWriter, wrapper);
                    settings.OriginFile = fileName;
                }
            }
        }
		/// <summary>
		/// Save queries to file
		/// </summary>
		/// <param name="fileName">Xml-file name</param>
		/// <param name="queries">Collection of queries</param>
		public static void SaveToXml(string fileName, List<QueryInfo> queries)
		{
			LoaderRootWrapper wrapper = new LoaderRootWrapper();

			wrapper.SqlInfos = new List<LoaderMSSQLQueryWrapper>
			{
				ReadLoaderQueryWrapper(queries, QuerySource.MSSQL),
				ReadLoaderQueryWrapper(queries, QuerySource.TDSQL),
				ReadLoaderQueryWrapper(queries, QuerySource.SQLite),
				ReadLoaderQueryWrapper(queries, QuerySource.SQLiteExternal),
				ReadLoaderQueryWrapper(queries, QuerySource.ActiveDirectory),
				ReadLoaderQueryWrapper(queries, QuerySource.EventLog),
				ReadLoaderQueryWrapper(queries, QuerySource.NetworkInformation)
			};

			XmlSerializer serializer = new XmlSerializer(typeof(LoaderRootWrapper));

			using (FileStream writer = new FileStream(fileName, FileMode.Create))
			{
				using (XmlWriter xmlWriter = XmlWriter.Create(writer, XmlUtils.GetXmlWriterSettings()))
				{
					serializer.Serialize(xmlWriter, wrapper);
				}
			}
		}
 		private static IEnumerable<QueryInfo> GetQueries(LoaderRootWrapper wrapper, QuerySource querySource)
 		{
			List<QueryInfo> queryInfos = wrapper.GetQueriesOfType(querySource).SelectMany(w => w.Infos).ToList();

			queryInfos.ForEach(q =>
			{
				q.OnDesialized();
				q.Source = querySource;
			});

			return queryInfos;
		}
		private static List<QueryInfo> GetQueries(LoaderRootWrapper wrapper)
		{
			List<QueryInfo> queries = new List<QueryInfo>();

			queries.AddRange(GetQueries(wrapper, QuerySource.MSSQL));
			queries.AddRange(GetQueries(wrapper, QuerySource.TDSQL));
			queries.AddRange(GetQueries(wrapper, QuerySource.SQLite));
			queries.AddRange(GetQueries(wrapper, QuerySource.SQLiteExternal));
			queries.AddRange(GetQueries(wrapper, QuerySource.ActiveDirectory));
			queries.AddRange(GetQueries(wrapper, QuerySource.EventLog));
			queries.AddRange(GetQueries(wrapper, QuerySource.NetworkInformation));

			return queries;
		}