Ejemplo n.º 1
0
        private static ProtokollerConfiguration DeSerialize(string txt)
        {
            ProtokollerConfiguration retVal = null;

            try
            {
                retVal = JsonNetDeSerialize <ProtokollerConfiguration>(txt);
            }
            catch (Exception)
            { }

            if (retVal == null)
            {
                try
                {
                    retVal = SerializeToString <ProtokollerConfiguration> .DeSerialize(txt);
                }
                catch (Exception)
                { }
            }

            ReReferenceProtokollerConfiguration(retVal);

            return(retVal);
        }
Ejemplo n.º 2
0
        public static void LoadFromFile(string filename)
        {
            StreamReader fstrm = new StreamReader(filename);

            ProtokollerConfiguration.ActualConfigInstance = DeSerialize((string)fstrm.ReadToEnd());
            fstrm.Close();
        }
Ejemplo n.º 3
0
        private static ProtokollerConfiguration DeSerialize(string txt)
        {
            ProtokollerConfiguration retVal = SerializeToString <ProtokollerConfiguration> .DeSerialize(txt);

            ReReferenceProtokollerConfiguration(retVal);

            return(retVal);
        }
Ejemplo n.º 4
0
 public static void Load()
 {
     if (File.Exists(ConfigFileName()))
     {
         StreamReader sstrm = new StreamReader(ConfigFileName(), false);
         var          conf  = sstrm.ReadToEnd();
         sstrm.Close();
         ProtokollerConfiguration.ActualConfigInstance = DeSerialize(conf);
     }
 }
Ejemplo n.º 5
0
        public static void ImportFromRegistry()
        {
            RegistryKey regKey = Registry.LocalMachine;

            regKey = regKey.CreateSubKey("SYSTEM\\CurrentControlSet\\services\\" + StaticServiceConfig.MyServiceName + "\\Parameters");
            if (regKey != null)
            {
                object conf = regKey.GetValue("XMLConfig");
                if (conf != null && (string)conf != "")
                {
                    ProtokollerConfiguration.ActualConfigInstance = DeSerialize((string)conf);
                }
                else
                {
                    MessageBox.Show("Error reading Config from the Registry, maybe you need to Login as Administrator, or no config has yet been created!");
                }
            }
        }
Ejemplo n.º 6
0
        public static void ReReferenceProtokollerConfiguration(ProtokollerConfiguration cfg)
        {
            //Recreate the References, because XMLSerializer creates copies all the time!
            foreach (DatasetConfig datasetConfig in cfg.Datasets)
            {
                if (datasetConfig.Storage != null)
                {
                    datasetConfig.Storage = cfg.Storages.Where(c => c.Name == datasetConfig.Storage.Name).FirstOrDefault();
                }
                if (datasetConfig.TriggerConnection != null)
                {
                    datasetConfig.TriggerConnection = cfg.Connections.Where(c => c.Name == datasetConfig.TriggerConnection.Name).FirstOrDefault();
                }

                foreach (DatasetConfigRow datasetConfigRow in datasetConfig.DatasetConfigRows)
                {
                    if (datasetConfigRow.Connection != null)
                    {
                        datasetConfigRow.Connection = cfg.Connections.Where(c => c.Name == datasetConfigRow.Connection.Name).FirstOrDefault();
                    }
                }
            }
        }
Ejemplo n.º 7
0
 public static void Clear()
 {
     ActualConfigInstance = new ProtokollerConfiguration();
 }
        public static void ReReferenceProtokollerConfiguration(ProtokollerConfiguration cfg)
        {
            //Recreate the References, because XMLSerializer creates copies all the time!
            foreach (DatasetConfig datasetConfig in cfg.Datasets)
            {
                if (datasetConfig.Storage != null)
                    datasetConfig.Storage = cfg.Storages.Where(c => c.Name == datasetConfig.Storage.Name).FirstOrDefault();
                if (datasetConfig.TriggerConnection != null)
                    datasetConfig.TriggerConnection = cfg.Connections.Where(c => c.Name == datasetConfig.TriggerConnection.Name).FirstOrDefault();

                foreach (DatasetConfigRow datasetConfigRow in datasetConfig.DatasetConfigRows)
                {
                    if (datasetConfigRow.Connection != null)
                    {
                        datasetConfigRow.Connection = cfg.Connections.Where(c => c.Name == datasetConfigRow.Connection.Name).FirstOrDefault();
                    }
                }
            }
        }
 public static void LoadFromFile(string filename)
 {
     StreamReader fstrm = new StreamReader(filename);
     ProtokollerConfiguration.ActualConfigInstance = DeSerialize((string) fstrm.ReadToEnd());
     fstrm.Close();
 }
 public static void Load()
 {
     if (File.Exists(ConfigFileName()))
     {
         StreamReader sstrm = new StreamReader(ConfigFileName(), false);
         var conf = sstrm.ReadToEnd();
         sstrm.Close();
         ProtokollerConfiguration.ActualConfigInstance = DeSerialize(conf);
     }
 }
 public static void ImportFromRegistry()
 {
     RegistryKey regKey = Registry.LocalMachine;
     regKey = regKey.CreateSubKey("SYSTEM\\CurrentControlSet\\services\\" + StaticServiceConfig.MyServiceName + "\\Parameters");
     if (regKey != null)
     {
         object conf = regKey.GetValue("XMLConfig");
         if (conf != null && (string)conf != "")
         {
             ProtokollerConfiguration.ActualConfigInstance = DeSerialize((string)conf);
         }
         else
         {
             MessageBox.Show("Error reading Config from the Registry, maybe you need to Login as Administrator, or no config has yet been created!");
         }
     }
 }
 public static void Clear()
 {
     ActualConfigInstance = new ProtokollerConfiguration();
 }