public ActionResult MailDebateAdd(int debatId, string mailBody) { var debate = BLLDebates.GetDebate(debatId); if (String.IsNullOrWhiteSpace(mailBody) && Request.Files["FileUpload"] != null && Request.Files["FileUpload"].ContentLength > 0) { HttpPostedFileBase hpf = Request.Files["FileUpload"] as HttpPostedFileBase; var blockBlob = AzureFileHelper.AddFile(debate.Event.IdConflict, hpf); var f = new ProofFile(); f.FilePath = blockBlob.Uri.AbsoluteUri; f.IdConflict = debate.Event.IdConflict; f.Name = blockBlob.Name; var file = BLLConflicts.AddFile(f); var mailDebate = BLLDebates.AddMailDebate(new MailDebate() { IdDebate = debatId, Body = "<a href='" + file.FilePath + "'>" + file.Name + "</a>", CreateDate = DateTime.Now, CreatedBy = User.Identity.GetId(), IdFile = file.Id }); foreach (var item in BLLDebates.GetUsersForDebate(debatId)) { Guid guid = Guid.NewGuid(); FastArbitreEmails.YouHaveMail(item, debate, Url.Action("MailDebate", "Arbitre", new { debatId = debate.Id }, this.Request.Url.Scheme) + "#mail_" + mailDebate.Id, Request.UrlReferrer.DnsSafeHost + Url.Action("Index", "Email", new { id = guid.ToString() }), guid); } } else { var mailDebate = BLLDebates.AddMailDebate(new MailDebate() { IdDebate = debatId, Body = mailBody, CreateDate = DateTime.Now, CreatedBy = User.Identity.GetId() }); foreach (var item in BLLDebates.GetUsersForDebate(debatId)) { Guid guid = Guid.NewGuid(); FastArbitreEmails.YouHaveMail(item, debate, Url.Action("MailDebate", "Arbitre", new { debatId = debate.Id }, this.Request.Url.Scheme) + "#mail_" + mailDebate.Id, Request.UrlReferrer.DnsSafeHost + Url.Action("Index", "Email", new { id = guid.ToString() }), guid); } } return(RedirectToAction("MailDebate", new { debatId = debatId })); }
public ActionResult StartProcedure(int conflictId, int debatTime, string mailBody, string mailTitle) { var evt = BLLConflicts.AddEvent(new Event() { DateBegin = DateTime.Now, Description = mailBody, IdConflict = conflictId, Name = mailTitle, Type = (int)EventTypeEnum.OfficialDocuments, IdUser = User.Identity.GetId() }); var debate = new Debate(); debate.CreateDate = DateTime.Now; debate.IdEvent = evt.Id; debate.CountDown = debatTime; debate.Type = (int)DebateTypeEnum.Mail; debate.Title = mailTitle; debate = BLLDebates.CreateDebate(debate); var mailDebate = new MailDebate(); mailDebate.CreateDate = DateTime.Now; mailDebate.CreatedBy = User.Identity.GetId(); mailDebate.IdDebate = debate.Id; mailDebate.Body = mailBody; mailDebate = BLLDebates.AddMailDebate(mailDebate); if (debate.MailDebates == null) { debate.MailDebates = new List <MailDebate>(); } foreach (var item in BLLDebates.GetUsersForDebate(debate.Id)) { Guid guid = Guid.NewGuid(); FastArbitreEmails.YouHaveMail(item, debate, Url.Action("MailDebate", "Arbitre", new { debatId = debate.Id }, this.Request.Url.Scheme) + "#mail_" + mailDebate.Id, Request.UrlReferrer.DnsSafeHost + Url.Action("Index", "Email", new { id = guid.ToString() }), guid); } debate.MailDebates.Add(mailDebate); return(RedirectToAction("Conflict", "Viewer", new { conflictId = conflictId })); }
public ActionResult StartDebate(int conflictId, int eventId, string debatType, string mailTitle, string mailBody, string visioTitle, string visioDescription, DateTime?rdv, int?debatTime) { var debate = new Debate(); debate.CreateDate = DateTime.Now; debate.IdEvent = eventId; debate.CountDown = debatTime; debate.Type = debatType == "mail" ? (int)DebateTypeEnum.Mail : (int)DebateTypeEnum.Visio; debate.Title = debate.Type == (int)DebateTypeEnum.Mail ? mailTitle : visioTitle; debate = BLLDebates.CreateDebate(debate); if (debate.Type == (int)DebateTypeEnum.Mail) { var mailDebate = new MailDebate(); mailDebate.CreateDate = DateTime.Now; mailDebate.CreatedBy = User.Identity.GetId(); mailDebate.IdDebate = debate.Id; mailDebate.Body = mailBody; mailDebate = BLLDebates.AddMailDebate(mailDebate); if (debate.MailDebates == null) { debate.MailDebates = new List <MailDebate>(); } foreach (var item in BLLDebates.GetUsersForDebate(debate.Id)) { Guid guid = Guid.NewGuid(); FastArbitreEmails.YouHaveMail(item, debate, Url.Action("MailDebate", "Arbitre", new { debatId = debate.Id }, this.Request.Url.Scheme) + "#mail_" + mailDebate.Id, Request.UrlReferrer.DnsSafeHost + Url.Action("Index", "Email", new { id = guid.ToString() }), guid); } debate.MailDebates.Add(mailDebate); return(RedirectToAction("MailDebate", new { debatId = debate.Id })); } else if (debate.Type == (int)DebateTypeEnum.Visio) { var conflict = BLLConflicts.GetConflictWithUsers(conflictId); var chatRoom = new ClickNClaim.OpenFireConnector.chatRoom(debate.Title, visioDescription, rdv.Value); OpenFireConnector.Connector connector = new OpenFireConnector.Connector("http://openfire-444e60hk.cloudapp.net:9090/", "admin", "SF211084agantio"); foreach (var item in conflict.UsersInConflicts) { var visioDebate = new MeetingDebate(); visioDebate.CreateDate = DateTime.Now; visioDebate.Date = rdv.Value; visioDebate.Description = visioDescription; // visioDebate.IdUser = item.IdUser; visioDebate.Link = "https://openfire-444e60hk.cloudapp.net:7443/ofmeet/?b=1-1461653024012"; visioDebate.Title = debate.Title; //visioDebate.IdDebate = debate.Id; //visioDebate = BLLDebates.AddMeetingDate(visioDebate); //if (debate.MeetingDebates == null) //{ // debate.MeetingDebates = new List<MeetingDebate>(); //} //debate.MeetingDebates.Add(visioDebate); var user = BLLUsers.GetUserById(item.IdUser); var existingUserInOpenFire = connector.UserExists(user.DisplayName.Replace(" ", ".")); if (existingUserInOpenFire == null) { existingUserInOpenFire = connector.CreateUser(new OpenFireConnector.user() { email = user.Email, name = user.DisplayName.Replace(' ', '.'), password = user.Email, username = user.DisplayName.Replace(' ', '.') }); } chatRoom.members.Add(new OpenFireConnector.member() { value = user.DisplayName.Replace(" ", ".").ToLower() + "@openfire" }); Guid guid = Guid.NewGuid(); FastArbitreEmails.VisioConferencePlanned(user.Email, rdv, visioTitle, visioDescription, connector.RoomLink + chatRoom.naturalName, user.DisplayName.Replace(" ", ".").ToLower(), user.Email, Request.UrlReferrer.DnsSafeHost + Url.Action("Index", "Email", new { id = guid.ToString() }), guid); } if (chatRoom.members.Where(c => c.value == conflict.Arbiter.DisplayName.Replace(" ", ".") + "@openfire").FirstOrDefault() != null) { chatRoom.members.RemoveAll(c => c.value == conflict.Arbiter.DisplayName.Replace(" ", ".") + "@openfire"); } chatRoom.owners.Add(new OpenFireConnector.owner() { value = conflict.Arbiter.DisplayName.Replace(" ", ".") + "@openfire" }); var link = connector.CreateChatroom(chatRoom); connector = null; } return(RedirectToAction("Conflict", "Viewer", new { conflictId = conflictId })); }