Beispiel #1
0
        public PyDataType GetMyExpiredContractList(PyBool isCorp, CallInformation call)
        {
            int ownerID = 0;

            if (isCorp == true)
            {
                ownerID = call.Client.CorporationID;
            }
            else
            {
                ownerID = call.Client.EnsureCharacterIsSelected();
            }

            List <int> contractList = this.DB.GetContractList(
                null, 0, null, null, null, null, null, null, null, 0, 0,
                null, null, call.Client.EnsureCharacterIsSelected(), call.Client.CorporationID, ownerID, null, true, true
                );

            return(KeyVal.FromDictionary(new PyDictionary()
            {
                ["contracts"] = this.DB.GetInformationForContractList(contractList),
                ["bids"] = this.DB.GetBidsForContractList(contractList),
                ["items"] = this.DB.GetItemsForContractList(contractList)
            }
                                         ));
        }
Beispiel #2
0
        public static void InitLanguageData()//根据系统环境自动初始化语言数据
        {
            string lang = System.Globalization.CultureInfo.CurrentCulture.EnglishName;
            string langData;

            if (lang.IndexOf("Chinese") != -1)
            {
                langData = CodeDonut.Properties.Resources.Lang_zh_cn;
            }
            else
            {
                langData = "";
            }

            string[] langKeyValArr = Regex.Split(langData, "\r\n|\r|\n");

            foreach (string KeyVal in langKeyValArr)
            {
                if (KeyVal.StartsWith("#"))
                {
                    continue;
                }

                string[] tempArr = Regex.Split(KeyVal, "=");
                if (tempArr.Length == 2)
                {
                    _langDictionary[tempArr[0]] = tempArr[1];
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Runs one prepared query with the given values as parameters and returns a KeyVal representing the result.
        /// KeyVals only hold ONE row
        /// </summary>
        /// <param name="query">The prepared query</param>
        /// <param name="values">The key-value pair of values to use when running the query</param>
        /// <returns>The PyDataType object representing the result</returns>
        public PyDataType PrepareKeyValQuery(string query, Dictionary <string, object> values)
        {
            try
            {
                MySqlConnection connection = null;
                // create the correct command
                MySqlCommand command = this.PrepareQuery(ref connection, query);

                // add values
                foreach (KeyValuePair <string, object> pair in values)
                {
                    command.Parameters.AddWithValue(pair.Key, pair.Value);
                }

                MySqlDataReader reader = command.ExecuteReader();

                using (connection)
                    using (reader)
                    {
                        if (reader.Read() == false)
                        {
                            return(null);
                        }

                        // run the prepared statement
                        return(KeyVal.FromMySqlDataReader(reader));
                    }
            }
            catch (Exception e)
            {
                Log.Error($"MySQL error: {e.Message}");
                throw;
            }
        }
        //    /**
        //     * Prepare to submit this form. A Connection object is created with the request set up from the form values. You
        //     * can then set up other options (like user-agent, timeout, cookies), then execute it.
        //     * @return a connection prepared from the values of this form.
        //     * @throws IllegalArgumentException if the form's absolute action URL cannot be determined. Make sure you pass the
        //     * document's base URI when parsing.
        //     */
        //    public Connection submit() {
        //        String action = hasAttr("action") ? absUrl("action") : baseUri();
        //        Validate.notEmpty(action, "Could not determine a form action URL for submit. Ensure you set a base URI when parsing.");
        //        Connection.Method method = attr("method").toUpperCase().equals("POST") ?
        //                Connection.Method.POST : Connection.Method.GET;
        //
        //        return Jsoup.connect(action)
        //                .data(formData())
        //                .method(method);
        //    }
        /// <summary>Get the data that this form submits.</summary>
        /// <remarks>
        /// Get the data that this form submits. The returned list is a copy of the data, and changes to the contents of the
        /// list will not be reflected in the DOM.
        /// </remarks>
        /// <returns>a list of key vals</returns>
        public virtual IList <KeyVal> FormData()
        {
            List <KeyVal> data = new List <KeyVal>();

            // iterate the form control elements and accumulate their values
            foreach (iText.StyledXmlParser.Jsoup.Nodes.Element el in elements)
            {
                if (!el.Tag().IsFormSubmittable())
                {
                    continue;
                }
                // contents are form listable, superset of submitable
                if (el.HasAttr("disabled"))
                {
                    continue;
                }
                // skip disabled form inputs
                String name = el.Attr("name");
                if (name.Length == 0)
                {
                    continue;
                }
                String type = el.Attr("type");
                if ("select".Equals(el.TagName()))
                {
                    iText.StyledXmlParser.Jsoup.Select.Elements options = el.Select("option[selected]");
                    bool set = false;
                    foreach (iText.StyledXmlParser.Jsoup.Nodes.Element option in options)
                    {
                        data.Add(KeyVal.Create(name, option.Val()));
                        set = true;
                    }
                    if (!set)
                    {
                        iText.StyledXmlParser.Jsoup.Nodes.Element option = el.Select("option").First();
                        if (option != null)
                        {
                            data.Add(KeyVal.Create(name, option.Val()));
                        }
                    }
                }
                else
                {
                    if ("checkbox".EqualsIgnoreCase(type) || "radio".EqualsIgnoreCase(type))
                    {
                        // only add checkbox or radio if they have the checked attribute
                        if (el.HasAttr("checked"))
                        {
                            String val = el.Val().Length > 0 ? el.Val() : "on";
                            data.Add(KeyVal.Create(name, val));
                        }
                    }
                    else
                    {
                        data.Add(KeyVal.Create(name, el.Val()));
                    }
                }
            }
            return(data);
        }
Beispiel #5
0
        public override string Solve_2()
        {
            lines = File.ReadAllText(InputFilePath).Split("\r\n\r\n");


            int runningGroupSum = 0;

            foreach (string line in lines)
            {
                int groupCount = line.Split("\r\n").Length;
                List <KeyVal <char, int> > answers = new List <KeyVal <char, int> >();
                char[] lineExplode = line.Replace("\r\n", "").ToCharArray();
                foreach (char character in lineExplode)
                {
                    KeyVal <char, int> exists = answers.Where(x => x.Id == character).FirstOrDefault();
                    if (exists == null)
                    {
                        answers.Add(new KeyVal <char, int>(character, 1));
                    }
                    else
                    {
                        for (int i = 0; i < answers.Count(); i++)
                        {
                            if (answers[i].Id == character)
                            {
                                answers[i] = new KeyVal <char, int>(answers[i].Id, ++answers[i].Value);
                            }
                        }
                    }
                }
                runningGroupSum += answers.Where(x => x.Value == groupCount).Count();
            }
            return($"{runningGroupSum}");
        }
Beispiel #6
0
        public ItemInfo(Stream file, VarCollection v) : this()
        {
            StreamReader  sr   = new StreamReader(file);
            VarCollection vars = new VarCollection(sr, v);
            KeyVal        line = null;

            while ((line = vars.ReadLine()) != null)
            {
                switch (line.Keyword.ToLower())
                {
                case "ground":
                    groundImg = line.Rest;
                    break;

                case "hand":
                    handImg = line.Rest;
                    break;

                case "weapon":
                    items[line.Rest] = new WeaponDescriptor(line.Rest, vars);
                    break;
//					case "item":
//						break;
                }
            }

            sr.Close();
        }
Beispiel #7
0
        // sadly it seems we will need null keyvals
        // do we need them EVERY time we ask?
        // let us say we do not
        public KeyVal KeyValAtKey(object k)
        {
            KeyVal val = null;

            dict.TryGetValue(k, out val);
            return(val);
        }
Beispiel #8
0
        public static void ReadSettings(
            VarCollection vc,
            KeyVal kv,
            Settings currSettings)
        {
            while ((kv = vc.ReadLine()) != null)
            {
                switch (kv.Keyword)
                {
                case "}":                         // all done
                    return;

                case "{":                         // starting out
                    break;

                default:
                    if (currSettings [kv.Keyword] != null)
                    {
                        currSettings[kv.Keyword].Value = kv.Rest;
                        currSettings[kv.Keyword].FireUpdate(kv.Keyword);
                    }
                    break;
                }
            }
        }
Beispiel #9
0
        public PyDataType GetStationInfo()
        {
            PyDictionary data = new PyDictionary
            {
                ["stationID"]             = this.ID,
                ["security"]              = this.Security,
                ["dockingCostPerVolume"]  = this.DockingCostPerVolume,
                ["maxShipVolumeDockable"] = this.MaxShipVolumeDockable,
                ["officeRentalCost"]      = this.OfficeRentalCost,
                ["operationID"]           = this.Operations.OperationID,
                ["stationTypeID"]         = this.Type.ID,
                ["ownerID"]         = this.OwnerID,
                ["solarSystemID"]   = this.SolarSystemID,
                ["constellationID"] = this.ConstellationID,
                ["regionID"]        = this.RegionID,
                ["stationName"]     = this.Name,
                ["x"] = this.X,
                ["y"] = this.Y,
                ["z"] = this.Z,
                ["reprocessingEfficiency"]   = this.ReprocessingEfficiency,
                ["reprocessingStationsTake"] = this.ReprocessingStationsTake,
                ["reprocessingHangarFlag"]   = this.ReprocessingHangarFlag,
                ["description"] = this.Operations.Description,
                ["serviceMask"] = this.Operations.ServiceMask
            };

            // TODO: CREATE OBJECTS FOR CONSTELLATION AND REGION ID SO THESE CAN BE FETCHED FROM MEMORY INSTEAD OF DATABASE

            return(KeyVal.FromDictionary(data));
        }
Beispiel #10
0
 private RootwardNode()
 {
     this.Parent         = this;
     this.SiblingOfChild = LeafwardNode.Nil;
     this.Data           = null;
     this.IsRed          = false;
 }
Beispiel #11
0
        private void txtSearch_TextChanged(object sender, EventArgs e)
        {
            string searchValue = txtSearch.Text;

            if (keyControl == 0)
            {
                listSongs_Search = songDAO.searchSong(searchValue);
                loadSongLabel();
            }
            else if (keyControl == 1)
            {
                SidePanel.Height = btHome.Height;
                SidePanel.Top    = btHome.Top;

                listAlbums = albumDAO.searchAlbums(searchValue);
                loadAlbumLabel();
            }
            else if (keyControl == 2)
            {
                SidePanel.Height = btAlbum.Height;
                SidePanel.Top    = btAlbum.Top;
                listArtist       = artistDAO.searchArtists(searchValue);
                loadArtistLabel();
            }
            else if (keyControl == 3)
            {
                var            cs             = new Cosine();
                List <SongDTO> listSongs_temp = songDAO.loadAllSongs();
                List <KeyVal>  lyricRanking   = new List <KeyVal>();
                for (int i = 0; i < listSongs_temp.Count; i++)
                {
                    KeyVal keyVal = new KeyVal(i, cs.Similarity(searchValue, listSongs_temp[i].Lyrics));
                    lyricRanking.Add(keyVal);
                }
                lyricRanking.Sort(delegate(KeyVal x, KeyVal y)
                {
                    int a = x.Value.CompareTo(y.Value);
                    a     = y.Value.CompareTo(x.Value);

                    return(a);
                });
                listSongs_Search = new List <SongDTO>();
                if (lyricRanking.Count >= 5)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        listSongs_Search.Add(listSongs_temp[lyricRanking[i].Id]);
                    }
                }
                loadSongLabel();
            }
            else if (keyControl == 4)
            {
                SidePanel.Height = btPlaylist.Height;
                SidePanel.Top    = btPlaylist.Top;
                listPlaylist     = playlistDAO.searchPlaylistsOfUser(username, searchValue);
                loadPlaylistLabel();
            }
        }
Beispiel #12
0
 private void RegisterActions(List <Action> actions)
 {
     foreach (Action action in actions)
     {
         KeyVal <Action, float> keyval = new KeyVal <Action, float>(action, bufferTime);
         inputBuffer.Add(keyval);
     }
 }
Beispiel #13
0
 public LeafwardNode(KeyVal data, bool isRed, LeafwardNode left, LeafwardNode right, Func <TAggregate, TKey, TVal, TAggregate, TAggregate> aggregator)
 {
     this.Data      = data;
     this.Left      = left;
     this.Right     = right;
     this.IsRed     = isRed;
     this.Aggregate = data == null ? default(TAggregate) : aggregator(left.Aggregate, data.Key, data.Val, right.Aggregate);
     this.Count     = data == null ? 0 : left.Count + 1 + right.Count;
 }
Beispiel #14
0
 public ZipperNode(KeyVal content, bool isRed, LeafwardNode left, LeafwardNode right, RootwardNode parent, Func <TAggregate, TKey, TVal, TAggregate, TAggregate> aggregator)
 {
     this.Data       = content;
     this.IsRed      = isRed;
     this.Left       = left;
     this.Right      = right;
     this.Parent     = parent;
     this.Aggregator = aggregator;
 }
Beispiel #15
0
 public ZipperNode(Func <TAggregate, TKey, TVal, TAggregate, TAggregate> aggregator)
 {
     this.Left       = LeafwardNode.Nil;
     this.Right      = LeafwardNode.Nil;
     this.Parent     = RootwardNode.Nil;
     this.Data       = null;
     this.IsRed      = false;
     this.Aggregator = aggregator;
 }
Beispiel #16
0
        public void Remove(object k)
        {
            KeyVal kv = KeyValAtKey(k);

            if (kv != null)
            {
                kv.Evacuate();
                dict.Remove(k);
            }
        }
Beispiel #17
0
        public string GetDailyReport(string option, DateTime date)
        {
            string result = "";

            switch (option)
            {
            case "ticketsd":
                List <KeyVal> ticketsd = _context.ReservedSeats.Where(x => x.reservation.date.Year == date.Year && x.reservation.date.Month == date.Month && x.reservation.date.Day == date.Day).Where(x => x.reservation.payed == true).GroupBy(x => x.reservation.screening.movie.title).Select(x => new KeyVal {
                    Key = x.Key, Value = x.Count()
                }).OrderByDescending(x => x.Value).ToList();
                result = JsonConvert.SerializeObject(ticketsd);
                break;

            case "revenued":
                var reservations = _context.Reservations.Where(x => x.date.Year == date.Year && x.date.Month == date.Month && x.date.Day == date.Day).Where(x => x.payed == true).Include(x => x.screening.movie).Include(x => x.screening).Include(x => x.reservedSeats).Include(x => x.reservedSeats).ThenInclude(x => x.TicketType).ToList();
                Dictionary <string, float> revenued = new Dictionary <string, float>();
                foreach (var reservation in reservations)
                {
                    //sa se calculeze cat costa rezervarea-> sa se adune la titlul corespunsator
                    float total = 0;
                    var   price = reservation.screening.price;
                    foreach (var ticket in reservation.reservedSeats)
                    {
                        total = total + (price - ticket.TicketType.discount * price);
                    }

                    if (revenued.ContainsKey(reservation.screening.movie.title))
                    {
                        revenued[reservation.screening.movie.title] = revenued[reservation.screening.movie.title] + total;
                    }
                    else
                    {
                        revenued.Add(reservation.screening.movie.title, total);
                    }
                }
                revenued = revenued.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);
                List <KeyVal> r = new List <KeyVal>();
                foreach (var rpm in revenued.Keys)
                {
                    KeyVal kv = new KeyVal();
                    kv.Key   = rpm;
                    kv.Value = revenued[rpm];
                    r.Add(kv);
                }

                result = JsonConvert.SerializeObject(r);
                break;

            default:
                result = "Error";
                break;
            }

            return(result);
        }
 /// <summary>
 /// 键名
 /// </summary>
 public string GetKeyName(Keys keyVal)
 {
     if (KeyVal >= Keys.D0 && KeyVal <= Keys.D9)
     {
         return(KeyVal.ToString().Substring(1));
     }
     else
     {
         return(KeyVal.ToString());
     }
 }
Beispiel #19
0
        // here's a place to optimize later
        public KeyVal Subscribe(object k)
        {
            KeyVal kv = KeyValAtKey(k);

            // not hanging onto this for now (would need GC stuff to prevent memory leak):
            if (kv == null)
            {
                kv = new KeyVal(k, null, this, false);
            }
            return(kv);
        }
Beispiel #20
0
 public void Add(object k, object v)
 {
     if (ContainsKey(k))
     {
         KeyValAtKey(k).val = v;
     }
     else
     {
         KeyVal kv = new KeyVal(k, v, this, true);
         dict.Add(k, kv);
     }
 }
Beispiel #21
0
        public PyDataType GetCharacterRankInfo(PyInteger characterID, CallInformation call)
        {
            // TODO: IMPLEMENT THIS

            return(KeyVal.FromDictionary(
                       new PyDictionary()
            {
                ["currentRank"] = 1,
                ["highestRank"] = 1,
                ["factionID"] = call.Client.WarFactionID
            }
                       ));
        }
        public void InputStream()
        {
            var kv = KeyVal.Create("file", "thumb.jpg", new MemoryStream());

            Assert.AreEqual("file", kv.Key());
            Assert.AreEqual("thumb.jpg", kv.Value());
            Assert.IsTrue(kv.HasInputStream());

            kv = KeyVal.Create("one", "two");
            Assert.AreEqual("one", kv.Key());
            Assert.AreEqual("two", kv.Value());
            Assert.IsFalse(kv.HasInputStream());
        }
Beispiel #23
0
        public PyDataType GetContract(PyInteger contractID, CallInformation call)
        {
            int callerCharacterID = call.Client.EnsureCharacterIsSelected();

            // TODO: Check for regionID ConWrongRegion

            return(KeyVal.FromDictionary(new PyDictionary()
            {
                ["contract"] = this.DB.GetContractInformation(contractID, callerCharacterID, call.Client.CorporationID),
                ["bids"] = this.DB.GetContractBids(contractID, callerCharacterID, call.Client.CorporationID),
                ["items"] = this.DB.GetContractItems(contractID, callerCharacterID, call.Client.CorporationID)
            }
                                         ));
        }
Beispiel #24
0
        public object ValueAtKey(object k)
        {
            KeyVal val = null;

            if (dict.TryGetValue(k, out val))
            {
                // NOT val.GetVal()
                return(val.val);
            }
            else
            {
                return(null);
            }
        }
Beispiel #25
0
        public PyDataType GetCloneState(CallInformation call)
        {
            int callerCharacterID = call.Client.EnsureCharacterIsSelected();

            Character character = this.ItemManager.LoadItem(callerCharacterID) as Character;

            return(KeyVal.FromDictionary(new PyDictionary
            {
                ["clones"] = this.ItemDB.GetClonesForCharacter(callerCharacterID, (int)character.ActiveCloneID),
                ["implants"] = this.ItemDB.GetImplantsForCharacterClones(callerCharacterID),
                ["timeLastJump"] = character.TimeLastJump
            }
                                         ));
        }
Beispiel #26
0
        public PyDataType BookmarkLocation(PyInteger itemID, PyNone unk, PyString name, PyString comment, CallInformation call)
        {
            if (ItemManager.IsStaticData(itemID) == false)
            {
                throw new CustomError("Bookmarks for non-static locations are not supported yet!");
            }

            ItemEntity item = this.ItemManager.GetItem(itemID);

            if (item.HasPosition == false)
            {
                throw new CustomError("Cannot bookmark a non-location item");
            }

            ulong bookmarkID = this.DB.CreateBookmark(call.Client.EnsureCharacterIsSelected(), item.ID, item.Type.ID,
                                                      name, comment, (double)item.X, (double)item.Y, (double)item.Z, item.LocationID);

            PyDataType bookmark = KeyVal.FromDictionary(new PyDictionary
            {
                ["bookmarkID"] = bookmarkID,
                ["itemID"]     = item.ID,
                ["typeID"]     = item.Type.ID,
                ["memo"]       = name,
                ["comment"]    = comment,
                ["x"]          = item.X,
                ["y"]          = item.Y,
                ["z"]          = item.Z,
                ["locationID"] = item.LocationID,
                ["created"]    = DateTime.UtcNow.ToFileTimeUtc()
            }
                                                        );

            // send a request to the client to update the bookmarks
            call.Client.ClusterConnection.SendServiceCall(call.Client, "addressbook", "OnBookmarkAdd",
                                                          new PyTuple(1)
            {
                [0] = bookmark
            }, new PyDictionary(), null, null, null, 0);

            return(new PyTuple(7)
            {
                [0] = bookmarkID,     // bookmarkID
                [1] = itemID,         // itemID
                [2] = item.Type.ID,   // typeID
                [3] = item.X,         // x
                [4] = item.Y,         // y
                [5] = item.Z,         // z
                [6] = item.LocationID //locationID
            });
        }
Beispiel #27
0
 public PyDataType GetKeyVal()
 {
     return(KeyVal.FromDictionary(
                new PyDictionary()
     {
         ["factionID"] = this.ID,
         ["factionName"] = this.Name,
         ["description"] = this.Description,
         ["solarSystemID"] = this.SolarSystemId,
         ["corporationID"] = this.CorporationId,
         ["militiaID"] = this.MilitiaCorporationId
     }
                ));
 }
Beispiel #28
0
        public void data()
        {
            IConnection con = HttpConnection.Connect("http://example.com/");

            con.Data("Name", "Val", "Foo", "bar");
            ICollection <KeyVal> values = con.Request().Data();

            Object[] data = values.ToArray();
            KeyVal   one  = (KeyVal)data[0];
            KeyVal   two  = (KeyVal)data[1];

            Assert.AreEqual("Name", one.Key());
            Assert.AreEqual("Val", one.Value());
            Assert.AreEqual("Foo", two.Key());
            Assert.AreEqual("bar", two.Value());
        }
Beispiel #29
0
        private void loadSteamLibraries()
        {
            String steamPath = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Valve\\Steam", "InstallPath", null).ToString();

            steamLibraries = new List <string>();
            steamLibraries.Add(steamPath);

            KeyVal <string, string> root = readChunkfile(steamPath + "\\steamapps\\libraryfolders.vdf");

            foreach (KeyValuePair <string, KeyVal <string, string> > child in root.Children)
            {
                if (Directory.Exists(child.Value.Value))
                {
                    steamLibraries.Add(child.Value.Value);
                }
            }
        }
Beispiel #30
0
        public PyDataType GetPostAuthenticationMessage(CallInformation call)
        {
            if (this.mConfiguration.MessageType == AuthenticationMessageType.NoMessage)
            {
                return(null);
            }

            if (this.mConfiguration.MessageType == AuthenticationMessageType.HTMLMessage)
            {
                return(KeyVal.FromDictionary(new PyDictionary
                {
                    ["message"] = this.mConfiguration.Message
                }
                                             ));
            }

            return(null);
        }