Exemplo n.º 1
0
        public static void BackupEnviroment()
        {
            string signature = DateTime.Now.Ticks.ToString();
            string tmpfolder = signature;
            string filename  = signature + ".back";
            string modfolder = hGestorModulo.ConfigTool.GetValor("RutaModulos");

            try {
                // creamos carpeta temporal
                WaitWin.SetText("Creando backup.....", 0);
                if (Directory.Exists(tmpfolder))
                {
                    Directory.Delete(tmpfolder, true);
                }
                Directory.CreateDirectory(tmpfolder);
                //copiamos contenido de la carpeta mudulos
                Util.CopyAll(new DirectoryInfo(modfolder),
                             new DirectoryInfo(tmpfolder));
                //copiamos el archivo de configuración
                Util.Copy(hGestorModulo.ConfigFile, Path.Combine(tmpfolder, hGestorModulo.ConfigFile), false);
                //comprimimos la carpeta temporal
                Util.AlertMessage(Tr.Catalog.GetString("Creado backup en ") + filename);
            } catch (Exception ex) {
                WaitWin.Hide();
                LogEx.CatchEx(ex);
            }
        }
Exemplo n.º 2
0
        private static bool SpecialArg(string arg)
        {
            try {
                if (arg == "--help")
                {
                    Help();
                    return(true);
                }
                if (arg == "--OnlyArgs")
                {
                    Cont = false;
                    return(true);
                }
                if (arg == "--noGtk")
                {
                    horizonte.hGestorModulo.GtkEnabled = false;
                    return(true);
                }

                return(false);
            } catch (Exception ex) {
                return(false);

                LogEx.CatchEx(ex, "SpecialArg");
            }
        }
Exemplo n.º 3
0
 public static void RestoreEnviroment(string BackupFile)
 {
     try {
         // hor://comando/horizonte_ShowWidget/hbuild_ModConsole
     } catch (Exception ex) {
         LogEx.CatchEx(ex);
     }
 }
Exemplo n.º 4
0
        public static bool ProcArgs(string[] args)
        {
            try {
                // Pasamos los argumentos a una diccionario
                Regex Spliter = new Regex(@"^-{1,2}|^/|=|:", RegexOptions.IgnoreCase | RegexOptions.Compiled);
                //Regex Remover = new Regex (@"^['""]?(.*?)['""]?$",RegexOptions.IgnoreCase | RegexOptions.Compiled);
                Dictionary <string, string> ArgsList = new Dictionary <string, string> ();
                string[] Partes;
                foreach (string arg in args)
                {
                    if (!SpecialArg(arg))
                    {
                        Partes = Spliter.Split(arg, 2);
                        if (Partes.Length == 1)
                        {
                            ArgsList.Add(Partes [0], "");
                        }
                        else
                        {
                            ArgsList.Add(Partes [0], Partes [1]);
                        }
                    }
                }
                // recorremos el diccionario de Argumentos
                string ArgKey;
                string ArgValue;
                foreach (string _key in ArgsList.Keys)
                {
                    ArgValue = ArgsList [_key];

                    //Comprobamos sí el Key se encuentra también en la lista de comandos
                    //y ejecutamos esl método asociado

                    if (hGestorModulo.CommandList.ContainsKey(_key))
                    {
                        if (ArgValue == "")
                        {
                            hGestorModulo.TestCommand(_key, "");
                        }
                        else
                        {
                            hGestorModulo.TestCommand(_key, ArgValue);
                        }
                    }
                    // procesamos otros argumentos
                }
                return(Cont);
            } catch (Exception ex) {
                LogEx.CatchEx(ex, "ProcArgs");
                return(Cont);
            }
        }
Exemplo n.º 5
0
 public static void AlertMessage(string Mensaje)
 {
     try {
         Gtk.Application.Invoke(delegate {
             MessageDialog md = new MessageDialog(null,
                                                  DialogFlags.Modal, MessageType.Warning,
                                                  ButtonsType.Ok, Mensaje);
             md.Run();
             md.Destroy();
         });
     } catch (Exception ex) {
         LogEx.CatchEx(ex, "AlertMessage");
     }
 }
Exemplo n.º 6
0
        private void GetOsVersion()
        {
            try {
                switch (System.Environment.OSVersion.Platform)
                {
                case PlatformID.MacOSX:
                case PlatformID.Unix:
                    IsUnixSystem = true;
                    break;

                default:
                    IsUnixSystem = false;
                    break;
                }
            } catch (Exception ex) {
                LogEx.CatchEx(ex, "GetOsVersion");
            }
        }
Exemplo n.º 7
0
        public static object RunCommand(string CommandKeyor, object[] Arg)
        {
            string CommandKey = string.Empty;

            try {
                // codificación rutas url.... hay que cambiar la codificación.
                //CommandKey = Encoding.ASCII.GetString(Encoding.ASCII.GetBytes(CommandKeyor.Trim()));
                //Console.WriteLine(CommandKeyor);
                //Console.WriteLine(CommandKey);
                //Console.WriteLine(CommandKeyor == CommandKey);
                CommandKey = CommandKeyor;
//				foreach (char c in CommandKey )
//				{
//					//if (c > 127)
//						//Console.WriteLine("Caracter no imprimible " + CommandKey);
//
//				}

                if (!CommandList.ContainsKey(CommandKey))
                {
                    Console.WriteLine("no existe el comando: " + CommandKey);
                }

                // recuperamos del diccionario el comando correspondiente al CommandKey
                hCommand RCommand = (hCommand)CommandList[CommandKey];

                // creamos el objeto de respuesta
                object ResObject = new object();

                // invocamos el método de la clase Panel con los argumentos
                ResObject = (object)RCommand.CommandAction.Invoke(RCommand.Panel, Arg);

                //devolvemos el objeto
                return(ResObject);
            } catch (Exception ex) {
                //LOG
                //object[]  _SetUpParam = new object[]{this,Catalog.GetString(string.Format("Error al procesar RunComman {0} ",CommandKey)),ex.ToString(),1};
                //RunCommand("Log_Trace",_SetUpParam);
                Console.WriteLine("*RunCommand* " + CommandKey + " ***");
                LogEx.CatchEx(ex, "RunCommand", null);
                return(new object());
            }
        }
Exemplo n.º 8
0
        public static void Copy(string Source, string Dest, bool IsDir)
        {
            try {
                if (IsDir)
                {
                    CopyAll(new System.IO.DirectoryInfo(Source), new System.IO.DirectoryInfo(Dest));
                }
                else
                {
                    System.IO.File.Copy(Source, Dest);
                }
            } catch (Exception ex) {
                LogEx.CatchEx(ex, "Copy");
            }
//
//			string Recursive = "";
//			if (IsDir) {
//				Recursive = "-r ";
//			}
//			string param = Recursive + SourceDir +" -d " + DestDir;
//			Process P;
//			P = Process.Start("cp",param);
//			P.WaitForExit(2000);
        }