Пример #1
0
        private void button_test_Click(object sender, EventArgs e)
        {
            string cardDateOfCreation    = "";
            int    cardDateOfCreationInt = 0;

            using (TrelloDbContext db = new TrelloDbContext())
            {
                var cards = db.Cards;
                foreach (TrelloCard card in cards)
                {
                    cardDateOfCreation    = "0x" + card.Id.Substring(0, 8);
                    cardDateOfCreationInt = Convert.ToInt32(cardDateOfCreation, 16);
                    MessageBox.Show((UnixTimeStampToDateTime(cardDateOfCreationInt)).ToString(), "Дата создания", MessageBoxButtons.OK);
                    MessageBox.Show((Convert.ToDateTime(card.DateLastActivity)).ToString(), "Дата последней активности", MessageBoxButtons.OK);
                    //break;
                }
                db.SaveChanges();
            }
        }
Пример #2
0
        private void getData()
        {
            listDatesCreate.Clear(); listDatesDue.Clear(); listDatesLast.Clear();
            listNames.Clear(); listCompleted.Clear();
            completed = 0; timeMid = 0;
            DateTime cardDateOfCreation   = new DateTime();
            DateTime cardDateLastActivity = new DateTime();
            DateTime cardDateDue          = new DateTime();

            using (TrelloDbContext db = new TrelloDbContext())
            {
                var           lists   = db.Lists;
                List <string> listIds = new List <string>();
                foreach (TrelloList list in lists)
                {
                    if (list.BoardId == Program.myBoardId)
                    {
                        listIds.Add(list.Id);
                    }
                }
                var cards = db.Cards;
                foreach (TrelloCard card in cards)
                {
                    if (listIds.Contains(card.ListId))
                    {
                        cardDateLastActivity = Convert.ToDateTime(card.DateLastActivity);
                        listDatesLast.Add(cardDateLastActivity);
                        cardDateDue = Convert.ToDateTime(card.Due);
                        listDatesDue.Add(cardDateDue);
                        string cardDateOfCreationStr = "0x" + card.Id.Substring(0, 8);
                        int    cardDateOfCreationInt = Convert.ToInt32(cardDateOfCreationStr, 16);
                        cardDateOfCreation = UnixTimeStampToDateTime(cardDateOfCreationInt);
                        listDatesCreate.Add(cardDateOfCreation);
                        listNames.Add(card.Name);
                        if (card.DueComplete == "true")
                        {
                            listCompleted.Add(true);
                            completed++;
                        }
                        else
                        {
                            listCompleted.Add(false);
                        }
                    }
                }
                db.Dispose();
            }

            double timeGeneral     = 0;
            double timeGenComplete = 0;

            //среднее время выполнения задачи
            for (int i = 0; i < listNames.Count; i++)
            {
                double time = listDatesDue[i].Subtract(listDatesCreate[i]).TotalHours;
                timeGeneral += time;
                if (listCompleted[i])
                {
                    timeGenComplete += time;
                }
            }
            timeMid         = timeGeneral / listNames.Count;
            timeMidComplete = timeGenComplete / completed;
        }