Esempio n. 1
0
 public MoveFilesService()
 {
     try
     {
         try
         {
             path = ConfigurationManager.AppSettings["ConfigDirectory"] != null ? ConfigurationManager.AppSettings["ConfigDirectory"].ToString() : "";
         }
         catch (Exception ePath)
         {
             path = "";
             Log.EscribeLog("Error al obtener el path desde appSettings: " + ePath.Message);
         }
         if (File.Exists(path + "info.xml"))
         {
             _conf         = XMLConfigurator.getXMLfile();
             id_Servicio   = _conf.id_Sitio;
             AETitle       = _conf.vchAETitle;
             vchPathRep    = _conf.vchPathLocal;
             vchClaveSitio = _conf.vchClaveSitio;
         }
         cargaServicio();
     }
     catch (Exception eSync)
     {
         Log.EscribeLog("Existe un error en MoveFilesService: " + eSync.Message);
     }
 }
 public MainWindow()
 {
     try
     {
         InitializeComponent();
         _configura = new Entidades.clsConfiguracion();
         //ConfigDA = new ConfiguracionDataAccess();
         //tbl_ConfigSitio _config = new tbl_ConfigSitio();
         //string mensaje = "";
         if (File.Exists(path + "info.xml"))
         {
             _configura = XMLConfigurator.getXMLfile();
             if (_configura != null)
             {
                 if (_configura.vchClaveSitio != "")
                 {
                     txtSitio.Text      = _configura.vchClaveSitio;
                     txtSitio.IsEnabled = false;
                 }
                 else
                 {
                     //    SitioName site = new SitioName();
                     //    site.Show();
                     //    this.Close();
                     txtSitio.IsEnabled = true;
                 }
             }
         }
         else
         {
             txtSitio.IsEnabled = true;
             //    string mensaje = "";
             //    bool existe = ConfigDA.getVerificaSitio(txtSitio.Text, ref mensaje);
             //    if (existe)
             //    {
             //        tbl_ConfigSitio mdl = new tbl_ConfigSitio();
             //        ConfigDA.getConfiguracion(txtSitio.Text, ref mensaje);
             //    }
         }
     }
     catch (Exception eMW)
     {
         MessageBox.Show("Existe un error al iniciar la aplicación: " + eMW.Message);
     }
 }
 private void cargarTimmer()
 {
     try
     {
         try
         {
             path = ConfigurationManager.AppSettings["ConfigDirectory"] != null ? ConfigurationManager.AppSettings["ConfigDirectory"].ToString() : "";
         }
         catch (Exception ePath)
         {
             path = "";
             Log.EscribeLog("Error al obtener el path desde appSettings: " + ePath.Message);
         }
         try
         {
             Logpath = ConfigurationManager.AppSettings["LogDirectory"] != null ? ConfigurationManager.AppSettings["LogDirectory"].ToString() : "";
         }
         catch (Exception ePath)
         {
             Logpath = "";
             Log.EscribeLog("Error al obtener el path desde Log: " + ePath.Message);
         }
         if (File.Exists(path + "info.xml"))
         {
             _conf         = XMLConfigurator.getXMLfile();
             id_Servicio   = _conf.id_Sitio;
             AETitle       = _conf.vchAETitle;
             vchPathRep    = _conf.vchPathLocal;
             vchClaveSitio = _conf.vchClaveSitio;
         }
         Console.WriteLine("Se cargó correctamente el servicio SenderFeed2SCUService. " + "[" + DateTime.Now.ToShortDateString() + DateTime.Now.ToShortTimeString() + "]");
         Log.EscribeLog("Se cargó correctamente el servicio SenderFeed2SCUService. ");
         int segundosPoleo;
         try
         {
             segundosPoleo = ConfigurationManager.AppSettings["segundosPoleo"] != null?Convert.ToInt32(ConfigurationManager.AppSettings["segundosPoleo"].ToString()) : 1;
         }
         catch (Exception eGPOLeo)
         {
             Log.EscribeLog("Existe un error al obtener el tiempo para el poleo del servicio: " + eGPOLeo.Message);
             segundosPoleo = 1;
         }
         int minutos = (int)(1000 * segundosPoleo);
         SenderTimer.Elapsed += new System.Timers.ElapsedEventHandler(SenderTimer_Elapsed);
         SenderTimer.Interval = minutos;
         SenderTimer.Enabled  = true;
         SenderTimer.Start();
         try
         {
             NapoleonSenderDataAccess.setService(id_Servicio, vchClaveSitio);
         }
         catch (Exception setSer)
         {
             Log.EscribeLog("Existe un error en setService: " + setSer.Message);
         }
     }
     catch (Exception eCS)
     {
         Log.EscribeLog("Existe un error en cargarServicio: " + eCS.Message);
     }
 }
Esempio n. 4
0
        static void Main()
        {
            //Kontextkonfiguration laden
            String _progPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);

            String contextPath        = String.Concat(_progPath, @"\CustomizedContext\");
            String defaultContextFile = String.Concat(_progPath, @"\DefaultContext.xml");
            String contextFile        = String.Concat(_progPath, @"\context.xml");

            if (Directory.Exists(contextPath))
            {
                try
                {
                    StreamWriter write = new StreamWriter(contextFile, false);
                    write.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                    write.WriteLine("<ContextRoot xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">");

                    StreamReader read = new StreamReader(defaultContextFile);
                    write.Write(read.ReadToEnd());
                    read.Close();

                    write.WriteLine("<Context ContextId=\"Customized\">");
                    DirectoryInfo dirInfo  = new DirectoryInfo(contextPath);
                    FileInfo[]    fileInfo = dirInfo.GetFiles("*.xml");
                    foreach (FileInfo item in fileInfo)
                    {
                        if (item != null)
                        {
                            write.WriteLine();

                            read = new StreamReader(item.FullName);
                            write.Write(read.ReadToEnd());
                            read.Close();

                            write.WriteLine();
                        }
                    }

                    write.WriteLine("</Context>");
                    write.WriteLine("</ContextRoot>");
                    write.Flush();
                    write.Close();
                }
                catch (Exception)
                {
                    if (MessageBox.Show("Context Files couldn't be read. Do you want to continue Application nonetheless without contexts?.", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                    {
                        contextFile = null;
                    }
                    else
                    {
                        return;
                    }
                }
            }

            try
            {
                if (contextFile != null)
                {
                    XMLConfigurator.Configure(contextFile);
                }

                //Actions freischalten
                ActionRegistry.Instance.RegisterAction(new SetVisibleAction());
                ActionRegistry.Instance.RegisterAction(new SetTextAction());
                ActionRegistry.Instance.RegisterAction(new SetDefaultValueAction());
            }
            catch (ContextCorruptedException ex)
            {
                MessageBox.Show(ex.Message + ". Application will shut down.", "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                return;
            }
            //Application.Run(new MainForm());

            UserProfile             active = null;
            SelectUserProfileDialog dlg    = null;

            try
            {
                dlg = new SelectUserProfileDialog();
            }
            catch (ConnectionCorruptedException ex)
            {
                MessageBox.Show(ex.Message + ". Application will shut down.", "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                return;
            }

            if (dlg != null)
            {
                // Dialog zentrieren
                dlg.Location = new Point((Screen.PrimaryScreen.WorkingArea.Width) / 2 - (dlg.Size.Width) / 2, Screen.PrimaryScreen.WorkingArea.Location.Y);

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        active = UserProfiles.Instance.Current;
                    }
                    catch (ConnectionCorruptedException ex)
                    {
                        MessageBox.Show(ex.Message + ". Application will shut down.", "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        return;
                    }

                    if (active != null)
                    {
                        try
                        {
                            DataFunctions.Instance.Update(active);
                            Cursor.Current = Cursors.WaitCursor;
                            Cursor.Show();
                            Application.Run(new MainForm(active));
                            Cursor.Current = Cursors.Default;
                        }
                        catch (DataFunctionsException ex)
                        {
                            MessageBox.Show("Changes of User Profile couldn't be saved. (" + ex.Message + ")" + ". Application will shut down.", "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                            return;
                        }
                        catch (ConnectionCorruptedException ex)
                        {
                            MessageBox.Show("Changes of User Profile couldn't be saved. (" + ex.Message + ")" + ". Application will shut down.", "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                            return;
                        }
                        catch (InvalidOperationException except)
                        {
                            MessageBox.Show(except.Message + ". Application will shut down.", "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                            return;
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        static void Main()
        {
            //Kontextkonfiguration laden
            String _progPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);

            String contextPath        = String.Concat(_progPath, @"\CustomizedContext\");
            String defaultContextFile = String.Concat(_progPath, @"\DefaultContext.xml");
            String contextFile        = String.Concat(_progPath, @"\context.xml");

            if (Directory.Exists(contextPath))
            {
                try
                {
                    StreamWriter write = new StreamWriter(contextFile, false);
                    write.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                    write.WriteLine("<ContextRoot xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">");

                    StreamReader read = new StreamReader(defaultContextFile);
                    write.Write(read.ReadToEnd());
                    read.Close();

                    write.WriteLine("<Context ContextId=\"Customized\">");
                    DirectoryInfo dirInfo  = new DirectoryInfo(contextPath);
                    FileInfo[]    fileInfo = dirInfo.GetFiles("*.xml");
                    foreach (FileInfo item in fileInfo)
                    {
                        if (item != null)
                        {
                            write.WriteLine();

                            read = new StreamReader(item.FullName);
                            write.Write(read.ReadToEnd());
                            read.Close();

                            write.WriteLine();
                        }
                    }

                    write.WriteLine("</Context>");
                    write.WriteLine("</ContextRoot>");
                    write.Flush();
                    write.Close();
                }
                catch (Exception)
                {
                    if (MessageBox.Show("Context Files couldn't be read. Do you want to continue Application nonetheless without contexts?.", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                    {
                        contextFile = null;
                    }
                    else
                    {
                        return;
                    }
                }
            }

            try
            {
                if (contextFile != null)
                {
                    XMLConfigurator.Configure(contextFile);
                }

                //Actions freischalten
                ActionRegistry.Instance.RegisterAction(new SetVisibleAction());
                ActionRegistry.Instance.RegisterAction(new SetTextAction());
                ActionRegistry.Instance.RegisterAction(new SetDefaultValueAction());
            }
            catch (ContextCorruptedException ex)
            {
                MessageBox.Show(ex.Message + ". Application will shut down.", "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                return;
            }

            UserProfile active = new UserProfile("Piesche");

            active.Context         = "Customized";
            active.LanguageContext = "English";
            active.LoginName       = "Piesche";
            active.ToolbarIcons    = "small";

            UserProfiles.Instance.Current = active;

            if (active != null)
            {
                try
                {
                    Cursor.Current = Cursors.WaitCursor;
                    Cursor.Show();
                    Application.Run(new EditContextForm());
                    Cursor.Current = Cursors.Default;
                }
                catch (InvalidOperationException except)
                {
                    MessageBox.Show(except.Message + ". Application will shut down.", "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    return;
                }
            }
        }