Exemplo n.º 1
0
        public void BuildMemoryStructure()
        {
            LoadingBar MemoryStructureBuilding = new LoadingBar(EventList.Count, EventList.Count, false);

            try
            {
                while (EventList.Count != 0)
                {
                    Node Event = EventList[0];
                    if (Event.AlwaysAwake == true)
                    {
                        MemoryStructure.Add(Event);
                        EventList.RemoveAll(x => x.MyId == Event.MyId);
                        MemoryStructureBuilding.Draw(EventList.Count);
                        //Console.WriteLine("ALWAYSAWAKENODE!");
                    }
                    else
                    {
                        CollectSubNodes(Event);
                        foreach (Node Established in MemoryStructure)
                        {
                            if (Established.MySubEventsIds.Contains(Event.MyId))
                            {
                                Established.LoadInSubEvents(new List <Node> {
                                    Event
                                });
                                break;
                            }
                        }
                        EventList.RemoveAll(x => x.MyId == Event.MyId);
                        MemoryStructureBuilding.Draw(EventList.Count);
                        //Console.WriteLine("SUBNODE");
                    }
                }
                Console.WriteLine("SUCCESSFULLY BUILT MEMORY UNIT");
                EventList = null;
                GC.Collect();
            }
            catch (Exception e)
            {
                Console.WriteLine("FAILED TO BUILD MEMORY UNIT");
                Console.WriteLine("ERROR LOG: " + e.ToString());
                Console.ReadLine();
            }
        }
Exemplo n.º 2
0
        public Consensus()
        {
            Client.Socket.On("Established", () =>
            {
                if (Established != null)
                {
                    Established.Invoke();
                }
                established = true;
            });

            Client.Socket.On("Lost", () =>
            {
                if (Lost != null)
                {
                    Lost.Invoke();
                }
                established = false;
            });
        }
Exemplo n.º 3
0
        public void InsertImage(string Filepath)
        {
            FileStream PGFileStream = new FileStream(Filepath, FileMode.Open, FileAccess.Read);

            BinaryReader PGReader = new BinaryReader(new BufferedStream(PGFileStream));

            var ImgByteA = PGReader.ReadBytes(Convert.ToInt32(PGFileStream.Length));

            string Sql = "insert into images (image) VALUES(@Image)";

            using (var Command = new NpgsqlCommand(Sql, Established))
            {
                NpgsqlParameter Parameter = Command.CreateParameter();
                Parameter.ParameterName = "@Image";
                Parameter.NpgsqlDbType  = NpgsqlTypes.NpgsqlDbType.Bytea;
                Parameter.Value         = ImgByteA;
                Command.Parameters.Add(Parameter);
                Established.Close();
                Established.Open();
                Command.ExecuteNonQuery();
            }
        }