Exemple #1
0
        public SaveResult InsertOrUpdate(ref MailDTO mail)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    long mailId = mail.MailId;
                    Mail entity = context.Mail.FirstOrDefault(c => c.MailId.Equals(mailId));

                    if (entity == null)
                    {
                        mail = Insert(mail, context);
                        return(SaveResult.Inserted);
                    }

                    mail.MailId = entity.MailId;
                    mail        = Update(entity, mail, context);
                    return(SaveResult.Updated);
                }
            }
            catch (Exception e)
            {
                Logger.Error($"{e} : ID {mail.ReceiverId}");
                return(SaveResult.Error);
            }
        }
Exemple #2
0
        private void SendMail(string body, ICollaborationDTO item)
        {
            var dto = new MailDTO();

            dto.Mailbox = new MailboxDTO {
                TypeName = "DSWMessage"
            };
            dto.Sender  = new ContactDTO(Parameters.MailSender);
            dto.Body    = body;
            dto.Subject = Parameters.MailSubject;

            if (Parameters.CreateEmailForEachRecipient)
            {
                var recipients = GetRecipients(item);
                foreach (var recipient in recipients)
                {
                    Array.Clear(dto.Recipients, 0, dto.Recipients.Length);
                    dto.AddRecipient(recipient);
                    MailConnector.Send(dto);
                }
            }
            else
            {
                var recipients = GetRecipients(item);
                dto.AddRecipients(recipients);
                MailConnector.Send(dto);
            }
        }
Exemple #3
0
    public void Initialize(MailDTO dto)
    {
        _mail = dto;

        Button btnClose = _transform.Find("BtnClose").GetComponent <Button>();

        btnClose.onClick.AddListener(OnBtnCloseClick);

        // 标题
        Text title = _transform.Find("Title").GetComponent <Text>();

        title.text = dto.subject;

        // 内容
        Text content = _transform.Find("Content").GetComponent <Text>();

        content.text = dto.body;

        // 邮件物品


        // 领取物品

        // 删除邮件
        Button btnDelete = _transform.Find("BtnDelete").GetComponent <Button>();

        btnDelete.onClick.AddListener(OnBtnDeleteClick);
    }
 public bool ToMail(MailDTO input, Mail output)
 {
     if (input == null)
     {
         output = null;
         return(false);
     }
     output.AttachmentAmount  = input.AttachmentAmount;
     output.AttachmentLevel   = input.AttachmentLevel;
     output.AttachmentRarity  = input.AttachmentRarity;
     output.AttachmentUpgrade = input.AttachmentUpgrade;
     output.AttachmentVNum    = input.AttachmentVNum;
     output.Date            = input.Date;
     output.EqPacket        = input.EqPacket;
     output.IsOpened        = input.IsOpened;
     output.IsSenderCopy    = input.IsSenderCopy;
     output.MailId          = input.MailId;
     output.Message         = input.Message;
     output.ReceiverId      = input.ReceiverId;
     output.SenderClass     = input.SenderClass;
     output.SenderGender    = input.SenderGender;
     output.SenderHairColor = input.SenderHairColor;
     output.SenderHairStyle = input.SenderHairStyle;
     output.SenderId        = input.SenderId;
     output.SenderMorphId   = input.SenderMorphId;
     output.Title           = input.Title;
     return(true);
 }
Exemple #5
0
        public bool SendMail(MailDTO mail)
        {
            try
            {
                SmtpClient client = new SmtpClient
                {
                    Port                  = 587,
                    EnableSsl             = true,
                    DeliveryMethod        = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,
                    Host                  = "smtp.gmail.com",
                    //mail adresi,şifre
                    Credentials = new NetworkCredential("*****@*****.**", "au2019au")
                };

                MailMessage mailMessage = new MailMessage("*****@*****.**", mail.To,
                                                          mail.Subject,
                                                          mail.Body);
                mailMessage.IsBodyHtml = true;

                client.Send(mailMessage);

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        public void SendItem(string senderName, long receivingCharacterId, short vnum, byte amount = 1, byte rare = 0, byte upgrade = 0, bool isNosmall = false)
        {
            if (!MSManager.Instance.AuthentificatedAdmins.ContainsKey(CurrentClient.ClientId) || MSManager.Instance.AuthentificatedAdmins[CurrentClient.ClientId].Authority != AuthorityType.GameMaster)
            {
                return;
            }
            //TODO: MailRefresh Call to Server
            long    charId = DAOFactory.CharacterDAO.LoadByAccount(MSManager.Instance.AuthentificatedAdmins[CurrentClient.ClientId].AccountId).FirstOrDefault().CharacterId;
            MailDTO mail   = new MailDTO
            {
                AttachmentAmount  = amount,
                IsOpened          = false,
                Date              = DateTime.Now,
                ReceiverId        = receivingCharacterId,
                SenderId          = charId,
                AttachmentRarity  = (byte)rare,
                AttachmentUpgrade = upgrade,
                IsSenderCopy      = false,
                Title             = isNosmall ? "NOSMALL" : senderName,
                AttachmentVNum    = vnum,
                SenderClass       = 0,
                SenderGender      = 0,
                SenderHairColor   = 0,
                SenderHairStyle   = 0,
                EqPacket          = "-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1",
                SenderMorphId     = -1
            };

            DAOFactory.MailDAO.InsertOrUpdate(ref mail);
        }
        public void SendMail(MailDTO mail)
        {
            if (!MSManager.Instance.AuthentificatedClients.Any(s => s.Equals(CurrentClient.ClientId)))
            {
                return;
            }

            DAOFactory.MailDAO.InsertOrUpdate(ref mail);

            if (mail.IsSenderCopy)
            {
                AccountConnection account = MSManager.Instance.ConnectedAccounts.Find(a => a.CharacterId.Equals(mail.SenderId));
                if (account?.ConnectedWorld != null)
                {
                    account.ConnectedWorld.MailServiceClient.GetClientProxy <IMailClient>().MailSent(mail);
                }
            }
            else
            {
                AccountConnection account = MSManager.Instance.ConnectedAccounts.Find(a => a.CharacterId.Equals(mail.ReceiverId));
                if (account?.ConnectedWorld != null)
                {
                    account.ConnectedWorld.MailServiceClient.GetClientProxy <IMailClient>().MailSent(mail);
                }
            }
        }
Exemple #8
0
        public async Task <IActionResult> DeleteEmployee(int id)
        {
            var user = await _repo.GetEmployee(id);

            if (user == null)
            {
                return(BadRequest("Employee Not Exist"));
            }

            var managerList = await _repo.GetManager(id);

            if (managerList.Count > 0)
            {
                return(BadRequest("Employee ID cannot able to delete due to linked with other Employee"));
            }

            _repo.Delete(user);

            if (await _repo.SaveAll())
            {
                MailDTO objMail = new MailDTO();
                objMail.TO      = user.EmailID;
                objMail.Subject = "Employee Deletion";
                objMail.Message = "Dear " + user.FirstName + "<br/><br/>"
                                  + "User Employee Id ( " + id + " ) is Deleted Sucessfully";
                _repo.SendEmail(objMail);
                _logger.LogInformation("Delete Employee Sucessfully and Email Sent");

                return(Ok(new { MsgCode = "03", TransferData = "Delete Successfully" }));
            }

            return(BadRequest("Failed to delete the Employee"));

            throw new Exception($"Delete user {id} has Dependency with Other User, Please Contact Adminisatrator");
        }
        public SaveResult InsertOrUpdate(ref MailDTO mail)
        {
            try
            {
                using (var context = DataAccessHelper.CreateContext())
                {
                    long mailId = mail.MailId;
                    Mail entity = context.Mail.FirstOrDefault(c => c.MailId.Equals(mailId));

                    if (entity == null) //new entity
                    {
                        mail = Insert(mail, context);
                        return(SaveResult.Inserted);
                    }
                    else //existing entity
                    {
                        mail.MailId = entity.MailId;
                        mail        = Update(entity, mail, context);
                        return(SaveResult.Updated);
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(SaveResult.Error);
            }
        }
Exemple #10
0
        private static MailDTO Insert(MailDTO mail, OpenNosContext context)
        {
            try
            {
                Mail entity = new Mail();
                Mapper.Mappers.MailMapper.ToMail(mail, entity);
                context.Mail.Add(entity);
                context.SaveChanges();
                if (Mapper.Mappers.MailMapper.ToMailDTO(entity, mail))
                {
                    return(mail);
                }

                return(null);
            }
            catch (DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (DbEntityValidationResult validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (DbValidationError validationError in validationErrors.ValidationErrors)
                    {
                        // raise a new exception nesting the current instance as InnerException
                        Logger.Error(new InvalidOperationException($"{validationErrors.Entry.Entity}:{validationError.ErrorMessage}  ID:{mail.ReceiverId}", raise));
                    }
                }
                return(null);
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
Exemple #11
0
        public void SendEmail(MailDTO obj)
        {
            string fromaddr = "*****@*****.**";
            string password = "******";

            MailMessage msg = new MailMessage();

            msg.Subject = obj.Subject;
            msg.From    = new MailAddress("*****@*****.**");
            msg.To.Add(obj.TO);
            //msg.To.Add(new MailAddress("*****@*****.**"));
            //msg.To.Add(new MailAddress(objEmployee.EmailID));
            string body = obj.Message;

            msg.Body       = body;
            msg.IsBodyHtml = true;

            SmtpClient smtp = new SmtpClient();

            smtp.Host = "smtp.gmail.com";
            smtp.Port = 587;
            smtp.UseDefaultCredentials = false;
            smtp.EnableSsl             = true;
            NetworkCredential nc = new NetworkCredential(fromaddr, password);

            smtp.Credentials = nc;
            smtp.Send(msg);
        }
Exemple #12
0
 private MailDTO Update(Mail entity, MailDTO respawn, OpenNosContext context)
 {
     if (entity != null)
     {
         _mapper.Map(respawn, entity);
         context.SaveChanges();
     }
     return(_mapper.Map <MailDTO>(entity));
 }
        public ActionResult Put([FromBody] MailDTO mailDto)
        {
            if (UsersDAO.UpdateMail(mailDto))
            {
                return(Ok(true));
            }

            return(BadRequest(false));
        }
Exemple #14
0
        public MailDTO Send(MailDTO mail)
        {
            mail.IsSent = _emailSendService.Send(mail);
            var newMail = _unitOfWork.Mails.Save(_mapper.Map <MailDTO, Mail>(mail));

            _unitOfWork.Save();

            return(_mapper.Map <Mail, MailDTO>(newMail));
        }
Exemple #15
0
        public void SendItem(long characterId, MallItem item)
        {
            if (!MSManager.Instance.AuthentificatedClients.Any(s => s.Equals(CurrentClient.ClientId)))
            {
                return;
            }

            MailDTO mailDTO = new MailDTO
            {
                AttachmentAmount  = (short)item.Amount,
                AttachmentRarity  = item.Rare,
                AttachmentUpgrade = item.Upgrade,
                AttachmentDesign  = item.Design,
                AttachmentVNum    = item.ItemVNum,
                Date         = DateTime.Now,
                EqPacket     = "",
                IsOpened     = false,
                IsSenderCopy = false,
                Message      = "",
                ReceiverId   = characterId,
                SenderId     = characterId,
                Title        = "ItemMall"
            };

            DAOFactory.MailDAO.InsertOrUpdate(ref mailDTO);

            MailDTO mail = new MailDTO
            {
                AttachmentAmount  = mailDTO.AttachmentAmount,
                AttachmentRarity  = mailDTO.AttachmentRarity,
                AttachmentUpgrade = mailDTO.AttachmentUpgrade,
                AttachmentDesign  = mailDTO.AttachmentDesign,
                AttachmentVNum    = mailDTO.AttachmentVNum,
                Date            = mailDTO.Date,
                EqPacket        = mailDTO.EqPacket,
                IsOpened        = mailDTO.IsOpened,
                IsSenderCopy    = mailDTO.IsSenderCopy,
                MailId          = mailDTO.MailId,
                Message         = mailDTO.Message,
                ReceiverId      = mailDTO.ReceiverId,
                SenderClass     = mailDTO.SenderClass,
                SenderGender    = mailDTO.SenderGender,
                SenderHairColor = mailDTO.SenderHairColor,
                SenderHairStyle = mailDTO.SenderHairStyle,
                SenderId        = mailDTO.SenderId,
                SenderMorphId   = mailDTO.SenderMorphId,
                Title           = mailDTO.Title
            };

            AccountConnection account = MSManager.Instance.ConnectedAccounts.Find(a => a.CharacterId.Equals(mail.ReceiverId));

            if (account?.ConnectedWorld != null)
            {
                account.ConnectedWorld.MailServiceClient.GetClientProxy <IMailClient>().MailSent(mail);
            }
        }
        public MailDTO ToTransfer()
        {
            var dto = new MailDTO();

            dto.Id         = Id;
            dto.SenderId   = SenderId;
            dto.ReceiverId = ReceiverId;

            return(dto);
        }
Exemple #17
0
 public async Task <MailDTO> CargarConfigMail(ConfigMail configMail)
 {
     try
     {
         MailDTO mailDTO = mapper.Map <ConfigMail, MailDTO>(configMail);
         return(mailDTO);
     }
     catch (Exception e)
     {
         return(null);
     }
 }
        public async Task <IActionResult> EnviarMAil([FromBody] MailMensajeDTO mailMensaje)
        {
            MailDTO mail = await mailRepositorio.CargarConfigMail(config.Value);

            if (await mail.EnvioAutentificacionProveedor(mailMensaje.EnviarA, mailMensaje.MensajeAEnviar))
            {
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
Exemple #19
0
    /// <summary>
    /// 删除邮件
    /// </summary>
    /// <param name="mailid"></param>
    public void Delete(int mailid)
    {
        for (int i = 0; i < _content.childCount; i++)
        {
            Transform child = _content.GetChild(i);
            MailDTO   dto   = child.GetComponent <ButtonEventListener>().dto;

            if (dto.id == mailid)
            {
                GameObject.Destroy(child.gameObject);
            }
        }
    }
 public IActionResult Contact([FromBody] MailDTO dto)
 {
     try
     {
         var id = GetTokenId.getId(User);
         _userService.SendMail(dto, id);
         return(Ok());
     }
     catch (Exception e)
     {
         return(BadRequest("Servis is temporary out of function"));
     }
 }
Exemple #21
0
        public IActionResult Contact([FromBody] MailDTO dto)
        {
            var userId = AuthMiddleware.GetUserId(User);

            try
            {
                _service.SendMail(dto, userId);
                return(Ok("Mail sent!"));
            }
            catch (Exception e)
            {
                return(BadRequest("Something went wrong!"));
            }
        }
Exemple #22
0
 public IEnumerable <MailDTO> LoadAll()
 {
     using (OpenNosContext context = DataAccessHelper.CreateContext())
     {
         List <MailDTO> result = new List <MailDTO>();
         foreach (Mail mail in context.Mail)
         {
             MailDTO dto = new MailDTO();
             Mapper.Mappers.MailMapper.ToMailDTO(mail, dto);
             result.Add(dto);
         }
         return(result);
     }
 }
Exemple #23
0
        private static MailDTO Update(Mail entity, MailDTO respawn, OpenNosContext context)
        {
            if (entity != null)
            {
                Mapper.Mappers.MailMapper.ToMail(respawn, entity);
                context.SaveChanges();
            }
            if (Mapper.Mappers.MailMapper.ToMailDTO(entity, respawn))
            {
                return(respawn);
            }

            return(null);
        }
Exemple #24
0
        public void SendMail(Mail mail)
        {
            if (!MSManager.Instance.AuthentificatedClients.Any(s => s.Equals(CurrentClient.ClientId)))
            {
                return;
            }

            MailDTO mailDTO = new MailDTO
            {
                AttachmentAmount  = mail.AttachmentAmount,
                AttachmentRarity  = mail.AttachmentRarity,
                AttachmentUpgrade = mail.AttachmentUpgrade,
                AttachmentVNum    = mail.AttachmentVNum,
                Date            = mail.Date,
                EqPacket        = mail.EqPacket,
                IsOpened        = mail.IsOpened,
                IsSenderCopy    = mail.IsSenderCopy,
                MailId          = mail.MailId,
                Message         = mail.Message,
                ReceiverId      = mail.ReceiverId,
                SenderClass     = mail.SenderClass,
                SenderGender    = mail.SenderGender,
                SenderHairColor = mail.SenderHairColor,
                SenderHairStyle = mail.SenderHairStyle,
                SenderId        = mail.SenderId,
                SenderMorphId   = mail.SenderMorphId,
                Title           = mail.Title
            };

            DAOFactory.MailDAO.InsertOrUpdate(ref mailDTO);
            mail.MailId = mailDTO.MailId;

            if (mail.IsSenderCopy)
            {
                AccountConnection account = MSManager.Instance.ConnectedAccounts.Find(a => a.CharacterId.Equals(mail.SenderId));
                if (account?.ConnectedWorld != null)
                {
                    account.ConnectedWorld.MailServiceClient.GetClientProxy <IMailClient>().MailSent(mail);
                }
            }
            else
            {
                AccountConnection account = MSManager.Instance.ConnectedAccounts.Find(a => a.CharacterId.Equals(mail.ReceiverId));
                if (account?.ConnectedWorld != null)
                {
                    account.ConnectedWorld.MailServiceClient.GetClientProxy <IMailClient>().MailSent(mail);
                }
            }
        }
    public static MailDTO GetMailDTO(MailData d)
    {
        MailDTO dto = new MailDTO();

        dto.id           = d.id;
        dto.sender_id    = d.sender_id;
        dto.receiver_id  = d.receiver_id;
        dto.subject      = d.subject;
        dto.body         = d.body;
        dto.deliver_time = d.deliver_time;
        dto.money        = d.money;
        dto.has_items    = d.has_items;

        return(dto);
    }
Exemple #26
0
 private MailDTO Insert(MailDTO mail, OpenNosContext context)
 {
     try
     {
         Mail entity = _mapper.Map <Mail>(mail);
         context.Mail.Add(entity);
         context.SaveChanges();
         return(_mapper.Map <MailDTO>(entity));
     }
     catch (Exception e)
     {
         Logger.Error(e);
         return(null);
     }
 }
Exemple #27
0
 public IEnumerable <MailDTO> LoadSentToCharacter(long characterId)
 {
     //s => s.ReceiverId == CharacterId && !s.IsSenderCopy && MailList.All(m => m.Value.MailId != s.MailId)).Take(50)
     using (OpenNosContext context = DataAccessHelper.CreateContext())
     {
         List <MailDTO> result = new List <MailDTO>();
         foreach (Mail mail in context.Mail.Where(s => s.ReceiverId == characterId && !s.IsSenderCopy).Take(40))
         {
             MailDTO dto = new MailDTO();
             Mapper.Mappers.MailMapper.ToMailDTO(mail, dto);
             result.Add(dto);
         }
         return(result);
     }
 }
Exemple #28
0
        public async Task <Employee> Register(Employee objEmployee)
        {
            await _context.Employee.AddAsync(objEmployee);

            await _context.SaveChangesAsync();

            MailDTO objMail = new MailDTO();

            objMail.TO      = objEmployee.EmailID;
            objMail.Subject = "Employee Reigistration";
            objMail.Message = "Dear " + objEmployee.FirstName + "<br/><br/>"

                              + "Register Sucessfully";
            SendEmail(objMail);
            return(objEmployee);
        }
    private void OnMailInfos(UserToken token, SocketModel model)
    {
        //List<MailData> mails = CacheManager.instance.GetPlayerData(token.characterid).mails;

        List <MailData> mails = CacheManager.instance.GetMailDatas(token.characterid);

        RespMailInfos resp = new RespMailInfos();

        foreach (MailData d in mails)
        {
            MailDTO dto = MailData.GetMailDTO(d);
            resp.mails.Add(dto);
        }

        NetworkManager.Send(token, (int)MsgID.MailInfos_SRES, resp);
    }
 public void SendMail(string worldGroup, MailDTO mail)
 {
     if (!IsCharacterConnected(worldGroup, mail.ReceiverId))
     {
         CharacterDTO chara = DAOFactory.CharacterDAO.LoadById(mail.ReceiverId);
         DAOFactory.MailDAO.InsertOrUpdate(ref mail);
     }
     else
     {
         AccountConnection account = MSManager.Instance.ConnectedAccounts.FirstOrDefault(a => a.CharacterId.Equals(mail.ReceiverId));
         if (account != null && account.ConnectedWorld != null)
         {
             account.ConnectedWorld.ServiceClient.GetClientProxy <ICommunicationClient>().SendMail(mail);
         }
     }
 }