Пример #1
0
        private void fill(ClientsInfo result)
        {
            if (chkFilter.Checked)
            {
                filterLocal(result);
            }
            if (chkRemoveOld.Checked)
            {
                filterOld(result, txtOldDays.Value);
            }
            txtTodayEntries.Text = result.GetEntriesForDay(DateTime.UtcNow).Count.ToString();
            txtTodayUsers.Text   = result.GetUsersForDay(DateTime.UtcNow).Count.ToString();
            txtEntriesCount.Text = result.Clients.Count.ToString();
            var uniqueInstances = result.GetUniqueUsers();

            txtUsersNumber.Text     = uniqueInstances.Count.ToString();
            txtUniqueInstances.Text = result.GetUniqueInstances().Count.ToString();
            txtFullVersion.Text     = result.GetFullVersionCount().ToString();
            fillInstanceTab(uniqueInstances);
            fillAllTab(result);
            fillRaports();
            fillPlatforms();
            fillPaid(result);
            fillOS(result, chkOsDetailed.Checked);
        }
Пример #2
0
 private void fillPaid(ClientsInfo results)
 {
     lvPaid.Items.Clear();
     cmbPaid.Items.Clear();
     foreach (string profile in results.GetFullVersionsProfiles())
     {
         cmbPaid.Items.Add(new ComboBoxItem(profile, profile));
     }
 }
Пример #3
0
        void fillOS(ClientsInfo result, bool detailed)
        {
            lvOS.Items.Clear();
            lvOSUsers.Items.Clear();
            var os = result.GetOS(detailed);

            foreach (var o in os)
            {
                var item = new ListViewItem(new string[] { o.Key, o.Value.Count.ToString() });
                item.Tag = o.Value;
                lvOS.Items.Add(item);
            }
        }
Пример #4
0
        private Dictionary <DateTime, int> splitByDate(ClientsInfo result)
        {
            Dictionary <DateTime, int> res = new Dictionary <DateTime, int>();

            foreach (var client in result.Clients)
            {
                if (!res.ContainsKey(client.Date.Date))
                {
                    res.Add(client.Date.Date, 0);
                }
                res[client.Date.Date] = res[client.Date.Date] + 1;
            }
            return(res);
        }
Пример #5
0
        private ClientsInfo processContent(string[] lines)
        {
            ClientsInfo info = new ClientsInfo();

            foreach (var line in lines)
            {
                if (!string.IsNullOrEmpty(line))
                {
                    ClientInstance instance = new ClientInstance(line);
                    info.Clients.Add(instance);
                }
            }
            return(info);
        }
Пример #6
0
        private void filterOld(ClientsInfo result, decimal value)
        {
            var instances = result.GetUniqueInstances();
            var list      = (from i in instances
                             where ((DateTime.Now - i.Value.Max(t => t.Date)).TotalDays > (double)value)
                             select i).ToDictionary(t => t.Key);

            for (int i = result.Clients.Count - 1; i >= 0; i--)
            {
                if (list.ContainsKey(result.Clients[i].InstanceId) && (!result.Clients[i].Version.StartsWith("Full") || result.Clients[i].Version == "Full 1.0.0"))
                {
                    result.Clients.RemoveAt(i);
                }
            }
        }
Пример #7
0
        public void GenerateReport(Chart chart1, ClientsInfo result)
        {
            chart1.Series.Clear();
            var title = new Title(ReportName);

            chart1.Titles.Add(title);

            Series series = new Series();

            series.ChartType           = SeriesChartType.Line;
            series.IsValueShownAsLabel = true;
            chart1.Series.Add(series);

            foreach (var pair in splitByDate(result))
            {
                series.Points.AddXY(pair.Key, pair.Value);
            }
        }
Пример #8
0
 void filterLocal(ClientsInfo result)
 {
     try
     {
         List <string> users = new List <string>(txtMyUsers.Text.Split(','));
         for (int i = result.Clients.Count - 1; i >= 0; i--)
         {
             if (users.IndexOf(result.Clients[i].Name.ToLower()) > -1)
             {
                 result.Clients.RemoveAt(i);
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show("Bład przy filtrowaniu: " + e.Message);
     }
 }
Пример #9
0
 void fillAllTab(ClientsInfo result)
 {
     //lvAll.BeginUpdate();
     lvAll.Items.Clear();
     lvAll.VirtualListSize = result.Clients.Count;
     //foreach (var clientInstance in result.Clients)
     //{
     //    int count = result.GetAllInstancesForUser(clientInstance.Name).Count;
     //    ListViewItem item = new ListViewItem(new string[] { clientInstance.Date.ToLocalTime().ToString(), clientInstance.Language, clientInstance.Version, clientInstance.InstanceId.ToString(), count.ToString(),clientInstance.Name,clientInstance.Platform.ToString() });
     //    bool isFirst=result.IsFirstRun(clientInstance);
     //    if(isFirst)
     //    {
     //        item.ImageKey = "New";
     //    }
     //    lvAll.Items.Add(item);
     //}
     //lvAll.EndUpdate();
 }
Пример #10
0
 private void startImplementation()
 {
     btnStart.Enabled = false;
     try
     {
         ClientsFileParser parser   = new ClientsFileParser();
         DateTime?         fromDate = null;
         if (chkGetFromDate.Checked)
         {
             fromDate = dateTimePicker2.Value;
         }
         result = parser.Parse(fromDate, chkAllPaid.Checked);
         fill(result);
     }
     finally
     {
         btnStart.Enabled = true;
     }
 }
Пример #11
0
        public ClientsInfo get_data(DateTime?fromDate, bool withAllPaid = true)
        {
            ClientsInfo info = new ClientsInfo();

            try
            {
                MySqlDataReader sqlReader;
                string          query = "SELECT  UserName, logindata.* FROM logindata LEFT JOIN profile ON (logindata.ProfileId = profile.GlobalId);";
                if (fromDate.HasValue)
                {
                    query = "SELECT  UserName, logindata.* FROM logindata LEFT JOIN profile ON (logindata.ProfileId = profile.GlobalId) WHERE LoginDateTime>?fromDate ";
                    if (withAllPaid)
                    {
                        query += " OR (SUBSTRING(ApplicationVersion,1,4)='Full' AND ApplicationVersion<>'Full 1.0.0')";
                    }
                }

                query += " ORDER BY LoginDateTime DESC";
                MySqlCommand sqlCommand = new MySqlCommand(query, sqlConn);
                sqlCommand.CommandTimeout = 500;
                if (fromDate.HasValue)
                {
                    sqlCommand.Parameters.Add("?fromDate", MySqlDbType.DateTime).Value = fromDate.Value;
                }
                sqlReader = sqlCommand.ExecuteReader();

                //sqlReader.Read();
                while (sqlReader.Read())
                {
                    ClientInstance instance = new ClientInstance(sqlReader);
                    info.Clients.Add(instance);
                }

                return(info);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return(null);
            }
        }
Пример #12
0
        public void GenerateReport(Chart chart1, ClientsInfo result)
        {
            chart1.Series.Clear();
            var title = new Title(ReportName);

            chart1.Titles.Add(title);

            Series series = new Series();

            series.ChartType           = SeriesChartType.Line;
            series.IsValueShownAsLabel = true;
            chart1.Series.Add(series);

            var cos =
                result.Clients.Where(x => x.Version.StartsWith("Full") && x.Version != "Full 1.0.0").OrderBy(x => x.Date)
                .GroupBy(x => x.Name);

            Dictionary <DateTime, int> dict = new Dictionary <DateTime, int>();
            DateTime date = new DateTime(2011, 8, 17);

            for (int i = 0; i < (DateTime.Now - date).TotalDays; i++)
            {
                dict.Add(date.AddDays(i).Date, 0);
            }

            foreach (var pair in cos)
            {
                var item = pair.First();
                if (!dict.ContainsKey(item.Date.Date))
                {
                    dict.Add(item.Date.Date, 0);
                }
                dict[item.Date.Date]++;
            }

            foreach (var i in dict)
            {
                series.Points.AddXY(i.Key, i.Value);
            }
        }