public static int CopyTemplatePathToWorkFolder(string dbpath, Int64 template_id, string workHolder) { int result = 0; TemplatePathListViewModel tplv = new TemplatePathListViewModel(); SQLiteClass.ExecuteSelectTableTemplatePath(dbpath, tplv, template_id); foreach (ListTemplatePath entry in tplv.Entries) { string theFilename = Path.GetFileName(entry.Path); string copyFileName = workHolder + "\\" + theFilename; if (File.Exists(copyFileName)) { var res = MessageBox.Show(Properties.Resources.NW_Template_Overwrite, "taskalu", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (res == MessageBoxResult.No) { continue; } } try { File.Copy(entry.Path, copyFileName, true); result += 1; } catch (Exception e) { MessageBox.Show(e.Message); } } return(result); }
public static Boolean ExecuteSelectTableTemplatePath(string dbpath, TemplatePathListViewModel tplv, Int64 template_id) { Boolean ret = false; string sql = "SELECT * from template_path WHERE template_id = @template_id ORDER BY torder ASC"; SQLiteConnection con = new SQLiteConnection("Data Source=" + dbpath + ";"); con.Open(); SQLiteCommand com = new SQLiteCommand(sql, con); com.Parameters.Add(sqliteParamInt64(com, "@template_id", template_id)); try { SQLiteDataReader sdr = com.ExecuteReader(); while (sdr.Read() == true) { ListTemplatePath lt = new ListTemplatePath(); lt.Id = (Int64)sdr["id"]; lt.Template_Id = (Int64)sdr["template_id"]; lt.Order = (Int64)sdr["torder"]; lt.Path = (string)sdr["path"]; tplv.Entries.Add(lt); } sdr.Close(); ret = true; } catch (Exception ex) { MessageBox.Show("database table template path select error!\n" + ex.Message); } finally { con.Close(); } return(ret); }