Click here to Skip to main content
15,885,435 members
Articles / Programming Languages / C#

Genesis Hybrid Smart Client Framework part III

Rate me:
Please Sign up or sign in to vote.
4.29/5 (10 votes)
19 Jun 2009Ms-PL10 min read 34K   7  
This is part III of a VII part series. This article covers the back-end of the Genesis Smart Client Framework including the database design.
#region Copyright Clause
/*
 * Blue Marble Genesis Smart Client Framework
 * 
 * Copyright � 2009 Blue Marble. All rights reserved.
 * 
 * This code is protected from any unauthorized duplication or viewing under
 * international copyright laws. Unauthorized access to this code is prosecutable
 * under the full extent of the law.
 */
#endregion

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using ICSharpCode.SharpZipLib.Zip;

public partial class deployment_Controls_UploadWizard_Upload : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (File1.PostedFile != null)
        {
            if (File1.PostedFile.FileName.EndsWith("zip"))
            {
                Guid zipFileGuid = Guid.NewGuid();

                string zipFileName = System.Configuration.ConfigurationManager.AppSettings["TempPath"] + zipFileGuid.ToString() + ".zip";

                File1.PostedFile.SaveAs(zipFileName);

                string tempDirectoryName = System.Configuration.ConfigurationManager.AppSettings["TempPath"] + zipFileGuid.ToString() + "\\";

                using (ZipInputStream s = new ZipInputStream(File.OpenRead(zipFileName)))
                {

                    ZipEntry theEntry;
                    while ((theEntry = s.GetNextEntry()) != null)
                    {

                        string directoryName = tempDirectoryName + Path.GetDirectoryName(theEntry.Name);
                        string fileName = Path.GetFileName(theEntry.Name);

                        // create directory
                        if (directoryName.Length > 0)
                        {
                            Directory.CreateDirectory(directoryName);
                        }

                        if (fileName != String.Empty)
                        {
                            using (FileStream streamWriter = File.Create(directoryName + "\\" + fileName))
                            {

                                int size = 2048;
                                byte[] data = new byte[2048];
                                while (true)
                                {
                                    size = s.Read(data, 0, data.Length);
                                    if (size > 0)
                                    {
                                        streamWriter.Write(data, 0, size);
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }

                string deployConfigurationFileName = tempDirectoryName + "deploy.xml";

                if (Session["DeploymentConfigurationFileName"] != null)
                {
                    Session.Remove("DeploymentConfigurationFileName");
                }

                Session.Add("DeploymentConfigurationFileName", deployConfigurationFileName);
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
We Fix Code
South Africa South Africa
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions