Ejemplo n.º 1
0
        /// <summary>
        /// ####### ########### ############.
        /// </summary>
        /// <param name="userConnection">######### ################# ###########.</param>
        /// <param name="entity">######, ## ######## ##### ####### ###########.</param>
        /// <param name="description">##### ###########.</param>
        /// <param name="schemaCaption">######### ######### ###### ###########.</param>
        public static void CreateReminding(
            UserConnection userConnection, Entity entity, string description, string schemaCaption = "")
        {
            Reminding remindingEntity = new Reminding(userConnection);
            string    subject         = entity.PrimaryDisplayColumnValue;
            DateTime  userDateTime    = userConnection.CurrentUser.GetCurrentDateTime();
            Guid      userContactId   = userConnection.CurrentUser.ContactId;
            var       condition       = new Dictionary <string, object> {
                {
                    "Author", userContactId
                }, {
                    "Contact", userContactId
                }, {
                    "Source", RemindingConsts.RemindingSourceAuthorId
                }, {
                    "SubjectCaption", subject
                }, {
                    "SysEntitySchema", entity.Schema.UId
                },
            };
            string hash = GetRemindingHash(condition);

            if (!string.IsNullOrEmpty(description))
            {
                subject = string.Format("{0} \"{1}\" {2}",
                                        string.IsNullOrEmpty(schemaCaption) ? entity.Schema.Caption.Value : schemaCaption,
                                        entity.PrimaryDisplayColumnValue,
                                        description);
            }
            if (!remindingEntity.FetchFromDB(new Dictionary <string, object> {
                { "Hash", hash }
            }, false))
            {
                remindingEntity.SetDefColumnValues();
            }
            description = TruncateString(subject, DescriptionTypeStringLength);
            subject     = TruncateString(subject, SubjectCaptionTypeStringLength);
            remindingEntity.SetColumnValue("ModifiedOn", userDateTime);
            remindingEntity.SetColumnValue("AuthorId", userContactId);
            remindingEntity.SetColumnValue("ContactId", userContactId);
            remindingEntity.SetColumnValue("SourceId", RemindingConsts.RemindingSourceAuthorId);
            remindingEntity.SetColumnValue("RemindTime", userDateTime);
            remindingEntity.SetColumnValue("Description", description);
            remindingEntity.SetColumnValue("SubjectCaption", subject);
            remindingEntity.SetColumnValue("Hash", hash);
            remindingEntity.SetColumnValue("SysEntitySchemaId", entity.Schema.UId);
            remindingEntity.SetColumnValue("SubjectId", entity.PrimaryColumnValue);
            remindingEntity.Save();
        }
Ejemplo n.º 2
0
        public static void CreateReminding(UserConnection userConnection, string description, Guid sysEntitySchemaId)
        {
            DateTime  userDateTime    = userConnection.CurrentUser.GetCurrentDateTime();
            Guid      userContactId   = userConnection.CurrentUser.ContactId;
            Reminding remindingEntity = new Reminding(userConnection);

            remindingEntity.SetDefColumnValues();
            string subject = TruncateString(description, SubjectCaptionTypeStringLength);

            description = TruncateString(description, DescriptionTypeStringLength);
            remindingEntity.SetColumnValue("AuthorId", userContactId);
            remindingEntity.SetColumnValue("ContactId", userContactId);
            remindingEntity.SetColumnValue("SourceId", RemindingConsts.RemindingSourceAuthorId);
            remindingEntity.SetColumnValue("RemindTime", userDateTime);
            remindingEntity.SetColumnValue("Description", description);
            remindingEntity.SetColumnValue("SubjectCaption", subject);
            remindingEntity.SetColumnValue("SysEntitySchemaId", sysEntitySchemaId);
            remindingEntity.SetColumnValue("SubjectId", Guid.Empty);
            remindingEntity.Save();
        }
        /// <inheritdoc cref="IDeduplicationRemindingRepository.CreateReminding"/>>
        public void CreateReminding(UserConnection userConnection, string remindingDesription,
                                    string remindingSubject, string schemaName)
        {
            Reminding remindingEntity = new Reminding(userConnection);
            var       manager         = userConnection.GetSchemaManager("EntitySchemaManager");
            var       targetSchema    = manager.FindItemByName(schemaName);

            manager = userConnection.GetSchemaManager("ClientUnitSchemaManager");
            var      loaderSchema  = manager.FindItemByName("DuplicatesSearchNotificationTargetLoader");
            var      subject       = schemaName;
            DateTime userDateTime  = userConnection.CurrentUser.GetCurrentDateTime();
            Guid     userContactId = userConnection.CurrentUser.ContactId;
            var      condition     = new Dictionary <string, object> {
                {
                    "Author", userContactId
                }, {
                    "Contact", userContactId
                }, {
                    "Source", RemindingConsts.RemindingSourceAuthorId
                }, {
                    "SubjectCaption", subject
                }, {
                    "SysEntitySchema", targetSchema.UId
                },
            };
            string description = remindingDesription;
            string hash        = GetRemindingHash(condition);

            subject = remindingSubject;
            if (!remindingEntity.FetchFromDB(new Dictionary <string, object> {
                { "Hash", hash }
            }, false))
            {
                remindingEntity.SetDefColumnValues();
            }
            subject = TruncateString(subject, SubjectCaptionTypeStringLength);
            remindingEntity.SetColumnValue("ModifiedOn", userDateTime);
            remindingEntity.SetColumnValue("AuthorId", userContactId);
            remindingEntity.SetColumnValue("ContactId", userContactId);
            remindingEntity.SetColumnValue("SourceId", RemindingConsts.RemindingSourceAuthorId);
            remindingEntity.SetColumnValue("RemindTime", userDateTime);
            remindingEntity.SetColumnValue("Description", description);
            remindingEntity.SetColumnValue("SubjectCaption", subject);
            remindingEntity.SetColumnValue("NotificationTypeId", RemindingConsts.NotificationTypeNotificationId);
            remindingEntity.SetColumnValue("Hash", hash);
            remindingEntity.SetColumnValue("SysEntitySchemaId", targetSchema.UId);
            remindingEntity.SetColumnValue("LoaderId", loaderSchema.UId);
            remindingEntity.SetColumnValue("IsRead", false);
            remindingEntity.Save();
        }