Example #1
0
        private void SendMailBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Email           mail            = new Email();
                EmailOperations emailOperations = new EmailOperations(mail);
                mail.EmailOperations = emailOperations;

                mail.EmailMethod = Email.eEmailMethod.OUTLOOK;

                mail.Subject = "Ginger Log Details";
                mail.Body    = BuildMailContentAsHTML();
                mail.MailTo  = "*****@*****.**";

                //add Full log
                if (System.IO.File.Exists(Amdocs.Ginger.CoreNET.log4netLib.GingerLog.GingerLogFile))
                {
                    mail.Attachments.Add(Amdocs.Ginger.CoreNET.log4netLib.GingerLog.GingerLogFile);
                }

                mail.EmailOperations.DisplayAsOutlookMail();

                if (mail.Event != null && mail.Event.IndexOf("Failed") >= 0)
                {
                    Reporter.ToUser(eUserMsgKey.StaticWarnMessage, "Failed to send the Log Details mail." + System.Environment.NewLine + System.Environment.NewLine + "Details: " + mail.Event);
                }
            }
            catch (Exception ex)
            {
                Reporter.ToUser(eUserMsgKey.StaticWarnMessage, "Failed to send the Log Details mail." + System.Environment.NewLine + System.Environment.NewLine + "Details: " + ex.Message);
            }
        }
        public async Task <bool> forgotPasswordAsync(string email, string securityQuestion, string securityQuestionReply)
        {
            var myuser = await _context.Users.FirstOrDefaultAsync(x => x.Email == email);

            if (myuser == null)
            {
                throw new KeyNotFoundException();
            }
            else
            {
                if (myuser.SecurityQuestion.Equals(securityQuestion) &&
                    myuser.SecurityQuestionAnswer.Equals(securityQuestionReply))
                {
                    if (myuser.IsEmailVerified ?? false)
                    {
                        var tempPassword = Authentication.generateTempPassord();
                        myuser.PasswordHash        = Authentication.generateUserHash(tempPassword);
                        myuser.IsTemporaryPassword = true;
                        EmailOperations.sendPasswordChangeEmailAsync(tempPassword, myuser.Name, myuser.Email);
                        _context.Update(myuser);
                        await _context.SaveChangesAsync();

                        return(true);
                    }
                    else
                    {
                        var token = Authentication.generateEmailTokenHash();
                        myuser.VerificationToken       = token;
                        myuser.VerificationTokenExpiry = DateTime.UtcNow.AddDays(1);
                        EmailOperations.sendVerificationEmailAsync(myuser.Name, myuser.Email, token);
                    }
                }
                return(false);
            }
        }
Example #3
0
        public CrmUserController()
        {
            //Remove this line if you want to use dependency injection

            crmuserRepository = new CrmUserRepository();
            mailOperations    = new EmailOperations();
        }
Example #4
0
 public DictationEmail()
 {
     InitializeComponent();
     _tbCtrl           = TbDictation;
     _voiceToText      = new VoiceToText();
     _emailOperations  = new EmailOperations();
     _chemOperations   = new ChemOperations();
     _fullResponces    = string.Empty;
     _partialResponces = string.Empty;
     _commandMode      = false;
 }
Example #5
0
        }                                                  //list of skill operations

        internal void ClearOperations()
        {
            //Operations
            EmailOperations = new EmailOperations();
            var chemOperations          = new ChemOperations();
            var unitConverterOperations = new UnitConverterOperations();

            Operations = new List <IOperation>
            {
                EmailOperations,
                chemOperations,
                unitConverterOperations
            };
        }
Example #6
0
        public void Execute(IReportInfo RI)
        {
            EmailOperations emailOperations = new EmailOperations(RunSetActionSendEmail.Email);

            RunSetActionSendEmail.Email.EmailOperations = emailOperations;

            //Make sure we clear in case use open the edit page twice
            RunSetActionSendEmail.Email.Attachments.Clear();

            //for compatibility with old HTML report sent by email
            if (RunSetActionSendEmail.HTMLReportTemplate != RunSetActionSendEmail.eHTMLReportTemplate.FreeText)
            {
                SetBodyFromHTMLReport((ReportInfo)RI);
            }

            if (RunSetActionSendEmail.EmailAttachments != null)
            {
                foreach (EmailAttachment r in RunSetActionSendEmail.EmailAttachments)
                {
                    //attach simple file
                    if (r.AttachmentType == EmailAttachment.eAttachmentType.File)
                    {
                        if (System.IO.File.Exists(r.Name))
                        {
                            AddAttachmentToEmail(RunSetActionSendEmail.Email, r.Name, r.ZipIt);
                        }
                        else
                        {
                            RunSetActionSendEmail.Email.Body = "ERROR: File not found: " + r.Name + Environment.NewLine + RunSetActionSendEmail.Email.Body;
                        }
                    }

                    //attach report - after generating from template
                    if (r.AttachmentType == EmailAttachment.eAttachmentType.Report)
                    {
                        string repFileName = null;// ReportTemplate.GenerateReport(r.Name, RI);
                        if (repFileName != null)
                        {
                            AddAttachmentToEmail(RunSetActionSendEmail.Email, repFileName, r.ZipIt);
                        }
                        else
                        {
                            RunSetActionSendEmail.Email.Body = "ERROR: Report Template not found: " + r + Environment.NewLine + RunSetActionSendEmail.Email.Body;
                        }
                    }
                }
            }
            RunSetActionSendEmail.Email.EmailOperations.Send();
        }
 public ResumeController(ResumeContext resumeContext,
                         DbOperations dbOperations,
                         FileOperations fileOperations,
                         UserAuthentication userAuthentication,
                         IWebHostEnvironment appEnvironment,
                         ILogger <ResumeController> logger,
                         EmailOperations emailOperations
                         )
 {
     _resumeContext      = resumeContext;
     _dbOperations       = dbOperations;
     _userAuthentication = userAuthentication;
     _logger             = logger;
     _fileOperations     = fileOperations;
     _emailOperations    = emailOperations;
     pathRoot            = appEnvironment.WebRootPath;
 }
Example #8
0
        public DictationEmail(bool record)
        {
            _commandMode = false;
            InitializeComponent();
            _voiceToText      = new VoiceToText();
            _emailOperations  = new EmailOperations();
            _chemOperations   = new ChemOperations();
            _fullResponces    = string.Empty;
            _partialResponces = string.Empty;
            _tbCtrl           = TbEmailAddress;

            //begin recording immediately
            if (record)
            {
                StartRecording();
            }
        }
Example #9
0
        public void Execute(IReportInfo RI)
        {
            EmailOperations emailOperations = new EmailOperations(RunSetActionSendSMS.SMSEmail);

            RunSetActionSendSMS.SMSEmail.EmailOperations = emailOperations;

            //TODO: check number of chars and show err if more or update Errors field
            RunSetActionSendSMS.SMSEmail.IsBodyHTML = false;

            bool isSuccess;

            isSuccess = RunSetActionSendSMS.SMSEmail.EmailOperations.Send();
            if (isSuccess == false)
            {
                RunSetActionSendSMS.Errors = RunSetActionSendSMS.SMSEmail.Event;
                Reporter.HideStatusMessage();
                RunSetActionSendSMS.Status = RunSetActionBase.eRunSetActionStatus.Failed;
            }
        }
        public async void RegisterUser(UserModel User)
        {
            string token = null;

            while (token == null || _context.Users.Any(u => u.VerificationToken == token))
            {
                token = Authentication.generateEmailTokenHash();
            }

            EmailOperations.sendVerificationEmailAsync(User.Name, User.Email, token);

            User.PasswordHash = Authentication.generateUserHash(User.PasswordHash);
            var now = DateTime.UtcNow;

            User.IsEmailVerified         = false;
            User.VerificationToken       = token;
            User.VerificationTokenExpiry = now.AddHours(24);
            User.IsTemporaryPassword     = false;
            _context.AddAsync(User);
            _context.SaveChanges();
        }
Example #11
0
        public void Execute(IReportInfo RI)
        {
            EmailOperations emailOperations = new EmailOperations(RunSetActionSendFreeEmail.Email);

            RunSetActionSendFreeEmail.Email.EmailOperations = emailOperations;

            RunSetActionSendFreeEmail.Email.Attachments.Clear();
            RunSetActionSendFreeEmail.Email.EmailOperations.alternateView = null;

            mVE.Value = RunSetActionSendFreeEmail.MailFrom;
            RunSetActionSendFreeEmail.Email.MailFrom = mVE.ValueCalculated;

            mVE.Value = RunSetActionSendFreeEmail.MailFromDisplayName;
            RunSetActionSendFreeEmail.Email.MailFromDisplayName = mVE.ValueCalculated;

            mVE.Value = RunSetActionSendFreeEmail.MailTo;
            RunSetActionSendFreeEmail.Email.MailTo = mVE.ValueCalculated;
            mVE.Value = RunSetActionSendFreeEmail.MailCC;
            RunSetActionSendFreeEmail.Email.MailCC = mVE.ValueCalculated;
            mVE.Value = RunSetActionSendFreeEmail.Subject;
            RunSetActionSendFreeEmail.Email.Subject = mVE.ValueCalculated;
            mVE.Value = RunSetActionSendFreeEmail.Bodytext;
            RunSetActionSendFreeEmail.Email.Body = mVE.ValueCalculated;
            mVE.Value = RunSetActionSendFreeEmail.MailHost;
            RunSetActionSendFreeEmail.Email.SMTPMailHost = mVE.ValueCalculated;
            mVE.Value = RunSetActionSendFreeEmail.MailUser;
            RunSetActionSendFreeEmail.Email.SMTPUser = mVE.ValueCalculated;
            bool isSuccess;

            isSuccess = RunSetActionSendFreeEmail.Email.EmailOperations.Send();
            if (isSuccess == false)
            {
                RunSetActionSendFreeEmail.Errors = RunSetActionSendFreeEmail.Email.Event;
                Reporter.HideStatusMessage();
                RunSetActionSendFreeEmail.Status = RunSetActionBase.eRunSetActionStatus.Failed;
            }
        }
        public string Login(UserModel Userinfo)
        {
            var hash = Authentication.generateUserHash(Userinfo.PasswordHash);
            var User = _context.Users
                       .Include(x => x.UserLocations)
                       .ThenInclude(x => x.UserPermission)
                       .FirstOrDefault(u => u.Email == Userinfo.Email && u.PasswordHash == hash);

            if (User == null)
            {
                return(null);
            }

            if (!(User.IsEmailVerified ?? false))
            {
                string token = null;
                if (User.VerificationTokenExpiry < DateTime.UtcNow)
                {
                    while (token == null || _context.Users.Any(u => u.VerificationToken == token))
                    {
                        token = Authentication.generateEmailTokenHash();
                    }
                }
                else
                {
                    token = User.VerificationToken;
                }
                EmailOperations.sendVerificationEmailAsync(User.Name, User.Email, token);
                return(null);
            }

            var ret = new Authentication(_context, _mapper).generateJwtToken(User);


            return(ret);
        }
Example #13
0
        public async Task <UserProfileDto?> UpdateUserAccountAsync(
            int locationId, IEnumerable <Claim> claims, UpdateNameEmailDto update)
        {
            var user_id = claims?.FirstOrDefault(x => x.Type == "ID");
            int id;

            if (!int.TryParse(user_id?.Value, out id))
            {
                return(null);
            }
            var user = await _context.Users
                       .Include(x => x.UserKeyMappings)
                       .ThenInclude(x => x.Keyholder)
                       .Include(x => x.ChangeEmailRequests)
                       .Include(x => x.UserLocations)
                       .FirstOrDefaultAsync(x => x.UserID == id);

            var keyholdemap = user?.UserKeyMappings?.FirstOrDefault(x => x.LocationId == locationId);

            if (keyholdemap == null)
            {
                return(null);
            }
            ;
            if (update.name != null)
            {
                user.Name = update.name;
            }
            Task save;

            if (update.email != null)
            {
                var email = EmailOperations.sendVerificationEmail(
                    user.Name, update.email, user.VerificationToken, true);
                user.Email                   = update.email;
                user.VerificationToken       = Authentication.generateEmailTokenHash();
                user.VerificationTokenExpiry = DateTime.UtcNow.AddDays(1);

                var changeRequest = new ChangeEmailRequest()
                {
                    User                    = user,
                    RequestedOn             = DateTime.UtcNow,
                    Email                   = update.email,
                    VerificationToken       = user.VerificationToken,
                    VerificationTokenExpiry = user.VerificationTokenExpiry,
                };
                await _context.EmailChangeRequests.AddAsync(changeRequest);

                _context.Users.Update(user);
                await email;
                save = _context.SaveChangesAsync();
            }
            else
            {
                _context.Users.Update(user);
                save = _context.SaveChangesAsync();
            }

            var model = _mapper.Map <UserProfileDto>(user);

            model.locationId = locationId;
            var tookit = _mapper.Map <ToolkitInfoDto>(keyholdemap.Keyholder);

            model.toolkitInfo = tookit;
            await save;

            return(model);
        }
Example #14
0
 public SignOnController()
 {
     _crmUserRepository      = new CrmUserRepository();
     _emailOperations        = new EmailOperations();
     _emailMessageRepository = new EmailMessagesRepository();
 }
Example #15
0
        public override void Execute()
        {
            Email           email           = new Email();
            EmailOperations emailOperations = new EmailOperations(email);

            email.EmailOperations = emailOperations;

            bool isSuccess;

            if (!string.IsNullOrEmpty(Host))
            {
                email.SMTPMailHost = Host;
            }
            try { email.SMTPPort = Convert.ToInt32(this.GetInputParamCalculatedValue(nameof(Port))); }
            catch { email.SMTPPort = 25; }

            email.Subject  = this.GetInputParamCalculatedValue(nameof(Subject));
            email.Body     = this.GetInputParamCalculatedValue(nameof(Body));
            email.MailFrom = this.GetInputParamCalculatedValue(nameof(MailFrom));
            email.MailTo   = this.GetInputParamCalculatedValue(nameof(Mailto));
            email.MailCC   = this.GetInputParamCalculatedValue(nameof(Mailcc));

            //add multi attachment files
            if (!string.IsNullOrEmpty(this.GetInputParamCalculatedValue(nameof(AttachmentFileName))))
            {
                String[] fileslist = this.GetInputParamCalculatedValue(nameof(AttachmentFileName)).Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (String filePath in fileslist)
                {
                    email.Attachments.Add(filePath);
                }
            }

            email.EnableSSL           = (bool)this.GetInputParamValue <bool>(Fields.EnableSSL);
            email.ConfigureCredential = (bool)this.GetInputParamValue <bool>(Fields.ConfigureCredential);
            email.SMTPUser            = this.GetInputParamCalculatedValue(nameof(User));
            email.SMTPPass            = this.GetInputParamCalculatedValue(nameof(Pass));

            if (email.EmailMethod == Email.eEmailMethod.SMTP)
            {
                email.MailFromDisplayName = this.GetInputParamCalculatedValue(nameof(MailFromDisplayName));
            }
            if (string.IsNullOrEmpty(email.MailTo))
            {
                Error = "Failed: Please provide TO email address.";
                return;
            }
            if (string.IsNullOrEmpty(Subject))
            {
                Error = "Failed: Please provide email subject.";
                return;
            }
            if (this.GetInputParamCalculatedValue(nameof(MailOption)) == Email.eEmailMethod.OUTLOOK.ToString())
            {
                email.EmailMethod = Email.eEmailMethod.OUTLOOK;
            }
            else
            {
                email.EmailMethod         = Email.eEmailMethod.SMTP;
                email.MailFromDisplayName = this.GetInputParamCalculatedValue(nameof(MailFromDisplayName));
                if (string.IsNullOrEmpty(email.MailFrom))
                {
                    Error = "Failed: Please provide FROM email address.";
                    return;
                }
            }

            isSuccess = email.EmailOperations.Send();
            if (isSuccess == false)
            {
                Error  = email.Event;
                Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed;
            }

            if (email.Event != null && email.Event.IndexOf("Failed") >= 0)
            {
                Error = email.Event;
            }
        }
Example #16
0
        internal SkillBuilder()
        {
            //Operations
            var chemOperations = new ChemOperations();

            EmailOperations = new EmailOperations(chemOperations);
            var unitConverterOperations = new UnitConverterOperations();

            //Lab Skills
            var getCompound = new SkillTemplate
            {
                Id           = "compoundSkill",
                OperationIds = new List <string> {
                    "Get_Compound"
                },
                SkillIds = new List <string>()
            };
            var getMolarity = new SkillTemplate
            {
                Id           = "molaritySkill",
                OperationIds = new List <string> {
                    "Get_Molarity"
                },
                SkillIds = new List <string>()
            };
            var getVolume = new SkillTemplate
            {
                Id           = "volumeSkill",
                OperationIds = new List <string> {
                    "Get_Volume"
                },
                SkillIds = new List <string>()
            };
            var getWeight = new SkillTemplate
            {
                Id           = "weightSkill",
                OperationIds = new List <string> {
                    "Get_Weight"
                },
                SkillIds = new List <string>()
            };
            var getMobilePhase = new SkillTemplate
            {
                Id           = "mobilePhaseSkill",
                OperationIds = new List <string> {
                    "Get_MobilePhase"
                },
                SkillIds = new List <string>()
            };
            var convertUnits = new SkillTemplate
            {
                Id           = "conversionSkill",
                OperationIds = new List <string> {
                    "Convert_Units"
                },
                SkillIds = new List <string>()
            };
            var sendEmail = new SkillTemplate
            {
                Id           = "emailSkill",
                OperationIds = new List <string> {
                    "Send_Email"
                },
                SkillIds = new List <string>()
            };

            //add to interfaces
            Operations = new List <IOperation>
            {
                EmailOperations,
                chemOperations,
                unitConverterOperations
            };
            Skills = new List <SkillTemplate>
            {
                getCompound,
                getMolarity,
                getVolume,
                getWeight,
                getMobilePhase,
                convertUnits,
                sendEmail
            };
            FillSkillLists();
        }