Beispiel #1
0
        public void AddAnalysis(string policyNumber, Analysis analysis)
        {
            OpenConnection();

            using (DbCommand command = _dbProviderFactory.CreateCommand())
            {
                command.Connection = _sqlConnection;
                var binFormatter = new ListBinaryFormatter<string>();
                command.CommandText =
                    "INSERT INTO Analyzes(PolicyNumber, TemplateTitle, Data, Date) VALUES(@PolicyNumber, @TemplateTitle, @Data, @Date)";

                command.Parameters.Add(GetParam("@TemplateTitle", analysis.TemplateTitle));
                command.Parameters.Add(GetParam("@Data", binFormatter.Serialize(analysis.Data)));
                command.Parameters.Add(GetParam("@Date", analysis.Date));
                command.Parameters.Add(GetParam("@PolicyNumber", policyNumber));

                try
                {
                    command.ExecuteNonQuery();
                }
                catch (Exception)
                {
                    throw new InvalidOperationException("Can't add analysis!");
                }
                finally
                {
                    _sqlConnection.Close();
                }
            }
        }
Beispiel #2
0
        public void AddAnalysis(string policyNumber, Analysis analysis)
        {
            OpenConnection();
            var binFormatter = new ListBinaryFormatter<string>();
            _command.CommandText =
                "INSERT INTO Analyzes(PolicyNumber, TemplateTitle, Data, Date) VALUES(@PolicyNumber, @TemplateTitle, @Data, @Date)";

            _command.Parameters.Add(GetParam("@TemplateTitle", analysis.TemplateTitle));
            _command.Parameters.Add(GetParam("@Data", binFormatter.Serialize(analysis.Data)));
            _command.Parameters.Add(GetParam("@Date", analysis.Date));
            _command.Parameters.Add(GetParam("@PolicyNumber", policyNumber));

            try
            {
                _command.ExecuteNonQuery();
                //LOGGING
                Logger.Info("Analysis was added");
            }
            catch (Exception ex)
            {
                //LOGGING
                Logger.Error("Can't add analysis!",ex);
                throw new InvalidOperationException("Can't add analysis!");
            }
            finally
            {
                CloseConnection();
            }
        }
Beispiel #3
0
        public void AddAnalysis(string policyNumber, Analysis analysis)
        {
            OpenConnection();

            using (DbCommand command = _dbProviderFactory.CreateCommand())
            {
                command.Connection = _sqlConnection;
                var binFormatter = new ListBinaryFormatter <string>();
                command.CommandText =
                    "INSERT INTO Analyzes(PolicyNumber, TemplateTitle, Data, Date) VALUES(@PolicyNumber, @TemplateTitle, @Data, @Date)";

                command.Parameters.Add(GetParam("@TemplateTitle", analysis.TemplateTitle));
                command.Parameters.Add(GetParam("@Data", binFormatter.Serialize(analysis.Data)));
                command.Parameters.Add(GetParam("@Date", analysis.Date));
                command.Parameters.Add(GetParam("@PolicyNumber", policyNumber));

                try
                {
                    command.ExecuteNonQuery();
                }
                catch (Exception)
                {
                    throw new InvalidOperationException("Can't add analysis!");
                }
                finally
                {
                    _sqlConnection.Close();
                }
            }
        }
Beispiel #4
0
        public void AddTemplate(Template template)
        {
            OpenConnection();

            using (DbCommand command = _dbProviderFactory.CreateCommand())
            {
                command.Connection = _sqlConnection;
                var binFormatter = new ListBinaryFormatter <string>();

                command.CommandText = "INSERT INTO Templates(Title, Data) VALUES(@Title, @Data)";

                command.Parameters.Add(GetParam("@Title", template.Title));
                command.Parameters.Add(GetParam("@Data", binFormatter.Serialize(template.Data)));

                try
                {
                    command.ExecuteNonQuery();
                }
                catch (SqlException)
                {
                    throw new InvalidOperationException("This template already exists!");
                }
                catch (Exception)
                {
                    throw new InvalidOperationException("Can't add template!");
                }
                finally
                {
                    _sqlConnection.Close();
                }
            }
        }
Beispiel #5
0
        public void AddAnalysis(string policyNumber, Analysis analysis)
        {
            OpenConnection();
            var binFormatter = new ListBinaryFormatter <string>();

            _command.CommandText =
                "INSERT INTO Analyzes(PolicyNumber, TemplateTitle, Data, Date) VALUES(@PolicyNumber, @TemplateTitle, @Data, @Date)";

            _command.Parameters.Add(GetParam("@TemplateTitle", analysis.TemplateTitle));
            _command.Parameters.Add(GetParam("@Data", binFormatter.Serialize(analysis.Data)));
            _command.Parameters.Add(GetParam("@Date", analysis.Date));
            _command.Parameters.Add(GetParam("@PolicyNumber", policyNumber));

            try
            {
                _command.ExecuteNonQuery();
                //LOGGING
                Logger.Info("Analysis was added");
            }
            catch (Exception ex)
            {
                //LOGGING
                Logger.Error("Can't add analysis!", ex);
                throw new InvalidOperationException("Can't add analysis!");
            }
            finally
            {
                CloseConnection();
            }
        }
Beispiel #6
0
        public void AddTemplate(Template template)
        {
            OpenConnection();
            var binFormatter = new ListBinaryFormatter <string>();

            _command.CommandText = "INSERT INTO Templates(Title, Data) VALUES(@Title, @Data)";

            _command.Parameters.Add(GetParam("@Title", template.Title));
            _command.Parameters.Add(GetParam("@Data", binFormatter.Serialize(template.Data)));

            try
            {
                _command.ExecuteNonQuery();
                //LOGGING
                Logger.Info("Template was added");
            }
            catch (SqlException ex)
            {
                //LOGGING
                Logger.Error("This template already exists!", ex);
                throw new InvalidOperationException("This template already exists!");
            }
            catch (Exception ex)
            {
                //LOGGING
                Logger.Error("Can't add template!", ex);
                throw new InvalidOperationException("Can't add template!");
            }
            finally
            {
                CloseConnection();
            }
        }
Beispiel #7
0
        public void AddTemplate(Template template)
        {
            OpenConnection();

            using (DbCommand command = _dbProviderFactory.CreateCommand())
            {
                command.Connection = _sqlConnection;
                var binFormatter = new ListBinaryFormatter<string>();

                command.CommandText = "INSERT INTO Templates(Title, Data) VALUES(@Title, @Data)";

                command.Parameters.Add(GetParam("@Title", template.Title));
                command.Parameters.Add(GetParam("@Data", binFormatter.Serialize(template.Data)));

                try
                {
                    command.ExecuteNonQuery();
                }
                catch (SqlException)
                {
                    throw new InvalidOperationException("This template already exists!");
                }
                catch (Exception)
                {
                    throw new InvalidOperationException("Can't add template!");
                }
                finally
                {
                    _sqlConnection.Close();
                }
            }
        }
Beispiel #8
0
        public void AddTemplate(Template template)
        {
            OpenConnection();
            var binFormatter = new ListBinaryFormatter<string>();

            _command.CommandText = "INSERT INTO Templates(Title, Data) VALUES(@Title, @Data)";

            _command.Parameters.Add(GetParam("@Title", template.Title));
            _command.Parameters.Add(GetParam("@Data", binFormatter.Serialize(template.Data)));

            try
            {
                _command.ExecuteNonQuery();
                //LOGGING
                Logger.Info("Template was added");
            }
            catch (SqlException ex)
            {
                //LOGGING
                Logger.Error("This template already exists!",ex);
                throw new InvalidOperationException("This template already exists!");
            }
            catch (Exception ex)
            {
                //LOGGING
                Logger.Error("Can't add template!",ex);
                throw new InvalidOperationException("Can't add template!");
            }
            finally
            {
                CloseConnection();
            }
        }