public void wirteGridData() { //加入日志 string d = DateTime.Now.ToString("yyyy-MM-dd"); string dataPath = FileKit.dataPath + "\\" + d + ".json"; List <DataModel> list = new List <DataModel>(); foreach (DataGridViewRow m in dataGridView.Rows) { string sort = Convert.ToString(m.Cells["sort"].Value); string phone = Convert.ToString(m.Cells["phone"].Value); string starttime = Convert.ToString(m.Cells["starttime"].Value); string inpath = Convert.ToString(m.Cells["inpath"].Value); string outpath = Convert.ToString(m.Cells["outpath"].Value); string transStatus = Convert.ToString(m.Cells["transStatus"].Value); string ftpStatus = Convert.ToString(m.Cells["ftpStatus"].Value); DataModel model = new DataModel(); model.phone = phone; model.starttime = starttime; model.sort = Convert.ToInt32(sort); model.inpath = inpath; model.outpath = outpath; model.transStatus = transStatus; model.ftpStatus = ftpStatus; list.Add(model); } FileKit.createFile(JsonConvert.SerializeObject(list), dataPath); }
/// <summary> /// 立即提交 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSubmit_Click(object sender, EventArgs e) { string phone = txtPhone.Text; string date = txtDate.Text; if (string.IsNullOrEmpty(phone)) { MessageBox.Show(TextKit.failMsg, "操作提示"); return; } if (!ValidateKit.isMobile(phone)) { MessageBox.Show(TextKit.failMobileMsg, "操作提示"); return; } DataGridViewRow row = new DataGridViewRow(); //排序 DataGridViewTextBoxCell sort = new DataGridViewTextBoxCell(); sort.Value = Convert.ToInt32(dataGridView.Rows.Count + 1); row.Cells.Add(sort); //手机号 DataGridViewTextBoxCell phoneCell = new DataGridViewTextBoxCell(); phoneCell.Value = phone; row.Cells.Add(phoneCell); DataGridViewTextBoxCell starttime = new DataGridViewTextBoxCell(); starttime.Value = date; row.Cells.Add(starttime); DataGridViewTextBoxCell transcodeCell = new DataGridViewTextBoxCell(); transcodeCell.Value = "等待转码"; row.Cells.Add(transcodeCell); DataGridViewTextBoxCell upCell = new DataGridViewTextBoxCell(); upCell.Value = "等待资源"; row.Cells.Add(upCell); DataGridViewTextBoxCell inPathCell = new DataGridViewTextBoxCell(); inPathCell.Value = this.pbInPath; row.Cells.Add(inPathCell); DataGridViewTextBoxCell outPathCell = new DataGridViewTextBoxCell(); outPathCell.Value = this.pbOutPath; row.Cells.Add(outPathCell); dataGridView.Rows.Add(row); DataModel data = new DataModel(); data.phone = phone; data.starttime = date; data.op = phone + " " + pbInPath + " " + pbOutPath;; data.sort = dataGridView.Rows.Count - 1; //获取个人摆拍 if (!string.IsNullOrEmpty(this.pbPhotoPath)) { data.photo = this.pbPhotoPath; //copy个性摆拍 System.IO.File.Copy(data.photo, System.IO.Directory.GetCurrentDirectory() + @"\ffmpeg\output\" + data.phone + ".jpg"); } UploadDataModel m = new UploadDataModel(); m.phone = data.phone; m.starttime = data.starttime; m.mac = MacKit.GetMacString(); FileKit.createFile(JsonConvert.SerializeObject(m), System.IO.Directory.GetCurrentDirectory() + @"\ffmpeg\output\" + data.phone + ".json"); txtPhone.Text = ""; txtDate.Text = ""; pbIn.Image = global::VideoApplication.Properties.Resources._in; pbOut.Image = global::VideoApplication.Properties.Resources._out; pbPhoto.Image = global::VideoApplication.Properties.Resources.image; this.pbInPath = ""; this.pbOutPath = ""; this.pbPhotoPath = ""; wirteGridData(); QueueKit.q.Enqueue(data); }
private void MainForm_Load(object sender, EventArgs e) { List <DataModel> data = JsonConvert.DeserializeObject <List <DataModel> >(FileKit.getData(FileKit.dataPath + "\\" + DateTime.Now.ToString("yyyy-MM-dd") + ".json")); if (data != null) { foreach (DataModel m in data) { DataGridViewRow row = new DataGridViewRow(); //排序 DataGridViewTextBoxCell sort = new DataGridViewTextBoxCell(); sort.Value = m.sort; row.Cells.Add(sort); //手机号 DataGridViewTextBoxCell phoneCell = new DataGridViewTextBoxCell(); phoneCell.Value = m.phone; row.Cells.Add(phoneCell); DataGridViewTextBoxCell starttime = new DataGridViewTextBoxCell(); starttime.Value = m.starttime; row.Cells.Add(starttime); DataGridViewTextBoxCell transcodeCell = new DataGridViewTextBoxCell(); transcodeCell.Value = m.transStatus; row.Cells.Add(transcodeCell); DataGridViewTextBoxCell ftpCell = new DataGridViewTextBoxCell(); ftpCell.Value = m.ftpStatus; row.Cells.Add(ftpCell); DataGridViewTextBoxCell inPathCell = new DataGridViewTextBoxCell(); inPathCell.Value = m.inpath; row.Cells.Add(inPathCell); DataGridViewTextBoxCell outPathCell = new DataGridViewTextBoxCell(); outPathCell.Value = m.outpath; row.Cells.Add(outPathCell); dataGridView.Rows.Add(row); DataModel dataQueueModel = new DataModel(); dataQueueModel.phone = m.phone; dataQueueModel.starttime = m.starttime; dataQueueModel.op = m.phone + " " + m.inpath + " " + m.outpath;; dataQueueModel.sort = m.sort - 1; //未转码成功,重新转码 if (m.transStatus != TextKit.transStatusSuccess) { //获取个人摆拍 if (!string.IsNullOrEmpty(m.photo)) { //copy个性摆拍 System.IO.File.Copy(m.photo, System.IO.Directory.GetCurrentDirectory() + @"\ffmpeg\output\" + m.phone + ".jpg"); } transcodeCell.Value = "等待转码"; ftpCell.Value = "等待资源"; QueueKit.q.Enqueue(dataQueueModel); } else { //未上传成功,重新上传 if (m.ftpStatus != TextKit.ftpStatusSuccess) { UploadDataModel uploadModel = new UploadDataModel(); uploadModel.phone = m.phone; uploadModel.starttime = m.starttime; uploadModel.mac = MacKit.GetMacString(); FileKit.createFile(JsonConvert.SerializeObject(m), System.IO.Directory.GetCurrentDirectory() + @"\ffmpeg\output\" + m.phone + ".json"); ftpCell.Value = "等待资源"; QueueKit.qftp.Enqueue(dataQueueModel); } } } } monitorQueue(); }