Ejemplo n.º 1
0
        // Home tab
        public void getDatabaseInfo()
        {
            long totalSize = 0;

            try
            {
                foreach (string jsonData in dataOpenFiles)
                {
                    var dataJsonFile = JsonConvert.DeserializeObject <Models.WebFile>(jsonData);
                    if (dataJsonFile.Size != "-" && dataJsonFile.Size != "" && dataJsonFile.Size != " ")
                    {
                        totalSize = totalSize + Convert.ToInt64(dataJsonFile.Size);
                    }
                }

                lblHomeStatsFiles.Text = String.Format(lblHomeStatsFiles.Text, UtilityTools.getFormattedNumber(dataOpenFiles.Count.ToString()), UtilityTools.bytesToString(totalSize), UtilityTools.getFormattedNumber(dataOpenDirectories.Count.ToString()));
            }
            catch { lblHomeStatsFiles.Text = String.Format(lblHomeStatsFiles.Text, UtilityTools.getFormattedNumber(dataOpenFiles.Count.ToString()), UtilityTools.bytesToString(totalSize), UtilityTools.getFormattedNumber(dataOpenDirectories.Count.ToString())); }

            try
            {
                // Database Info
                var dataJsonInfo = JsonConvert.DeserializeObject <Models.DatabaseInfo>(databaseInfo);
                lblHomeStatsDatabaseUpdated.Text = String.Format(lblHomeStatsDatabaseUpdated.Text, Convert.ToDateTime(dataJsonInfo.LastUpdated).ToShortDateString());
            }
            catch { lblHomeStatsDatabaseUpdated.Text = "Updated: n/a"; }
        }
Ejemplo n.º 2
0
        public void showFiles(List <string> dataFiles)
        {
            BackGroundWorker.RunWorkAsync <List <string> >(() => searchFiles(dataFiles), (data) =>
            {
                if (tabFiles.InvokeRequired)
                {
                    loadFilesCallBack b = new loadFilesCallBack(showFiles);
                    Invoke(b, new object[] { dataFiles });
                }
                else
                {
                    ComponentResourceManager resources = new ComponentResourceManager(typeof(MainForm));
                    cmboBoxFilesSort.SelectedIndex     = 0; dataGridFiles.Rows.Clear();
                    cmboBoxFilesHost.Items.Clear(); cmboBoxFilesHost.Items.Add(resources.GetString("cmboBoxFilesHost.Items"));

                    stopWatch.Start();

                    foreach (string jsonData in data)
                    {
                        var dataJson         = JsonConvert.DeserializeObject <Models.WebFile>(jsonData);
                        string formattedDate = dataJson.DateAdded;
                        if (dataJson.DateAdded != "-")
                        {
                            formattedDate = UtilityTools.getTimeAgo(Convert.ToDateTime(dataJson.DateAdded));
                        }
                        string formattedSize = dataJson.Size;
                        if (dataJson.Size != "-")
                        {
                            formattedSize = UtilityTools.bytesToString(Convert.ToInt64(dataJson.Size));
                        }
                        dataGridFiles.Rows.Add(dataJson.Type, dataJson.Title, formattedSize, formattedDate, dataJson.Host, dataJson.URL);

                        if (!(cmboBoxFilesHost.Items.Contains(dataJson.Host)))
                        {
                            cmboBoxFilesHost.Items.Add(dataJson.Host);
                        }
                    }

                    stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed;
                    lblFilesResultsInfo.Text      = UtilityTools.getFormattedNumber(dataGridFiles.Rows.Count.ToString()) + " / " + UtilityTools.getFormattedNumber(dataFiles.Count.ToString()) + " Files (" + String.Format("{0:0.000}", ts.TotalSeconds) + " Seconds)"; stopWatch.Reset();

                    tab.SelectedTab = currentTab;

                    cmboBoxFilesHost.DropDownWidth = UtilityTools.DropDownWidth(cmboBoxFilesHost);
                    imgSpinner.Visible             = false;
                }
            });
        }