Beispiel #1
0
        public static Snapshot Load(string Id)
        {
            Snapshot result = null;

            if (File.Exists (SorentoLib.Services.Config.Get<string> (SorentoLib.Enums.ConfigKey.path_snapshot) + Id +".zip"))
            {
                result = new Snapshot ();
                result._id = Id;

                #region READ MANIFEST
                {
                    try
                    {
                        System.Diagnostics.Process proc = new System.Diagnostics.Process();
                        proc.EnableRaisingEvents=false;
                        proc.StartInfo.FileName="unzip";
                        proc.StartInfo.WorkingDirectory = Environment.CurrentDirectory +"/"+ SorentoLib.Services.Config.Get<string> (SorentoLib.Enums.ConfigKey.path_temp);
                        proc.StartInfo.Arguments = "-qq " + Environment.CurrentDirectory +"/"+ SorentoLib.Services.Config.Get<string> (SorentoLib.Enums.ConfigKey.path_snapshot) + Id +".zip " + Id + "/manifest.xml -d "+ Environment.CurrentDirectory +"/"+ SorentoLib.Services.Config.Get<string> (SorentoLib.Enums.ConfigKey.path_temp);
                        proc.Start ();
                        proc.WaitForExit ();

                        result._manifest = SorentoLib.Tools.Helpers.FileToItem (SorentoLib.Services.Config.Get<string> (SorentoLib.Enums.ConfigKey.path_temp) + Id + "/manifest.xml");

                        Directory.Delete (Path.GetDirectoryName (SorentoLib.Services.Config.Get<string> (SorentoLib.Enums.ConfigKey.path_temp) + Id +"/"), true);
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine (exception.Message);
                        throw new Exception (string.Format (Strings.Exception.ServicesSnapshotLoadManifest, Id));
                    }
                }
                #endregion
            }
            else
            {
                throw new Exception (string.Format (Strings.Exception.ServicesSnapshotLoad, Id));
            }

            return result;
        }
Beispiel #2
0
        public static Snapshot Take(string Description)
        {
            Snapshot result = new Snapshot (Description);

            List<string> errors = new List<string> ();

            string workingdirectory = Environment.CurrentDirectory +"/"+ SorentoLib.Services.Config.Get<string> (SorentoLib.Enums.ConfigKey.path_temp);
            string snapshotroot = workingdirectory + result._id +"/";

            #region CREATE SNAPSHOTROOT
            Directory.CreateDirectory (snapshotroot);
            #endregion

            #region ADDINS
            foreach (SorentoLib.Addins.ISnapshot snapshot in AddinManager.GetExtensionObjects (typeof(SorentoLib.Addins.ISnapshot)))
            {
                errors.AddRange (snapshot.Take (snapshotroot));
            }
            #endregion

            #region CREATE MANIFEST
            {
                SorentoLib.Tools.Helpers.ItemToFile (result._manifest, snapshotroot + "manifest.xml");
            }
            #endregion

            #region CREATE ARCHIVE
            {
                try
                {
                    System.Diagnostics.Process process = new System.Diagnostics.Process();
                    process.StartInfo.FileName = "zip";
                    process.StartInfo.WorkingDirectory = workingdirectory;
                    process.StartInfo.Arguments = "-rq "+ workingdirectory + result.FileName +" "+ result.Id;
                    process.Start ();
                    process.WaitForExit ();

                    string source = workingdirectory + result.FileName;
                    string destination = SorentoLib.Services.Config.Get<string> (SorentoLib.Enums.ConfigKey.path_snapshot) + result.FileName;
                    SNDK.IO.CopyFile (source, destination);
                }
                catch (Exception exception)
                {
                    errors.Add (exception.Message);
                }
            }
            #endregion

            #region CLEANUP
            {
                try
                {
                    Directory.Delete (snapshotroot, true);
                    File.Delete (workingdirectory + result.FileName);
                }
                catch (Exception exception)
                {
                    errors.Add (exception.Message);
                }
            }
            #endregion

            return result;
        }
Beispiel #3
0
        public static void Develop(Snapshot Snapshot)
        {
            List<string> errors = new List<string> ();

            string workingdirectory = SorentoLib.Services.Config.Get<string> (SorentoLib.Enums.ConfigKey.path_snapshot);
            string snapshotroot = workingdirectory + Snapshot.Id +"/";

            #region UNZIP ARCHIVE
            {
                System.Diagnostics.Process process = new System.Diagnostics.Process ();
                process.StartInfo.FileName = "unzip";
                process.StartInfo.WorkingDirectory = workingdirectory;
                process.StartInfo.Arguments = "-q "+ Snapshot.Id +".zip";
                process.Start ();
                process.WaitForExit ();
            }
            #endregion

            #region ADDINS
            foreach (SorentoLib.Addins.ISnapshot snapshot in AddinManager.GetExtensionObjects (typeof (SorentoLib.Addins.ISnapshot)))
            {
                errors.AddRange (snapshot.Develop (snapshotroot));
            }
            #endregion

            #region CLEANUP
            {
                Directory.Delete (snapshotroot, true);
            }
            #endregion

            foreach (string error in errors)
            {
                Console.WriteLine (error);
            }
        }