public DataTable LoadReviewInfo(RegisterDocument doc) { Console.WriteLine("Loading review info..."); string filepath = Path.Combine(projectFolder, @"review.load.sqlite.sql"); string sql = File.ReadAllText(filepath); sql += " AND docno = @docno "; sql += " AND doc_version = @version "; sql += "order by review_date desc"; Console.WriteLine(doc); Console.WriteLine(sql); DataTable dt = new DataTable(); using (var cmd = new SQLiteCommand(sql, m_dbConnection)) { cmd.Parameters.AddWithValue("@docno", doc.DocumentNumber); cmd.Parameters.AddWithValue("@version", doc.Version); SQLiteDataAdapter da = new SQLiteDataAdapter(); da.SelectCommand = cmd; da.Fill(dt); } Console.WriteLine("Found {0} review info", dt.Rows.Count); return(dt); }
public void ImportDocumentData(RegisterDocument d) { string filepath = Path.Combine(projectFolder, @"register.import.sqlite.sql"); string sql = File.ReadAllText(@"register.import.sqlite.sql"); SQLiteCommand cmd = new SQLiteCommand(sql, m_dbConnection); cmd.Parameters.AddWithValue("@docno", d.DocumentNumber); cmd.Parameters.AddWithValue("@title", d.Title); cmd.Parameters.AddWithValue("@discipline", d.Discipline); cmd.Parameters.AddWithValue("@revision", d.Revision); cmd.Parameters.AddWithValue("@revision_date", d.RevisionDate); cmd.Parameters.AddWithValue("@version", d.Version); cmd.Parameters.AddWithValue("@status", d.Status); cmd.Parameters.AddWithValue("@int_cd", d.InternalNumber); cmd.Parameters.AddWithValue("@review_status", d.ReviewStatus); cmd.Parameters.AddWithValue("@registered_by", d.RegisteredBy); cmd.Parameters.AddWithValue("@registered", d.Registered); cmd.Parameters.AddWithValue("@organization", d.Organization); cmd.Parameters.AddWithValue("@descr", d.Note); cmd.Parameters.AddWithValue("@type", d.Type); cmd.Parameters.AddWithValue("@current", d.Current); cmd.ExecuteNonQuery(); cmd.Dispose(); }
private void ShowRegisterDocumentInfo(object sender, EventArgs e) { var viewForm = _form.RegisterDocumentDetailView; var docno = _form.RegisterDocumentDetailView.Number; var version = _form.RegisterDocumentDetailView.Version; RegisterDocument doc = _service.LoadDocument(docno, version); viewForm.Number = doc.DocumentNumber; viewForm.Title = doc.Title; viewForm.Revision = doc.Revision; viewForm.RevisionDate = doc.RevisionDate; viewForm.Status = doc.Status; viewForm.Registered = doc.Registered; viewForm.RegisteredBy = doc.RegisteredBy; viewForm.Note = doc.Note; viewForm.ReviewStatus = doc.ReviewStatus; viewForm.Version = doc.Version; viewForm.Type = doc.Type; viewForm.Organization = doc.Organization; viewForm.Current = doc.Current == "1" ? "(Top Version)" : "(Old Version)"; viewForm.InternalNumber = doc.InternalNumber; viewForm.Discipline = doc.Discipline; if (OnLoadRegisterDocument != null) { OnLoadRegisterDocument(this, doc); } }
public List <RegisterFile> LoadReviewRegisterFiles(RegisterDocument doc) { string registerURI = Properties.Settings.Default.register_folder_uri; registerURI = String.IsNullOrEmpty(registerURI) ? "register" : registerURI; string targetDirectory = registerURI + "/" + RegisterFile.SanitizeName(doc.DocumentNumber) + "/" + doc.Version + "/extra"; string[] files = new string[0]; try { LogUtil.Log(String.Format("Looking for files... {0}", targetDirectory)); files = Directory.GetFiles(targetDirectory); } catch (DirectoryNotFoundException e) { e.Log(); } var registerFiles = new List <RegisterFile>(); foreach (string fileName in files) { var regfile = new RegisterFile(fileName); registerFiles.Add(regfile); LogUtil.Log(String.Format("Processed file: {0}", regfile)); } return(registerFiles); }
public void ImportCSVFile(string csvfile) { FileStream fs = new FileStream(csvfile, FileMode.Open, FileAccess.Read); List <RegisterDocument> docs = new List <RegisterDocument>(); using (StreamReader reader = new StreamReader(fs, Encoding.Default)) { reader.ReadLine(); // skip header while (!reader.EndOfStream) { var line = reader.ReadLine(); var values = line.Split(','); RegisterDocument d = new RegisterDocument(); d.DocumentNumber = values[4]; d.Title = values[5]; d.Discipline = values[6]; d.Revision = values[7]; d.Version = values[8]; d.Status = values[9]; docs.Add(d); } } ImportData(docs); }
public RegisterDocument LoadDocument(string docno, string version = null) { string filepath = Path.Combine(projectFolder, @"register.load.sqlite.sql"); string sql = File.ReadAllText(filepath); sql += " AND docno = @docno "; if (version != null) { sql += " AND doc_version = @version "; } else { sql += " AND doc_current = 1 "; } RegisterDocument doc = null; using (var cmd = new SQLiteCommand(sql, m_dbConnection)) { cmd.Parameters.AddWithValue("@docno", docno); if (version != null) { cmd.Parameters.AddWithValue("@version", version); } using (SQLiteDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { doc = new RegisterDocument { DocumentNumber = reader["docno"].ToString(), Title = reader["title"].ToString(), Discipline = reader["discipline"].ToString(), Registered = reader["registered"].ToString(), RegisteredBy = reader["registered_by"].ToString(), ReviewStatus = reader["review_status"].ToString(), Revision = reader["revision"].ToString(), RevisionDate = reader["revision_date"].ToString(), Status = reader["doc_status"].ToString(), Version = reader["doc_version"].ToString(), Note = reader["descr"].ToString(), Organization = reader["organization"].ToString(), Current = reader["doc_current"].ToString(), Type = reader["doc_type"].ToString(), InternalNumber = reader["int_cd"].ToString() }; } } //cmd.Dispose(); } return(doc); }
public DataTable LoadReviewInfo(RegisterDocument doc) { try { return(_dao.LoadReviewInfo(doc)); } catch (Exception e) { e.Log(); throw e; } }
private void LogRegisterImportedData(object sender, RegisterDocument d) { LogImportMessage(String.Format("Imported {0}", d.ToString())); }
private void ShowRegisterDocumentFiles(object sender, RegisterDocument doc) { _form.RegisterFilesDS = _service.LoadRegisterFiles(doc); }
protected virtual void OnRegisterDocumentImported(RegisterDocument d) { RegisterDocumentImported?.Invoke(this, d); }