Esempio n. 1
0
        private UserDefinition GetFirst(IDbConnection connection, BaseCriteria criteria)
        {
            var user = connection.TrySingle <Entities.UserRow>(criteria);

            if (user != null)
            {
                var tenant = connection.ById <Entities.TenantRow>(user.TenantId);
                return(new UserDefinition
                {
                    UserId = user.UserId.Value,
                    Username = user.Username,
                    Email = user.Email,
                    UserImage = user.UserImage,
                    UserPhone = user.PhoneNumber,
                    DisplayName = user.DisplayName,
                    IsActive = user.IsActive.Value,
                    Source = user.Source,
                    PasswordHash = user.PasswordHash,
                    PasswordSalt = user.PasswordSalt,
                    UpdateDate = user.UpdateDate,
                    LastDirectoryUpdate = user.LastDirectoryUpdate,
                    TenantId = user.TenantId.Value,
                    TenantName = tenant.TenantName,
                    InsertDate = user.InsertDate,
                    RestrictedToCabinets = user.RestrictedToCabinets ?? 1,
                    TenantCurrencyId = tenant.CurrencyId ?? 1
                });
            }
            return(null);
        }
Esempio n. 2
0
        public RetrieveResponse <string> RetrieveEmailSignature(IDbConnection connection, RetrieveRequest request)
        {
            var user     = (UserDefinition)Authorization.UserDefinition;
            var response = new RetrieveResponse <string>();

            //Get Email Signature
            if (connection.ById <TenantRow>(user.TenantId).OverrideUsersEmailSignature ?? false)
            {
                response.Entity = connection.ById <TenantRow>(user.TenantId).TenantEmailSignature;
            }
            else
            {
                response.Entity = connection.ById <UserRow>(user.UserId).EmailSignature;
            }
            return(response);
        }
Esempio n. 3
0
        public bool SendById(IDbConnection connection, long mailId)
        {
            var mail       = connection.ById <MailRow>(mailId);
            var settings   = Config.Get <MailingServiceSettings>();
            var status     = MailStatus.Sent;
            var retryCount = (mail.RetryCount ?? 0) + 1;

            string errorMessage = null;

            try
            {
                var config  = Config.Get <MailingServiceSettings>();
                var env     = Config.Get <EnvironmentSettings>();
                var message = BuildMessage(mail);
                var client  = new SmtpClient();

                if (client.DeliveryMethod == SmtpDeliveryMethod.SpecifiedPickupDirectory &&
                    string.IsNullOrEmpty(client.PickupDirectoryLocation))
                {
                    var pickupPath = HostingEnvironment.MapPath("~/App_Data");
                    pickupPath = Path.Combine(pickupPath, "Mail");
                    Directory.CreateDirectory(pickupPath);
                    client.PickupDirectoryLocation = pickupPath;
                }

                client.Send(message);
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
                status       = retryCount < settings.RetryLimit ?
                               MailStatus.InQueue : MailStatus.Failed;
            }

            connection.UpdateById(new MailRow
            {
                MailId       = mail.MailId,
                Status       = status,
                SentDate     = DateTime.Now,
                ErrorMessage = errorMessage,
                RetryCount   = retryCount
            });

            return(errorMessage != null);
        }
Esempio n. 4
0
    public static TRow TryFirstByName <TRow>(this IDbConnection connection, string name)
        where TRow : Row, IIdRow, INameRow, new()
    {
        if (name == null)
        {
            return(null);
        }

        var row = new TRow();

        var id = connection.GetIdByName <TRow>(name);

        if (id != null)
        {
            return(connection.ById <TRow>(id));
        }
        else
        {
            return(null);
        }
    }