public void AttachmentsAddInternal( Domain.DTO.DTO_Ticket TkData, Domain.Enums.MailSettings ownerSettings, Domain.Enums.MailSettings creatorSettings) { if (!this.SaveTicket(TkData, ownerSettings, creatorSettings, true)) { return; } Domain.Message message = service.MessageGetFromTicketDraft(TkData.TicketId, TkData.CreatorId); if (message == null || View.DraftMsgId != message.Id) { return; } List <lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions> FileActions = service.UploadAvailableActionsGet(Domain.Enums.MessageUserType.Partecipant, 0, 0, null); if (!FileActions.Contains(lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitem)) { return; } service.AttachmentsAddFiles(message.Id, View.GetUploadedItems(message, RepositoryAttachmentUploadActions.uploadtomoduleitem)); this.InitView(); }
public void AttachmentsAddAlsoToCommunity( Domain.DTO.DTO_Ticket TkData, Domain.Enums.MailSettings ownerSettings, Domain.Enums.MailSettings creatorSettings, Boolean alwaysLastVersion) { if (!this.SaveTicket(TkData, ownerSettings, creatorSettings, true)) { return; } Domain.Message Msg = service.MessageGetFromTicketDraft(TkData.TicketId, TkData.CreatorId); if (Msg == null || View.DraftMsgId != Msg.Id) { return; } int UserID = (this.UserContext != null) ? UserContext.CurrentUserID : 0; lm.Comol.Core.FileRepository.Domain.ModuleRepository cRepository = service.GetRepositoryPermissions(CurrentCommunityId, UserID); List <lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions> actions = service.UploadAvailableActionsGet(MessageUserType.Partecipant, CurrentCommunityId, UserContext.CurrentUserID, cRepository); if (!actions.Contains(lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitemandcommunity)) { return; } //service.MessageDraftUpdate(HtmlText, PreviewText, View.CurrentTicketId, View.DraftMsgId); //------------------------------------------------------------------------------------- service.AttachmentsAddFiles(View.DraftMsgId, View.GetUploadedItems(Msg, RepositoryAttachmentUploadActions.uploadtomoduleitemandcommunity)); //------------------------------------------------------------------------------------- this.InitView(); }
public void AttachmentsAddInternal(Domain.DTO.DTO_Ticket TkData, Boolean alwaysLastVersion) { if (!SaveTicket(TkData, true) || View.CurrentUser.PersonId <= 0) { return; } Domain.Message Msg = service.MessageGetFromTicketDraft(TkData.TicketId, TkData.CreatorId); if (Msg == null) { return; } List <lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions> actions = service.UploadAvailableActionsGet(Domain.Enums.MessageUserType.Partecipant, 0, 0, null); if (!actions.Contains(lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitem)) { return; } service.AttachmentsAddFiles(View.DraftMsgId, View.CurrentUser.UserId, View.GetUploadedItems(Msg)); this.InitView(); }
public void AttachmentsLinkFromCommunity(Domain.DTO.DTO_Ticket TkData, Domain.Enums.MailSettings ownerSettings, Domain.Enums.MailSettings creatorSettings, List <ModuleActionLink> links) { if (!this.SaveTicket(TkData, ownerSettings, creatorSettings, true)) { return; } Domain.Message Msg = service.MessageGetFromTicketDraft(TkData.TicketId, TkData.CreatorId); if (Msg == null || View.DraftMsgId != Msg.Id) { return; } int UserID = (this.UserContext != null) ? UserContext.CurrentUserID : 0; lm.Comol.Core.FileRepository.Domain.ModuleRepository cRepository = service.GetRepositoryPermissions(CurrentCommunityId, UserID); List <lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions> actions = service.UploadAvailableActionsGet(MessageUserType.Partecipant, CurrentCommunityId, UserContext.CurrentUserID, cRepository); if (!actions.Contains(lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions.linkfromcommunity)) { return; } IList <Domain.TicketFile> attachments = service.AttachmentsLinkFiles(View.DraftMsgId, links); int addedfiles = 0; if (attachments != null) { addedfiles = attachments.Count(); } this.InitView(); }
public void InitView() { if (!CheckSessionAccess()) { return; } //Boolean IsNewAndOtherTicket = false; Domain.DTO.DTO_AddInit values = new Domain.DTO.DTO_AddInit(); //Utente Domain.TicketUser Usr = service.UserGetfromPerson(UserContext.CurrentUserID); if (Usr == null) { View.DisplaySessionTimeout(View.ViewCommunityId); return; } Domain.Enums.TicketAddCondition Cond = service.PermissionTicketUsercanCreate(); if (Cond == Domain.Enums.TicketAddCondition.CheckCount && service.TicketGetNumOpen(Usr.Id) >= Access.MaxSended) { View.ShowCantCreate(Domain.Enums.CantCreate.MaxSend); } int DraftNum = service.TicketGetNumDraft(Usr.Id); //DDL Lingue values.availableLanguages = service.LanguagesGetAvailableSys(); int CommunityId = CurrentCommunityId; //Ticket (Se draft, altrimenti nuovo!) Domain.DTO.DTO_Ticket Tk = new Domain.DTO.DTO_Ticket(); if (View.CurrentTicketId <= 0) { //Controllo se può creare nuovi Ticket (Bozze) if (!(Cond == Domain.Enums.TicketAddCondition.CanCreate || (Cond == Domain.Enums.TicketAddCondition.CheckCount && (DraftNum < Access.MaxDraft)))) { if (View.CurrentTicketId <= 0) { View.ShowCantCreate(Domain.Enums.CantCreate.MaxDraftNoSend); View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.NoPermission, CommunityId, ModuleTicket.InteractionType.None); return; } } //Creo un nuovo Ticket in BOZZA Tk = service.TicketCreateNewDraft(Usr.Id, CommunityId, View.GetDraftTitle(), View.GetDraftPreview()); values.IsNew = true; //Una volta creato, redirezione alla pagina con il ticket appena creato, per evitare problema F5. View.GotoNewTicketCreated(Tk.Code); return; } else { //Prendo il Ticket in Bozza Tk = service.TicketGetDraft(View.CurrentTicketId); } //SE Ticket == null o cercano di accedere ad un Ticket non valido //o non è possibile creare un nuovo Ticket. if (Tk == null || Tk.TicketId <= 0 || !Tk.IsDraft) { View.ShowCantCreate(Domain.Enums.CantCreate.permission); return; } //Carico Ticket (Nuovo, appena creato o precedente che sia) CommunityId = Tk.CommunityId; View.CurrentTicketId = Tk.TicketId; View.ViewCommunityId = CommunityId; View.DraftMsgId = Tk.DraftMsgId; values.TicketData = Tk; values.CurrentCommunityId = CommunityId; values.FileCommunityId = CurrentCommunityId; //Action List <KeyValuePair <int, String> > Objects = new List <KeyValuePair <int, string> >(); Objects.Add(ModuleTicket.KVPgetUser(service.UserGetIdfromPerson(UserContext.CurrentUserID))); View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.ExternalCreate, -1, ModuleTicket.InteractionType.None, Objects); //End Action values.HasOtherDraft = (values.IsNew && DraftNum > 0); this.UpdateCommunity(CommunityId, Tk.CategoryId); //USER! values.CurrentUser.UserId = Usr.Id; if (Usr.Person != null) { values.CurrentUser.PersonId = Usr.Person.Id; values.CurrentUser.Name = Usr.Person.Name; values.CurrentUser.SName = Usr.Person.Surname; values.CurrentUser.LanguageCode = Usr.LanguageCode; values.CurrentUser.Mail = Usr.Person.Mail; } else { values.CurrentUser.PersonId = 0; values.CurrentUser.Name = Usr.Name; values.CurrentUser.SName = Usr.Sname; values.CurrentUser.LanguageCode = Usr.LanguageCode; // TicketService.LangMultiCODE; //OR SYS DEFAULT!? values.CurrentUser.Mail = Usr.mail; } //Behalf if (Usr.Person != null) { values.CanBehalf = service.SettingPermissionGet(Usr.Id, Usr.Person.TypeID, Domain.Enums.PermissionType.Behalf); } else { values.CanBehalf = false; } // Notification (sono state messe qui a differenza di "Edit" in cui sono messe nel service. // SPOSTARE IN SERVICE? if (Tk.IsBehalf) { if (Tk.HideToOwner) { bool isdefaultCreator = false; values.CreatorMailSettings = service.MailSettingsGet(Usr.Id, Tk.TicketId, false, ref isdefaultCreator); values.IsDefaultNotCreator = isdefaultCreator; values.OwnerMailSettings = MailSettings.none; values.IsDefaultNotOwner = true; } else { bool isdefaultOwner = false; bool isdefaultCreator = false; values.CreatorMailSettings = service.MailSettingsGet(Usr.Id, Tk.TicketId, false, ref isdefaultCreator); values.IsDefaultNotCreator = isdefaultCreator; values.OwnerMailSettings = service.MailSettingsGet(Tk.OwnerId, Tk.TicketId, false, ref isdefaultOwner); values.IsDefaultNotOwner = isdefaultOwner; } values.IsCreatorNotificationEnable = Usr.IsNotificationActiveUser; values.IsOwnerNotificationEnable = Tk.IsOwnerNotificationActive; } else { values.OwnerMailSettings = MailSettings.none; bool isdefaultCreator = false; values.CreatorMailSettings = service.MailSettingsGet(Usr.Id, Tk.TicketId, false, ref isdefaultCreator); values.IsDefaultNotCreator = isdefaultCreator; values.IsDefaultNotOwner = true; values.IsCreatorNotificationEnable = Usr.IsNotificationActiveUser; //values.IsOwnerNotificationEnable = Usr.IsNotificationActiveUser; } values.CanListUsers = CanListUsers(UserContext.CurrentCommunityID); //Upload File comunità //Repository 4 upload int CurPersId = (Usr.Person != null) ? Usr.Person.Id : 0; lm.Comol.Core.FileRepository.Domain.ModuleRepository cRepository = service.GetRepositoryPermissions(values.FileCommunityId, CurPersId); List <RepositoryAttachmentUploadActions> actions = service.UploadAvailableActionsGet(MessageUserType.Partecipant, values.FileCommunityId, Usr.Person.Id, cRepository); //if (values.TicketData.Attachments != null && values.TicketData.Attachments.Any()) //{ // alreadyLinkedFiles = (from Domain.DTO.DTO_AttachmentItem atc in values.TicketData.Attachments // where atc.File != null && atc.Link != null // select new dtoCoreItemFileLink<long>() // { // CreatedBy = atc.CreatedBy, // CreatedOn = atc.CreatedOn, // Deleted = atc.Deleted, // ItemFileLinkId = atc.IdAttachment,//fl.Id, // StatusId = 0, // Link = atc.Link, // Owner = atc.CreatedBy, // isVisible = (atc.Deleted == BaseStatusDeleted.None && !atc.File.isDeleted), // File = atc.File // }).ToList<iCoreItemFileLink<long>>(); // //ModifiedBy = atc.ModifiedBy, // //ModifiedOn = atc.ModifiedOn, // // && fl.Visibility == Domain.Enums.FileVisibility.visible // //NO: se non è visibile, non lo è per l'utente, manager e resolver lo possono vedere E comunque non posso linkarlo nuovamente. //} RepositoryAttachmentUploadActions dAction = RepositoryAttachmentUploadActions.none; View.InitView(values, actions, dAction, cRepository, Tk.DraftMsgId); initCommunitySelector(Tk.CommunityId); }
//TODO: notification - V - test public Boolean SaveTicket(Domain.DTO.DTO_Ticket TkData, Domain.Enums.MailSettings ownerSettings, Domain.Enums.MailSettings creatorSettings, Boolean ForUpload = false) { if (!CheckSessionAccess()) { View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.NoPermission, -1, ModuleTicket.InteractionType.None); View.ShowError(Domain.Enums.TicketCreateError.NoPermission); return(false); } Domain.Enums.TicketCreateError Error = Domain.Enums.TicketCreateError.none; Domain.Enums.TicketAddCondition Cond = service.PermissionTicketUsercanCreate(); if (Cond == Domain.Enums.TicketAddCondition.CheckCount) { if (TkData.IsDraft) { if (!(service.TicketGetNumDraft(TkData.CreatorId) <= Access.MaxDraft)) { Error = Domain.Enums.TicketCreateError.ToMuchDraft; } } else { if (!(service.TicketGetNumOpen(TkData.CreatorId) <= Access.MaxSended)) { Error = Domain.Enums.TicketCreateError.ToMuchTicket; } } } else if (Cond != Domain.Enums.TicketAddCondition.CanCreate) { Error = Domain.Enums.TicketCreateError.NoPermission; } if (Error != Domain.Enums.TicketCreateError.none) { View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.NoPermission, this.CurrentCommunityId, ModuleTicket.InteractionType.None); View.ShowError(Error); return(false); } Error = service.TicketCreate(ref TkData); Boolean CanSave = false; if (Error == Domain.Enums.TicketCreateError.none) { CanSave = true; } else if (Error == Domain.Enums.TicketCreateError.NoCategory || Error == Domain.Enums.TicketCreateError.NoText || Error == Domain.Enums.TicketCreateError.NoTitle) { CanSave = ForUpload || TkData.IsDraft; } if (CanSave) { //Begin Action List <KeyValuePair <int, String> > Objects = new List <KeyValuePair <int, string> >(); Objects.Add(ModuleTicket.KVPgetUser(TkData.CreatorId)); Objects.Add(ModuleTicket.KVPgetTicket(TkData.TicketId)); if (TkData.IsDraft) { View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.TicketCreateDraft, this.CurrentCommunityId, ModuleTicket.InteractionType.UserWithLearningObject, Objects); } else { View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.TicketCreate, this.CurrentCommunityId, ModuleTicket.InteractionType.UserWithLearningObject, Objects); } //End Action //NOTIFICATION //Se DISABLED, SOLO per il creator corrente (no behalf) if (ownerSettings != MailSettings.DISABLED) { bool IsOwner = creatorSettings == MailSettings.DISABLED; service.NotificationSetTicketOwner(TkData.TicketId, ownerSettings, IsOwner); } if (creatorSettings != MailSettings.DISABLED) { service.NotificationSetTicketCreatorCurrent(TkData.TicketId, creatorSettings); } //TODO: notification - test if (!TkData.IsDraft) { SendNotification(TkData.DraftMsgId, TkData.CreatorId, ModuleTicket.NotificationActionType.TicketSend); //SE inviato il DraftMsgdiventa il Primo messaggio. //Il Creator è sempre quello che "fa fede" sulle logiche di invio. } View.TicketCreated(TkData.TicketId, TkData.IsDraft); if (!ForUpload) { this.InitView(); } } else { View.ShowError(Error); return(false); } return(true); }
public void InitView() { if (!CheckUser()) { View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.NoPermission, -1, ModuleTicket.InteractionType.None); View.ShowCantCreate(false, false); return; } IList <Domain.DTO.DTO_CategoryTree> Categories = service.CategoriesGetTreeDLL(0, CategoryTREEgetType.System); if (Categories.Count <= 0) { View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.NoPermission, -1, ModuleTicket.InteractionType.None); View.ShowCantCreate(true, false); return; } Domain.Enums.TicketAddCondition Cond = service.PermissionTicketUsercanCreateExternal(); if (Cond == Domain.Enums.TicketAddCondition.NoPermission) { View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.NoPermission, -1, ModuleTicket.InteractionType.None); View.ShowCantCreate(false, false); return; } Domain.DTO.DTO_AddInit values = new Domain.DTO.DTO_AddInit(); values.CurrentUser = View.CurrentUser; //DDL Lingue values.availableLanguages = service.LanguagesGetAvailableSys(); int CommunityId = CurrentCommunityId; // View.ViewCommunityId;//this.UserContext.CurrentCommunityID; //Ticket (Se draft, altrimenti nuovo!) Domain.DTO.DTO_Ticket Tk = new Domain.DTO.DTO_Ticket(); if (View.CurrentTicketId > 0) { //Carico Ticket precedente Tk = service.TicketGetDraft(View.CurrentTicketId, View.CurrentUser.UserId); if (Tk != null && Tk.TicketId > 0) { values.TicketData = Tk; CommunityId = Tk.CommunityId; } } else { if (Cond == Domain.Enums.TicketAddCondition.CheckCount && (service.TicketGetNumDraft(values.CurrentUser.UserId) > Access.MaxDraft)) { View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.NoPermission, -1, ModuleTicket.InteractionType.None); View.ShowCantCreate(false, true); return; } else if (Cond == Domain.Enums.TicketAddCondition.NoPermission || Cond == Domain.Enums.TicketAddCondition.NoUser) { View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.NoPermission, -1, ModuleTicket.InteractionType.None); View.ShowCantCreate(false, false); return; } //Creo un nuovo Ticket in BOZZA Tk = service.TicketCreateNewDraft(View.CurrentUser.UserId, CommunityId, View.GetDraftTitle(), View.GetDraftPreview()); values.IsNew = true; } //SE Ticket == null o cercano di accedere ad un Ticket non valido //o non è possibile creare un nuovo Ticket. if (Tk == null || Tk.TicketId <= 0) { View.ShowCantCreate(false, false); return; } View.ViewCommunityId = CommunityId; View.CurrentTicketId = Tk.TicketId; View.DraftMsgId = Tk.DraftMsgId; //Categorie disponibili - TO DO - //values.Categories = service.CategoriesGetTreeDLLSystem(CommunityId); values.CurrentCommunityId = CommunityId; //String ComName = service.GetAltCommunityName(this.UserContext.CurrentCommunityID); //if(ComName == TicketService.ComErrName) // ComName = if (values.TicketData != null && values.TicketData.CategoryId > 0) { //Domain.DTO.DTO_CategoryTree SelectedCate = service.CategoryGetDTOCatTree(values.TicketData.CategoryId); View.refreshCategory(Categories, values.TicketData.CategoryId); } else { View.refreshCategory(Categories, service.CategoryDefaultGetID()); } View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.ExternalCreate, -1, ModuleTicket.InteractionType.None); //Impostazioni notifica //notification bool isNotifDef = false; values.CreatorMailSettings = Domain.Enums.MailSettings.none; values.OwnerMailSettings = service.MailSettingsGet(View.CurrentUser.UserId, Tk.TicketId, false, ref isNotifDef); values.IsDefaultNotOwner = isNotifDef; //values.IsBehalf = Tk.IsBehalf; //values.OwnerMailSettings = service.MailSettingsGet(Tk.OwnerId, Tk.TicketId, false, ref isdefaultOwner); View.InitView(values); }
public bool SaveTicket(Domain.DTO.DTO_Ticket TkData, Boolean ForUpload = false) { if (!CheckUser()) { View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.NoPermission, -1, ModuleTicket.InteractionType.None); View.ShowCantCreate(false, false); return(false); } Domain.Enums.TicketCreateError Error = Domain.Enums.TicketCreateError.none; Domain.Enums.TicketAddCondition Cond = service.PermissionTicketUsercanCreateExternal(); if (Cond == Domain.Enums.TicketAddCondition.CheckCount) { if (TkData.IsDraft) { if (!(service.TicketGetNumDraft(TkData.CreatorId) <= Access.MaxDraft)) { Error = Domain.Enums.TicketCreateError.ToMuchDraft; } } else { if (!(service.TicketGetNumOpen(TkData.CreatorId) <= Access.MaxSended)) { Error = Domain.Enums.TicketCreateError.ToMuchTicket; } } } else if (Cond != Domain.Enums.TicketAddCondition.CanCreate) { Error = Domain.Enums.TicketCreateError.NoPermission; } if (Error != Domain.Enums.TicketCreateError.none) { View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.NoPermission, this.CurrentCommunityId, ModuleTicket.InteractionType.None); View.ShowError(Error); return(false); } //Boolean CanCreate = false; //if (Cond == Domain.Enums.TicketAddCondition.CanCreate) // CanCreate = true; //else if (Cond == Domain.Enums.TicketAddCondition.CheckCount) //{ // if (TkData.IsDraft) // { // if (service.TicketGetNumDraft(TkData.UserId) <= Access.MaxDraft) // CanCreate = true; // } // else // { // if (service.TicketGetNumOpen(TkData.UserId) <= Access.MaxSended) // CanCreate = true; // } //} //if (!CanCreate) //{ // View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.NoPermission, -1, ModuleTicket.InteractionType.None); // //View.SendAction(ModuleTicket.ActionType.NoPermission, this.CurrentCommunityId); // //View.SendAction(ModuleTicket.ActionType.NoPermission); // View.ShowCantCreate(false); // return; //} Error = service.TicketCreateExternal(View.CurrentUser, ref TkData); if (Error == Domain.Enums.TicketCreateError.none || TkData.IsDraft && Error != Domain.Enums.TicketCreateError.NoCategory) { //Begin Action List <KeyValuePair <int, String> > Objects = new List <KeyValuePair <int, string> >(); Objects.Add(ModuleTicket.KVPgetUser(TkData.CreatorId)); Objects.Add(ModuleTicket.KVPgetTicket(TkData.TicketId)); if (TkData.IsDraft) { View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.TicketCreateDraft, -1, ModuleTicket.InteractionType.UserWithLearningObject, Objects); } else { View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.TicketCreate, -1, ModuleTicket.InteractionType.UserWithLearningObject, Objects); } //End Action service.NotificationSetTicketCreatorExternal(TkData.TicketId, TkData.MailSettings, View.CurrentUser.UserId); if (!TkData.IsDraft) { SendNotification(TkData.DraftMsgId, TkData.CreatorId, ModuleTicket.NotificationActionType.TicketSend); } View.TicketCreated(TkData.TicketId, TkData.IsDraft); } else { View.ShowError(Error); return(false); } return(true); }