public MailOperationStatus CheckDomainDns(string domainName, ServerDns dns, Func <DistributedTask, string> translateMailOperationStatus = null) { var tenant = CoreContext.TenantManager.GetCurrentTenant(); var user = SecurityContext.CurrentAccount; var operations = MailOperations.GetTasks() .Where(o => { var oTenant = o.GetProperty <int>(MailOperation.TENANT); var oUser = o.GetProperty <string>(MailOperation.OWNER); var oType = o.GetProperty <MailOperationType>(MailOperation.OPERATION_TYPE); var oSource = o.GetProperty <string>(MailOperation.SOURCE); return(oTenant == tenant.TenantId && oUser == user.ID.ToString() && oType == MailOperationType.CheckDomainDns && oSource == domainName); }); var runningOperation = operations.FirstOrDefault(o => o.Status <= DistributedTaskStatus.Running); if (runningOperation != null) { return(GetMailOperationStatus(runningOperation.Id, translateMailOperationStatus)); } var op = new MailCheckMailserverDomainsDnsOperation(tenant, user, domainName, dns); return(QueueTask(op, translateMailOperationStatus)); }
public MailOperationStatus RecalculateFolders(Func <DistributedTask, string> translateMailOperationStatus = null) { var tenant = CoreContext.TenantManager.GetCurrentTenant(); var user = SecurityContext.CurrentAccount; var operations = MailOperations.GetTasks() .Where(o => { var oTenant = o.GetProperty <int>(MailOperation.TENANT); var oUser = o.GetProperty <string>(MailOperation.OWNER); var oType = o.GetProperty <MailOperationType>(MailOperation.OPERATION_TYPE); return(oTenant == tenant.TenantId && oUser == user.ID.ToString() && oType == MailOperationType.RecalculateFolders); }); var runningOperation = operations.FirstOrDefault(o => o.Status <= DistributedTaskStatus.Running); if (runningOperation != null) { return(GetMailOperationStatus(runningOperation.Id, translateMailOperationStatus)); } var op = new MailRecalculateFoldersOperation(tenant, user, this); return(QueueTask(op, translateMailOperationStatus)); }
public MailOperationStatus QueueTask(MailOperation op, Func <DistributedTask, string> translateMailOperationStatus = null) { var task = op.GetDistributedTask(); MailOperations.QueueTask(op.RunJob, task); return(GetMailOperationStatus(task.Id, translateMailOperationStatus)); }
public async Task <UserLoginResponse> SignIn(UserSignInRequestModel ObjSignInRequestModel) { UserLoginResponse ObjUserLoginResponse = new UserLoginResponse(); try { using (RCS_dbContext context = new RCS_dbContext()) { UserLogin userLogin = await context.UserLogins.AsNoTracking().FirstOrDefaultAsync(a => a.UserName == ObjSignInRequestModel.UserName && a.Password == ObjSignInRequestModel.Password.ToUpper()); if (userLogin != null) { ObjUserLoginResponse.UserLogin = userLogin; if (ObjUserLoginResponse.UserLogin.Id > 0) { MailOperations mailOperations = new MailOperations(); string name = userLogin.FirstName + " " + userLogin.LastName.ToUpper(); if (mailOperations.SendSignInEmail(new System.Net.Mail.MailAddress(userLogin.UserName, name))) { ObjUserLoginResponse.ResponseCode = ResponseCode.Success; } } } } } catch (System.Exception ex) { ObjUserLoginResponse.ResponseCode = ResponseCode.Exception; ObjUserLoginResponse.Exception = ex; } return(ObjUserLoginResponse); }
public async Task <UserLoginResponse> ReVerifySignUp(SignUpRequestModel ObjSignUpRequestModel) { UserLoginResponse ObjUserLoginResponse = new UserLoginResponse(); try { using (RCS_dbContext context = new RCS_dbContext()) { UserLogin userLogin = await context.UserLogins.FirstOrDefaultAsync(x => x.UserName.ToUpper().Equals(ObjSignUpRequestModel.UserName.ToUpper())); if (userLogin != null) { userLogin.Status = UserLoginStatus.Verified; if (userLogin.Id > 0) { UserOtp userOtp = await context.UserOtps.FirstOrDefaultAsync(x => x.UserLoginId == userLogin.Id && x.IsExpired == false); if (userOtp != null) { //string OTP = Guid.NewGuid().ToString("n").Substring(0, 8) + "@DCL"; UserOtp _userOtp = new UserOtp(); userOtp.IsExpired = true; userLogin.Password = GlobalProperties.RandomOTP; //Add new UserOtp _userOtp.UserLoginId = userLogin.Id; _userOtp.Otp = userLogin.Password; _userOtp.IsExpired = false; _userOtp.CreatedByIpaddress = ObjSignUpRequestModel.ActionByIPAddress; _userOtp.CreatedBy = ObjSignUpRequestModel.ActionByUserID; var UserOTP_EntityEntry = await context.AddAsync(_userOtp); int Response = await context.SaveChangesAsync(); if (Response > 0) { MailOperations mailOperations = new MailOperations(); string name = userLogin.FirstName + " " + userLogin.LastName.ToUpper(); if (mailOperations.SendSignUpEmail(new System.Net.Mail.MailAddress(userLogin.UserName, name), _userOtp.Otp)) { ObjUserLoginResponse.ResponseCode = ResponseCode.Success; } } else { ObjUserLoginResponse.ResponseCode = ResponseCode.Inserted; } } } } } } catch (System.Exception ex) { ObjUserLoginResponse.ResponseCode = ResponseCode.Exception; ObjUserLoginResponse.Exception = ex; } return(ObjUserLoginResponse); }
public async Task <UserLoginResponse> SignUp(SignUpRequestModel ObjSignUpRequestModel) { UserLoginResponse ObjUserLoginResponse = new UserLoginResponse(); try { using (RCS_dbContext context = new RCS_dbContext()) { UserLogin userLogin = new UserLogin(); userLogin.UserName = ObjSignUpRequestModel.UserName; userLogin.Password = GlobalProperties.RandomOTP; userLogin.FirstName = ObjSignUpRequestModel.FirstName; userLogin.LastName = ObjSignUpRequestModel.LastName; userLogin.Mobile = ObjSignUpRequestModel.Mobile; userLogin.Type = ObjSignUpRequestModel.Type; userLogin.CreatedByIpaddress = ObjSignUpRequestModel.ActionByIPAddress; userLogin.CreatedBy = ObjSignUpRequestModel.ActionByUserID; var UserLogins_EntityEntry = await context.UserLogins.AddAsync(userLogin); int UserLogins_Response = await context.SaveChangesAsync(); if (UserLogins_Response > 0) { ObjUserLoginResponse.UserLogin = await context.UserLogins.AsNoTracking().FirstOrDefaultAsync(a => a.Id == userLogin.Id); UserOtp userOtp = new UserOtp(); userOtp.UserLoginId = ObjUserLoginResponse.UserLogin.Id; userOtp.Otp = userLogin.Password; userOtp.CreatedByIpaddress = ObjSignUpRequestModel.ActionByIPAddress; userOtp.CreatedBy = ObjSignUpRequestModel.ActionByUserID; var UserOTP_EntityEntry = await context.AddAsync(userOtp); int UserOTP_Response = await context.SaveChangesAsync(); if (UserOTP_Response > 0) { ObjUserLoginResponse.ResponseCode = ResponseCode.Inserted; MailOperations mailOperations = new MailOperations(); string name = userLogin.FirstName + " " + userLogin.LastName.ToUpper(); if (mailOperations.SendSignUpEmail(new System.Net.Mail.MailAddress(userLogin.UserName, name), userOtp.Otp)) { ObjUserLoginResponse.ResponseCode = ResponseCode.Success; } } } } } catch (System.Exception ex) { ObjUserLoginResponse.ResponseCode = ResponseCode.Exception; ObjUserLoginResponse.Exception = ex; } return(ObjUserLoginResponse); }
public MailViewModel() { // Instantiate a private instance of the mail operations object _mailOperations = new MailOperations(); this.MailItems = new ObservableCollection <MailItemViewModel>(); //construct relay commands to be bound to controls on a UI this.SendMailCommand = new RelayCommand(ExecuteSendMailCommandAsync); this.GetMailCommand = new RelayCommand(ExecuteGetMailCommandAsync); this.GetPrevPageCommand = new RelayCommand(ExecuteGetPrevPageCommandAsync, CanGetPrevPage); this.DeleteMailCommand = new RelayCommand(ExecuteDeleteMailCommandAsync, CanDeleteMail); }
public string TestEmail() { MailOperations mailOperations = new MailOperations(); if (mailOperations.TestEmail()) { return("Mail Sent."); } else { return("FAILED TO SEND EMAIL."); } }
public async Task <UserLoginResponse> VerifySignUp(string OTP, string EmailAddress) { UserLoginResponse ObjUserLoginResponse = new UserLoginResponse(); try { using (RCS_dbContext context = new RCS_dbContext()) { UserLogin userLogin = await context.UserLogins.FirstOrDefaultAsync(x => x.UserName.ToUpper().Equals(EmailAddress.ToUpper())); if (userLogin != null) { userLogin.Status = UserLoginStatus.Verified; if (userLogin.Id > 0) { UserOtp userOtp = await context.UserOtps.FirstOrDefaultAsync(x => x.UserLoginId == userLogin.Id && x.Otp == OTP && x.IsExpired == false); if (userOtp != null) { userOtp.IsExpired = true; context.SaveChanges(); if (userOtp.CreatedDateTime > DateTime.Now.AddMinutes(int.Parse("-" + GlobalProperties.OTPExpiryMinutes))) { userLogin.Status = UserLoginStatus.ApprovalInProcess; ObjUserLoginResponse.UserLogin = userLogin; MailOperations mailOperations = new MailOperations(); string name = userLogin.FirstName + " " + userLogin.LastName.ToUpper(); if (mailOperations.SendVerificationEmail(new System.Net.Mail.MailAddress(userLogin.UserName, name), userOtp.Otp)) { ObjUserLoginResponse.ResponseCode = ResponseCode.Success; } } else { ObjUserLoginResponse.ResponseCode = ResponseCode.Expired; } } } } } } catch (System.Exception ex) { ObjUserLoginResponse.ResponseCode = ResponseCode.Exception; ObjUserLoginResponse.Exception = ex; } return(ObjUserLoginResponse); }
public async Task <object> SignUp(User user) { SignUpRespone response = new SignUpRespone(); response = userService.UserSignUp(user); if (response.Code == 1) { string link = "<a href='http://localhost:6868/Login/Activate?email=" + user.Email + "&valKey=" + Security.sha512encrypt(user.ValidationKey) + "'>"; string subjectName = "Ardan Ticaret Aktivasyon İşlemi"; //todo image işi ayarlanacak. string image = ""; string body = "Kayıt işlemini tamamlamak için lütfen linke " + link + "tıklayınız.</a>" + image; await MailOperations.SendMailForSignUp(subjectName, body, user.Email); } return(response); }
public async Task <UserLoginResponse> UserInsert(UserLogin userLogin) { UserLoginResponse ObjUserLoginResponse = new UserLoginResponse(); try { using (RCS_dbContext context = new RCS_dbContext()) { var UserLogins_EntityEntry = await context.UserLogins.AddAsync(userLogin); int UserLogins_Response = await context.SaveChangesAsync(); if (UserLogins_Response > 0) { ObjUserLoginResponse.UserLogin = await context.UserLogins.AsNoTracking().FirstOrDefaultAsync(a => a.Id == userLogin.Id); UserOtp userOtp = new UserOtp(); userOtp.UserLoginId = ObjUserLoginResponse.UserLogin.Id; userOtp.Otp = userLogin.Password; userOtp.CreatedByIpaddress = userLogin.CreatedByIpaddress; userOtp.CreatedBy = userLogin.CreatedBy; var UserOTP_EntityEntry = await context.AddAsync(userOtp); int UserOTP_Response = await context.SaveChangesAsync(); if (UserOTP_Response > 0) { ObjUserLoginResponse.ResponseCode = ResponseCode.Inserted; MailOperations mailOperations = new MailOperations(); string name = userLogin.FirstName + " " + userLogin.LastName.ToUpper(); if (mailOperations.SendCreateUserEmail(new System.Net.Mail.MailAddress(userLogin.UserName, name), userOtp.Otp)) { ObjUserLoginResponse.ResponseCode = ResponseCode.Success; } } } } } catch (System.Exception ex) { ObjUserLoginResponse.ResponseCode = ResponseCode.Exception; ObjUserLoginResponse.Exception = ex; } return(ObjUserLoginResponse); }
public List <MailOperationStatus> GetMailOperations(Func <DistributedTask, string> translateMailOperationStatus = null) { var operations = MailOperations.GetTasks().Where( o => o.GetProperty <int>(MailOperation.TENANT) == TenantProvider.CurrentTenantID && o.GetProperty <string>(MailOperation.OWNER) == SecurityContext.CurrentAccount.ID.ToString()); var list = new List <MailOperationStatus>(); foreach (var o in operations) { if (string.IsNullOrEmpty(o.Id)) { continue; } list.Add(GetMailOperationStatus(o.Id, translateMailOperationStatus)); } return(list); }
public MailOperationStatus RemoveMailbox(MailBoxData mailbox, Func <DistributedTask, string> translateMailOperationStatus = null) { var tenant = CoreContext.TenantManager.GetCurrentTenant(); var user = SecurityContext.CurrentAccount; var operations = MailOperations.GetTasks() .Where(o => { var oTenant = o.GetProperty <int>(MailOperation.TENANT); var oUser = o.GetProperty <string>(MailOperation.OWNER); var oType = o.GetProperty <MailOperationType>(MailOperation.OPERATION_TYPE); return(oTenant == tenant.TenantId && oUser == user.ID.ToString() && oType == MailOperationType.RemoveMailbox); }) .ToList(); var sameOperation = operations.FirstOrDefault(o => { var oSource = o.GetProperty <string>(MailOperation.SOURCE); return(oSource == mailbox.MailBoxId.ToString()); }); if (sameOperation != null) { return(GetMailOperationStatus(sameOperation.Id, translateMailOperationStatus)); } var runningOperation = operations.FirstOrDefault(o => o.Status <= DistributedTaskStatus.Running); if (runningOperation != null) { throw new MailOperationAlreadyRunningException("Remove mailbox operation already running."); } var op = new MailRemoveMailboxOperation(tenant, user, mailbox); return(QueueTask(op, translateMailOperationStatus)); }
private async void btnGetMyMails_Click(object sender, RoutedEventArgs e) { setLoadingString("Loading.."); clearAllLists(); if (AppCapabilities == null) { await getAppCapabilities(); } var mailClient = ExchangeClient.ensureOutlookClientCreated(AppCapabilities, "Mail"); await MailOperations.sendMail(mailClient, FileParse.readMails()); var myMails = await MailOperations.getMails(mailClient); foreach (var myMail in myMails) { Mails.Add(new MyMail { Subject = myMail.Subject }); } setLoadingString(""); }
public MailOperationStatus GetMailOperationStatus(string operationId, Func <DistributedTask, string> translateMailOperationStatus = null) { var defaultResult = new MailOperationStatus { Id = null, Completed = true, Percents = 100, Status = "", Error = "", Source = "", OperationType = -1 }; if (string.IsNullOrEmpty(operationId)) { return(defaultResult); } var operations = MailOperations.GetTasks().ToList(); foreach (var o in operations) { if (!string.IsNullOrEmpty(o.InstanseId) && Process.GetProcesses().Any(p => p.Id == int.Parse(o.InstanseId))) { continue; } o.SetProperty(MailOperation.PROGRESS, 100); MailOperations.RemoveTask(o.Id); } var operation = operations .FirstOrDefault( o => o.GetProperty <int>(MailOperation.TENANT) == TenantProvider.CurrentTenantID && o.GetProperty <string>(MailOperation.OWNER) == SecurityContext.CurrentAccount.ID.ToString() && o.Id.Equals(operationId)); if (operation == null) { return(defaultResult); } if (DistributedTaskStatus.Running < operation.Status) { operation.SetProperty(MailOperation.PROGRESS, 100); MailOperations.RemoveTask(operation.Id); } var operationTypeIndex = (int)operation.GetProperty <MailOperationType>(MailOperation.OPERATION_TYPE); var result = new MailOperationStatus { Id = operation.Id, Completed = operation.GetProperty <bool>(MailOperation.FINISHED), Percents = operation.GetProperty <int>(MailOperation.PROGRESS), Status = translateMailOperationStatus != null ? translateMailOperationStatus(operation) : operation.GetProperty <string>(MailOperation.STATUS), Error = operation.GetProperty <string>(MailOperation.ERROR), Source = operation.GetProperty <string>(MailOperation.SOURCE), OperationType = operationTypeIndex, Operation = Enum.GetName(typeof(MailOperationType), operationTypeIndex) }; return(result); }