Example #1
0
        static void Main(string[] args)
        {
            var ac = new ActivitySystem();
            ac.Run("http://127.0.0.1:8080/");

            Console.ReadLine();
        }
        public ActivityService( ActivitySystem system, string ip, int port )
        {
            InitializeSevice( system, ip, port );

            ActivitySystem = system;

            ActivitySystem.ActivityAdded += ActivitySystem_ActivityAdded;
            ActivitySystem.ActivityChanged += ActivitySystem_ActivityChanged;
            ActivitySystem.ActivityRemoved += ActivitySystem_ActivityRemoved;

            ActivitySystem.DeviceAdded += ActivitySystem_DeviceAdded;
            ActivitySystem.DeviceChanged += ActivitySystem_DeviceChanged;
            ActivitySystem.DeviceRemoved += ActivitySystem_DeviceRemoved;

            ActivitySystem.UserAdded += ActivitySystem_UserAdded;
            ActivitySystem.UserChanged += ActivitySystem_UserChanged;
            ActivitySystem.UserRemoved += ActivitySystem_UserRemoved;

            ActivitySystem.ResourceAdded += ActivitySystem_ResourceAdded;
            ActivitySystem.ResourceChanged += ActivitySystem_ResourceChanged;
            ActivitySystem.ResourceRemoved += ActivitySystem_ResourceRemoved;

            ActivitySystem.NotificationAdded += ActivitySystem_NotificationAdded;
            ActivitySystem.NotificationChanged += ActivitySystem_NotificationChanged;
            ActivitySystem.NotificationRemoved += ActivitySystem_NotificationRemoved;

            ActivitySystem.FileResourceAdded += ActivitySystem_FileResourceAdded;
            ActivitySystem.FileResourceChanged += ActivitySystem_FileResourceChanged;
            ActivitySystem.FileResourceRemoved += ActivitySystem_FileResourceRemoved;

            Instance = this;

        }
Example #3
0
        static void Main(string[] args)
        {
            var ac = new ActivitySystem();

            ac.Run("http://127.0.0.1:8080/");

            Console.ReadLine();
        }
Example #4
0
        protected void Application_Start()
        {
            //RouteTable.Routes.MapHubs();
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();
            //AreaRegistration.RegisterAllAreas();
            //Create a user
            var user = new User
            {
                Name = "SmartPortalServer"
            };
            //Create a device
            var device = new Device
            {
                DeviceType = DeviceType.Desktop,
                DevicePortability = DevicePortability.Stationary,
                Owner = user
            };
            //create databaseconfiguration
            var databaseConfiguration = new DatabaseConfiguration("localhost", 8080, "smartportal");
            var activitySystem = new ActivitySystem(databaseConfiguration) { Device = device };

            Portal.Instance().ActivitySystem = activitySystem;

            //  HANDLERS
            activitySystem.UserAdded += activitySystem_UserAdded;
            activitySystem.UserChanged += activitySystem_userChanged;

            activitySystem.StartLocationTracker();
            activitySystem.Tracker.TagEnter += Tracker_TagEnter;

            /*

            //Start a activityservice which wraps an activity system into a REST service
            var activityService = new ActivityService(activitySystem, "127.0.0.1", 8060);
            activityService.Start();

            //make the system discoverable on the LAN
             activityService.StartBroadcast(DiscoveryType.Zeroconf, "smartPortalActivitySystem", "smartPortal", "1234");
              */
        }
Example #5
0
        public ActivityService( ActivitySystem system, string ip, int port )
        {
            InitializeSevice( system, ip, port );

            ActivitySystem = system;

            ActivitySystem.ActivityAdded += ActivitySystem_ActivityAdded;
            ActivitySystem.ActivityChanged += ActivitySystem_ActivityChanged;
            ActivitySystem.ActivityRemoved += ActivitySystem_ActivityRemoved;

            ActivitySystem.DeviceAdded += ActivitySystem_DeviceAdded;
            ActivitySystem.DeviceChanged += ActivitySystem_DeviceChanged;
            ActivitySystem.DeviceRemoved += ActivitySystem_DeviceRemoved;

            ActivitySystem.UserAdded += ActivitySystem_UserAdded;
            ActivitySystem.UserChanged += ActivitySystem_UserChanged;
            ActivitySystem.UserRemoved += ActivitySystem_UserRemoved;

        }
Example #6
0
 /// <summary>
 /// 清除各个子面板
 /// </summary>
 public void UnInitLobbyMainSystems()
 {
     WXLoginSystem.Destroy();
     RealNameApproveSystem.Destroy();
     LobbyMainSystem.Destroy();
     ShareWxSystem.Destroy();
     HolidayActivitySystem.Destroy();
     GetGiftSpreadBagSystem.Destroy();
     UserInfoSystem.Destroy();
     GamePlayingMethodSystem.Destroy();
     ProductAgencySystem.Destroy();
     CustomSystem.Destroy();
     PlayerMessageSystem.Destroy();
     ActivitySystem.Destroy();
     ActiveGiftSystem.Destroy();
     CreatRoomMessageSystem.Destroy();
     JoinRoomShowSystem.Destroy();
     InsteadOpenRoomSystem.Destroy();
     SelectAreaSystem.Destroy();
     HistroyGradeSystem.Destroy();
     ParlorShowSystem.Destroy();
     RedPageShowSystem.Destroy();
 }
Example #7
0
        private void StartClientAndSystem()
        {
            var webconfiguration = WebConfiguration.DefaultWebConfiguration;

            const string ravenDatabaseName = "activitysystem";

            var databaseConfiguration = new DatabaseConfiguration(webconfiguration.Address, webconfiguration.Port, ravenDatabaseName);

            _activitySystem = new ActivitySystem(databaseConfiguration);

            InitializeEvents(_activitySystem);

            _activitySystem.StartLocationTracker();

            InitializeData(_activitySystem);

            _activityService = new ActivityService(_activitySystem, Net.GetIp(IpType.All), 8070);
            _activityService.Start();


            _activityService.StartBroadcast(DiscoveryType.Zeroconf,
                                            "Department-x", "Anonymous Hospital, 4th floor");
        }
 public ResourcesController(ActivitySystem system)
 {
     _system = system;
 }
 public ResourcesController(ActivitySystem system)
 {
     _system = system;
 }
 public NotificationsController(ActivitySystem system)
 {
     _system = system;
 }
Example #11
0
        void InitializeSevice( ActivitySystem system, string ip, int port )
        {
            ActivitySystem = system;

            Ip = ip;
            Port = port;

            Initialized( this, new EventArgs() );
        }
Example #12
0
 public DevicesController(ActivitySystem system)
 {
     _system = system;
 }
 public TagLocationsController(ActivitySystem system)
 {
     _system = system;
 }
 public TagLocationsController(ActivitySystem system)
 {
     _system = system;
 }
 public NotificationsController(ActivitySystem system)
 {
     _system = system;
 }
Example #16
0
        private void StartClientAndSystem()
        {
            _activitySystem = new ActivitySystem(systemName: "WardNode-" + Guid.NewGuid());

            _activitySystem.ConnectionEstablished += _activitySystem_ConnectionEstablished;

            InitializeEvents(_activitySystem);

            _activitySystem.Run(Net.GetUrl(_webConfiguration.Address, _webConfiguration.Port, "").ToString());

            _activitySystem.StartBroadcast(ABC.Infrastructure.Discovery.DiscoveryType.Zeroconf,
                "Department-x", "Anonymous Hospital, 4th floor");

            _activitySystem.StartLocationTracker();
        }
Example #17
0
 public FilesController(ActivitySystem system)
 {
     _system = system;
 }
 public DevicesController(ActivitySystem system)
 {
     _system = system;
 }
Example #19
0
 public UsersController(ActivitySystem system)
 {
     _system = system;
 }
Example #20
0
 public FilesController(ActivitySystem system)
 {
     _system = system;
 }
Example #21
0
 public UsersController(ActivitySystem system)
 {
     _system = system;
 }
Example #22
0
        static void Main(string[] args)
        {
            //Create a user
            var user = new User
            {
                Name = "Steven"
            };

            //Create a device
            var device = new Device
            {
                DeviceType = DeviceType.Desktop,
                DevicePortability = DevicePortability.Stationary,
                Owner = user
            };

            //create databaseconfiguration
            var databaseConfiguration = new DatabaseConfiguration("127.0.0.1", 8080, "test");

            //create activitysystem: this is the main component that provides an activity-
            //centric wrapper over a pure datastore. This system cam be used by the UI
            //directly through events or be exposed to a REST service using the activityservice
            //and accessed on other devices by using the activityclient
            activitySystem = new ActivitySystem(databaseConfiguration,false) { Device = device };

            //add handlers to the system for local UI support.
            activitySystem.ActivityAdded+=activitySystem_ActivityAdded;
            activitySystem.DeviceAdded += activitySystem_DeviceAdded;
            activitySystem.UserAdded += activitySystem_UserAdded;

            //Start a activityservice which wraps an activity system into a REST service
            var activityService = new ActivityService(activitySystem, "127.0.0.1", 8060);
            activityService.Start();

            //make the system discoverable on the LAN
            activityService.StartBroadcast(DiscoveryType.Zeroconf, "activitySystem", "mycompany","1234");

            activitySystem.StartLocationTracker();
            activitySystem.Tracker.TagEnter += Tracker_TagEnter;

            //Wait for one second to allow the service to start
            Thread.Sleep(1000);

            //Use the discoverymanager to find the activityservice and connect to it
            //using an activityclient. This should be used to connect to the
            //activity system from a different device.
            var disco = new DiscoveryManager();

            disco.DiscoveryAddressAdded += (sender, e) =>
            {
                if (e.ServiceInfo.Code != "1234")
                    return;

                var foundWebConfiguration = new WebConfiguration(e.ServiceInfo.Address);

                //Note that you don't have to use discovery but can connect directly
                //if you know the IP
                var activityClient = new ActivityClient(foundWebConfiguration.Address, foundWebConfiguration.Port, device);
                activityClient.ActivityAdded += activityClient_ActivityAdded;
                activityClient.UserAdded += activityClient_UserAdded;
                activityClient.DeviceAdded += activityClient_DeviceAdded;

                activityClient.FileResourceAdded += (o, i) =>
                {
                    Console.WriteLine("Resource {0} update received from activityclient over http", i.Resource.Id);

                    using (var stream = activityClient.GetFileResource(i.Resource))
                    {
                        var fileStream = File.Create(@"C:\Users\Public\Pictures\Sample Pictures\Desert-"+DateTime.Now.ToShortDateString()+".jpg", (int)stream.Length);
                        var bytesInStream = new byte[stream.Length];
                        stream.Read(bytesInStream, 0, bytesInStream.Length);
                        fileStream.Write(bytesInStream, 0, bytesInStream.Length);
                        fileStream.Close();
                    }
                };

                var act = new Activity();

                activityClient.AddActivity(act);
                //activityClient.AddFileResource(
                //    act,
                //    "IMG",
                //    Path.GetFileName(@"C:\Users\Public\Pictures\Sample Pictures\Desert.jpg"),
                //    new MemoryStream(File.ReadAllBytes(@"C:\Users\Public\Pictures\Sample Pictures\Desert.jpg")));
            };

            disco.Find(DiscoveryType.Zeroconf);

            //To produce test data
            while (true)
            {
                Console.WriteLine("Press a + enter for new activity, press u + enter for new user");
                var input = Console.ReadLine();
                if(input == "a")
                    activitySystem.AddActivity(new Activity());
                if(input == "u")
                    activitySystem.AddUser(new User());
            }
        }
Example #23
0
        static void Main(string[] args)
        {
            //Create a user
            var user = new User
            {
                Name = "Steven"
            };

            //Create a device
            var device = new Device
            {
                DeviceType        = DeviceType.Desktop,
                DevicePortability = DevicePortability.Stationary,
                Owner             = user
            };


            //create databaseconfiguration
            var databaseConfiguration = new DatabaseConfiguration("127.0.0.1", 8080, "test");

            //create activitysystem: this is the main component that provides an activity-
            //centric wrapper over a pure datastore. This system cam be used by the UI
            //directly through events or be exposed to a REST service using the activityservice
            //and accessed on other devices by using the activityclient
            activitySystem = new ActivitySystem(databaseConfiguration, false)
            {
                Device = device
            };

            //add handlers to the system for local UI support.
            activitySystem.ActivityAdded += activitySystem_ActivityAdded;
            activitySystem.DeviceAdded   += activitySystem_DeviceAdded;
            activitySystem.UserAdded     += activitySystem_UserAdded;

            //Start a activityservice which wraps an activity system into a REST service
            var activityService = new ActivityService(activitySystem, "127.0.0.1", 8060);

            activityService.Start();

            //make the system discoverable on the LAN
            activityService.StartBroadcast(DiscoveryType.Zeroconf, "activitySystem", "mycompany", "1234");

            activitySystem.StartLocationTracker();
            activitySystem.Tracker.TagEnter += Tracker_TagEnter;

            //Wait for one second to allow the service to start
            Thread.Sleep(1000);

            //Use the discoverymanager to find the activityservice and connect to it
            //using an activityclient. This should be used to connect to the
            //activity system from a different device.
            var disco = new DiscoveryManager();

            disco.DiscoveryAddressAdded += (sender, e) =>
            {
                if (e.ServiceInfo.Code != "1234")
                {
                    return;
                }

                var foundWebConfiguration = new WebConfiguration(e.ServiceInfo.Address);

                //Note that you don't have to use discovery but can connect directly
                //if you know the IP
                var activityClient = new ActivityClient(foundWebConfiguration.Address, foundWebConfiguration.Port, device);
                activityClient.ActivityAdded += activityClient_ActivityAdded;
                activityClient.UserAdded     += activityClient_UserAdded;
                activityClient.DeviceAdded   += activityClient_DeviceAdded;

                activityClient.FileResourceAdded += (o, i) =>
                {
                    Console.WriteLine("Resource {0} update received from activityclient over http", i.Resource.Id);

                    using (var stream = activityClient.GetFileResource(i.Resource))
                    {
                        var fileStream    = File.Create(@"C:\Users\Public\Pictures\Sample Pictures\Desert-" + DateTime.Now.ToShortDateString() + ".jpg", (int)stream.Length);
                        var bytesInStream = new byte[stream.Length];
                        stream.Read(bytesInStream, 0, bytesInStream.Length);
                        fileStream.Write(bytesInStream, 0, bytesInStream.Length);
                        fileStream.Close();
                    }
                };

                var act = new Activity();

                activityClient.AddActivity(act);
                //activityClient.AddFileResource(
                //    act,
                //    "IMG",
                //    Path.GetFileName(@"C:\Users\Public\Pictures\Sample Pictures\Desert.jpg"),
                //    new MemoryStream(File.ReadAllBytes(@"C:\Users\Public\Pictures\Sample Pictures\Desert.jpg")));
            };

            disco.Find(DiscoveryType.Zeroconf);



            //To produce test data
            while (true)
            {
                Console.WriteLine("Press a + enter for new activity, press u + enter for new user");
                var input = Console.ReadLine();
                if (input == "a")
                {
                    activitySystem.AddActivity(new Activity());
                }
                if (input == "u")
                {
                    activitySystem.AddUser(new User());
                }
            }
        }