示例#1
0
    /// <summary>
    /// Returns extension object
    /// </summary>
    /// <param name="name">Extension name</param>
    /// <returns>Extension</returns>
    static ManagedExtension DataStoreExtension(string name)
    {
        ManagedExtension ex = null;

        TrainEngine.Core.DataStore.ExtensionSettings xs = new TrainEngine.Core.DataStore.ExtensionSettings(name);
        XmlSerializer serializer = new XmlSerializer(typeof(ManagedExtension));
        object        o          = xs.GetSettings();

        if (o != null)
        {
            if (o.GetType().Name == "FileStream")
            {
                Stream stm = (FileStream)o;
                ex = (ManagedExtension)serializer.Deserialize(stm);
                stm.Close();
            }
            else
            {
                if (!string.IsNullOrEmpty((string)o))
                {
                    using (StringReader reader = new StringReader(o.ToString()))
                    {
                        ex = (ManagedExtension)serializer.Deserialize(reader);
                    }
                }
            }
        }
        return(ex);
    }
示例#2
0
 /// <summary>
 /// Saves ext. manager object to XML file
 /// or database table using provider model
 /// </summary>
 /// <returns>True if successful</returns>
 public static bool SaveToStorage()
 {
     foreach (ManagedExtension ext in _extensions)
     {
         TrainEngine.Core.DataStore.ExtensionSettings xs = new TrainEngine.Core.DataStore.ExtensionSettings(ext.Name);
         xs.SaveSettings(ext);
     }
     return(true);
 }
    /// <summary>
    /// Method to change extension status
    /// </summary>
    /// <param name="extension">Extensio Name</param>
    /// <param name="enabled">If true, enables extension</param>
    public static void ChangeStatus(string extension, bool enabled)
    {
        foreach (ManagedExtension x in _extensions)
        {
          if (x.Name == extension)
          {
        x.Enabled = enabled;
        TrainEngine.Core.DataStore.ExtensionSettings xs = new TrainEngine.Core.DataStore.ExtensionSettings(x.Name);
        xs.SaveSettings(x);
        SaveToCache();

        string ConfigPath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "Web.Config";
        File.SetLastWriteTimeUtc(ConfigPath, DateTime.UtcNow);
        break;
          }
        }
    }
示例#4
0
    /// <summary>
    /// Method to change extension status
    /// </summary>
    /// <param name="extension">Extensio Name</param>
    /// <param name="enabled">If true, enables extension</param>
    public static void ChangeStatus(string extension, bool enabled)
    {
        foreach (ManagedExtension x in _extensions)
        {
            if (x.Name == extension)
            {
                x.Enabled = enabled;
                TrainEngine.Core.DataStore.ExtensionSettings xs = new TrainEngine.Core.DataStore.ExtensionSettings(x.Name);
                xs.SaveSettings(x);
                SaveToCache();

                string ConfigPath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "Web.Config";
                File.SetLastWriteTimeUtc(ConfigPath, DateTime.UtcNow);
                break;
            }
        }
    }
    /// <summary>
    /// Returns extension object
    /// </summary>
    /// <param name="name">Extension name</param>
    /// <returns>Extension</returns>
    static ManagedExtension DataStoreExtension(string name)
    {
        ManagedExtension ex = null;
        TrainEngine.Core.DataStore.ExtensionSettings xs = new TrainEngine.Core.DataStore.ExtensionSettings(name);
        XmlSerializer serializer = new XmlSerializer(typeof(ManagedExtension));
        object o = xs.GetSettings();

        if (o != null)
        {
          if (o.GetType().Name == "FileStream")
          {
        Stream stm = (FileStream)o;
        ex = (ManagedExtension)serializer.Deserialize(stm);
        stm.Close();
          }
          else
          {
        if (!string.IsNullOrEmpty((string)o))
        {
          using (StringReader reader = new StringReader(o.ToString()))
          {
            ex = (ManagedExtension)serializer.Deserialize(reader);
          }
        }
          }
        }
        return ex;
    }
 /// <summary>
 /// Save individual extension to storage
 /// </summary>
 /// <param name="ext">Extension</param>
 /// <returns>True if saved</returns>
 public static bool SaveToStorage(ManagedExtension ext)
 {
     TrainEngine.Core.DataStore.ExtensionSettings xs = new TrainEngine.Core.DataStore.ExtensionSettings(ext.Name);
     xs.SaveSettings(ext);
     return true;
 }