Exemplo n.º 1
0
        internal void fillChar(PilotRow pilotrow)
        {
            Thread t = new Thread(new ParameterizedThreadStart(fillCharThread));

            t.Start(pilotrow);
            m_personThreads.Add(t);
        }
Exemplo n.º 2
0
        void fillCharThread(object pilotrowobj)
        {
            PilotRow pilotrow = pilotrowobj as PilotRow;

            try
            {
                ESI.NET.Models.SearchResults character = searchItem(pilotrow.m_name, SearchCategory.Character);
                long id = character.Characters[0];
                pilotrow.m_id = String.Format("{0}", id);

                downloadImage(1, pilotrow.m_id);

                Task <EsiResponse <ESI.NET.Models.Character.Information> > charTask = Task.Run <EsiResponse <ESI.NET.Models.Character.Information> >(async() => await m_client.Character.Information((int)id));
                charTask.Wait();

                pilotrow.m_birthday  = charTask.Result.Data.Birthday.ToShortDateString();
                pilotrow.m_secstatus = String.Format("{0}", charTask.Result.Data.SecurityStatus);
            }
            catch (Exception)
            {
                return;
            }
            finally
            {
                m_mainForm.statusStrip1.Invoke((MethodInvoker) delegate { m_mainForm.UpdateStatus(false, false, false, true); });
            }

            // be gentle
            Thread.Sleep(500);

            // getting killmails from other users
            // https://zkillboard.com/api/kills/characterID/1792033579/no-items/
            // https://zkillboard.com/api/losses/characterID/1792033579/no-items/no-attackers/
            string resp = new WebClient().DownloadString("https://zkillboard.com/api/kills/characterID/" + pilotrow.m_id + "/no-items/");

            if (resp.Length <= 0 || !resp.StartsWith("["))
            {
                MessageBox.Show(resp, "Error from zkillboard.com");
                return;
            }

            dynamic page = JsonConvert.DeserializeObject(resp);

            pilotrow.m_kills = page.Count;

            // check current ship and group members
            if (pilotrow.m_kills > 0)
            {
                //check date "11/29/2016 00:33:02" "2018-08-26T01:20:42Z"
                string   lastkill = page[0].killmail_time;
                DateTime now      = DateTime.Now;
                now = now.AddHours(-5);
                DateTime myDate = DateTime.ParseExact(lastkill, "MM/dd/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
                if (myDate > now)
                {
                    pilotrow.m_fightCompanions = page[0].attackers.Count - 1;
                    for (int i = 0; i < page[0].attackers.Count; i++)
                    {
                        if (page[0].attackers[i].character_id == pilotrow.m_id)
                        {
                            pilotrow.m_shipId = page[0].attackers[i].ship_type_id;
                        }
                    }
                }
            }

            resp = new WebClient().DownloadString("https://zkillboard.com/api/losses/characterID/" + pilotrow.m_id + "/no-items/no-attackers/");

            if (resp.Length <= 0 || !resp.StartsWith("["))
            {
                MessageBox.Show(resp, "Error from zkillboard.com");
                return;
            }

            page = JsonConvert.DeserializeObject(resp);
            pilotrow.m_deaths = page.Count;
            m_mainForm.statusStrip1.Invoke((MethodInvoker) delegate { m_mainForm.UpdateStatus(false, false, true, true); });
        }
Exemplo n.º 3
0
        private void CheckClipboardData()
        {
            if (bCheckClipboardDataRunning || m_esi == null || !StaticData.getInstance().m_loaded)
            {
                return;
            }

            bCheckClipboardDataRunning = true;

            if (Clipboard.ContainsText(TextDataFormat.Text))
            {
                Debug.WriteLine("CheckClipboardData()");
                string clipboardText = Clipboard.GetText(TextDataFormat.Text);

                if (m_oldClipboardText != clipboardText)
                {
                    m_oldClipboardText = clipboardText;
                    // check if d-scan
                    bool            bDScan  = false;
                    MatchCollection matches = Regex.Matches(clipboardText, @"^(\d+)\t([^\t]+).*$", RegexOptions.Multiline);
                    if (matches.Count > 0)
                    {
                        m_ships.Clear();
                    }
                    foreach (Match match in matches)
                    {
                        bDScan = true;

                        ShipRow shiprow = new ShipRow();
                        shiprow.m_name   = match.Groups[2].Value.Trim();
                        shiprow.m_typeid = match.Groups[1].Value.Trim();

                        try
                        {
                            StaticData sd      = StaticData.getInstance();
                            string     groupId = sd.m_typeIds[shiprow.m_typeid]["groupID"];
                            shiprow.m_typename = sd.m_typeIds[shiprow.m_typeid]["name"]["en"];
                            shiprow.m_faction  = sd.m_typeIds[shiprow.m_typeid]["sofFactionName"];
                            shiprow.m_category = sd.m_groupIds[groupId]["name"]["en"];
                            m_ships.Add(shiprow);

                            m_esi.downloadImage(0, shiprow.m_typeid);
                        }
                        catch (Exception)
                        {
                            // try next row
                        }
                    }
                    if (bDScan)
                    {
                        //dataGridViewMain.Invoke((MethodInvoker)delegate { UpdateStatus(true, false, true, false); });
                        UpdateStatus(true, false, true, false);
                    }

                    // check local persons
                    bool bLocalScan = false;
                    if (!bDScan)
                    {
                        string ownname = m_esi.getLoggedUserName();
                        clipboardText += "\r\n"; // just to be sure
                        matches        = Regex.Matches(clipboardText, @"^(.*)$", RegexOptions.Multiline);
                        foreach (Match match in matches)
                        {
                            if (match.Groups[1].Value.Trim() == ownname)
                            {
                                bLocalScan = true;
                                break;
                            }
                        }
                        if (bLocalScan)
                        {
                            m_local.Clear();
                            m_esi.killAllPersonThreads();
                            foreach (Match match in matches)
                            {
                                string name = match.Groups[1].Value.Trim();
                                if (name.Length > 0 && name != ownname)
                                {
                                    PilotRow pilotrow = new PilotRow();
                                    pilotrow.m_name = name;
                                    m_esi.fillChar(pilotrow);
                                    m_local.Add(pilotrow);
                                }
                            }
                            //dataGridViewMain.Invoke((MethodInvoker)delegate { UpdateStatus(false, true, false, true); });
                            UpdateStatus(false, true, false, true);
                        }
                    }
                }
            }
            bCheckClipboardDataRunning = false;
        }