public filesModel getModelByRow(DataRow dr) { filesModel model = new filesModel(); if ((dr["ID"] != null) && (dr["ID"].ToString() != "")) { model.ID = new Guid(dr["ID"].ToString()); } model.file_sid = dr["file_sid"].ToString(); model.file_name = dr["file_name"].ToString(); model.file_info = dr["file_info"].ToString(); model.Content = dr["Content"].ToString(); if (((dr["file_mark"] != null) && (dr["file_mark"].ToString() != "")) && IsNumber(dr["file_mark"].ToString())) { model.file_mark = new int?(int.Parse(dr["file_mark"].ToString())); } if ((dr["Original_table"] != null) && (dr["Original_table"].ToString() != "")) { model.Original_table = dr["Original_table"].ToString(); } if ((dr["sid_ColumnName"] != null) && (dr["sid_ColumnName"].ToString() != "")) { model.Sid_ColumnName = dr["sid_ColumnName"].ToString(); } if ((dr["prjcode"] != null) && (dr["prjcode"].ToString() != "")) { model.Prjcode = dr["prjcode"].ToString(); } if (((dr["sid_ColumnType"] != null) && (dr["sid_ColumnType"].ToString() != "")) && IsNumber(dr["sid_ColumnType"].ToString())) { model.Sid_ColumnType = int.Parse(dr["sid_ColumnType"].ToString()); } return(model); }
public IActionResult Postjson() { var files = Request.Form.Files; filesModel fmodel = new filesModel(); fmodel.files = new List <FileUploadModel>(); //FileUploadModel fl = new FileUploadModel(); //fl.name = "twitter.png"; //fl.size = 600000; //fl.url = "Download?fname=" + fl.name; //fl.thumbnail_url = "https://jquery-file-upload.appspot.com/image%2Fpng/195107973/twitter.png"; //fl.delete_type = "DELETE"; //fl.delete_url = ""; //fmodel.files.Add(fl); foreach (var file in files) { savetodisk(file); fmodel.files.Add(new FileUploadModel { name = file.FileName, size = file.Length, url = "Download?fname=" + file.FileName, thumbnailUrl = "Download?fname=" + file.FileName, deleteType = "DELETE", deleteUrl = "delete?fname=" + file.FileName }); } // string k = @"{'files': [ {'name': 'picture1.jpg', 'size': 902604, 'url': 'http:\/\/ example.org\/ files\/ picture1.jpg', 'thumbnailUrl': 'http:\/\/ example.org\/ files\/ thumbnail\/ picture1.jpg', 'deleteUrl': 'http:\/\/ example.org\/ files\/ picture1.jpg','deleteType': 'DELETE' }]}"; return(Json(fmodel)); }
protected void btnQuery_Click(object sender, EventArgs e) { filesModel filesModel = new filesModel(); string value = this.hidenID.Value; if (value != "") { try { filesModel = this.FL.GetModel(new Guid(value)); if (filesModel != null) { string table = string.Empty; table = filesModel.Original_table.ToString(); string id = filesModel.file_sid.ToString(); string rowName = filesModel.Sid_ColumnName.ToString(); this.CreateUrl(table, id, rowName); } } catch (Exception) { base.RegisterScript("alert('系统提示:\\n\\n查看地址转换失败!');"); } } }
public List <filesModel> DataTableToList(DataTable dt) { List <filesModel> list = new List <filesModel>(); int count = dt.Rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { filesModel item = new filesModel(); if ((dt.Rows[i]["ID"] != null) && (dt.Rows[i]["ID"].ToString() != "")) { item.ID = new Guid(dt.Rows[i]["ID"].ToString()); } if ((dt.Rows[i]["file_sid"] != null) && (dt.Rows[i]["file_sid"].ToString() != "")) { item.file_sid = dt.Rows[i]["file_sid"].ToString(); } if ((dt.Rows[i]["file_name"] != null) && (dt.Rows[i]["file_name"].ToString() != "")) { item.file_name = dt.Rows[i]["file_name"].ToString(); } if ((dt.Rows[i]["file_info"] != null) && (dt.Rows[i]["file_info"].ToString() != "")) { item.file_info = dt.Rows[i]["file_info"].ToString(); } if ((dt.Rows[i]["file_mark"] != null) && (dt.Rows[i]["file_mark"].ToString() != "")) { item.file_mark = new int?(int.Parse(dt.Rows[i]["file_mark"].ToString())); } if ((dt.Rows[i]["Original_table"] != null) && (dt.Rows[i]["Original_table"].ToString() != "")) { item.Original_table = dt.Rows[i]["Original_table"].ToString(); } if ((dt.Rows[i]["Content"] != null) && (dt.Rows[i]["Content"].ToString() != "")) { item.Content = dt.Rows[i]["Content"].ToString(); } list.Add(item); } } return(list); }
protected void btnFiles_Click(object sender, EventArgs e) { this.GET_SelectRow(); string text = string.Empty; if (this.ViewState["i_id"] != null) { text = this.ViewState["i_id"].ToString(); } if (text != "") { using (SqlConnection sqlConnection = new SqlConnection(SqlHelper.ConnectionString)) { sqlConnection.Open(); SqlTransaction sqlTransaction = sqlConnection.BeginTransaction(); DatumLogic datumLogic = new DatumLogic(); try { if (datumLogic.UpdateByID(HighlightsList.table_name, "i_id", text, sqlTransaction)) { string[] array = text.Split(new char[] { ',' }); if (array.Length > 0) { for (int i = 0; i < array.Length; i++) { if (!string.IsNullOrEmpty(array[i].ToString())) { if (this.flc.Exists(array[i].ToString(), sqlTransaction)) { this.flc.Update(array[i].ToString(), 1, HighlightsList.table_name, sqlTransaction); } else { if (this.ViewState[HighlightsList.temTable] != null) { DataTable dataTable = this.ViewState[HighlightsList.temTable] as DataTable; foreach (DataRow dr in dataTable.Rows) { filesModel filesModel = new filesModel(); filesModel = this.flc.getModelByRow(dr); if (filesModel.file_sid == array[i].ToString()) { this.flc.Add(filesModel, sqlTransaction); } } } } } } } sqlTransaction.Commit(); this.JS.Text = "alert('操作成功!');"; this.Data_Bind(); } } catch (Exception) { sqlTransaction.Rollback(); base.RegisterScript("alert('系统提示:\\n\\n操作失败!');"); } } } }
protected void btnFiles_Click(object sender, EventArgs e) { this.GET_SelectRow(); string text = string.Empty; if (this.ViewState["i_id"] != null) { text = this.ViewState["i_id"].ToString(); } if (text != "") { using (SqlConnection sqlConnection = new SqlConnection(SqlHelper.ConnectionString)) { sqlConnection.Open(); SqlTransaction sqlTransaction = sqlConnection.BeginTransaction(); DatumLogic datumLogic = new DatumLogic(); try { if (datumLogic.UpdateByID(EPC_17_Ppm_ScienceInnovate_EngineerConfirmList.table_name, 1, "ID", text, sqlTransaction)) { string[] array = text.Split(new char[] { ',' }); if (array.Length > 0) { for (int i = 0; i < array.Length; i++) { if (!string.IsNullOrEmpty(array[i].ToString())) { if (this.flc.Exists(array[i].ToString(), sqlTransaction)) { this.flc.Update(array[i].ToString(), 1, EPC_17_Ppm_ScienceInnovate_EngineerConfirmList.table_name, sqlTransaction); } else { if (this.ViewState[EPC_17_Ppm_ScienceInnovate_EngineerConfirmList.temTable] != null) { DataTable dataTable = this.ViewState[EPC_17_Ppm_ScienceInnovate_EngineerConfirmList.temTable] as DataTable; foreach (DataRow dr in dataTable.Rows) { filesModel filesModel = new filesModel(); filesModel = this.flc.getModelByRow(dr); if (filesModel.file_sid == array[i].ToString()) { this.flc.Add(filesModel, sqlTransaction); } } } } } } } sqlTransaction.Commit(); base.RegisterScript("top.ui.show('操作成功!')"); this.MeasureBind(this._PrjCode, this._BigSort, this._SmallSort); } } catch (Exception ex) { ex.ToString(); sqlTransaction.Rollback(); sqlConnection.Close(); base.RegisterScript("top.ui.show('操作失败!');"); } } } }
public bool Update(filesModel model, SqlTransaction trans) { return(this.dal.Update(model, trans)); }
public void Add(filesModel model, SqlTransaction trans) { this.dal.Add(model, trans); }
private void btnAddQueue_Click(object sender, EventArgs e) { try { toggleUI(false); if (txtPathFrom.Text == txtPathTo.Text) { throw new Exception("Source and destination directory must be different"); } if (string.IsNullOrEmpty(txtPathFrom.Text)) { throw new Exception("Source directory is empty"); } if (string.IsNullOrEmpty(txtPathTo.Text)) { throw new Exception("Destination directory is empty"); } this.mangaName = txtPathFrom.Text.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries).Last(); dataGridView1.DataSource = null; fileList.Clear(); directoryList.Clear(); string regexMatch_sorting = ((cboChapterNumberRegEx.SelectedIndex == -1) ? cboChapterNumberRegEx.Text : cboChapterNumberRegEx.SelectedItem.ToString()); string regexMatch_chapterTitle = ((cboChapterTitleRegEx.SelectedIndex == -1) ? cboChapterTitleRegEx.Text : cboChapterTitleRegEx.SelectedItem.ToString()); BackgroundWorker bw = new BackgroundWorker(); bw.WorkerReportsProgress = true; bw.DoWork += new DoWorkEventHandler( delegate(object o, DoWorkEventArgs args) { var directory_tmp = new directoryModel(); foreach (var item in Directory.GetDirectories(txtPathFrom.Text)) { try { var directoryName = item.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries).Last(); var regexMatches_temp = Regex.Matches(directoryName, regexMatch_sorting); directory_tmp.sorting = regexMatches_temp[0].Groups[Convert.ToInt32(txtChapterNumberRegExGroup.Text)].Value.Trim(); if (chkChapterTitleEnabled.Enabled) { regexMatches_temp = Regex.Matches(directoryName, regexMatch_chapterTitle); try { directory_tmp.chapterTitle = regexMatches_temp[0].Groups[Convert.ToInt32(txtChapterTitleRegExGroup.Text)].Value.Trim(); } catch { directory_tmp.chapterTitle = null; } } } catch { continue; } directory_tmp.directoryName = item; directoryList.Add(directory_tmp); directory_tmp = new directoryModel(); } fileList.Clear(); int fileCounter = 1; directoryList = directoryList.OrderBy(x => x.sorting, new NaturalStringComparer()).ToList(); var file_tmp = new filesModel(); foreach (var directory_item in directoryList) { int fileCounter_sort = 1; foreach (var file_item in Directory.GetFiles(directory_item.directoryName)) { if (chkChapterTitleEnabled.Enabled) { file_tmp.chapterTitle = directory_item.chapterTitle; } file_tmp.sorting = string.Format("Chapter {0} {1}", directory_item.sorting, fileCounter_sort); file_tmp.from = file_item; //file_tmp.to = string.Format("{0}\\{1}{2}", txtPathTo.Text, fileCounter.ToString().PadLeft(7, '0'), Path.GetExtension(file_item)); file_tmp.to = string.Format("{0}\\{1}\\{2}{3}", txtPathTo.Text, this.mangaName, fileCounter.ToString().PadLeft(7, '0'), Path.GetExtension(file_item)); file_tmp.pageNo = fileCounter; fileCounter++; fileCounter_sort++; fileList.Add(file_tmp); file_tmp = new filesModel(); } } fileList = fileList.OrderBy(x => x.sorting, new NaturalStringComparer()).ToList(); }); bw.ProgressChanged += new ProgressChangedEventHandler(delegate(object o, ProgressChangedEventArgs args) { }); bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler( delegate(object o, RunWorkerCompletedEventArgs args) { toggleUI(true); if (args.Error != null) { fileList.Clear(); directoryList.Clear(); dataGridView1.DataSource = null; MessageBox.Show(args.Error.Message, "Manga Renamer", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { dataGridView1.DataSource = fileList; dataGridView1.AutoResizeColumns(); progressBar1.Minimum = 0; progressBar1.Maximum = fileList.Count; } }); bw.RunWorkerAsync(); } catch (Exception ex) { directoryList.Clear(); fileList.Clear(); dataGridView1.DataSource = null; MessageBox.Show(ex.Message, "Manga Renamer", MessageBoxButtons.OK, MessageBoxIcon.Error); } }