コード例 #1
0
        public Tuple <bool, string> Post(TheftEntity entity)
        {
            MySqlCommand     cmd              = new MySqlCommand();
            MySqlConnection  sqlConnection    = new MySqlConnection();
            MySqlTransaction objTrans         = null;
            string           connectionString = GlobalVariables.ConnectionString;

            using (sqlConnection = new MySqlConnection(connectionString))
            {
                DataSet ds = new DataSet();

                cmd = new MySqlCommand();
                try
                {
                    if (sqlConnection.State == 0)
                    {
                        sqlConnection.Open();
                    }
                    objTrans        = sqlConnection.BeginTransaction();
                    cmd.Transaction = objTrans;
                    cmd.Connection  = sqlConnection;
                    cmd.CommandText = "InsertTheftDetails";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@Id", entity.Id);
                    cmd.Parameters.AddWithValue("@Location", entity.Location);
                    cmd.Parameters.AddWithValue("@Rcode", entity.Rcode);
                    cmd.Parameters.AddWithValue("@Dcode", entity.Dcode);
                    cmd.Parameters.AddWithValue("@Status", entity.Status);
                    cmd.Parameters.AddWithValue("@Shopcode", entity.ShopCode);
                    cmd.Parameters.AddWithValue("@Reason", entity.Reason);
                    cmd.Parameters.AddWithValue("@IssueType", entity.IssueType);
                    cmd.Parameters.AddWithValue("@Address", entity.Address);
                    cmd.Parameters.AddWithValue("@URL", entity.VideoURL);
                    cmd.Parameters.AddWithValue("@ImageURL", entity.ImageURL);
                    cmd.Parameters.AddWithValue("@DocDate", entity.DocDate);
                    cmd.Parameters.AddWithValue("@CompletedDate", entity.CompletedDate);
                    cmd.ExecuteNonQuery();
                    objTrans.Commit();
                    cmd.Parameters.Clear();
                    cmd.Dispose();

                    //Mail sending
                    MailSending mail = new MailSending();
                    mail.SendMailForIncident(entity, "Theft");
                    return(new Tuple <bool, string>(true, JsonConvert.SerializeObject(ds)));
                }
                catch (Exception ex)
                {
                    AuditLog.WriteError(ex.Message + " : " + ex.StackTrace);
                    objTrans.Rollback();
                    return(new Tuple <bool, string>(false, "Exception occured"));
                }
                finally
                {
                    sqlConnection.Close();
                    cmd.Dispose();
                    ds.Dispose();
                }
            }
        }
コード例 #2
0
 public void SendMailForIncident(TheftEntity entity, string _subject)
 {
     try
     {
         CommonEntity common = new CommonEntity
         {
             ToMailid    = "*****@*****.**",
             ToCC        = "[email protected] ",
             Subject     = _subject + " Information",
             BodyMessage = "Hi Rajaram, <br/> Reason :" + entity.Reason + " <br/>"
                           + "Address = " + entity.Address + "<br/>"
                           + "Issues Type = " + entity.IssueType + "<br/>"
                           + "Shop Code = " + entity.ShopCode + "<br/>"
                           + "Incident Date = " + entity.Dcode + "<br/><br/>"
                           + "Regards" + "<br/>"
                           + "SI Team"
         };
         SendForAll(common);
     }
     catch (Exception ex)
     {
         AuditLog.WriteError(ex.Message);
     }
 }