Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                using (NPoco.Database db = new NPoco.Database(Db.GetOpenMySqlConnection()))
                {
                    Exclude exclude = db.SingleOrDefaultById <Exclude>(_id);
                    if (exclude == null)
                    {
                        UserInterface.DisplayMessageBox(this, "Unable to locate exclude", MessageBoxIcon.Exclamation);
                        return;
                    }

                    if (chkFalsePositive.Checked == true)
                    {
                        exclude.FalsePositive = true;
                    }
                    else
                    {
                        exclude.FalsePositive = false;
                    }

                    exclude.Comment = txtComment.Text;
                    db.Update(exclude);

                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }
            }
            catch (Exception ex)
            {
                UserInterface.DisplayErrorMessageBox("An error occurred whilst editing the exclude: " + ex.Message);
            }
        }
Example #2
0
 public int Update <T>(T obj)
 {
     using (NPoco.IDatabase dbContext = new NPoco.Database(connectionString, NPoco.DatabaseType.SqlServer2012))
     {
         return(dbContext.Update(obj));
     }
 }
Example #3
0
        /// <summary>
        /// Partial update for <c>CompanyDto</c> by only updating the specified columns.
        /// </summary>
        /// <param name="docId"></param>
        /// <param name="company"></param>
        /// <param name="ops">A <c>string</c> collection </param>
        /// <returns></returns>
        public int PartialUpdate(Guid docId, Company company, IEnumerable <string> ops)
        {
            int res;

            using (var conn = new NpgsqlConnection(dbAccess.connectionString))
            {
                using (var db = new NPoco.Database(conn))
                {
                    db.Connection.Open();
                    res = db.Update(CompanyDto.Translate(company), docId, ops);
                    db.Connection.Close();
                }
            }

            return(res);
        }
Example #4
0
        /// <summary>
        /// Update a <c>CompanyDto</c> object.
        /// </summary>
        /// <param name="company">A <c>Comapny</c>. This will be translated to a <c>ComapnyDto</c> before the update operation.</param>
        /// <returns><c>int</c> denoting the success value of the operation.</returns>
        public int Update(Company company)
        {
            int res;

            using (var conn = new NpgsqlConnection(dbAccess.connectionString))
            {
                using (var db = new NPoco.Database(conn))
                {
                    db.Connection.Open();
                    res = db.Update(CompanyDto.Translate(company));
                    db.Connection.Close();
                }
            }

            return(res);
        }
 public void StoreScriptItem(ScriptItem item)
 {
     lock (this)
     {
         if (_dbcon != null)
         {
             using (var db = new NPoco.Database(_dbcon.Connection, NPoco.DatabaseType.SQLite))
             {
                 if (db.FirstOrDefault <ScriptItem>("select * from Scripts where Name=@0", item.Name) == null)
                 {
                     db.Insert("Scripts", null, item);
                 }
                 else
                 {
                     db.Update("Scripts", "Name", item);
                 }
             }
         }
     }
 }
Example #6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                using (NPoco.Database db = new NPoco.Database(Db.GetOpenMySqlConnection()))
                {
                    Exclude exclude = db.SingleOrDefaultById<Exclude>(_id);
                    if (exclude == null)
                    {
                        UserInterface.DisplayMessageBox(this, "Unable to locate exclude", MessageBoxIcon.Exclamation);
                        return;
                    }

                    if (chkFalsePositive.Checked == true)
                    {
                        exclude.FalsePositive = true;
                    }
                    else
                    {
                        exclude.FalsePositive = false;
                    }

                    exclude.Comment = txtComment.Text;
                    db.Update(exclude);

                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }
            }
            catch (Exception ex)
            {
                UserInterface.DisplayErrorMessageBox("An error occurred whilst editing the exclude: " + ex.Message);
            }
        }
Example #7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="session"></param>
        private void UpdateDatabaseSession()
        {
            List<string> methods = new List<string>();
            string host = string.Empty;
            foreach (Message message in this.parser.Messages)
            {
                // Ensure that the request object is valid
                if (message.Request.Method.Length == 0)
                {
                    continue;
                }

                host = message.Request.Host;

                if (methods.Contains(message.Request.Method) == false)
                {
                    methods.Add(message.Request.Method);
                }
            }

            using (DbConnection dbConnection = Db.GetOpenConnection(this.outputPath))
            using (var db = new NPoco.Database(dbConnection, NPoco.DatabaseType.SQLCe))
            {
                var obj = db.SingleOrDefaultById<Session>(this.session.Id);
                if (obj != null)
                {
                    methods.Sort();
                    this.session.HttpMethods = string.Join(",", methods);
                    this.session.HttpHost = host;
                    int ret = db.Update(this.session);
                }
            }
        }