public List <Template> GetTemplates() { OpenConnection(); using (DbCommand command = _dbProviderFactory.CreateCommand()) { command.Connection = _sqlConnection; command.CommandText = "SELECT * FROM Templates"; var templates = new List <Template>(); var binFormatter = new ListBinaryFormatter <string>(); try { using (DbDataReader dataReader = command.ExecuteReader()) { while (dataReader.Read()) { var title = (string)dataReader["Title"]; IList <string> data = binFormatter.Deserialize((byte[])dataReader["Data"]); templates.Add(new Template(data, title)); } } } catch (Exception) { throw new InvalidOperationException("Can't get templates!"); } finally { _sqlConnection.Close(); } return(templates); } }
public List <Template> GetTemplates() { OpenConnection(); _command.CommandText = "SELECT * FROM Templates"; var templates = new List <Template>(); var binFormatter = new ListBinaryFormatter <string>(); try { using (DbDataReader dataReader = _command.ExecuteReader()) { while (dataReader.Read()) { var title = (string)dataReader["Title"]; IList <string> data = binFormatter.Deserialize((byte[])dataReader["Data"]); templates.Add(new Template(data, title)); } } //LOGGING Logger.Info("Templates were obtained"); } catch (Exception ex) { //LOGGING Logger.Error("Can't get templates!", ex); throw new InvalidOperationException("Can't get templates!"); } finally { CloseConnection(); } return(templates); }
public Template GetTemplate(string title) { OpenConnection(); _command.CommandText = "SELECT * FROM Templates WHERE Title = @Title"; _command.Parameters.Add(GetParam("@Title", title)); Template template = null; var binFormatter = new ListBinaryFormatter <string>(); try { using (DbDataReader dataReader = _command.ExecuteReader()) { while (dataReader.Read()) { template = new Template(binFormatter.Deserialize((byte[])dataReader["Data"]), title); } } //LOGGING Logger.Info("Template was obtained"); } catch (Exception ex) { //LOGGING Logger.Error("Can't get template!", ex); throw new InvalidOperationException("Can't get template!"); } finally { CloseConnection(); } return(template); }
public List <Analysis> GetAnalyzes(string policyNumber) { OpenConnection(); using (DbCommand command = _dbProviderFactory.CreateCommand()) { command.Connection = _sqlConnection; command.CommandText = "SELECT TemplateTitle, Data, Date FROM Analyzes WHERE PolicyNumber = @PolicyNumber"; command.Parameters.Add(GetParam("@PolicyNumber", policyNumber)); var analyzes = new List <Analysis>(); var binFormatter = new ListBinaryFormatter <string>(); try { using (DbDataReader dataReader = command.ExecuteReader()) { while (dataReader.Read()) { var data = (byte[])dataReader["Data"]; var title = (string)dataReader["TemplateTitle"]; var date = (DateTime)dataReader["Date"]; analyzes.Add(new Analysis(binFormatter.Deserialize(data), title, date)); } } } catch (Exception) { throw new InvalidOperationException("Can't get analyzes!"); } finally { _sqlConnection.Close(); } return(analyzes); } }
public List <Analysis> GetAnalyzes(string policyNumber) { OpenConnection(); _command.CommandText = "SELECT TemplateTitle, Data, Date FROM Analyzes WHERE PolicyNumber = @PolicyNumber"; _command.Parameters.Add(GetParam("@PolicyNumber", policyNumber)); var analyzes = new List <Analysis>(); var binFormatter = new ListBinaryFormatter <string>(); try { using (DbDataReader dataReader = _command.ExecuteReader()) { while (dataReader.Read()) { var data = (byte[])dataReader["Data"]; var title = (string)dataReader["TemplateTitle"]; var date = (DateTime)dataReader["Date"]; analyzes.Add(new Analysis(binFormatter.Deserialize(data), title, date)); } } //LOGGING Logger.Info("Analyzes were obtained"); } catch (Exception ex) { //LOGGING Logger.Error("Can't get analyzes!", ex); throw new InvalidOperationException("Can't get analyzes!"); } finally { CloseConnection(); } return(analyzes); }
public Template GetTemplate(string title) { OpenConnection(); using (DbCommand command = _dbProviderFactory.CreateCommand()) { command.Connection = _sqlConnection; command.CommandText = "SELECT * FROM Templates WHERE Title = @Title"; command.Parameters.Add(GetParam("@Title", title)); Template template = null; var binFormatter = new ListBinaryFormatter <string>(); try { using (DbDataReader dataReader = command.ExecuteReader()) { while (dataReader.Read()) { template = new Template(binFormatter.Deserialize((byte[])dataReader["Data"]), title); } } } catch (Exception) { throw new InvalidOperationException("Can't get template!"); } finally { _sqlConnection.Close(); } return(template); } }
public List<Template> GetTemplates() { OpenConnection(); using (DbCommand command = _dbProviderFactory.CreateCommand()) { command.Connection = _sqlConnection; command.CommandText = "SELECT * FROM Templates"; var templates = new List<Template>(); var binFormatter = new ListBinaryFormatter<string>(); try { using (DbDataReader dataReader = command.ExecuteReader()) { while (dataReader.Read()) { var title = (string) dataReader["Title"]; IList<string> data = binFormatter.Deserialize((byte[]) dataReader["Data"]); templates.Add(new Template(data, title)); } } } catch (Exception) { throw new InvalidOperationException("Can't get templates!"); } finally { _sqlConnection.Close(); } return templates; } }
public Template GetTemplate(string title) { OpenConnection(); using (DbCommand command = _dbProviderFactory.CreateCommand()) { command.Connection = _sqlConnection; command.CommandText = "SELECT * FROM Templates WHERE Title = @Title"; command.Parameters.Add(GetParam("@Title", title)); Template template = null; var binFormatter = new ListBinaryFormatter<string>(); try { using (DbDataReader dataReader = command.ExecuteReader()) { while (dataReader.Read()) { template = new Template(binFormatter.Deserialize((byte[]) dataReader["Data"]), title); } } } catch (Exception) { throw new InvalidOperationException("Can't get template!"); } finally { _sqlConnection.Close(); } return template; } }
public List<Analysis> GetAnalyzes(string policyNumber) { OpenConnection(); using (DbCommand command = _dbProviderFactory.CreateCommand()) { command.Connection = _sqlConnection; command.CommandText = "SELECT TemplateTitle, Data, Date FROM Analyzes WHERE PolicyNumber = @PolicyNumber"; command.Parameters.Add(GetParam("@PolicyNumber", policyNumber)); var analyzes = new List<Analysis>(); var binFormatter = new ListBinaryFormatter<string>(); try { using (DbDataReader dataReader = command.ExecuteReader()) { while (dataReader.Read()) { var data = (byte[]) dataReader["Data"]; var title = (string) dataReader["TemplateTitle"]; var date = (DateTime) dataReader["Date"]; analyzes.Add(new Analysis(binFormatter.Deserialize(data), title, date)); } } } catch (Exception) { throw new InvalidOperationException("Can't get analyzes!"); } finally { _sqlConnection.Close(); } return analyzes; } }
public List<Template> GetTemplates() { OpenConnection(); _command.CommandText = "SELECT * FROM Templates"; var templates = new List<Template>(); var binFormatter = new ListBinaryFormatter<string>(); try { using (DbDataReader dataReader = _command.ExecuteReader()) { while (dataReader.Read()) { var title = (string) dataReader["Title"]; IList<string> data = binFormatter.Deserialize((byte[]) dataReader["Data"]); templates.Add(new Template(data, title)); } } //LOGGING Logger.Info("Templates were obtained"); } catch (Exception ex) { //LOGGING Logger.Error("Can't get templates!",ex); throw new InvalidOperationException("Can't get templates!"); } finally { CloseConnection(); } return templates; }
public Template GetTemplate(string title) { OpenConnection(); _command.CommandText = "SELECT * FROM Templates WHERE Title = @Title"; _command.Parameters.Add(GetParam("@Title", title)); Template template = null; var binFormatter = new ListBinaryFormatter<string>(); try { using (DbDataReader dataReader = _command.ExecuteReader()) { while (dataReader.Read()) { template = new Template(binFormatter.Deserialize((byte[]) dataReader["Data"]), title); } } //LOGGING Logger.Info("Template was obtained"); } catch (Exception ex) { //LOGGING Logger.Error("Can't get template!",ex); throw new InvalidOperationException("Can't get template!"); } finally { CloseConnection(); } return template; }
public List<Analysis> GetAnalyzes(string policyNumber) { OpenConnection(); _command.CommandText = "SELECT TemplateTitle, Data, Date FROM Analyzes WHERE PolicyNumber = @PolicyNumber"; _command.Parameters.Add(GetParam("@PolicyNumber", policyNumber)); var analyzes = new List<Analysis>(); var binFormatter = new ListBinaryFormatter<string>(); try { using (DbDataReader dataReader = _command.ExecuteReader()) { while (dataReader.Read()) { var data = (byte[]) dataReader["Data"]; var title = (string) dataReader["TemplateTitle"]; var date = (DateTime) dataReader["Date"]; analyzes.Add(new Analysis(binFormatter.Deserialize(data), title, date)); } } //LOGGING Logger.Info("Analyzes were obtained"); } catch (Exception ex) { //LOGGING Logger.Error("Can't get analyzes!", ex); throw new InvalidOperationException("Can't get analyzes!"); } finally { CloseConnection(); } return analyzes; }