예제 #1
0
        public ApplicationBase ApplicationFactory(ApplicationServer server, XmlDocument ConfigFile, DirectoryInfo BaseDir)
        {
            ObjectHandle    handle = Activator.CreateInstance(AssemblyName, TypeName);
            ApplicationBase app    = (ApplicationBase)handle.Unwrap();

            app.Configure(server, BaseDir, ConfigFile);
            return(app);
        }
예제 #2
0
        public ApplicationBase DeployNewApplication(byte[] ArchiveBuffer, string Filename)
        {
            EnterMethod();
            try
            {
                MemoryStream InputStream = new MemoryStream(ArchiveBuffer);
                string       ext         = Path.GetExtension(Filename).ToLower();
                if (ext == ".zip" || ext == ".tar" || ext == ".gz")
                {
                    string appname  = Path.GetFileNameWithoutExtension(Filename);
                    string BasePath = ApplicationsBaseDir + appname;
                    if (Directory.Exists(BasePath))
                    {
                        throw new ApplicationException(string.Format("Application Directory '{0}' already exists", appname));
                    }
                    LogString("Deploying to " + BasePath);
                    switch (ext)
                    {
                    case ".zip":
                        UnzipFile(InputStream, BasePath);
                        break;

                    case ".tar":
                        UnTarFile(InputStream, BasePath, false);
                        break;

                    case ".gz":
                        UnTarFile(InputStream, BasePath, true);
                        break;
                    }
                    ApplicationBase app = LoadApplication(new DirectoryInfo(BasePath));
                    if (app == null)
                    {
                        Directory.Delete(BasePath, true);
                        throw new ApplicationException("Invalid application archive.  Unable to read valid configuration file.");
                    }
                    return(app);
                }
                else
                {
                    throw new ApplicationException(string.Format("Unable to deploy application from file type: {0}", ext));
                }
            }
            catch (Exception E)
            {
                SendError(E);
                throw;
            }
            finally
            {
                ExitMethod();
            }
        }
예제 #3
0
 private ApplicationBase LoadApplication(DirectoryInfo dir)
 {
     EnterMethod();
     try
     {
         XmlDocument doc = new XmlDocument();
         if (dir.GetFiles("app.config").Length != 0)
         {
             doc.Load(dir.FullName + Path.DirectorySeparatorChar + "app.config");
         }
         string          AppTypeName = ApplicationBase.ReadAppSetting(doc, "Application.Type", "unknown");
         ApplicationBase app         = null;
         foreach (ApplicationType apptype in AvailableApplicationTypes)
         {
             if (apptype.ApplicationTypeName == AppTypeName)
             {
                 LogString("Loading {0}...", AppTypeName);
                 app = apptype.ApplicationFactory(this, doc, dir);
                 LogString("Created {0}: {1}", AppTypeName, app.Name);
                 Applications.Add(app);
                 app.Load();
                 break;
             }
         }
         if (app == null)
         {
             LogString("Unknown application: " + AppTypeName);
         }
         return(app);
     }
     catch (Exception E)
     {
         SendError(E);
         throw;
     }
     finally
     {
         ExitMethod();
     }
 }
예제 #4
0
		/// <summary>
		///    <para>Adds a <see cref='.ApplicationBase'/> with the specified value to the 
		///    <see cref='.ApplicationCollection'/> .</para>
		/// </summary>
		/// <param name='value'>The <see cref='.ApplicationBase'/> to add.</param>
		/// <returns>
		///    <para>The index at which the new element was inserted.</para>
		/// </returns>
		/// <seealso cref='.ApplicationCollection.AddRange'/>
		public int Add(ApplicationBase value) {
			return List.Add(value);
		}
예제 #5
0
		/// <summary>
		///     <para>
		///       Initializes a new instance of <see cref='.ApplicationCollection'/> containing any array of <see cref='.ApplicationBase'/> objects.
		///    </para>
		/// </summary>
		/// <param name='value'>
		///       A array of <see cref='.ApplicationBase'/> objects with which to intialize the collection
		/// </param>
		public ApplicationCollection(ApplicationBase[] value) {
			this.AddRange(value);
		}
예제 #6
0
		/// <summary>
		///    <para> Removes a specific <see cref='.ApplicationBase'/> from the 
		///    <see cref='.ApplicationCollection'/> .</para>
		/// </summary>
		/// <param name='value'>The <see cref='.ApplicationBase'/> to remove from the <see cref='.ApplicationCollection'/> .</param>
		/// <returns><para>None.</para></returns>
		/// <exception cref='System.ArgumentException'><paramref name='value'/> is not found in the Collection. </exception>
		public void Remove(ApplicationBase value) {
			List.Remove(value);
		}
예제 #7
0
		/// <summary>
		/// <para>Inserts a <see cref='.ApplicationBase'/> into the <see cref='.ApplicationCollection'/> at the specified index.</para>
		/// </summary>
		/// <param name='index'>The zero-based index where <paramref name='value'/> should be inserted.</param>
		/// <param name=' value'>The <see cref='.ApplicationBase'/> to insert.</param>
		/// <returns><para>None.</para></returns>
		/// <seealso cref='.ApplicationCollection.Add'/>
		public void Insert(int index, ApplicationBase value) {
			List.Insert(index, value);
		}
예제 #8
0
		/// <summary>
		///    <para>Returns the index of a <see cref='.ApplicationBase'/> in 
		///       the <see cref='.ApplicationCollection'/> .</para>
		/// </summary>
		/// <param name='value'>The <see cref='.ApplicationBase'/> to locate.</param>
		/// <returns>
		/// <para>The index of the <see cref='.ApplicationBase'/> of <paramref name='value'/> in the 
		/// <see cref='.ApplicationCollection'/>, if found; otherwise, -1.</para>
		/// </returns>
		/// <seealso cref='.ApplicationCollection.Contains'/>
		public int IndexOf(ApplicationBase value) {
			return List.IndexOf(value);
		}
예제 #9
0
		/// <summary>
		/// <para>Copies the <see cref='.ApplicationCollection'/> values to a one-dimensional <see cref='System.Array'/> instance at the 
		///    specified index.</para>
		/// </summary>
		/// <param name='array'><para>The one-dimensional <see cref='System.Array'/> that is the destination of the values copied from <see cref='.ApplicationCollection'/> .</para></param>
		/// <param name='index'>The index in <paramref name='array'/> where copying begins.</param>
		/// <returns>
		///   <para>None.</para>
		/// </returns>
		/// <exception cref='System.ArgumentException'><para><paramref name='array'/> is multidimensional.</para> <para>-or-</para> <para>The number of elements in the <see cref='.ApplicationCollection'/> is greater than the available space between <paramref name='arrayIndex'/> and the end of <paramref name='array'/>.</para></exception>
		/// <exception cref='System.ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception>
		/// <exception cref='System.ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception>
		/// <seealso cref='System.Array'/>
		public void CopyTo(ApplicationBase[] array, int index) {
			List.CopyTo(array, index);
		}
예제 #10
0
		/// <summary>
		/// <para>Gets a value indicating whether the 
		///    <see cref='.ApplicationCollection'/> contains the specified <see cref='.ApplicationBase'/>.</para>
		/// </summary>
		/// <param name='value'>The <see cref='.ApplicationBase'/> to locate.</param>
		/// <returns>
		/// <para><see langword='true'/> if the <see cref='.ApplicationBase'/> is contained in the collection; 
		///   otherwise, <see langword='false'/>.</para>
		/// </returns>
		/// <seealso cref='.ApplicationCollection.IndexOf'/>
		public bool Contains(ApplicationBase value) {
			return List.Contains(value);
		}
예제 #11
0
		/// <summary>
		/// <para>Copies the elements of an array to the end of the <see cref='.ApplicationCollection'/>.</para>
		/// </summary>
		/// <param name='value'>
		///    An array of type <see cref='.ApplicationBase'/> containing the objects to add to the collection.
		/// </param>
		/// <returns>
		///   <para>None.</para>
		/// </returns>
		/// <seealso cref='.ApplicationCollection.Add'/>
		public void AddRange(ApplicationBase[] value) {
			for (int i = 0; (i < value.Length); i = (i + 1)) {
				this.Add(value[i]);
			}
		}
예제 #12
0
 /// <summary>
 ///    <para>Adds a <see cref='.ApplicationBase'/> with the specified value to the
 ///    <see cref='.ApplicationCollection'/> .</para>
 /// </summary>
 /// <param name='value'>The <see cref='.ApplicationBase'/> to add.</param>
 /// <returns>
 ///    <para>The index at which the new element was inserted.</para>
 /// </returns>
 /// <seealso cref='.ApplicationCollection.AddRange'/>
 public int Add(ApplicationBase value)
 {
     return(List.Add(value));
 }
예제 #13
0
 /// <summary>
 ///    <para> Removes a specific <see cref='.ApplicationBase'/> from the
 ///    <see cref='.ApplicationCollection'/> .</para>
 /// </summary>
 /// <param name='value'>The <see cref='.ApplicationBase'/> to remove from the <see cref='.ApplicationCollection'/> .</param>
 /// <returns><para>None.</para></returns>
 /// <exception cref='System.ArgumentException'><paramref name='value'/> is not found in the Collection. </exception>
 public void Remove(ApplicationBase value)
 {
     List.Remove(value);
 }
예제 #14
0
 /// <summary>
 /// <para>Inserts a <see cref='.ApplicationBase'/> into the <see cref='.ApplicationCollection'/> at the specified index.</para>
 /// </summary>
 /// <param name='index'>The zero-based index where <paramref name='value'/> should be inserted.</param>
 /// <param name=' value'>The <see cref='.ApplicationBase'/> to insert.</param>
 /// <returns><para>None.</para></returns>
 /// <seealso cref='.ApplicationCollection.Add'/>
 public void Insert(int index, ApplicationBase value)
 {
     List.Insert(index, value);
 }
예제 #15
0
 /// <summary>
 ///    <para>Returns the index of a <see cref='.ApplicationBase'/> in
 ///       the <see cref='.ApplicationCollection'/> .</para>
 /// </summary>
 /// <param name='value'>The <see cref='.ApplicationBase'/> to locate.</param>
 /// <returns>
 /// <para>The index of the <see cref='.ApplicationBase'/> of <paramref name='value'/> in the
 /// <see cref='.ApplicationCollection'/>, if found; otherwise, -1.</para>
 /// </returns>
 /// <seealso cref='.ApplicationCollection.Contains'/>
 public int IndexOf(ApplicationBase value)
 {
     return(List.IndexOf(value));
 }
예제 #16
0
 /// <summary>
 /// <para>Gets a value indicating whether the
 ///    <see cref='.ApplicationCollection'/> contains the specified <see cref='.ApplicationBase'/>.</para>
 /// </summary>
 /// <param name='value'>The <see cref='.ApplicationBase'/> to locate.</param>
 /// <returns>
 /// <para><see langword='true'/> if the <see cref='.ApplicationBase'/> is contained in the collection;
 ///   otherwise, <see langword='false'/>.</para>
 /// </returns>
 /// <seealso cref='.ApplicationCollection.IndexOf'/>
 public bool Contains(ApplicationBase value)
 {
     return(List.Contains(value));
 }