Exemplo n.º 1
0
        public bool SendMail()
        {
            MailMessage message = new MailMessage(FromAddress, ToAddress, Subject, MessageText);

            SetServer();
            SmtpClient client = new SmtpClient();

            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.EnableSsl      = EnableSSL;
            client.Port           = Port;

            if (Encrypted)
            {
            }
            message.CC.Add(CC);
            message.Bcc.Add(BCC);
            client.Host = _SMTPServer;
            NetworkCredential credential = new NetworkCredential(_SMTPUsername, _SMTPPassword);

            credential.GetCredential(client.Host, Port, AuthenticationType);
            client.UseDefaultCredentials = false;
            client.Credentials           = credential;
            message.ReplyTo = message.From;
            try
            {
                client.Send(message);
            }
            catch (Exception err)
            {
                MMDBExceptionHandler.HandleException(err);
                throw(err);
            }
            return(true);
        }
Exemplo n.º 2
0
        public static DataSet RunProcedure(string ConnectionString, string ProcedureName, ref List <MMDBDataParameter> Parameters, ProcedureReturnType returntype)
        {
            try
            {
                Database db = DatabaseFactory.CreateDatabase(ConnectionString);

                DbCommand dbCommand = db.GetStoredProcCommand(ProcedureName);

                //We could add more parms if ever needed.
                foreach (MMDBDataParameter dp in Parameters)
                {
                    //Code for no default date.
                    DateTime dt;
                    if ((dp.DBType == DbType.Date || dp.DBType == DbType.DateTime || dp.DBType == DbType.DateTime2) && (dp.ParameterValue.ToDateTime() <= DateTime.MinValue))
                    {
                        dp.ParameterValue = "01/01/1799";
                    }

                    db.AddParameter(dbCommand, dp.ParameterName, dp.DBType, dp.ParameterSize, dp.Direction, true, 10, 10, dp.ParameterName, DataRowVersion.Default, dp.ParameterValue);
                }

                DataSet ds = null;
                switch (returntype)
                {
                case ProcedureReturnType.DataSet:
                    ds = db.ExecuteDataSet(dbCommand);
                    break;

                case ProcedureReturnType.ExecuteOnly:
                case ProcedureReturnType.ParameterOnly:
                    db.ExecuteNonQuery(dbCommand);
                    break;
                }

                foreach (MMDBDataParameter dp in Parameters)
                {
                    if (dp.Direction == ParameterDirection.Output || dp.Direction == ParameterDirection.InputOutput)
                    {
                        //We will update the value
                        dp.ParameterValue = dbCommand.Parameters[@"@" + dp.ParameterName].Value.ToString();
                    }
                }

                if (returntype == ProcedureReturnType.DataSet)
                {
                    return(ds);
                }
                else
                {
                    return(null);
                }
                //Send out Parms
            }
            catch (Exception err)
            {
                MMDBExceptionHandler.HandleException(err);
                Parameters = null;
                return(null);
            }
        }
Exemplo n.º 3
0
 public bool RemoveUserFromRole(string Username, string Rolename)
 {
     try
     {
         Roles.RemoveUserFromRole(Username, Rolename);
         return(true);
     }
     catch (Exception err)
     {
         MMDBExceptionHandler.HandleException(err);
         return(false);
     }
 }
Exemplo n.º 4
0
 public bool ChangeEmailAddress(string newEmailAddress)
 {
     try
     {
         MembershipUser user = Membership.GetUser(Profile.UserName);
         user.Email = newEmailAddress;
         Membership.UpdateUser(user);
         return(true);
     }
     catch (Exception err)
     {
         MMDBExceptionHandler.HandleException(err);
         return(false);
     }
 }
Exemplo n.º 5
0
 public bool CheckRole(string Username, string Rolename)
 {
     try
     {
         return(Roles.IsUserInRole(Username, Rolename));
     }
     catch (ArgumentException /*err*/)
     {
         return(false);
     }
     catch (Exception err)
     {
         MMDBExceptionHandler.HandleException(err);
         return(false);
     }
 }
Exemplo n.º 6
0
 public bool AddUserToRole(string Username, string Rolename)
 {
     if (!Roles.RoleExists(Rolename))
     {
         Roles.CreateRole(Rolename);
     }
     try
     {
         Roles.AddUserToRole(Username, Rolename);
         return(true);
     }
     catch (Exception err)
     {
         MMDBExceptionHandler.HandleException(err);
         return(false);
     }
 }