protected virtual List <Select> GetSelectsFromProviders()
        {
            Dictionary <string, object> parameters = new Dictionary <string, object> {
                { "sysAdminUnitId", _sysAdminUnitId },
                { "userConnection", _userConnection }
            };
            NotificationUtilities notificationUtilities = new NotificationUtilities();
            List <string>         classNames            = notificationUtilities
                                                          .GetNotificationProviderClassNames(NotificationProviderType.Visa, _userConnection);
            List <Select> selectsFromProviders = new List <Select>();

            if (classNames.Count > 0)
            {
                object[] objectParams = { parameters };
                foreach (string className in classNames)
                {
                    var    classInstance  = notificationUtilities.GetClassInstance(className, objectParams);
                    Select providerSelect = ((INotificationProvider)classInstance).GetEntitiesSelect();
                    if (providerSelect != null)
                    {
                        selectsFromProviders.Add(providerSelect);
                    }
                }
            }
            return(selectsFromProviders);
        }
Exemplo n.º 2
0
        public virtual INotificationInfo GetNotificationInfo()
        {
            var    notificationTypeName = TryGeNotificationTypeName();
            string loaderName           = GetSchemaName(UserConnection.ClientUnitSchemaManager, Entity.LoaderId);
            string schemaName           = GetSchemaName(UserConnection.EntitySchemaManager, Entity.SysEntitySchemaId);
            INotificationSettingsRepository notificationSettingsRepository = ClassFactory.Get <NotificationSettingsRepository>(
                new ConstructorArgument("userConnection", UserConnection));
            Guid notificationTypeId = Entity.NotificationTypeId;
            Guid imageId            = notificationSettingsRepository.GetNotificationImage(Entity.SysEntitySchemaId, notificationTypeId);
            Guid sysAdminUnitId     = NotificationUtilities.GetSysAdminUnitId(UserConnection, Entity.ContactId);
            var  title = Entity.PopupTitle.IsNullOrWhiteSpace() ? Entity.Description : Entity.PopupTitle;

            return(new NotificationInfo {
                Title = title,
                Body = Entity.SubjectCaption,
                ImageId = imageId,
                EntityId = Entity.SubjectId,
                EntitySchemaName = schemaName,
                MessageId = Entity.Id,
                LoaderName = loaderName,
                SysAdminUnit = sysAdminUnitId,
                GroupName = notificationTypeName,
                RemindTime = Entity.RemindTime
            });
        }
Exemplo n.º 3
0
        private Select GetSelectFromProviders()
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("sysAdminUnitId", _sysAdminUnitId);
            parameters.Add("userConnection", _userConnection);
            NotificationUtilities notificationUtilities = new NotificationUtilities();
            Select        mainSelect = null;
            List <string> classNames = notificationUtilities
                                       .GetNotificationProviderClassNames(NotificationProviderType.Visa, _userConnection);

            if (classNames.Count == 0)
            {
                return(null);
            }
            object[] objectParams = new object[] { parameters };
            foreach (string className in classNames)
            {
                var    classInstance  = notificationUtilities.GetClassInstance(className, objectParams);
                Select providerSelect = ((INotificationProvider)classInstance).GetEntitiesSelect();
                if (providerSelect != null)
                {
                    mainSelect = mainSelect == null
                                                ? providerSelect
                                                : mainSelect.UnionAll(providerSelect) as Select;
                }
            }
            return(mainSelect);
        }
        public override Select GetEntitiesSelect()
        {
            Select sysAdminUnitInRoleSelect = GetSysAdminUnitInRoleSelect();
            ISchemaManagerItem <EntitySchema> invoiceEntitySchema =
                UserConnection.EntitySchemaManager.FindItemByName(InvoiceSchemaName);
            Guid sysImage = GetNotificationImage(InvoiceVisaSchemaName, RemindingConsts.NotificationTypeRemindingId);

            Guid[]    finallyStatuses = NotificationUtilities.GetFinallyVisaStatuses(UserConnection);
            string    invoiceCaption  = invoiceEntitySchema.Caption;
            QueryCase queryCase       = GetQueryCase();
            var       entitiesSelect  = new Select(UserConnection)
                                        .Column(InvoiceVisaSchemaName, "Id")
                                        .Column(InvoiceVisaSchemaName, "CreatedOn")
                                        .Column(InvoiceVisaSchemaName, "CreatedById")
                                        .Column(InvoiceVisaSchemaName, "ModifiedOn")
                                        .Column(InvoiceVisaSchemaName, "ModifiedById")
                                        .Column(InvoiceVisaSchemaName, "ProcessListeners")
                                        .Column(InvoiceVisaSchemaName, "Objective")
                                        .Column(queryCase).As("VisaOwnerId")
                                        .Column(InvoiceVisaSchemaName, "IsAllowedToDelegate")
                                        .Column(InvoiceVisaSchemaName, "DelegatedFromId")
                                        .Column(InvoiceVisaSchemaName, "StatusId")
                                        .Column(InvoiceVisaSchemaName, "SetById")
                                        .Column(InvoiceVisaSchemaName, "SetDate")
                                        .Column(InvoiceVisaSchemaName, "IsCanceled")
                                        .Column(InvoiceVisaSchemaName, "Comment")
                                        .Column(Column.Parameter(InvoiceSchemaName)).As("VisaSchemaName")
                                        .Column(InvoiceSchemaName, "Number").As("Title")
                                        .Column(InvoiceSchemaName, "Id").As("VisaObjectId")
                                        .Column(InvoiceSchemaName, "StartDate").As("Date")
                                        .Column("Account", "Name").As("Account")
                                        .Column("Contact", "Name").As("Contact")
                                        .Column(Column.Parameter(Guid.Empty)).As("VisaSchemaTypeId")
                                        .Column(Column.Parameter(string.Empty)).As("VisaTypeName")
                                        .Column(Column.Parameter(invoiceCaption)).As("VisaSchemaCaption")
                                        .Column(Column.Parameter(InvoiceSchemaName)).As("SchemaName")
                                        .Column(Column.Parameter(sysImage)).As("ImageId")
                                        .Distinct()
                                        .From(InvoiceVisaSchemaName)
                                        .InnerJoin(InvoiceSchemaName).On(InvoiceSchemaName, "Id").IsEqual(InvoiceVisaSchemaName, "InvoiceId")
                                        .InnerJoin(sysAdminUnitInRoleSelect).As("SysAdminUnitRole")
                                        .On(InvoiceVisaSchemaName, "VisaOwnerId").IsEqual("SysAdminUnitRole", "SysAdminUnitRoleId")
                                        .LeftOuterJoin("SysUserInRole")
                                        .On("SysUserInRole", "SysRoleId").IsEqual("SysAdminUnitRole", "SysAdminUnitId")
                                        .LeftOuterJoin("Account").On("Account", "Id").IsEqual(InvoiceSchemaName, "AccountId")
                                        .LeftOuterJoin("Contact").On("Contact", "Id").IsEqual(InvoiceSchemaName, "ContactId")
                                        .Where(InvoiceVisaSchemaName, "VisaOwnerId").In(
                new Select(UserConnection).Column("SysAdminUnitRoleId").From("SysAdminUnitInRole")
                .Where("SysAdminUnitId").IsEqual(Column.Parameter(_sysAdminUnit)))
                                        .And(InvoiceVisaSchemaName, "StatusId").Not().In(Column.Parameters(finallyStatuses))
                                        .And(InvoiceVisaSchemaName, "IsCanceled").IsEqual(Column.Parameter(false)) as Select;

            return(entitiesSelect);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Returns <see cref="Select"/> of entity./>
        /// </summary>
        /// <returns>A <see cref="Select"/> instance.</returns>
        public override Select GetEntitiesSelect()
        {
            Select sysAdminUnitInRoleSelect = GetSysAdminUnitInRoleSelect();

            Guid[]    finallyStatuses = NotificationUtilities.GetFinallyVisaStatuses(UserConnection);
            QueryCase queryCase       = GetVisaOwnerQueryCase();
            var       entitiesSelect  = new Select(UserConnection)
                                        .Distinct()
                                        .Column(Visa, "Id")
                                        .Column(Visa, "CreatedOn")
                                        .Column(Visa, "CreatedById")
                                        .Column(Visa, "ModifiedOn")
                                        .Column(Visa, "ModifiedById")
                                        .Column(Visa, "ProcessListeners")
                                        .Column(Visa, "Objective").As("Objective")
                                        .Column(queryCase).As("VisaOwnerId")
                                        .Column(Visa, "IsAllowedToDelegate")
                                        .Column(Visa, "DelegatedFromId")
                                        .Column(Visa, "StatusId")
                                        .Column(Visa, "SetById")
                                        .Column(Visa, "SetDate").As("SetDate")
                                        .Column(Visa, "IsCanceled")
                                        .Column(Visa, "Comment")
                                        .Column(Column.Parameter(Visa)).As("VisaSchemaName")
                                        .Column(Name, TitleColumn).As("Title")
                                        .Column(Name, "Id").As("VisaObjectId")
                                        .Column(Visa, "CreatedOn").As("Date")
                                        .Column(Column.Parameter(string.Empty)).As("Account")
                                        .Column(Column.Parameter(string.Empty)).As("Contact")
                                        .Column(Column.Parameter(Guid.Empty)).As("VisaSchemaTypeId")
                                        .Column(Column.Parameter(string.Empty)).As("VisaTypeName")
                                        .Column(Column.Parameter(Caption)).As("VisaSchemaCaption")
                                        .Column(Column.Parameter(Name)).As("SchemaName")
                                        .Column(Column.Parameter(ImageId)).As("ImageId")
                                        .From(Visa)
                                        .InnerJoin(Name).On(Name, "Id").IsEqual(Visa, VisaMasterColumn)
                                        .InnerJoin(sysAdminUnitInRoleSelect).As("SysAdminUnitRole")
                                        .On(Visa, "VisaOwnerId").IsEqual("SysAdminUnitRole", "SysAdminUnitRoleId")
                                        .LeftOuterJoin("SysUserInRole")
                                        .On("SysUserInRole", "SysRoleId").IsEqual("SysAdminUnitRole", "SysAdminUnitId")
                                        .Where(Visa, "VisaOwnerId").In(
                new Select(UserConnection).Column("SysAdminUnitRoleId").From("SysAdminUnitInRole")
                .Where("SysAdminUnitId").IsEqual(Column.Parameter(_sysAdminUnit)))
                                        .And().OpenBlock(Visa, "StatusId").Not().In(Column.Parameters(finallyStatuses))
                                        .Or(Visa, "StatusId").IsNull()
                                        .CloseBlock()
                                        .And(Visa, "IsCanceled").IsEqual(Column.Parameter(false)) as Select;

            return(entitiesSelect);
        }
        protected override INotificationInfo GetRecordNotificationInfo(Dictionary <string, string> dictionaryColumnValues)
        {
            Guid imageId = NotificationUtilities.GetSysImageBySchemaName(UserConnection, dictionaryColumnValues["EntitySchemaName"]);

            return(new NotificationInfo()
            {
                Title = dictionaryColumnValues["Description"],
                Body = dictionaryColumnValues["SubjectCaption"],
                ImageId = imageId,
                EntityId = new Guid(dictionaryColumnValues["EntityId"]),
                EntitySchemaName = dictionaryColumnValues["EntitySchemaName"],
                MessageId = new Guid(dictionaryColumnValues["Id"]),
                LoaderName = dictionaryColumnValues["LoaderName"],
                SysAdminUnit = new Guid(dictionaryColumnValues["SysAdminUnitId"]),
                GroupName = Group
            });
        }
Exemplo n.º 7
0
        protected override INotificationInfo GetRecordNotificationInfo(Dictionary <string, string> dictionaryColumnValues)
        {
            string body          = GetBody(dictionaryColumnValues);
            Guid   imageId       = NotificationUtilities.GetSysImageBySchemaName(UserConnection, "Invoice");
            string titleTemplate = UserConnection.GetLocalizableString("InvoiceNotificationProvider", "TitleTemplate");

            return(new NotificationInfo()
            {
                Title = titleTemplate,
                Body = body,
                ImageId = imageId,
                EntityId = new Guid(dictionaryColumnValues["InvoiceId"]),
                EntitySchemaName = "Invoice",
                MessageId = new Guid(dictionaryColumnValues["Id"]),
                SysAdminUnit = new Guid(dictionaryColumnValues["SysAdminUnitId"]),
                GroupName = Group
            });
        }
        protected override INotificationInfo GetRecordNotificationInfo(Dictionary <string, string> dictionaryColumnValues)
        {
            string body    = GetBody(dictionaryColumnValues);
            string title   = GetTitle(dictionaryColumnValues);
            Guid   imageId = NotificationUtilities.GetSysImageBySchemaName(UserConnection, "Forecast");

            return(new NotificationInfo()
            {
                Title = title,
                Body = body,
                ImageId = imageId,
                EntityId = new Guid(dictionaryColumnValues["EntityId"]),
                EntitySchemaName = "Forecast",
                MessageId = new Guid(dictionaryColumnValues["Id"]),
                SysAdminUnit = new Guid(dictionaryColumnValues["SysAdminUnitId"]),
                GroupName = Group
            });
        }
Exemplo n.º 9
0
        protected override void AddColumns(Select select)
        {
            Guid sysImage = NotificationUtilities.GetSysImageBySchemaName(UserConnection, InvoiceVisaSchemaName);

            select
            .Column(InvoiceVisaSchemaName, "Id").As("Id")
            .Column(InvoiceVisaSchemaName, "Objective").As("Objective")
            .Column(InvoiceVisaSchemaName, "StatusId").As("StatusId")
            .Column(InvoiceVisaSchemaName, "IsCanceled").As("IsCanceled")
            .Column(InvoiceVisaSchemaName, "VisaOwnerId").As("SysAdminUnitId")
            .Column(Column.Parameter(InvoiceSchemaName)).As("VisaSchemaName")
            .Column(InvoiceSchemaName, "Number").As("Title")
            .Column(InvoiceSchemaName, "Id").As("VisaObjectId")
            .Column(InvoiceSchemaName, "StartDate").As("Date")
            .Column("Account", "Name").As("Account")
            .Column("Contact", "Name").As("Contact")
            .Column(Column.Parameter(InvoiceSchemaName)).As("SchemaName")
            .Column(Column.Parameter(sysImage)).As("ImageId");
        }
Exemplo n.º 10
0
        public virtual void PublishClientNotificationInfo(string operation)
        {
            var contactId    = Entity.OwnerId;
            var sysAdminUnit = NotificationUtilities.GetSysAdminUnitId(UserConnection, contactId);
            var message      = new {
                recordId = Entity.Id,
                operation,
                notificationGroup = "ESNNotification",
                markAsRead        = Entity.IsRead
            };
            var simpleMessage = new SimpleMessage {
                Body = JsonConvert.SerializeObject(message),
                Id   = sysAdminUnit
            };

            simpleMessage.Header.Sender = "UpdateReminding";
            var manager = MsgChannelManager.Instance;
            var channel = manager.FindItemByUId(sysAdminUnit);

            channel?.PostMessage(simpleMessage);
        }
Exemplo n.º 11
0
 protected override void AddConditions(Select select)
 {
     Guid[] finallyStatuses = NotificationUtilities.GetFinallyVisaStatuses(UserConnection);
     select.Where(OrderVisaSchemaName, "StatusId").Not().In(Column.Parameters(finallyStatuses))
     .And(OrderVisaSchemaName, "IsCanceled").IsEqual(Column.Parameter(false));
 }
Exemplo n.º 12
0
 public virtual bool IsFinalStatus(Guid statusId)
 {
     Guid[] finallyStatuses = NotificationUtilities.GetFinallyVisaStatuses(UserConnection);
     return(finallyStatuses.Contains(statusId));
 }