Exemplo n.º 1
0
 public void SaveClientSystem(ClientSystem c, SystemInventory si)
 {//Mehtod is onlyused to initial save the system
     try
     {
         connection = new SQLiteConnection("Data Source=" + dbpath + ";Version=3; foreign keys=true;");
         connection.Open();
         command             = new SQLiteCommand(connection);
         command.CommandText = "INSERT INTO clientsystem (clientSystemNumber, networknumber, computername, type, serial, clientIP) VALUES(@clientSystemNumber, @networknumber, @computername, @type, @serial, @clientIP);";
         command.Parameters.AddWithValue("@clientSystemNumber", c.ClientSystemNumber);
         command.Parameters.AddWithValue("@networknumber", c.Networknumber);
         command.Parameters.AddWithValue("@computername", c.Computername);
         command.Parameters.AddWithValue("@type", c.Type);
         command.Parameters.AddWithValue("@serial", c.Serial);
         command.Parameters.AddWithValue("@clientIP", c.ClientIP.ToString());
         command.ExecuteNonQuery();
         //Connect clientsystem to systeminventory in database
         command.CommandText = "INSERT INTO containsSystem (systemInventoryNumber, clientSystemNumber) VALUES(@systemInventoryNumber, @clientSystemNumber);";
         command.Parameters.AddWithValue("@clientSystemNumber", c.ClientSystemNumber);
         command.Parameters.AddWithValue("@systemInventoryNumber", si.SystemInventoryNumber);
         command.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         MessageBox.Show("Error SQL Write Clientsystem", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Log.WriteLog(e.Message);
     }
     connection.Close();
 }
Exemplo n.º 2
0
        public static void Split(ClientSystem system)
        {
            var clients = system.Clients.ToList();

            Instance.mUnits.Remove(system);
            clients.ForEach(item => Instance.mUnits.Add(item));
        }
Exemplo n.º 3
0
 //Updates the Clientinformations in the view
 public void ClientSelected(Object c)
 {
     if (c != null)
     {
         currentSystem = (ClientSystem)c;
         view.UpdateClientDetails(currentSystem.Computername, currentSystem.ClientIP.ToString(), currentSystem.Type);
     }
 }
Exemplo n.º 4
0
        public static ClientSystem Merge(String systemName, List <Client> clients)
        {
            var traces = new HashSet <NetworkTraceInfo>(clients.SelectMany(item => item.FoundInTraces));
            var system = new ClientSystem(systemName, clients, traces);

            clients.ForEach(item => Instance.mUnits.Remove(item));
            Instance.mUnits.Add(system);

            return(system);
        }
Exemplo n.º 5
0
 /// <summary>
 /// 单独会话模式:每个请求创建一个通道,结束或异常时会 自动关闭和中断的服务代理
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void TestAutoAbortChannelWhenError()
 {
     try
     {
         Console.WriteLine("x/y={2} when x={0} and y={1}", 4, 2, ClientSystem.CCalculator().Divide(4, 2));;
         ClientSystem.CCalNoErHandle().TestThrowError();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
Exemplo n.º 6
0
        public ArrayList GetClientSystems()
        {
            ArrayList list_ClientSystems = new ArrayList();

            try
            {
                connection = new SQLiteConnection("Data Source=" + dbpath + ";Version=3;MultipleActiveResultSets=True; foreign keys=true;");
                connection.Open();
                command             = new SQLiteCommand(connection);
                command.CommandText = "SELECT * FROM clientsystem;";
                SQLiteDataReader r = command.ExecuteReader();
                while (r.Read())
                {
                    ClientSystem c;
                    object       test = r["networknumber"];
                    if (test != DBNull.Value)
                    {
                        c = new ClientSystem(r.GetInt32(0), IPAddress.Parse((string)r["clientIP"]), r.GetInt32(1));
                    }
                    else
                    {
                        c = new ClientSystem(r.GetInt32(0), IPAddress.Parse((string)r["clientIP"]), -1);
                    }
                    test = r["type"];
                    if (test != DBNull.Value)
                    {
                        c.Type         = (string)r["type"];
                        c.Computername = (string)r["computername"];
                        c.Serial       = (string)r["serial"];
                    }
                    else
                    {
                        c.Type         = null;
                        c.Computername = null;
                        c.Serial       = null;
                    }
                    list_ClientSystems.Add(c);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error SQL Reading ClientSystems", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log.WriteLog(e.Message);
            }
            connection.Close();
            return(list_ClientSystems);
        }
Exemplo n.º 7
0
 public void UpdateClientSystem(ClientSystem c)
 {
     try
     {
         connection = new SQLiteConnection("Data Source=" + dbpath + ";Version=3; foreign keys=true;");
         connection.Open();
         command             = new SQLiteCommand(connection);
         command.CommandText = "UPDATE clientsystem SET computername=@computername, computername=@computername, type=@type, serial=@serial WHERE clientSystemNumber=@clientSystemNumber ;";
         command.Parameters.AddWithValue("@clientSystemNumber", c.ClientSystemNumber);
         command.Parameters.AddWithValue("@computername", c.Computername);
         command.Parameters.AddWithValue("@type", c.Type);
         command.Parameters.AddWithValue("@serial", c.Serial);
         command.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         MessageBox.Show("Error SQL Update ClientSystem", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Log.WriteLog(e.Message);
     }
     connection.Close();
 }
Exemplo n.º 8
0
        public ArrayList GetSystemInventories()
        {
            ArrayList list_systeminventories = new ArrayList();

            try
            {
                connection = new SQLiteConnection("Data Source=" + dbpath + ";Version=3; MultipleActiveResultSets=True; foreign keys=true;");
                connection.Open();
                command             = new SQLiteCommand(connection);
                command.CommandText = "SELECT * FROM systeminventory;";
                SQLiteDataReader r = command.ExecuteReader();
                while (r.Read())
                {
                    SystemInventory currentSystemInventory = new SystemInventory(r.GetInt32(1), r.GetInt32(0));
                    currentSystemInventory.Date = (DateTime)r.GetDateTime(2);
                    //Get the beloning clientsystems of the systeminventory
                    SQLiteCommand command2 = new SQLiteCommand(connection);
                    command2.CommandText = "SELECT clientSystemNumber FROM containsSystem WHERE systemInventoryNumber=@siNumber;";
                    command2.Parameters.AddWithValue("@siNumber", currentSystemInventory.SystemInventoryNumber);
                    SQLiteDataReader r_inner = command2.ExecuteReader();
                    while (r_inner.Read())
                    {
                        int clientsystemkNumber = r_inner.GetInt32(0);
                        //Get the beloning Clientsystem
                        SQLiteCommand command3 = new SQLiteCommand(connection);
                        command3.CommandText = "SELECT * FROM clientsystem WHERE clientSystemNumber=@clientSystemNumber;";
                        command3.Parameters.AddWithValue("@clientSystemNumber", clientsystemkNumber);
                        SQLiteDataReader r_inner_inner = command3.ExecuteReader();
                        while (r_inner_inner.Read())
                        {
                            ClientSystem c;
                            object       test = r_inner_inner["networknumber"];
                            if (test != DBNull.Value)
                            {
                                c = new ClientSystem(r_inner_inner.GetInt32(0), IPAddress.Parse((string)r_inner_inner["clientIP"]), r_inner_inner.GetInt32(1));
                            }
                            else
                            {
                                c = new ClientSystem(r_inner_inner.GetInt32(0), IPAddress.Parse((string)r_inner_inner["clientIP"]), -1);
                            }
                            test = r_inner_inner["type"];
                            if (test != DBNull.Value)
                            {
                                c.Type         = (string)r_inner_inner["type"];
                                c.Computername = (string)r_inner_inner["computername"];
                                c.Serial       = (string)r_inner_inner["serial"];
                            }
                            else
                            {
                                c.Type         = null;
                                c.Computername = null;
                                c.Serial       = null;
                            }
                            currentSystemInventory.AddSystemToInventory(c);
                        } //END ClientSystem
                    }     //END containsSystem
                    list_systeminventories.Add(currentSystemInventory);
                }         //END SI
            }
            catch (Exception e)
            {
                MessageBox.Show("Error SQL Reading SystemInventories", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log.WriteLog(e.Message);
            }
            connection.Close();


            return(list_systeminventories);
        }
 public void AddClientSystem(ClientSystem c)
 {
     lstClients.Items.Add(c);
 }
Exemplo n.º 10
0
        private static void _client_Started()
        {
            var world           = new World();
            var commandRecorder = new EntityCommandRecorder();

            var scene = new Scene("Client", world, commandRecorder);

            var factory = _client.GraphicsDevice.ResourceFactory;

            var materialInputLayouts = new MaterialInputLayouts();

            var textureLayout = factory.CreateResourceLayout(
                new ResourceLayoutDescription(
                    new ResourceLayoutElementDescription("SurfaceTexture", ResourceKind.TextureReadOnly, ShaderStages.Fragment),
                    new ResourceLayoutElementDescription("SurfaceSampler", ResourceKind.Sampler, ShaderStages.Fragment),
                    new ResourceLayoutElementDescription("TextureColour", ResourceKind.UniformBuffer, ShaderStages.Fragment)));

            materialInputLayouts.ResourceLayouts["Texture"] = textureLayout;

            materialInputLayouts.ResourceLayouts["WorldTransform"] = factory.CreateResourceLayout(
                new ResourceLayoutDescription(
                    new ResourceLayoutElementDescription("WorldBuffer", ResourceKind.UniformBuffer, ShaderStages.Vertex)));

            materialInputLayouts.ResourceLayouts["SceneInputs"] = factory.CreateResourceLayout(
                new ResourceLayoutDescription(
                    new ResourceLayoutElementDescription("ProjectionBuffer", ResourceKind.UniformBuffer, ShaderStages.Vertex),
                    new ResourceLayoutElementDescription("ViewBuffer", ResourceKind.UniformBuffer, ShaderStages.Vertex),
                    new ResourceLayoutElementDescription("SceneLighting", ResourceKind.UniformBuffer, ShaderStages.Fragment)));

            materialInputLayouts.ResourceLayouts["CameraInputs"] = factory.CreateResourceLayout(
                new ResourceLayoutDescription(
                    new ResourceLayoutElementDescription("CameraInfo", ResourceKind.UniformBuffer, ShaderStages.Vertex)));

            materialInputLayouts.VertexLayouts["Model"] = new VertexLayoutDescription(
                new VertexElementDescription("Position", VertexElementSemantic.Position, VertexElementFormat.Float3),
                new VertexElementDescription("TexCoords", VertexElementSemantic.TextureCoordinate, VertexElementFormat.Float2),
                new VertexElementDescription("Normal", VertexElementSemantic.Normal, VertexElementFormat.Float3));

            materialInputLayouts.VertexLayouts["Lighting"] = new VertexLayoutDescription(
                new VertexElementDescription("Light", VertexElementSemantic.Color, VertexElementFormat.Float1));

            var mesh3dMaterial = new Material(_client.GraphicsDevice, _client.MainSceneFramebuffer, _client.Resources.LoadText("Shaders\\Mesh.vs"), _client.Resources.LoadText("Shaders\\Mesh.fg"),
                                              new string[] { "Model" }, new string[] { "SceneInputs", "WorldTransform", "Texture" }, materialInputLayouts);

            var lightMeshMaterial = new Material(_client.GraphicsDevice, _client.MainSceneFramebuffer, _client.Resources.LoadText("Shaders\\LightMesh.vs"), _client.Resources.LoadText("Shaders\\LightMesh.fg"),
                                                 new string[] { "Model", "Lighting" }, new string[] { "SceneInputs", "WorldTransform", "Texture", "CameraInputs" }, materialInputLayouts);

            var voxelTexturesResource = _client.Resources.LoadImage("Textures\\spritesheet_tiles.png");
            var voxelTexture          = new MaterialTexture(_client.GraphicsDevice, textureLayout, voxelTexturesResource, RgbaFloat.White);
            var redVoxelTexture       = new MaterialTexture(_client.GraphicsDevice, textureLayout, voxelTexturesResource, RgbaFloat.Red);
            var semiTransVoxelColour  = new MaterialTexture(_client.GraphicsDevice, textureLayout, voxelTexturesResource, new RgbaFloat(1.0f, 1.0f, 1.0f, 0.8f));

            Action <Entity> setVoxelRender = (Entity e) =>
            {
                e.Set(new LightVertexResources());
                e.Set(lightMeshMaterial);
                e.Set(voxelTexture);
            };

            var networkedEntities = new NetworkedEntities(world);

            var clientSystem = new ClientSystem(world, _messageTargetMap, _clientMessagingChannel);

            clientSystem.AddListener(new TransformMessageApplier(networkedEntities));
            clientSystem.AddListener(new ClientEntityAssignmentApplier(networkedEntities));
            clientSystem.AddListener(new VoxelSpaceMessageApplier(networkedEntities));
            clientSystem.AddListener(new VoxelGridMessageApplier(setVoxelRender, networkedEntities));
            clientSystem.AddListener(new VoxelGridChangeMessageApplier(networkedEntities));
            clientSystem.AddListener(new EntityRemover(networkedEntities));
            clientSystem.AddListener(new ComponentSyncMessageApplier <EntityMetaData>(networkedEntities));

            scene.AddSystem(clientSystem);

            var parallelRunner = new DefaultParallelRunner(8);

            var px = Image.Load("Assets\\Textures\\cloudtop_rt.png");
            var nx = Image.Load("Assets\\Textures\\cloudtop_lf.png");
            var py = Image.Load("Assets\\Textures\\cloudtop_up.png");
            var ny = Image.Load("Assets\\Textures\\cloudtop_dn.png");
            var pz = Image.Load("Assets\\Textures\\cloudtop_bk.png");
            var nz = Image.Load("Assets\\Textures\\cloudtop_ft.png");

            scene.AddSystem(new SkyboxRenderer(_client.GraphicsDevice, _client.MainSceneFramebuffer, px, nx, py, ny, pz, nz));

            scene.AddSystem(new MeshGeometryRenderer(_client.GraphicsDevice, materialInputLayouts, world));
            scene.AddSystem(new LightMeshGeometryRenderer(_client.GraphicsDevice, materialInputLayouts, world));

            var voxelTypes = LoadVoxelTypes();

            var editors = new List <IEditor>()
            {
                new SelectedEntitySystem(world),
                new EntityInspector(world),
                new EntityList(world),
                new SystemList(scene),
                new VoxelEditor(_clientMessagingChannel, world, voxelTypes.Select((t, i) => (t.Name, new Voxel()
                {
                    Exists = true, BlockType = (ushort)i
                })).ToArray()),
                new VoxelSpaceLoader(_clientMessagingChannel, world)
            };

            _editorMenu.AddEditorSet("Client", editors);

            scene.AddSystem(_editorMenu);
            scene.AddSystems(editors);

            scene.AddSystem(new SunLightPropogationSystem(world, new VoxelTypes(voxelTypes)));

            scene.AddSystem(new VoxelGridMesher(commandRecorder, world, new VoxelTypes(voxelTypes), _client.GraphicsDevice, parallelRunner));

            scene.AddSystem(new MeshGeometryCleaner(world));
            scene.AddSystem(new LightVertexCleaner(world));

            scene.AddSystem(new TransformLerper(networkedEntities, world));

            scene.AddSystem(new FlagClearingSystem <NeighbourMemberChanged>(world));

            scene.AddSystem(new InputForceApplierInputSystem(_clientMessagingChannel, world));
            scene.AddSystem(new SimpleCameraMoverInputSystem(_clientMessagingChannel, world));

            world.SubscribeEntityDisposed((in Entity e) =>
            {
                if (e.Has <VoxelGrid>())
                {
                    var voxelGrid = e.Get <VoxelGrid>();
                    voxelGrid.VoxelSpace.Remove(voxelGrid.MemberIndex);
                }
            });
Exemplo n.º 11
0
 public MyFactory(ClientSystem SystemName)
 {
     CurSystem = SystemName;
 }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            ProductSystem           productSystem    = new ProductSystem();
            ClientSystem            clientSystem     = new ClientSystem();
            ProductAdapter          productAdapter   = new ProductAdapter();
            BillingStatisticsSystem statisticsSystem = new BillingStatisticsSystem(productAdapter);
            BonusFactory            bonusFactory     = new BonusFactory();

            Client client1 = new Client("Ina", "Munteanu", new DateTime(1996, 1, 1));

            clientSystem.AddClient(client1);
            Client client2 = new Client("Maria", "Zeru", new DateTime(1997, 1, 1));

            clientSystem.AddClient(client2);


            Product product1 = new Product();

            product1.Name  = "name1";
            product1.Price = 8;
            product1.DoP   = DateTime.Now;
            productSystem.AddProduct(product1);

            Product product2 = new Product();

            product2.Name  = "name2";
            product2.Price = 12;
            product2.DoP   = DateTime.Now;

            //Decorator
            LimitedEditionProduct limitedEditionProduct1 = new LimitedEditionProduct(product2);

            limitedEditionProduct1.EndOfPromotion = new DateTime(2020, 1, 1);
            productSystem.AddProduct(limitedEditionProduct1);

            Product product3 = new Product();

            product3.Name  = "name3";
            product3.Price = 3;
            product3.DoP   = DateTime.Now;
            productSystem.AddProduct(product3);


            //Flyweight
            Console.WriteLine("\nFlyweight:");
            IBonus bonus = bonusFactory.GetBonus("PrimeUserBonus");

            bonus.AddBonus(client2);
            client2.ShowDiscountData();


            //Bridge
            Console.WriteLine("\nBridge:");
            //client1.ShowPersonalData();
            //client1.EditPersonalData();
            //client1.ShowPersonalData();


            //Adapter
            Console.WriteLine("\nAdapter:");
            statisticsSystem.ShowProductsNameList();
            statisticsSystem.ShowAveragePrice();

            //Decorator
            Console.WriteLine("\nDecorator:");
            limitedEditionProduct1.ShowData();


            //Facade
            Console.WriteLine("\nFacade:");
            //client1.SetClientDiscountStatus();
            bonus.AddBonus(client1);
            client1.AddToCart(product1);
            client1.AddToCart(limitedEditionProduct1);
            client1.TopUpAccount(21);
            client1.GetThePurchaseInfo();
            client1.Purchase();

            //client1.ShowBallanceData();


            Console.ReadKey();
        }
Exemplo n.º 13
0
        //scan Network for Clients
        private void scanNetwork(ProgressBar progress)
        {
            //Create a new system Inventory
            currentSystemInventory = CreateSystemInventroy(currentCustomer.Cnumber);
            Log.WriteLog("New SystemInventory created");
            //Get the latest systemnumber
            int latestsystemnumber;

            //only if there is no data, set it manually
            if (list_systems.Count <= 0)
            {
                latestsystemnumber = 0;
            }
            else
            {
                currentSystem      = (ClientSystem)list_systems[list_systems.Count - 1];
                latestsystemnumber = currentSystem.ClientSystemNumber;
            }
            //Get number adresses
            int i = 0;

            foreach (Network n in selectedNetworks)
            {
                foreach (IPAddress ip in n.IpAddresses)
                {
                    i++;
                }
            }
            if (progress != null)
            {
                progress.Value   = 0;
                progress.Maximum = i;
            }
            //scan Networks
            Dictionary <String, IPAddress> unique = new Dictionary <string, IPAddress>();

            foreach (Network n in selectedNetworks)
            {
                // Ping each ip address of the network with timeout of 100ms
                foreach (IPAddress ip in n.IpAddresses)
                {
                    try
                    {
                        if (progress != null)
                        {
                            progress.PerformStep();
                        }
                        unique.Add(ip.ToString(), ip);
                        Ping      pingSender = new Ping();
                        PingReply reply      = pingSender.Send(ip, 100);
                        Log.WriteLog(string.Format("Ping: {0}", ip.ToString()));
                        if (reply.Status == IPStatus.Success)
                        {
                            currentSystem = new ClientSystem(++latestsystemnumber, ip, n.NetworkNumber);
                            list_systems.Add(currentSystem);
                            db.SaveClientSystem(currentSystem, currentSystemInventory);
                            currentSystemInventory.AddSystemToInventory(currentSystem);
                            Log.WriteLog(string.Format("System {0} added to Systeminventory",
                                                       currentSystem.ClientIP.ToString()));
                        }
                    }
                    //If dictionary contains key already
                    catch (ArgumentException e)
                    {
                        Log.WriteLog(string.Format("IP-Addresse already in list: {0}", ip.ToString()));
                        Log.WriteLog(e.Message);
                    }
                }
            }
        }