Esempio n. 1
0
 public MainPage()
 {
     this.InitializeComponent();
     lunchPlanHandler = new LunchPlanHandler();
     mealHandler      = new MealHandler();
     dbHandler        = new DBHandler();
     messageHandler   = new MessageHandler();
     adminHandler     = new AdminHandler();
     iPHandler        = new IPHandler();
     model            = dbHandler.Model;
     CmbBoxWeekNumbers.ItemsSource   = Enumerable.Range(1, 52);
     CmbBoxWeekNumbers.SelectedIndex = GetIso8601WeekOfYear(DateTime.Now) - 1;
     ShowSelectedLunchPlan(GetIso8601WeekOfYear(DateTime.Now));
     BtnDeleteDish.IsHitTestVisible = false;
     BtnDeleteDish.Opacity          = 0.4;
     try
     {
         ListViewDatabaseDishes.ItemsSource = model.Meals.OrderByDescending(m => m.TimesChosen);
         LoadMessage();
     }
     catch (ArgumentNullException e)
     {
         Debug.Write(e);
     }
 }
Esempio n. 2
0
        public StructuredNode(AHAddress add, string realm) : base(add, realm)
        {
            /**
             * Here are the ConnectionOverlords
             */
            _leafco = new LeafConnectionOverlord(this);
            AddConnectionOverlord(_leafco);
            _snco = new StructuredNearConnectionOverlord(this);
            AddConnectionOverlord(_snco);
            _ssco = new StructuredShortcutConnectionOverlord(this);
            AddConnectionOverlord(_ssco);
#if !BRUNET_SIMULATOR
            _iphandler = new IPHandler();
            _iphandler.Subscribe(this, null);
            AddTADiscovery(new LocalDiscovery(this, Realm, _rpc, _iphandler));
#endif

            /**
             * Turn on some protocol support :
             */
            /// Turn on Packet Forwarding Support :
            GetTypeSource(PType.Protocol.Forwarding).Subscribe(new PacketForwarder(this), null);
            //Handles AHRouting:
            GetTypeSource(PType.Protocol.AH).Subscribe(new AHHandler(this), this);
            GetTypeSource(PType.Protocol.Echo).Subscribe(new EchoHandler(), this);

            //Add the standard RPC handlers:
            _rpc.AddHandler("sys:ctm", new CtmRequestHandler(this));
            sys_link = new ConnectionPacketHandler(this);
            _rpc.AddHandler("sys:link", sys_link);
            _rpc.AddHandler("trace", new TraceRpcHandler(this));
            //Serve some public information about our ConnectionTable
            _rpc.AddHandler("ConnectionTable", new ConnectionTableRpc(ConnectionTable, _rpc));
            //Add a map-reduce handlers:
            _mr_handler = new MapReduceHandler(this);
            //Subscribe it with the RPC handler:
            _rpc.AddHandler("mapreduce", _mr_handler);

            //Subscribe map-reduce tasks
            _mr_handler.SubscribeTask(new MapReduceTrace(this));
            _mr_handler.SubscribeTask(new MapReduceRangeCounter(this));


            /*
             * Handle Node state changes.
             */
            StateChangeEvent += delegate(Node n, Node.ConnectionState s) {
                if (s == Node.ConnectionState.Leaving)
                {
                    //Start our StructuredNode specific leaving:
                    Leave();
                }
            };

            _connection_table.ConnectionEvent    += new EventHandler(this.EstimateSize);
            _connection_table.ConnectionEvent    += new EventHandler(this.UpdateNeighborStatus);
            _connection_table.DisconnectionEvent += new EventHandler(this.EstimateSize);
            _connection_table.DisconnectionEvent += new EventHandler(this.UpdateNeighborStatus);
        }
Esempio n. 3
0
 public LocalDiscovery(ITAHandler ta_handler, string realm, RpcManager rpc, IPHandler iphandler) :
     base(ta_handler)
 {
     _rpc       = rpc;
     _iphandler = iphandler;
     _realm     = realm;
     _rpc.AddHandler(RPC_CLASS, this);
 }
Esempio n. 4
0
        public string[] MgmtTestsExtendedArray(IPHandler ipHandler)
        {
            string[] testMgmt = new string[5];

            testMgmt[0] = "tracert " + ipHandler.OverrideIP;
            testMgmt[1] = "iperf-2.0.13-win -c " + ipHandler.OverrideIP + " -t 50 -i 5 -w 150k";
            testMgmt[2] = "iperf-2.0.13-win -c " + ipHandler.OverrideIP + " -t 50 -R -i 5 -w 150k";
            testMgmt[3] = "iperf-2.0.13-win -c " + ipHandler.OverrideIP + " -t 50 -i 5 -w 300k";
            testMgmt[4] = "iperf-2.0.13-win -c " + ipHandler.OverrideIP + " -t 50 -R -i 5 -w 300k";

            return(testMgmt);
        }
Esempio n. 5
0
        public string[] MgmtTestsArray(IPHandler ipHandler)
        {
            string[] testMgmt = new string[7];

            testMgmt[0] = "tracert " + ipHandler.OverrideIP;
            testMgmt[1] = "iperf-2.0.13-win -c " + ipHandler.OverrideIP + " -t 50 -i 1";
            testMgmt[2] = "iperf-2.0.13-win -c " + ipHandler.OverrideIP + " -t 50 -R -i 1";
            testMgmt[3] = "iperf-2.0.13-win -c " + ipHandler.OverrideIP + " -t 50 -u -i 1";
            testMgmt[4] = "iperf-2.0.13-win -c " + ipHandler.OverrideIP + " -t 50 -u -R -i 1";
            testMgmt[5] = "iperf-2.0.13-win -c " + ipHandler.OverrideIP + " -t 50 -u -b 200M -i 1";
            testMgmt[6] = "iperf-2.0.13-win -c " + ipHandler.OverrideIP + " -t 50 -u -b 200M -R -i 1";

            return(testMgmt);
        }
Esempio n. 6
0
 public MainPage()
 {
     this.InitializeComponent();
     lunchPlanHandler = new LunchPlanHandler();
     mealHandler      = new MealHandler();
     dbHandler        = new DBHandler();
     messageHandler   = new MessageHandler();
     imageHandler     = new ImageHandler();
     rSSFeedHandler   = new RSSFeedHandler("http://feeds.tv2.dk/nyhederne_seneste/rss");
     iPHandler        = new IPHandler();
     clockHandler     = new ClockHandler();
     Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().Title = CalendarHandler.GetStringDate("dd/MM/yyyy") + " - Uge : " + CalendarHandler.GetWeekNumber();
     UpdateIp();
     counter = 0;
     SetDpTimer();
 }
Esempio n. 7
0
        private static ManagementScope getScope(string target, bool subscription)
        {
            ManagementScope scope;

            if (subscription)
            {
                scope = new ManagementScope("\\\\" + target + "\\Root\\subscription", options);
            }
            else
            {
                scope = new ManagementScope("\\\\" + target + "\\Root\\CIMV2", options);
            }
            try
            {
                scope.Connect();
            }
            //user credentials cannot be used in local connections
            catch (ManagementException)
            {
                scope.Options = new ConnectionOptions();
                scope.Connect();
            }
            catch (UnauthorizedAccessException)
            {
                //scope refers to local ip. If credential in options a different from current user credentials,
                //it will cause an 'access denied' exception
                if (IPHandler.get_local_ip().Equals(target) || target.Equals("127.0.0.1"))
                {
                    scope.Options = new ConnectionOptions();
                    scope.Connect();
                }
                else
                {
                    //access denied (wrong credentials)
                    return(null);
                }
            }
            //RPC server is unavaliable
            catch (System.Runtime.InteropServices.COMException e)
            {
                return(null);
            }

            return(scope);
        }
Esempio n. 8
0
 /// <summary>
 /// Inserts the machines current IP into the database (mostly obsolete with a static IP assigned)
 /// </summary>
 private void UpdateIp()
 {
     try
     {
         if (iPHandler.HasIp())
         {
             iPHandler.UpdateIP(IPHandler.CheckIP());
         }
         else
         {
             iPHandler.CreateNewIp(IPHandler.CheckIP());
         }
     }
     catch (Exception error)
     {
         DataValidation.SaveError(error.ToString());
     }
 }