Пример #1
0
        public ActionResult PreViewEmailFolderFeedback(string name)
        {
            FeedbackFolder email = new FeedbackFolder();
            // set up the email ...
            email.To = "*****@*****.**";
            email.folder = reposetory.GetFolder(new Guid("9b93e5c0-7caf-e411-bf26-c485084553de"));
            email.Person = reposetory.GetPerson(new Guid("983504df-3e8b-4af7-a54d-308090a74a02"));
            email.message = "test besked på at det virker atgsepråer";
            //email.ReplyToList.Add("*****@*****.**");
            email.Send();
            return new EmailViewResult(email);

        }
Пример #2
0
        public ActionResult Communicate(MessageFolderModel MessageContext)
        {
            List<NR.Models.NRMembership> Active = new List<NR.Models.NRMembership>();
            if (MessageContext.NewMessageTo == null || !MessageContext.NewMessageTo.Any())
            {
                ModelState.AddModelError("NewMessageTo", General.ErrorNoRecipients);

            }

            if (MessageContext.Short)
            {
                if (String.IsNullOrWhiteSpace(MessageContext.BodyShort)) ModelState.AddModelError("BodyShort", General.ErrorNoBody);
            }
            else
            {
                if (String.IsNullOrWhiteSpace(MessageContext.Head) & String.IsNullOrWhiteSpace(MessageContext.Body)) ModelState.AddModelError("", General.ErrorNoHeadOrBody);
            }

            if (ModelState.ContainsKey("Folder.FoldereName"))
                ModelState["Folder.FoldereName"].Errors.Clear();

            MessageContext.Folder = reposetory.GetFolder(MessageContext.Folder.FolderID);
            MessageContext.LinkActive = MessageContext.Folder.Status != FolderStatus.Input;

            if (ModelState.IsValid)
            {

                List<Guid> Recivers = new List<Guid>();

                Active = reposetory.GetAssociationActivePersons(CurrentProfile.AssociationID);
                Person Sender = reposetory.GetPerson(CurrentProfile.PersonID);


                foreach (Guid PersonID in MessageContext.NewMessageTo)
                {
                    if (PersonID == MistConversations.Int2Guid(0))
                    {
                        Recivers = Active.Select(m => m.Person.PersonID).ToList();
                    }
                    else if (PersonID == MistConversations.Int2Guid(1))
                    {
                        Recivers.AddRange(reposetory.GetAssociationTeamLeadersPersons(CurrentProfile.AssociationID).Select(m => m.PersonID).ToList());
                    }
                    else if (PersonID == MistConversations.Int2Guid(2))
                    {
                        Recivers.AddRange(reposetory.GetAssociationPersonsNoFeedback(CurrentProfile.AssociationID, MessageContext.Folder.FolderID).Select(m => m.PersonID).ToList());
                    }
                    else
                    {
                        Recivers.Add(PersonID);
                    }
                }

                foreach (Guid PID in Recivers)
                {
                    Person P = reposetory.GetPerson(PID);
                    if (!string.IsNullOrWhiteSpace(P.Email))
                    {
                        FeedbackFolder email = new FeedbackFolder();
                        //// set up the email ...
                        email.To = P.Email;
                        email.ReplyTo = CurrentProfile.Email;
                        email.folder = MessageContext.Folder;
                        email.Person = P;
                        email.message = MessageContext.Body;
                        email.Link = MessageContext.Link;
                        try
                        {
                            email.Send();
                        }
                        catch (Exception e)
                        {
                            LogFile.Write(e, "Email:" + P.Email);
                        }
                    }
                    if (MessageContext.Short)
                    {
#if DUMMYTEXT
                        ITextMessage SMSGateway = TextServiceProviderFactory.GetTextServiceProviderrInstance("NR.Infrastructure.DummyTextGateway", CurrentProfile.TextServiceProviderUserName, CurrentProfile.TextServiceProviderPassword);
#else
                        ITextMessage SMSGateway = TextServiceProviderFactory.GetTextServiceProviderrInstance(CurrentProfile.TextServiceProvider, CurrentProfile.TextServiceProviderUserName, CurrentProfile.TextServiceProviderPassword);
#endif

                        if (CurrentProfile.PersonID == Guid.Empty)
                        {
                            SMSGateway.FromText = General.SystemTextMessagesFrom;
                        }
                        else
                        {
                            SMSGateway.From = Sender;
                        }
                        
                        //SMSGateway.FromText = CurrentProfile.PersonID == Guid.Empty ? General.SystemTextMessagesFrom : string.IsNullOrWhiteSpace(CurrentProfile.Mobile) ? General.SystemTextMessagesFrom : CurrentProfile.Mobile;
                        SMSGateway.Message = MessageContext.BodyShort.ReplaceTagPerson(P);

                        //if (MessageContext.Link) SMSGateway.Message += "\r\n" + string.Format(General.FeedbackTextLink, Url.Action("FeedBack", "Planning", new { P = PID, F = MessageContext.Folder.FolderID }, "http"));
                        SMSGateway.Recipient = new List<Person> { P };
                        if (DateTime.Now.AddMinutes(1).Hour < 11) SMSGateway.DeliveryTime = DateTime.Now.AddMinutes(1).Date.AddHours(11);
                        reposetory.NewTextMessage(SMSGateway, CurrentProfile.AssociationID);

                        SMSGateway.HandShakeUrl = Url.Action("TextXStatus", "Account", new { ID = SMSGateway.TextId }, "http");

                        if (SMSGateway.Send())
                        {

                        };
                    }

                }

                ViewBag.FormSucces = true;

            }


            List<SelectListItem> AssItems = reposetory.GetAssociationActivePersons(CurrentProfile.AssociationID).Select(d => new SelectListItem { Value = d.Person.PersonID.ToString(), Text = d.Person.FullName }).ToList();
            AssItems.Insert(0, new SelectListItem { Text = General.MissingFeedback, Value = MistConversations.Int2Guid(2).ToString() });
            AssItems.Insert(0, new SelectListItem { Text = General.Teamleaders, Value = MistConversations.Int2Guid(1).ToString() });
            AssItems.Insert(0, new SelectListItem { Text = General.All, Value = MistConversations.Int2Guid(0).ToString() });

            MessageContext.List = AssItems;

            return View(MessageContext);
        }