Esempio n. 1
0
        public void AddChannelSetting(lm.Comol.Core.Notification.Domain.NotificationChannel channel, List <dtoChannelConfigurator> items)
        {
            View.HideUserMessage();
            if (UserContext.isAnonymous)
            {
                Logout(View.CurrentType, View.IdTemplate, View.IdVersion);
            }
            else
            {
                dtoChannelConfigurator config = Service.GetDraftChannelConfigurator(channel, View.CurrentType, 0);
                if (config == null)
                {
                    View.DisplayTemplateUnableToAddNotificationChannel();
                }
                else
                {
                    List <lm.Comol.Core.Notification.Domain.NotificationChannel> channels = Service.GetAvailableChannels(View.CurrentType, View.IdVersion);
                    channels.Remove(channel);
                    channels = channels.Where(t => !items.Where(i => i.Channel == t).Any()).ToList();

                    //config.AvailableModuleCodes = View.GetModuleCodesForNotification().Select(m => m.Key).ToList();
                    items.Add(config);
                    //UpdateInUseSettings(items);
                    View.ChannelSettings = items;
                    View.LoadChannelSettings(items);
                    View.LoadChannels(channels);
                    View.SendUserAction(View.IdTemplateCommunity, Service.ServiceModuleID(), ModuleTemplateMessages.ActionType.AddNotificationSetting);
                }
            }
        }
Esempio n. 2
0
 private void LoadItems(ModuleGenericTemplateMessages permissions, lm.Comol.Core.Notification.Domain.NotificationChannel channel, dtoTemplateItem current, dtoSelectorContext context, long idTemplate, long idVersion, List <dtoTemplateItem> items = null)
 {
     if (items == null)
     {
         items = Service.GetAvailableTemplates(permissions, context, idTemplate, idVersion, channel);
     }
     if (items.Count == 0)
     {
         View.LoadEmptyTemplate();
         View.AllowPreview = false;
         View.AllowSelect  = false;
     }
     else
     {
         View.LoadTemplates(items);
     }
 }
Esempio n. 3
0
        public void InitView(ModuleGenericTemplateMessages permissions, lm.Comol.Core.Notification.Domain.NotificationChannel channel, dtoSelectorContext context, long idTemplate, long idVersion, Boolean isVerifyed = false, List <dtoTemplateItem> items = null)
        {
            View.isInitialized = true;
            if (!isVerifyed)
            {
                if (context.IdModule <= 0 && !String.IsNullOrEmpty(context.ModuleCode))
                {
                    context.IdModule = CurrentManager.GetModuleID(context.ModuleCode);
                }
                if (context.IdModule > 0 && String.IsNullOrEmpty(context.ModuleCode))
                {
                    context.ModuleCode = CurrentManager.GetModuleCode(context.IdModule);
                }
                context.IsForPortal = (context.IsForPortal && context.IdCommunity == 0 && context.IdOrganization == 0);
                if (context.IdOrganizationCommunity <= 0)
                {
                    if (context.IdOrganization > 0)
                    {
                        context.IdOrganizationCommunity = CurrentManager.GetIdCommunityFromOrganization(context.IdOrganization);
                    }
                    else if (context.IdCommunity > 0 && context.IdOrganization <= 0)
                    {
                        Community community = CurrentManager.GetCommunity(context.IdCommunity);
                        context.IdOrganizationCommunity = (community == null) ? 0 : ((community.IdFather == 0) ? community.Id : CurrentManager.GetIdCommunityFromOrganization(community.IdOrganization));
                    }
                }
            }
            dtoTemplateItem current = Service.GetDefaultAutomaticTemplate(context, channel);

            if (UserContext.isAnonymous)
            {
                LoadCurrentTemplate(current);
                View.AllowPreview = false;
                View.AllowSelect  = false;
            }
            else
            {
                LoadItems(permissions, channel, current, context, idTemplate, idVersion, items);
            }
        }
Esempio n. 4
0
        public void InitView(ModuleGenericTemplateMessages permissions, lm.Comol.Core.Notification.Domain.NotificationChannel channel, long idAction, Int32 idModule, String moduleCode, Int32 idCommunty, Int32 idOrganization = 0, Boolean forPortal = false, long idTemplate = 0, long idVersion = 0, lm.Comol.Core.DomainModel.ModuleObject obj = null, List <dtoTemplateItem> items = null)
        {
            dtoSelectorContext c = new dtoSelectorContext();

            c.IdAction       = idAction;
            c.IdModule       = (idModule > 0) ? idModule : (!String.IsNullOrEmpty(moduleCode) ? CurrentManager.GetModuleID(moduleCode) : 0);
            c.ModuleCode     = (!String.IsNullOrEmpty(moduleCode)) ? moduleCode : (idModule > 0 ? CurrentManager.GetModuleCode(idModule) : "");
            c.IdCommunity    = idCommunty;
            c.IdOrganization = idOrganization;
            if (idCommunty > 0 && idOrganization <= 0)
            {
                Community community = CurrentManager.GetCommunity(idCommunty);
                c.IdOrganizationCommunity = (community == null) ? 0 : ((community.IdFather == 0) ? community.Id : CurrentManager.GetIdCommunityFromOrganization(community.IdOrganization));
            }
            else if (idOrganization > 0)
            {
                c.IdOrganizationCommunity = CurrentManager.GetIdCommunityFromOrganization(idOrganization);
            }
            c.IsForPortal = (forPortal && idCommunty == 0 && idOrganization == 0);
            c.ObjectOwner = obj;
            InitView(permissions, channel, c, idTemplate, idVersion, true, items);
        }
Esempio n. 5
0
 public System.Threading.Tasks.Task NotifyActionAsync(string istanceIdentifier, lm.Comol.Core.Notification.Domain.NotificationChannel channel, lm.Comol.Core.Notification.Domain.NotificationMode mode, lm.Comol.Core.Notification.Domain.NotificationAction action, int idSenderUser, string ipAddress, string proxyIpAddress)
 {
     return(base.Channel.NotifyActionAsync(istanceIdentifier, channel, mode, action, idSenderUser, ipAddress, proxyIpAddress));
 }
Esempio n. 6
0
 public void NotifyAction(string istanceIdentifier, lm.Comol.Core.Notification.Domain.NotificationChannel channel, lm.Comol.Core.Notification.Domain.NotificationMode mode, lm.Comol.Core.Notification.Domain.NotificationAction action, int idSenderUser, string ipAddress, string proxyIpAddress)
 {
     base.Channel.NotifyAction(istanceIdentifier, channel, mode, action, idSenderUser, ipAddress, proxyIpAddress);
 }
 public dtoNotificationMessages(lm.Comol.Core.Notification.Domain.NotificationChannel channel)
 {
     Channel = channel;
 }
Esempio n. 8
0
        public List <lm.Comol.Core.TemplateMessages.Domain.CommonNotificationSettings> SaveNotificationSettings(TemplateLevel level, List <lm.Comol.Core.BaseModules.TemplateMessages.Domain.dtoModuleEvent> settings, Boolean forPortal, Int32 idCommunity, Int32 idOrganization, ModuleObject obj = null, lm.Comol.Core.Notification.Domain.NotificationChannel channel = lm.Comol.Core.Notification.Domain.NotificationChannel.Mail, lm.Comol.Core.Notification.Domain.NotificationMode mode = lm.Comol.Core.Notification.Domain.NotificationMode.Automatic)
        {
            List <lm.Comol.Core.TemplateMessages.Domain.CommonNotificationSettings> items = new List <lm.Comol.Core.TemplateMessages.Domain.CommonNotificationSettings>();

            try
            {
                Manager.BeginTransaction();
                litePerson p = Manager.GetLitePerson(UC.CurrentUserID);
                if (p != null && p.TypeID != (int)UserTypeStandard.Guest)
                {
                    List <lm.Comol.Core.TemplateMessages.Domain.CommonNotificationSettings> inUse = null;
                    if (obj == null)
                    {
                        inUse = (from n in Manager.GetIQ <lm.Comol.Core.TemplateMessages.Domain.CommonNotificationSettings>()
                                 where n.Settings.Channel == channel && n.Settings.Mode == mode && n.Settings.ActionType != lm.Comol.Core.Notification.Domain.NotificationActionType.Ignore && n.Settings.ActionType != lm.Comol.Core.Notification.Domain.NotificationActionType.None &&
                                 (n.ObjectOwner == null || (idCommunity != -1 && (idCommunity == n.IdCommunity)) || (idOrganization != -1 && idOrganization == n.IdOrganization) || n.IsForPortal)
                                 select n).ToList();
                    }
                    else
                    {
                        inUse = (from n in Manager.GetIQ <lm.Comol.Core.TemplateMessages.Domain.CommonNotificationSettings>()
                                 where n.Settings.Channel == channel && n.Settings.Mode == mode && n.Settings.ActionType != lm.Comol.Core.Notification.Domain.NotificationActionType.Ignore && n.Settings.ActionType != lm.Comol.Core.Notification.Domain.NotificationActionType.None &&
                                 (
                                     (n.ObjectOwner != null && n.ObjectOwner.ObjectLongID == obj.ObjectLongID && n.ObjectOwner.ObjectTypeID == obj.ObjectTypeID && n.ObjectOwner.ServiceCode == obj.ServiceCode) ||
                                     (idCommunity != -1 && (idCommunity == n.IdCommunity)) || (idOrganization != -1 && idOrganization == n.IdOrganization) || n.IsForPortal
                                 )
                                 select n).ToList();
                    }
                    Dictionary <String, Int32> mInfo = Manager.GetIdModules(settings.Select(s => s.ModuleCode).Distinct().ToList());
                    foreach (lm.Comol.Core.BaseModules.TemplateMessages.Domain.dtoModuleEvent setting in settings)
                    {
                        CommonNotificationSettings current = null;
                        var query = inUse.Where(n => n.Settings.IdModuleAction == setting.IdEvent && n.Settings.ModuleCode == setting.ModuleCode);
                        if (obj == null)
                        {
                            query = query.Where(n => n.ObjectOwner == null);
                        }
                        else
                        {
                            query = query.Where(n => (n.ObjectOwner != null && n.ObjectOwner.ObjectLongID == obj.ObjectLongID && n.ObjectOwner.ObjectTypeID == obj.ObjectTypeID && n.ObjectOwner.ServiceCode == obj.ServiceCode));
                        }
                        switch (level)
                        {
                        case TemplateLevel.Portal:
                            #region "Portal Saving Settings"
                            current = query.Where(n => n.IsForPortal && n.ObjectOwner == null).FirstOrDefault();
                            if (current == null && setting.IdTemplate > 0)
                            {
                                current = new CommonNotificationSettings();
                                current.CreateMetaInfo(p, UC.IpAddress, UC.ProxyIpAddress);
                                current.IsEnabled               = true;
                                current.IsForPortal             = true;
                                current.Settings.ActionType     = lm.Comol.Core.Notification.Domain.NotificationActionType.BySystem;
                                current.Settings.Channel        = channel;
                                current.Settings.IdModule       = (mInfo.ContainsKey(setting.ModuleCode) ? mInfo[setting.ModuleCode]: 0);
                                current.Settings.IdModuleAction = setting.IdEvent;
                                current.Settings.Mode           = mode;
                                current.Settings.ModuleCode     = setting.ModuleCode;
                            }
                            else if (current != null && (current.Deleted == BaseStatusDeleted.None || (setting.IdTemplate > 0 && current.Deleted != BaseStatusDeleted.None)))
                            {
                                current.UpdateMetaInfo(p, UC.IpAddress, UC.ProxyIpAddress);
                            }
                            if (current != null)
                            {
                                current.Deleted = (setting.IdTemplate > 0) ?  BaseStatusDeleted.None: BaseStatusDeleted.Manual;
                                if (setting.IdTemplate > 0)
                                {
                                    current.AlwaysLastVersion = (setting.IdVersion == 0);
                                    current.Template          = Manager.Get <TemplateDefinition>(setting.IdTemplate);
                                    current.Version           = (setting.IdVersion == 0) ? null : Manager.Get <TemplateDefinitionVersion>(setting.IdVersion);
                                }
                                Manager.SaveOrUpdate(current);
                                items.Add(current);
                            }
                            #endregion
                            break;

                        case TemplateLevel.Organization:
                            //#region "Organization Saving Settings"
                            //if (setting.IdTemplate > 0) {
                            //    if (setting.ItemLevel== TemplateLevel.Organization)

                            //}
                            //if (setting.IdTemplate<=0){
                            //    // rimuovo
                            //}
                            //current = query.Where(n=>!n.IsForPortal && && n.ObjectOwner==null).FirstOrDefault();
                            //if (current == null && setting.IdTemplate>0)
                            //{
                            //    current = new CommonNotificationSettings();
                            //    current.CreateMetaInfo(p, UC.IpAddress, UC.ProxyIpAddress);
                            //    current.IsEnabled = true;
                            //    current.IsForPortal = true;
                            //    current.Settings.ActionType = NotificationActionType.BySystem;
                            //    current.Settings.Channel = channel;
                            //    current.Settings.IdModule= (mInfo.ContainsKey(setting.ModuleCode) ? mInfo[setting.ModuleCode]: 0);
                            //    current.Settings.IdModuleAction= setting.IdEvent;
                            //    current.Settings.Mode= mode;
                            //    current.Settings.ModuleCode= setting.ModuleCode;
                            //}
                            //else if (current != null && (current.Deleted== BaseStatusDeleted.None || (setting.IdTemplate>0 && current.Deleted!= BaseStatusDeleted.None)))
                            //    current.UpdateMetaInfo(p, UC.IpAddress, UC.ProxyIpAddress);
                            //if (current != null) {
                            //    current.Deleted =(setting.IdTemplate>0) ?  BaseStatusDeleted.None: BaseStatusDeleted.Manual;
                            //    if (setting.IdTemplate>0){
                            //        current.AlwaysLastVersion = (setting.IdVersion == 0);
                            //        current.Template = Manager.Get<TemplateDefinition>(setting.IdTemplate);
                            //        current.Version = (setting.IdVersion == 0) ? null : Manager.Get<TemplateDefinitionVersion>(setting.IdVersion);
                            //    }
                            //    Manager.SaveOrUpdate(current);
                            //    items.Add(current);
                            //}
                            //#endregion
                            break;
                        }
                    }
                }
                else
                {
                    items = null;
                }
                Manager.Commit();
            }
            catch (Exception ex) {
                Manager.RollBack();
                items = null;
            }
            return(items);
        }