private void InitialTree(object parentId, TreeNode parentNode, bool isShowAll) { List <object[]> list = SQLiteHelper.ExecuteColumnsQuery($"SELECT bfi_id, bfi_name, bfi_path, bfi_state, bfi_type FROM backup_files_info WHERE bfi_pid='{parentId}' ORDER BY rowid", 5); for (int i = 0; i < list.Count; i++) { int state = Convert.ToInt32(list[i][3]); if (state != 1 || isShowAll) { TreeNode treeNode = new TreeNode() { Name = GetValue(list[i][0]), Text = GetValue(list[i][1]), Tag = GetValue(list[i][2]), ImageIndex = (state == 1) ? 3 : -1, ToolTipText = GetValue(list[i][4]), }; parentNode.Nodes.Add(treeNode); InitialTree(treeNode.Name, treeNode, isShowAll); } } if (list.Count == 0) { if (parentNode.ImageIndex != 3) { parentNode.ImageIndex = parentNode.SelectedImageIndex = 2; } else if (parentNode.ImageIndex == 3) { parentNode.SelectedImageIndex = 3; } } }
private void Frm_Export_Load(object sender, EventArgs e) { LoadFileInfo(UserHelper.GetUser().UserSpecialId); List <object[]> projectIds = SQLiteHelper.ExecuteColumnsQuery($"SELECT pi_id FROM project_info WHERE pi_obj_id='{UserHelper.GetUser().UserSpecialId}'", 1); for (int i = 0; i < projectIds.Count; i++) { LoadFileInfo(projectIds[i][0]); List <object[]> pro_top_ids = SQLiteHelper.ExecuteColumnsQuery($"SELECT ti_id FROM topic_info WHERE ti_obj_id='{projectIds[i][0]}'", 1); for (int j = 0; j < pro_top_ids.Count; j++) { LoadFileInfo(pro_top_ids[j][0]); List <object[]> pro_top_sub_ids = SQLiteHelper.ExecuteColumnsQuery($"SELECT si_id FROM subject_info WHERE si_obj_id='{pro_top_ids[j][0]}'", 1); for (int k = 0; k < pro_top_sub_ids.Count; k++) { LoadFileInfo(pro_top_sub_ids[k][0]); } } } List <object[]> topicIds = SQLiteHelper.ExecuteColumnsQuery($"SELECT ti_id FROM topic_info WHERE ti_obj_id='{UserHelper.GetUser().UserSpecialId}'", 1); for (int i = 0; i < topicIds.Count; i++) { LoadFileInfo(topicIds[i][0]); List <object[]> pro_top_sub_ids = SQLiteHelper.ExecuteColumnsQuery($"SELECT si_id FROM subject_info WHERE si_obj_id='{topicIds[i][0]}'", 1); for (int k = 0; k < pro_top_sub_ids.Count; k++) { LoadFileInfo(pro_top_sub_ids[k][0]); } } pro_Show.Maximum = list.Count; }
private int GetTotalFileAmountBySpiId(object objId) { int count = 0; count += GetCount(objId); List <object[]> list = SQLiteHelper.ExecuteColumnsQuery($"SELECT pi_id FROM project_info WHERE pi_obj_id='{objId}'", 1); for (int i = 0; i < list.Count; i++) { count += GetCount(list[i][0]); List <object[]> list3 = SQLiteHelper.ExecuteColumnsQuery($"SELECT ti_id FROM topic_info WHERE ti_obj_id='{list[i][0]}'", 1); for (int j = 0; j < list3.Count; j++) { count += GetCount(list3[j][0]); List <object[]> list5 = SQLiteHelper.ExecuteColumnsQuery($"SELECT si_id FROM subject_info WHERE si_obj_id='{list3[j][0]}'", 1); for (int k = 0; k < list5.Count; k++) { count += GetCount(list5[k][0]); } } List <object[]> list4 = SQLiteHelper.ExecuteColumnsQuery($"SELECT si_id FROM subject_info WHERE si_obj_id='{list[i][0]}'", 1); for (int j = 0; j < list4.Count; j++) { count += GetCount(list4[j][0]); } } List <object[]> list2 = SQLiteHelper.ExecuteColumnsQuery($"SELECT ti_id FROM topic_info WHERE ti_obj_id='{objId}'", 1); for (int i = 0; i < list2.Count; i++) { count += GetCount(list2[i][0]); List <object[]> list4 = SQLiteHelper.ExecuteColumnsQuery($"SELECT si_id FROM subject_info WHERE si_obj_id='{list2[i][0]}'", 1); for (int j = 0; j < list4.Count; j++) { count += GetCount(list4[j][0]); } } return(count); }
private void Btn_Start_Click(object sender, EventArgs e) { progressBar1.Maximum = GetTotalFileAmountBySpiId(UserHelper.GetUser().UserSpecialId); int count = progressBar1.Maximum, okcount = 0, nocount = 0; string rootFolder = txt_FilePath.Text + "\\" + SQLiteHelper.ExecuteOnlyOneQuery($"SELECT spi_name FROM special_info WHERE spi_id='{UserHelper.GetUser().UserSpecialId}'"); if (!Directory.Exists(rootFolder)) { Directory.CreateDirectory(rootFolder); } //专项下的文件 CopyFile(ref okcount, ref nocount, rootFolder, GetFileLinkByObjId(UserHelper.GetUser().UserSpecialId)); //专项下的项目 List <object[]> list2 = SQLiteHelper.ExecuteColumnsQuery($"SELECT pi_id, pi_name FROM project_info WHERE pi_obj_id='{UserHelper.GetUser().UserSpecialId}'", 2); for (int i = 0; i < list2.Count; i++) { string _rootFolder = rootFolder + "\\" + list2[i][1]; if (!Directory.Exists(_rootFolder)) { Directory.CreateDirectory(_rootFolder); } //项目下的文件 CopyFile(ref okcount, ref nocount, _rootFolder, GetFileLinkByObjId(list2[i][0])); //项目下的课题 List <object[]> list5 = SQLiteHelper.ExecuteColumnsQuery($"SELECT ti_id, ti_name FROM topic_info WHERE ti_obj_id='{list2[i][0]}'", 2); for (int j = 0; j < list5.Count; j++) { string _rootFolder2 = _rootFolder + "\\" + list5[j][1]; if (!Directory.Exists(_rootFolder2)) { Directory.CreateDirectory(_rootFolder2); } //课题下的文件 CopyFile(ref okcount, ref nocount, _rootFolder2, GetFileLinkByObjId(list5[j][0])); //课题下的子课题 List <object[]> list6 = SQLiteHelper.ExecuteColumnsQuery($"SELECT si_id, si_name FROM subject_info WHERE si_obj_id='{list5[j][0]}'", 2); for (int k = 0; k < list6.Count; k++) { string _rootFolder3 = _rootFolder2 + "\\" + list6[k][1]; if (!Directory.Exists(_rootFolder3)) { Directory.CreateDirectory(_rootFolder3); } CopyFile(ref okcount, ref nocount, _rootFolder3, GetFileLinkByObjId(list6[k][0])); } } //项目下的子课题 List <object[]> list7 = SQLiteHelper.ExecuteColumnsQuery($"SELECT si_id, si_name FROM subject_info WHERE si_obj_id='{list2[i][0]}'", 2); for (int j = 0; j < list7.Count; j++) { string _rootFolder2 = _rootFolder + "\\" + list7[j][1]; if (!Directory.Exists(_rootFolder2)) { Directory.CreateDirectory(_rootFolder2); } CopyFile(ref okcount, ref nocount, _rootFolder2, GetFileLinkByObjId(list7[j][0])); } } //专项下的课题 List <object[]> list4 = SQLiteHelper.ExecuteColumnsQuery($"SELECT ti_id, ti_name FROM topic_info WHERE ti_obj_id='{UserHelper.GetUser().UserSpecialId}'", 2); for (int i = 0; i < list4.Count; i++) { string _rootFolder = rootFolder + "\\" + list4[i][1]; if (!Directory.Exists(_rootFolder)) { Directory.CreateDirectory(_rootFolder); } //课题下的文件 CopyFile(ref okcount, ref nocount, _rootFolder, GetFileLinkByObjId(list4[i][0])); //课题下的子课题 List <object[]> list6 = SQLiteHelper.ExecuteColumnsQuery($"SELECT si_id, si_name FROM subject_info WHERE si_obj_id='{list4[i][0]}'", 2); for (int k = 0; k < list6.Count; k++) { string _rootFolder3 = _rootFolder + "\\" + list6[k][1]; if (!Directory.Exists(_rootFolder3)) { Directory.CreateDirectory(_rootFolder3); } CopyFile(ref okcount, ref nocount, _rootFolder3, GetFileLinkByObjId(list6[k][0])); } } MessageBox.Show($"备份完成,共计{count}个文件,成功{okcount}个,失败{nocount}个。", "操作成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); Close(); }
/// <summary> /// 根据指定对象ID获取文件链接 /// </summary> /// <param name="objId">指定ID</param> private static List <object[]> GetFileLinkByObjId(object objId) => SQLiteHelper.ExecuteColumnsQuery($"SELECT fi_link FROM files_info WHERE fi_obj_id='{objId}'", 1);
private void btn_Export_Click(object sender, EventArgs e) { object KEY = "SAVE_PATH"; object value = SQLiteHelper.ExecuteOnlyOneQuery($"SELECT dd_name FROM data_dictionary WHERE dd_code='{KEY}'"); if (value != null) { /* ----复制文件----*/ pro_Show.Maximum = GetTotalFileAmountBySpiId(UserHelper.GetUser().UserSpecialId); int count = pro_Show.Maximum, okcount = 0, nocount = 0; string rootFolder = value + "\\" + SQLiteHelper.ExecuteOnlyOneQuery($"SELECT spi_name FROM special_info WHERE spi_id='{UserHelper.GetUser().UserSpecialId}'"); if (!Directory.Exists(rootFolder)) { Directory.CreateDirectory(rootFolder); } //专项下的文件 CopyFile(ref okcount, ref nocount, rootFolder, GetFileLinkByObjId(UserHelper.GetUser().UserSpecialId)); //专项下的项目 List <object[]> list2 = SQLiteHelper.ExecuteColumnsQuery($"SELECT pi_id, pi_name FROM project_info WHERE pi_obj_id='{UserHelper.GetUser().UserSpecialId}'", 2); for (int i = 0; i < list2.Count; i++) { string _rootFolder = rootFolder + "\\" + list2[i][1]; if (!Directory.Exists(_rootFolder)) { Directory.CreateDirectory(_rootFolder); } //项目下的文件 CopyFile(ref okcount, ref nocount, _rootFolder, GetFileLinkByObjId(list2[i][0])); //项目下的课题 List <object[]> list5 = SQLiteHelper.ExecuteColumnsQuery($"SELECT ti_id, ti_name FROM topic_info WHERE ti_obj_id='{list2[i][0]}'", 2); for (int j = 0; j < list5.Count; j++) { string _rootFolder2 = _rootFolder + "\\" + list5[j][1]; if (!Directory.Exists(_rootFolder2)) { Directory.CreateDirectory(_rootFolder2); } //课题下的文件 CopyFile(ref okcount, ref nocount, _rootFolder2, GetFileLinkByObjId(list5[j][0])); //课题下的子课题 List <object[]> list6 = SQLiteHelper.ExecuteColumnsQuery($"SELECT si_id, si_name FROM subject_info WHERE si_obj_id='{list5[j][0]}'", 2); for (int k = 0; k < list6.Count; k++) { string _rootFolder3 = _rootFolder2 + "\\" + list6[k][1]; if (!Directory.Exists(_rootFolder3)) { Directory.CreateDirectory(_rootFolder3); } CopyFile(ref okcount, ref nocount, _rootFolder3, GetFileLinkByObjId(list6[k][0])); } } //项目下的子课题 List <object[]> list7 = SQLiteHelper.ExecuteColumnsQuery($"SELECT si_id, si_name FROM subject_info WHERE si_obj_id='{list2[i][0]}'", 2); for (int j = 0; j < list7.Count; j++) { string _rootFolder2 = _rootFolder + "\\" + list7[j][1]; if (!Directory.Exists(_rootFolder2)) { Directory.CreateDirectory(_rootFolder2); } CopyFile(ref okcount, ref nocount, _rootFolder2, GetFileLinkByObjId(list7[j][0])); } } //专项下的课题 List <object[]> list4 = SQLiteHelper.ExecuteColumnsQuery($"SELECT ti_id, ti_name FROM topic_info WHERE ti_obj_id='{UserHelper.GetUser().UserSpecialId}'", 2); for (int i = 0; i < list4.Count; i++) { string _rootFolder = rootFolder + "\\" + list4[i][1]; if (!Directory.Exists(_rootFolder)) { Directory.CreateDirectory(_rootFolder); } //课题下的文件 CopyFile(ref okcount, ref nocount, _rootFolder, GetFileLinkByObjId(list4[i][0])); //课题下的子课题 List <object[]> list6 = SQLiteHelper.ExecuteColumnsQuery($"SELECT si_id, si_name FROM subject_info WHERE si_obj_id='{list4[i][0]}'", 2); for (int k = 0; k < list6.Count; k++) { string _rootFolder3 = _rootFolder + "\\" + list6[k][1]; if (!Directory.Exists(_rootFolder3)) { Directory.CreateDirectory(_rootFolder3); } CopyFile(ref okcount, ref nocount, _rootFolder3, GetFileLinkByObjId(list6[k][0])); } } MessageBox.Show($"备份完成,共计{count}个文件,成功{okcount}个,失败{nocount}个。", "操作成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); /* ----合成文件清单----*/ string filePath = value + "\\重大专项项目(课题)档案交接清单"; MicrosoftWordHelper.WriteDocument(filePath, list); if (MessageBox.Show("文件清单合成完毕, 是否需要现在打开?", "温馨提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes) { LoadDocumnet(filePath); } Close(); } else { MessageBox.Show("尚未指定文件存放路径。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }