Ejemplo n.º 1
0
        public async Task Start()
        {
            Reset();

            try
            {
                this.Status = DownloadStatus.Downloading;

                await Download();

                //下载完成,开始合并和转换格式
                this.Status = DownloadStatus.Converting;
                await ProcessVideo(PartList.Select(part => part.StorePath).ToList(), this.StorePath, this.OutputFormat);

                this.Status = DownloadStatus.Success;
            }
            catch (TaskCanceledException e)
            {
                this.Status = DownloadStatus.New;
                return;
            }
            catch (Exception e)
            {
                this.Status = DownloadStatus.Error;
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var quickID = int.Parse(textBox1.Text);
                if (AllParts.Contains(quickID))
                {
                    throw new Exception();
                }
                AllParts.Add(quickID);

                using (var context = new InventoryContext())
                {
                    var part = context.Part.Where(x => x.QuickID == quickID).FirstOrDefault();
                    if (part == null)
                    {
                        throw new ArgumentNullException();
                    }
                    PartList.Add(part);

                    var grid = PartList.Select(x => new
                    {
                        QuickID      = x.QuickID,
                        PartNumber   = x.PartNumber,
                        SerialNumber = x.SerialNumber,
                        Description  = x.Description,
                        Location     = x.Location,
                        Category     = x.Category,
                        Quantity     = 1
                    }).ToList();

                    dataGridView1.DataSource = null;
                    dataGridView1.DataSource = grid;
                }
            }
            catch (ArgumentNullException)
            {
                MessageBox.Show("That QuickID was not found.");
            }
            catch (Exception ex)
            {
                MessageBox.Show($"You cannot add the same QuickID twice \r\n \r\n {ex.Message}");
            }
        }