Ejemplo n.º 1
0
            public override void Invoke(SpoolSpace Memory)
            {
                Cell x = this._Parameters[0].Evaluate(Memory);

                if (x.Affinity == CellAffinity.ARRAY)
                {
                    x.ARRAY.Sort();
                }
                else if (x.Affinity == CellAffinity.TREF)
                {
                    Table t = this._Host.OpenTable(x.valueTREF);
                    Key   k = new Key();
                    if (this._Parameters.Count >= 2)
                    {
                        Cell y = this._Parameters[1].Evaluate(Memory);
                        if (y.IsNumeric)
                        {
                            k.Add(y.valueINT);
                        }
                        else if (y.IsArray)
                        {
                            foreach (Cell z in y.valueARRAY)
                            {
                                k.Add(z.valueINT);
                            }
                        }
                        else
                        {
                            k = Key.Build(t.Columns.Count);
                        }
                    }
                    Spectre.Tables.TableUtil.Sort(t, k);
                }
            }
Ejemplo n.º 2
0
            public override void BeginInvoke(SpoolSpace Memory)
            {
                // Do the checks, need an aggregate and we must be part of a loop
                if (!this._Parameters.ContainsAggregate || !this._Parameters.ContainsNonAggregate)
                {
                    throw new Exception("Dictionary aggregates must contain at least one aggregate and one non-aggregate");
                }

                //if (this._Parent == null || !this._Parent.IsBreakable)
                //    throw new Exception("Aggregates can only appear in loop statements");

                // We don't need to invoke the base method

                // Build the keys
                Key k = new Key(), v = new Key();
                int idx = 0;

                foreach (Expression x in this._Parameters)
                {
                    if (x.IsAggregate)
                    {
                        v.Add(idx);
                    }
                    else
                    {
                        k.Add(idx);
                    }
                    idx++;
                }

                // Set up the staging table //
                this._StorageTree = new DictionaryTable(this._Host, Host.RandomPath(), this._Parameters.Columns, k, Page.DEFAULT_SIZE);
            }
Ejemplo n.º 3
0
        public void Add(string key, string value)
        {
            var pair = Pair(key, value);

            Key.Add(pair.Item1);
            Value.Add(pair.Item2);
        }
        private Attendance Retrieve(Person aPerson, Event anEvent)
        {
            Key key = new Key(true);

            key.Add("id_person", aPerson.Id);
            key.Add("id_event", anEvent.Id);

            Attendance anAttendance =
                Broker.SessionBroker.TryRetrieveInstance(typeof(Attendance), key) as Attendance;

            // If found, return it
            if (anAttendance != null)
            {
                return(anAttendance);
            }

            return(null);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Adds a single folder and the files contained within it.
 /// </summary>
 /// <param name="key">Path of folder.</param>
 /// <param name="value">Paths list of files.</param>
 public void Add(string key, List <string> value)
 {
     if (key != null && value != null)
     {
         Key.Add(key);
         Value.Add(value);
         FolderCount++;
         FileCount += (ulong)value.Count;
     }
 }
Ejemplo n.º 6
0
 public void Insert(string k, string v)
 {
     if (NonHashedKeys.Contains(k))
     {
         throw new ArgumentException("Key already exists.");
     }
     else
     {
         NonHashedKeys.Add(k);
         int keyHashed = Hash(k, Max);
         Key.Add(keyHashed);
         Value.Add(v);
     }
 }
        public Instrument Retrieve(string name)
        {
            Key key = new Key(typeof(Instrument), true);

            key.Add("name", name);

            Instrument anInstrument = Broker.SessionBroker.TryRetrieveInstance(
                typeof(Instrument), key) as Instrument;

            if (anInstrument != null)
            {
                return(anInstrument);
            }

            throw new InstrumentDoesNotExistException("No existe un instrumento con ese nombre");
        }
Ejemplo n.º 8
0
        public EventType Retrieve(int id)
        {
            Key key = new Key(typeof(EventType), true);

            key.Add("id", id);

            EventType anEventType = Broker.SessionBroker.TryRetrieveInstance(
                typeof(EventType), key) as EventType;

            if (anEventType != null)
            {
                return(anEventType);
            }

            throw new EventTypeDoesNotExistException();
        }
        public Person RetrieveByDNI(int dni)
        {
            // I look for a person by his DNI
            Key key = new Key(typeof(Person), true);

            key.Add("dni", dni);

            Person aPerson = Broker.SessionBroker.TryRetrieveInstance(typeof(Person), key) as Person;

            // If found, it's returned
            if (aPerson != null)
            {
                return(aPerson);
            }

            // the person who is looked for does not exist
            throw new PersonDoesNotExistException("No existe una persona con ese DNI");
        }
        public Event Retrieve(DateTime date)
        {
            // Seconds are not important
            DateTime dateWithoutSeconds = new DateTime(date.Year, date.Month, date.Day,
                                                       date.Hour, date.Minute, 0);

            Key key = new Key(typeof(Event), true);

            key.Add("date", dateWithoutSeconds);

            Event anEvent = Broker.SessionBroker.TryRetrieveInstance(
                typeof(Event), key) as Event;

            if (anEvent != null)
            {
                return(anEvent);
            }

            throw new EventDoesNotExistException();
        }
Ejemplo n.º 11
0
        public Map(List <string> key, List <string> value, int max)
        {
            Key = EmptyList; //Initialize Key so it won't throw a null error

            if (key.Count != value.Count)
            {
                throw new ArgumentException("Key and value lists must be the same length.");
            }

            NonHashedKeys = key;
            Value         = value;
            Max           = max;

            //Populate the Key array with hashed keys
            for (int i = 0; i < key.Count; i++)
            {
                Key.Add(Hash(key[i], Max));
            }

            Key.RemoveAt(0);
        }
Ejemplo n.º 12
0
        static void ProcessJSON(JSON control)
        {
            KeySet keys = null;

            //  Get the keys

            if (control["input"].ContainsKey("key"))
            {
                keys = new KeySet(control["input"]["key"]);
            }
            if (control["input"].ContainsKey("pwd"))
            {
                Key key = new Key();
                key.Add("kty", "oct");
                key.Add("k", Message.base64urlencode(UTF8Encoding.UTF8.GetBytes(control["input"]["pwd"].AsString())));
                keys = new KeySet();
                keys.Add(key);
            }
            if (keys == null)
            {
                Console.WriteLine("No keys found");
                return;
            }

            //
            //  Check that we can validate each of these items
            //
            //  Start with compact

            if (control["output"].ContainsKey("compact"))
            {
                Console.WriteLine("    Compact");
                for (int i = 0; i < keys.Count; i++)
                {
                    Message msg = Message.DecodeFromString(control["output"]["compact"].AsString());

                    CheckMessage(msg, keys[i], control["input"]);
                }

                //
                //  Build a new version of the message
                //

                BuildCompact(control, keys);
            }

            if (control["output"].ContainsKey("json"))
            {
                Console.WriteLine("     Full");
                for (int i = 0; i < keys.Count; i++)
                {
                    Message msg = Message.DecodeFromJSON(control["output"]["json"]);

                    CheckMessage(msg, keys[i], control["input"]);
                }
            }

            if (control["output"].ContainsKey("json_flat"))
            {
                Console.WriteLine("     Flat");
                for (int i = 0; i < keys.Count; i++)
                {
                    Message msg = Message.DecodeFromJSON(control["output"]["json_flat"]);

                    CheckMessage(msg, keys[i], control["input"]);
                }
            }
        }
Ejemplo n.º 13
0
        public AuthClient(Socket socket) : base(socket)
        {
            Console.WriteLine("New client connected {0}", this.Socket.RemoteEndPoint.ToString());
            this.SendPacket(new ProtocolRequired(1945, 1945));

            #region key

            this.Key = new List <int>();
            Key.Add(111);
            Key.Add(205);
            Key.Add(118);
            Key.Add(9);
            Key.Add(52);
            Key.Add(161);
            Key.Add(97);
            Key.Add(184);
            Key.Add(109);
            Key.Add(127);
            Key.Add(46);
            Key.Add(12);
            Key.Add(169);
            Key.Add(191);
            Key.Add(118);
            Key.Add(230);
            Key.Add(231);
            Key.Add(137);
            Key.Add(3);
            Key.Add(21);
            Key.Add(67);
            Key.Add(122);
            Key.Add(75);
            Key.Add(122);
            Key.Add(214);
            Key.Add(75);
            Key.Add(244);
            Key.Add(14);
            Key.Add(128);
            Key.Add(42);
            Key.Add(73);
            Key.Add(26);
            Key.Add(105);
            Key.Add(80);
            Key.Add(107);
            Key.Add(103);
            Key.Add(129);
            Key.Add(218);
            Key.Add(124);
            Key.Add(23);
            Key.Add(84);
            Key.Add(240);
            Key.Add(1);
            Key.Add(247);
            Key.Add(18);
            Key.Add(203);
            Key.Add(216);
            Key.Add(130);
            Key.Add(139);
            Key.Add(69);
            Key.Add(2);
            Key.Add(53);
            Key.Add(200);
            Key.Add(150);
            Key.Add(217);
            Key.Add(11);
            Key.Add(99);
            Key.Add(106);
            Key.Add(94);
            Key.Add(132);
            Key.Add(216);
            Key.Add(237);
            Key.Add(143);
            Key.Add(11);
            Key.Add(88);
            Key.Add(92);
            Key.Add(34);
            Key.Add(237);
            Key.Add(29);
            Key.Add(53);
            Key.Add(164);
            Key.Add(47);
            Key.Add(228);
            Key.Add(109);
            Key.Add(111);
            Key.Add(252);
            Key.Add(143);
            Key.Add(190);
            Key.Add(155);
            Key.Add(162);
            Key.Add(238);
            Key.Add(252);
            Key.Add(221);
            Key.Add(73);
            Key.Add(85);
            Key.Add(154);
            Key.Add(203);
            Key.Add(133);
            Key.Add(67);
            Key.Add(75);
            Key.Add(53);
            Key.Add(64);
            Key.Add(218);
            Key.Add(194);
            Key.Add(108);
            Key.Add(144);
            Key.Add(165);
            Key.Add(102);
            Key.Add(254);
            Key.Add(103);
            Key.Add(238);
            Key.Add(23);
            Key.Add(129);
            Key.Add(255);
            Key.Add(2);
            Key.Add(245);
            Key.Add(106);
            Key.Add(161);
            Key.Add(111);
            Key.Add(105);
            Key.Add(148);
            Key.Add(176);
            Key.Add(109);
            Key.Add(134);
            Key.Add(120);
            Key.Add(129);
            Key.Add(31);
            Key.Add(97);
            Key.Add(143);
            Key.Add(9);
            Key.Add(179);
            Key.Add(185);
            Key.Add(137);
            Key.Add(160);
            Key.Add(34);
            Key.Add(18);
            Key.Add(207);
            Key.Add(164);
            Key.Add(17);
            Key.Add(132);
            Key.Add(239);
            Key.Add(94);
            Key.Add(110);
            Key.Add(159);
            Key.Add(203);
            Key.Add(44);
            Key.Add(192);
            Key.Add(25);
            Key.Add(5);
            Key.Add(132);
            Key.Add(31);
            Key.Add(149);
            Key.Add(235);
            Key.Add(220);
            Key.Add(252);
            Key.Add(102);
            Key.Add(128);
            Key.Add(106);
            Key.Add(230);
            Key.Add(233);
            Key.Add(30);
            Key.Add(177);
            Key.Add(250);
            Key.Add(117);
            Key.Add(39);
            Key.Add(21);
            Key.Add(70);
            Key.Add(83);
            Key.Add(149);
            Key.Add(84);
            Key.Add(183);
            Key.Add(4);
            Key.Add(84);
            Key.Add(236);
            Key.Add(173);
            Key.Add(108);
            Key.Add(201);
            Key.Add(177);
            Key.Add(53);
            Key.Add(185);
            Key.Add(97);
            Key.Add(200);
            Key.Add(128);
            Key.Add(71);
            Key.Add(202);
            Key.Add(79);
            Key.Add(162);
            Key.Add(241);
            Key.Add(57);
            Key.Add(239);
            Key.Add(23);
            Key.Add(132);
            Key.Add(134);
            Key.Add(217);
            Key.Add(157);
            Key.Add(91);
            Key.Add(199);
            Key.Add(234);
            Key.Add(150);
            Key.Add(3);
            Key.Add(95);
            Key.Add(2);
            Key.Add(26);
            Key.Add(12);
            Key.Add(183);
            Key.Add(155);
            Key.Add(79);
            Key.Add(244);
            Key.Add(16);
            Key.Add(10);
            Key.Add(155);
            Key.Add(169);
            Key.Add(219);
            Key.Add(38);
            Key.Add(141);
            Key.Add(64);
            Key.Add(117);
            Key.Add(117);
            Key.Add(164);
            Key.Add(125);
            Key.Add(176);
            Key.Add(110);
            Key.Add(204);
            Key.Add(208);
            Key.Add(155);
            Key.Add(81);
            Key.Add(106);
            Key.Add(160);
            Key.Add(128);
            Key.Add(236);
            Key.Add(237);
            Key.Add(0);
            Key.Add(66);
            Key.Add(55);
            Key.Add(120);
            Key.Add(109);
            Key.Add(222);
            Key.Add(128);
            Key.Add(61);
            Key.Add(253);
            Key.Add(22);
            Key.Add(206);
            Key.Add(5);
            Key.Add(186);
            Key.Add(127);
            Key.Add(131);
            Key.Add(37);
            Key.Add(218);
            Key.Add(38);
            Key.Add(122);
            Key.Add(63);
            Key.Add(144);
            Key.Add(244);
            Key.Add(99);
            Key.Add(227);
            Key.Add(82);
            Key.Add(14);
            Key.Add(138);
            Key.Add(39);
            Key.Add(134);
            Key.Add(177);
            Key.Add(64);
            Key.Add(234);
            Key.Add(91);
            Key.Add(67);
            Key.Add(132);
            Key.Add(113);
            Key.Add(124);
            Key.Add(102);
            Key.Add(192);
            Key.Add(109);
            Key.Add(48);
            Key.Add(143);
            Key.Add(77);
            Key.Add(2);
            Key.Add(246);
            Key.Add(87);
            Key.Add(35);
            Key.Add(240);
            Key.Add(219);
            Key.Add(114);
            Key.Add(125);
            Key.Add(215);
            Key.Add(238);
            Key.Add(171);
            Key.Add(67);
            Key.Add(27);
            Key.Add(13);
            Key.Add(139);
            Key.Add(162);
            Key.Add(70);
            Key.Add(150);
            Key.Add(161);
            Key.Add(175);
            Key.Add(213);
            Key.Add(128);
            Key.Add(122);
            Key.Add(24);
            Key.Add(5);
            Key.Add(38);
            Key.Add(72);
            Key.Add(177);
            Key.Add(63);
            Key.Add(238);
            Key.Add(190);
            Key.Add(102);
            Key.Add(182);
            Key.Add(62);
            Key.Add(158);
            Key.Add(246);
            Key.Add(183);
            Key.Add(115);
            Key.Add(158);
            Key.Add(21);
            Key.Add(114);

            #endregion

            this.salt = AuthenticationUtils.GenerateTicket(); //ticket == salt dans patch client
            this.SendPacket(new HelloConnectMessage(this.salt, this.Key));
        }
Ejemplo n.º 14
0
        private void AppendJoinKey(S_ScriptParser.Join_predicate_unitContext context, Schema LColumns, string LAlias, Key LKey, Schema RColumns, string RAlias, Key RKey)
        {
            string LNameSpace = (context.name()[0].unit_name().Length == 1 ? null : context.name()[0].unit_name()[0].GetText());
            string LName      = context.name()[0].unit_name().Last().GetText();
            string RNameSpace = (context.name()[1].unit_name().Length == 1 ? null : context.name()[1].unit_name()[0].GetText());
            string RName      = context.name()[1].unit_name().Last().GetText();

            // Look for a missing left alias
            if (LNameSpace == null && LColumns.Contains(LName))
            {
                LNameSpace = LAlias;
            }
            else if (LNameSpace == null && RColumns.Contains(LName))
            {
                LNameSpace = RAlias;
            }
            else if (LNameSpace == null)
            {
                throw new Exception(string.Format("Column name '{0}' is invalid", LName));
            }

            // Look for a missing right alias
            if (RNameSpace == null && LColumns.Contains(RName))
            {
                RNameSpace = LAlias;
            }
            else if (LNameSpace == null && RColumns.Contains(RName))
            {
                RNameSpace = RAlias;
            }
            else if (LNameSpace == null)
            {
                throw new Exception(string.Format("Column name '{0}' is invalid", LName));
            }

            // Check which namespace this belongs to
            if (LNameSpace == LAlias && RNameSpace == RAlias)
            {
                int lidx = LColumns.ColumnIndex(LName);
                int ridx = RColumns.ColumnIndex(RName);
                if (lidx == Schema.OFFSET_NULL)
                {
                    throw new Exception(string.Format("Column '{0}' does not exist in '{1}'", LName, LAlias));
                }
                if (ridx == Schema.OFFSET_NULL)
                {
                    throw new Exception(string.Format("Column '{0}' does not exist in '{1}'", RName, RAlias));
                }
                LKey.Add(lidx);
                RKey.Add(ridx);
            }
            else if (RNameSpace == LAlias && LNameSpace == RAlias)
            {
                string x = LName;
                LName = RName;
                RName = x;
                int lidx = LColumns.ColumnIndex(LName);
                int ridx = RColumns.ColumnIndex(RName);
                if (lidx == Schema.OFFSET_NULL)
                {
                    throw new Exception(string.Format("Column '{0}' does not exist in '{1}'", LName, LAlias));
                }
                if (ridx == Schema.OFFSET_NULL)
                {
                    throw new Exception(string.Format("Column '{0}' does not exist in '{1}'", RName, RAlias));
                }
                LKey.Add(lidx);
                RKey.Add(ridx);
            }
            else
            {
                throw new Exception(string.Format("Join predicate is invalid '{0}.{1}' and '{2}.{3}'", LNameSpace, LName, RNameSpace, RName));
            }
        }