Example #1
0
        public void AddStream(Models.Stream stream, bool local, Panel toPanel)
        {
            StreamInfo ctrlInfo = new StreamInfo
            {
                infoFileURL = stream.URL,
            };

            if (stream.Size != "-")
            {
                ctrlInfo.infoSize.Text = UtilityTools.bytesToString(Convert.ToInt32(stream.Size));
            }
            else
            {
                ctrlInfo.infoSize.Text = stream.Size;
            }
            if (stream.DateUploaded != "-")
            {
                ctrlInfo.infoAge.Text = UtilityTools.getTimeAgo(Convert.ToDateTime(stream.DateUploaded));
            }
            else
            {
                ctrlInfo.infoAge.Text = stream.DateUploaded;
            }
            ctrlInfo.infoName.Text = stream.Name;
            toPanel.Controls.Add(ctrlInfo);
        }
Example #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;
                }
            });
        }
Example #3
0
        private void loadLocalFiles()
        {
            dataFilesLocal.Clear();

            foreach (var pathFile in Directory.GetFiles(userDownloadsDirectory))
            {
                var dataJson = new Models.WebFile
                {
                    URL       = pathFile,
                    Host      = rm.GetString("local"),
                    Title     = Path.GetFileNameWithoutExtension(pathFile),
                    Type      = Path.GetExtension(pathFile).Replace(".", "").ToUpper(),
                    Size      = UtilityTools.bytesToString(new FileInfo(pathFile).Length),
                    DateAdded = File.GetCreationTime(pathFile).ToString()
                };

                dataFilesLocal.Add(JsonConvert.SerializeObject(dataJson));
            }
        }
Example #4
0
        private void btnRequestFileSize_ClickButtonArea(object Sender, MouseEventArgs e)
        {
            try
            {
                btnRequestFileSize.Visible = false;

                WebRequest req = WebRequest.Create(infoFileURL.Text);
                req.Method  = "HEAD";
                req.Timeout = 7000;
                using (HttpWebResponse fileResponse = (HttpWebResponse)req.GetResponse())
                {
                    int ContentLength;
                    if (int.TryParse(fileResponse.Headers.Get("Content-Length"), out ContentLength))
                    {
                        infoSize.Text = UtilityTools.bytesToString(ContentLength);
                    }
                    else
                    {
                        infoSize.Text = "Error";
                    }
                }
            }
            catch { infoSize.Text = "Error"; }
        }
Example #5
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"; }
        }