Example #1
0
        ///////////////////////////////////////////////////////////////////////

        internal static bool Dispose(
            IEvent @event /* in */
            )
        {
            try
            {
                IDisposable disposable = @event as IDisposable;

                if (disposable != null)
                {
                    disposable.Dispose(); /* throw */
                    disposable = null;

                    return(true);
                }
            }
            catch (Exception e)
            {
                TraceOps.DebugTrace(
                    e, typeof(Event).Name,
                    TracePriority.EventError);
            }

            return(false);
        }
Example #2
0
        ///////////////////////////////////////////////////////////////////////

        #region Public Constructors
        public _Hash(
            ICommandData commandData
            )
            : base(commandData)
        {
            lock (syncRoot)
            {
                if (defaultAlgorithms == null)
                {
                    try
                    {
                        defaultAlgorithms = GetAlgorithms();
                    }
                    catch (Exception e)
                    {
                        TraceOps.DebugTrace(
                            e, typeof(_Hash).Name,
                            TracePriority.InternalError);
                    }

                    //
                    // HACK: Prevent this block from being entered again for
                    //       this application domain.
                    //
                    if (defaultAlgorithms == null)
                    {
                        defaultAlgorithms = new StringList();
                    }
                }
            }
        }
Example #3
0
        public static GuidCollection EnsureUpdatesStaged(IList <Guid> guids, bool sync, out ITaskExecutionInstance inst)
        {
            inst = null;
            GuidCollection nonstagedUpdates = GetNonstagedUpdates(guids);

            if (nonstagedUpdates.Count <= 0)
            {
                return(nonstagedUpdates);
            }
            EventLog.ReportVerbose(string.Format("Staging {0} updates...", nonstagedUpdates.Count), "Stage & Distribute");
            try {
                for (int i = 0; i < 5; i++)
                {
                    inst = Item.GetItem <DownloadSWUPackageTask>(Tasks.Singletons70.DownloadSWUPackage, ItemLoadFlags.WriteableIgnoreAll).CreateInstanceForReplication(nonstagedUpdates, DownloadFilter.Auto, DownloadSWUPackageTask.EReason.DOWNLOAD_STAGE);
                    if (sync)
                    {
                        TaskHelper.WaitForTaskToComplete(inst);
                    }
                    else
                    {
                        return(nonstagedUpdates);
                    }
                    if (inst.InstanceStatus == Altiris.TaskManagement.Common.TaskInstanceStatus.Completed)
                    {
                        return(nonstagedUpdates);
                    }
                }
            }
            catch (Exception exception) {
                TraceOps.TRACE(exception);
            }
            throw new Exception(string.Format("Unable to stage '{0}' updates.", nonstagedUpdates.Count));
        }
Example #4
0
        private void MainServerForm_Location(object sender, EventArgs e)
        {
            var location = Location;

            location.X += Width;
            TraceOps.SetLogPosition(location);
        }
Example #5
0
 public static void ShowClientDetails(object sender, EventArgs e)
 {
     foreach (ConnectionTable.ClientInformation clientInformation in _connectionTable.GetChecked())
     {
         TraceOps.Out("ClientInformation for " + clientInformation.GetName());
         try
         {
             ConnectionTable.ClientInformation information = clientInformation;
             var thread = new Thread(new ThreadStart(() =>
             {
                 var clientDetailForm = new ServerClientDetailForm(information)
                 {
                     TopLevel = false
                 };
                 var d = new PluginFormCallback(SetWindowToPanel);
                 _mainForm.Invoke(d, new object[] { clientDetailForm });
             }));
             thread.Start();
         }
         catch (Exception et)
         {
             TraceOps.Out(et.ToString());
         }
     }
 }
Example #6
0
        private void ConnectToServer(string ip, int port)
        {
            TraceOps.Out("Connect to: " + ip + " : " + port);
            Services.GetService(ip, port, typeof(ConnectionTable));
            Services.GetService(ip, port, typeof(MessageQueue));
            _connectionTable = ConnectionTable.GetRemote(ip, port);
            _messageQueue    = MessageQueue.GetRemote(ip, port);
            _name            = HashOps.GetFqdn();

            try
            {
                foreach (IClientPlugin plugin in _plugins)
                {
                    plugin.SetForm(this);
                    plugin.SetName(ref _name);
                    plugin.SetQueue(ref _messageQueue);
                    plugin.SetTable(ref _connectionTable);
                }

                _networkClient     = new NetworkClient(ref _messageQueue, ref _connectionTable, _name);
                _taskManager       = new TaskManager(ref _messageQueue, ref _name);
                _taskManager.Task += TaskManagerOnTask;
                if (_plugins != null)
                {
                    _taskManager.SetListener(_plugins);
                }
            }
            catch (Exception ex)
            {
                TraceOps.Out(ex.Message);
            }
        }
Example #7
0
        private void MainServerForm_Load(object sender, EventArgs e)
        {
            TraceOps.LoadLog();
            try
            {
                _name = "Server";

                Services.PrepareSetService(_port);
                Services.SetService(typeof(ConnectionTable));
                Services.SetService(typeof(MessageQueue));

                _connectionTable = ConnectionTable.GetRemote("localhost", _port);
                _messageQueue    = MessageQueue.GetRemote("localhost", _port);

                _taskManager       = new TaskManager(ref _messageQueue, ref _name);
                _taskManager.Task += TaskManagerOnTask;

                var ci = new ConnectionTable.ClientInformation(_name);
                ci.SetGroup("server");
                ci.SetIp(NetworkOps.GetIpString(HashOps.GetFqdn()));
                ci.SetPort(_port);
                _connectionTable.Set(_name, ci);

                LoadClientsTable();
                LoadPlugIns();
            }
            catch (Exception ex)
            {
                TraceOps.Out(ex.Message);
            }
        }
Example #8
0
 public static void StartZTree(object sender, EventArgs eventArgs)
 {
     try
     {
         var exeToRun = Path.Combine(Path.GetTempPath(), "ztree.exe");
         if (ProcessControl.FindProcess("ztree"))
         {
             DialogResult dialogResult = MessageBox.Show(Resources.Control_StartZTree_Are_you_sure_to_restart_z_Tree_, Resources.Control_StartZTree_z_Tree_is_still_running, MessageBoxButtons.YesNo);
             if (dialogResult == DialogResult.No)
             {
                 return;
             }
         }
         try
         {
             FindDeleteFileAndStartAgain(exeToRun, "ztree", true);
         }
         catch (Exception innerException)
         {
             TraceOps.Out(innerException.ToString());
         }
     }
     catch (Exception exception)
     {
         TraceOps.Out(exception.ToString());
     }
 }
Example #9
0
        private void MessageWorker()
        {
            try
            {
                Register();

                while (_clientRunning)
                {
                    Thread.Sleep(Threshold);

                    var cpu = _cpuCounter.NextValue();

                    var count = _messageQueue.GetCount(_name);

                    var processes = "";
                    foreach (Process p in Process.GetProcesses())
                    {
                        if (p.MainWindowTitle.Length > 1)
                        {
                            processes += p.MainWindowTitle + "; ";
                        }
                    }

                    var ci = _connectionTable.Get(_name);
                    ci.SetPerformance(cpu);
                    ci.SetApplicationNames(processes);
                    ci.SetMessagesInQueue(count);
                    _connectionTable.Set(_name, ci);
                }
            }
            catch (Exception exception)
            {
                TraceOps.Out(exception.ToString());
            }
        }
Example #10
0
        public void SetTask(Message message)
        {
            try
            {
                var thread = new Thread(new ThreadStart(() =>
                {
                    try
                    {
                        TraceOps.Out("WebControl Client recived Message: " + message.GetCommand());
                        if (message.GetCommand() == "open_browser")
                        {
                            var d = new PluginCallback(_control.StartBrowser);
                            _mainForm.Invoke(d, new object[] { });
                        }

                        if (message.GetCommand() == "open_custom_browser")
                        {
                            var d = new PluginCallback(_control.StartCustomBrowser);
                            _mainForm.Invoke(d, new object[] { });
                        }

                        if (message.GetCommand() == "close_browser")
                        {
                            var d = new PluginCallback(_control.StopBrowser);
                            _mainForm.Invoke(d, new object[] { });
                        }

                        if (message.GetCommand() == "change_url")
                        {
                            var p     = message.GetParameter();
                            var value = "";

                            if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                            {
                                value = Message.GetAttribute(p, "url");
                            }

                            if (value != "")
                            {
                                _control.SetUrl(value);
                            }

                            var d = new PluginCallback(_control.ChangeUrl);
                            _mainForm.Invoke(d, new object[] { });
                        }
                    }
                    catch (Exception e)
                    {
                        TraceOps.Out(e.ToString());
                    }
                }));
                thread.Start();
            }
            catch (Exception e)
            {
                TraceOps.Out(e.ToString());
            }
        }
Example #11
0
 private void notifyIcon_DoubleClick(object sender, EventArgs e)
 {
     if (FormWindowState.Minimized == WindowState)
     {
         Show();
         TraceOps.SetLogVisible();
         WindowState = FormWindowState.Normal;
     }
 }
Example #12
0
 private void TaskManagerOnTask(Message message)
 {
     switch (message.GetCommand())
     {
     default:
         TraceOps.Out(message.GetCommand());
         break;
     }
 }
Example #13
0
 public Window()
 {
     try
     {
         this.CreateHandle(new CreateParams());
     }
     catch (Exception ex)
     {
         TraceOps.Out(System.Environment.NewLine + "Target  :  " + ex.TargetSite.ToString() + System.Environment.NewLine + "Message :  " + ex.Message.ToString() + System.Environment.NewLine + "Stack   :  " + ex.StackTrace.ToString());
     }
 }
Example #14
0
 public static void RemoteStopLeaf(object sender, EventArgs e)
 {
     foreach (ConnectionTable.ClientInformation clientInformation in _connectionTable.GetChecked())
     {
         TraceOps.Out(clientInformation.GetName());
         var p = new string[, ] {
             { }, { }
         };
         var m = new Message(p, true, "stop_zleaf", clientInformation.GetName());
         _messageQueue.SetMessage(m);
     }
 }
Example #15
0
        private void securityOptionsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var securityOptionsForm = new SecurityOptionsForm()
            {
                TopLevel = true
            };

            if (securityOptionsForm.ShowDialog() == DialogResult.OK)
            {
                TraceOps.Out("Set PaceServer Security.\r\n");
            }
        }
Example #16
0
 private void MainClientForm_Location(object sender, EventArgs e)
 {
     if (Visible == true)
     {
         var location = Location;
         location.X += Width;
         TraceOps.SetLogPosition(location);
     }
     else
     {
         TraceOps.SetLogHidden();
     }
 }
Example #17
0
        ///////////////////////////////////////////////////////////////////////

        #region Error Handling Methods
        public static void Fail(
            Configuration configuration,
            Assembly assembly,
            string message,
            string category
            )
        {
            TraceOps.ShowMessage(
                configuration, assembly, message, category,
                MessageBoxButtons.OK, MessageBoxIcon.Error);

            Environment.Exit(1);
        }
Example #18
0
 public void StartCustomBrowser()
 {
     try
     {
         _customBrowserForm = new CustomBrowser()
         {
             TopLevel = true
         };
         _customBrowserForm.Show();
     }
     catch (Exception exception)
     {
         TraceOps.Out(exception.ToString());
     }
 }
Example #19
0
        public void StartZLeaf()
        {
            try
            {
                var exeToRun  = Path.Combine(Path.GetTempPath(), "zleaf.exe");
                var ci        = _connectionTable.Get("Server");
                var arguments = ClientModel.BuildCommandLineOptionsZLeaf(ci.GetIp(), _name, 200, 200, 200, 200);

                ProcessControl.FindDeleteFileAndStartAgain(exeToRun, "zleaf", true, true, Resources.zleaf, arguments);
            }
            catch (Exception exception)
            {
                TraceOps.Out(exception.ToString());
            }
        }
Example #20
0
        public void RegisterGlobalHotKey(ModifierKeys modifier, Keys key, Form mainForm)
        {
            try
            {
                _currentId = _currentId + 1;

                if (!RegisterHotKey(_window.Handle, _currentId, (uint)modifier, (uint)key))
                {
                    TraceOps.Out("Couldn’t register the hot key.");
                }
            }
            catch (Exception ex)
            {
                TraceOps.Out(System.Environment.NewLine + "Target  :  " + ex.TargetSite.ToString() + System.Environment.NewLine + "Message :  " + ex.Message.ToString() + System.Environment.NewLine + "Stack   :  " + ex.StackTrace.ToString());
            }
        }
Example #21
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            var p = new string[, ] {
                { "p1", "v1" }, { "p2", "v2" }
            };
            var m = new Message(p, true, "ping", "Server");

            if (_messageQueue != null)
            {
                _messageQueue.SetMessage(m);
            }
            else
            {
                TraceOps.Out("no connection to server message queue");
            }
        }
Example #22
0
        private void preferencesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var preferencesForm = new PreferencesForm()
            {
                TopLevel = true
            };

            if (preferencesForm.ShowDialog() == DialogResult.OK)
            {
                var startOnSystemStart = preferencesForm.checkBoxRunOnStartup.Checked;
                if (startOnSystemStart)
                {
                    TraceOps.Out("Set PaceServer Preferences.\r\n");
                }
            }
        }
Example #23
0
        private void TaskManagerOnTask(Message message)
        {
            switch (message.GetCommand())
            {
            case "":
                Console.WriteLine("Case 1");
                break;

            case "a":
                Console.WriteLine("Case 2");
                break;

            default:
                TraceOps.Out(message.GetCommand());
                break;
            }
        }
Example #24
0
        private void MainClientForm_Load(object sender, EventArgs e)
        {
            TraceOps.LoadLog();
            Services.PrepareGetService();
            SystemOps.SetAutoStart();

            _configServer          = new ConfigServer();
            _configServer.Changed += ConfigServerOnChanged;

            _keyboard = new KeyboardControl();
            _keyboard.RegisterGlobalHotKey(Constants.NOMOD, Keys.Left, this);
            _keyboard.RegisterGlobalHotKey(Constants.NOMOD, Keys.Right, this);
            _keyboard.KeyPressed += HandleHotkey;


            DllLoader.InitializeClientPlugIns(_plugins);
        }
Example #25
0
 public KeyboardControl()
 {
     Running = true;
     try
     {
         _window.KeyPressed += delegate(object sender, KeyPressedEventArgs args)
         {
             if (KeyPressed != null)
             {
                 KeyPressed(this, args);
             }
         };
     }
     catch (Exception ex)
     {
         TraceOps.Out(System.Environment.NewLine + "Target  :  " + ex.TargetSite.ToString() + System.Environment.NewLine + "Message :  " + ex.Message.ToString() + System.Environment.NewLine + "Stack   :  " + ex.StackTrace.ToString());
     }
 }
Example #26
0
        public void StopBrowser()
        {
            try
            {
                if (_customBrowserForm != null)
                {
                    _customBrowserForm.Visible = false;
                }

                if (_browserForm != null)
                {
                    _browserForm.Visible = false;
                }
            }
            catch (Exception exception)
            {
                TraceOps.Out(exception.ToString());
            }
        }
Example #27
0
            protected override void WndProc(ref Message m)
            {
                try
                {
                    base.WndProc(ref m);
                    if (m.Msg == WM_HOTKEY)
                    {
                        var key      = (Keys)(((int)m.LParam >> 16) & 0xFFFF);
                        var modifier = (ModifierKeys)((int)m.LParam & 0xFFFF);

                        if (KeyPressed != null)
                        {
                            KeyPressed(this, new KeyPressedEventArgs(modifier, key));
                        }
                    }
                }
                catch (Exception ex)
                {
                    TraceOps.Out(System.Environment.NewLine + "Target  :  " + ex.TargetSite.ToString() + System.Environment.NewLine + "Message :  " + ex.Message.ToString() + System.Environment.NewLine + "Stack   :  " + ex.StackTrace.ToString());
                }
            }
Example #28
0
        ///////////////////////////////////////////////////////////////////////

        #region Application Exit Event Handler
        private static void ApplicationExit(
            object sender,
            EventArgs e
            )
        {
            Configuration configuration;

            lock (syncRoot)
            {
                configuration = savedConfiguration;
            }

            TraceOps.Trace(configuration, "Exiting.", TraceCategory);

            string error = null;

            if (!FileOps.DeleteInUse(configuration, ref error))
            {
                Fail(configuration, assembly, error, TraceCategory);
            }
        }
Example #29
0
        public static void ChangeUrl(object sender, EventArgs e)
        {
            var changeUrlForm = new ServerChangeUrlForm()
            {
                TopLevel = true
            };

            TraceOps.Out("result" + changeUrlForm.ShowDialog().ToString());
            if (changeUrlForm.textBoxUrl.Text != null)
            {
                var url = changeUrlForm.textBoxUrl.Text;
                var p   = new string[, ] {
                    { "url", url }
                };

                foreach (var m in from ConnectionTable.ClientInformation clientInformation in _connectionTable.GetChecked() select new Message(p, true, "change_url", clientInformation.GetName()))
                {
                    _messageQueue.SetMessage(m);
                }
            }
        }
Example #30
0
        public void SetTask(Message message)
        {
            TraceOps.Out("ExternalControl Client recived Message: " + message.GetCommand());
            if (message.GetCommand() == "start_externalcontrol")
            {
                var d = new PluginCallback(_control.RemoteStartProcess);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "start_externalcontrol")
            {
                var d = new PluginCallback(_control.RemoteStopProcess);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "restart_windows")
            {
                var d = new PluginCallback(_control.RemoteStartProcess);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "logoff_windows")
            {
                var d = new PluginCallback(_control.RemoteStartProcess);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "shutdown_windows")
            {
                var d = new PluginCallback(_control.RemoteStartProcess);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "start_keylogging")
            {
                var d = new PluginCallback(_control.RemoteKeyLogging);
                _mainForm.Invoke(d, new object[] { });
            }
        }