/// <summary>
        /// Obtains language identifier from support mailbox, that set in system setting.
        /// </summary>
        /// <inheritdoc />
        public override Guid GetLanguageId(Guid entityRecordId)
        {
            Guid defaultLanguageMessageId = SystemSettings.GetValue(UserConnection, DefaultMessageLanguageCode,
                                                                    default(Guid));

            return(defaultLanguageMessageId);
        }
Esempio n. 2
0
        public string GenerateCode(UserConnection userConnection)
        {
            var codeMask   = SystemSettings.GetValue(userConnection, "UsrPeriodicalPublicationCodeMask").ToString();
            var lastNumber = SystemSettings.GetValue(userConnection, "UsrPeriodicalPublicationLastNumber").ToString();

            SystemSettings.SetValue(userConnection, "UsrPeriodicalPublicationLastNumber", int.Parse(lastNumber) + 1);
            return(string.Format(codeMask, int.Parse(lastNumber)));
        }
Esempio n. 3
0
        /// <summary>
        /// Close case entity whether condition of predicate is correct.
        /// </summary>
        /// <param name="entity">Case entity.</param>
        /// <param name="predicate">Predicate to check the condition for case closing.</param>
        /// <param name="needFetch">Need reload entity from database.</param>
        /// <returns>Is case saved.</returns>
        public virtual bool CloseOnCondition(Entity entity, Predicate <Entity> predicate,
                                             bool needFetch = false)
        {
            var userConnection = entity.UserConnection;
            var closureCodeId  = SystemSettings.GetValue(userConnection,
                                                         "CaseClosureCodeDef", Guid.Empty);

            return(CloseOnCondition(entity, predicate, CaseConsts.CaseStatusClosedId, closureCodeId, needFetch));
        }
 public CaseMessageListener(UserConnection userConnection) : base(userConnection)
 {
     HistorySchemaName = "CaseMessageHistory";
     HistorySchemaReferenceColumnName = "CaseId";
     ListenerSchemaUId                = CaseConsts.CaseSchemaUId;
     NeedCheckExistenceOfRecord       = true;
     _userConnection                  = userConnection;
     _casePortalNotificationProcessId = SystemSettings.GetValue <Guid>(userConnection,
                                                                       "CasePortalMessageMultiLanguageProcess", Guid.Empty);
 }
Esempio n. 5
0
        /// <summary>
        /// Provides language identifier from mailboxes for incident registration.
        /// </summary>
        /// <param name="caseEntityRecordId">Case entity identifier.</param>
        /// <inheritdoc />
        public override Guid GetLanguageId(Guid caseEntityRecordId)
        {
            string supportServiceEmail = SystemSettings.GetValue(UserConnection,
                                                                 DefaultSupportServiceEmailCode, string.Empty);

            if (!string.IsNullOrEmpty(supportServiceEmail))
            {
                Guid languageId = GetLanguageId(supportServiceEmail);
                return(languageId);
            }
            return(Guid.Empty);
        }
Esempio n. 6
0
 /// <summary><see cref="ExchangeClient"/> ctor.</summary>
 /// <param name="userConnection">An instance of the user connection.</param>
 /// <param name="emailCredentials">An instance of the user email credentials.</param>
 public ExchangeClient(UserConnection userConnection, EmailContract.DTO.Credentials emailCredentials)
     : this(userConnection) {
     _credentials = new ExchangeCredentials {
         UserName       = emailCredentials.UserName,
         UserPassword   = emailCredentials.Password,
         IsAutodiscover = emailCredentials.IsAutodiscover,
         ServerAddress  = emailCredentials.ServiceUrl,
         UseOAuth       = emailCredentials.UseOAuth
     };
     ServicePointManager.ServerCertificateValidationCallback += ValidateRemoteCertificate;
     _ignoreSslWarnings = (bool)SysSettings.GetValue(userConnection, "IgnoreExchangeSSLWarnings", false);
 }
Esempio n. 7
0
 /// <summary>
 /// Sets current synchronization version.
 /// </summary>
 /// <param name="userConnection"><see cref="UserConnection"/> instance.</param>
 /// <remarks>In order to detect appointment delete in exchange calendar, we need to check all
 /// synced appointments for some period. Default period for this operation is seven days,
 /// also it can be changed using DeleteAppointmentsSyncDays setting.</remarks>
 private void SetVersion(UserConnection userConnection)
 {
     Version = UserSettings.LastSyncDate < UserSettings.ImportActivitiesFrom
                         ? UserSettings.ImportActivitiesFrom
                         : UserSettings.LastSyncDate;
     if (userConnection.GetIsFeatureEnabled("SyncDeletedAppointments"))
     {
         var deleteAppointmentsSyncDays = SysSettings.GetValue <int>(userConnection, "DeleteAppointmentsSyncDays", 7);
         try {
             Version = Version.AddDays(-1 * deleteAppointmentsSyncDays);
         } catch (ArgumentOutOfRangeException) { }
     }
 }
Esempio n. 8
0
 /// <summary><see cref="ExchangeClient"/> ctor.</summary>
 /// <param name="userConnection">An instance of the user connection.</param>
 /// <param name="credentials">An instance of the user credentials.</param>
 public ExchangeClient(UserConnection userConnection, Credentials credentials)
     : this(userConnection) {
     var mailServer = GetMailServer(credentials.ServerId);
     _credentials = new ExchangeCredentials {
         UserName       = credentials.UserName,
         UserPassword   = credentials.UserPassword,
         IsAutodiscover = mailServer.UseAutodiscover,
         ServerAddress  = mailServer.ServerAddress,
         UseOAuth       = credentials.UseOAuth
     };
     ServicePointManager.ServerCertificateValidationCallback += ValidateRemoteCertificate;
     _ignoreSslWarnings = (bool)SysSettings.GetValue(userConnection, "IgnoreExchangeSSLWarnings", false);
 }
        /// <summary>
        /// Method that returns default calendar id by service item or system setting.
        /// </summary>
        /// <returns>Default calendar guid.</returns>
        private Guid GetCalendar()
        {
            EntitySchemaQuery esqServiceItem = new EntitySchemaQuery(UserConnection.EntitySchemaManager, "ServiceItem");

            esqServiceItem.AddColumn("Calendar");
            var serviceItemEntity   = esqServiceItem.GetEntity(UserConnection, _priorityServiceSLADataModel.ServiceItemId);
            var calendarServiceItem = serviceItemEntity.GetTypedColumnValue <Guid>("CalendarId");

            if (calendarServiceItem != Guid.Empty)
            {
                return(calendarServiceItem);
            }
            return(SystemSettings.GetValue <Guid>(UserConnection, CalendarConsts.BaseCalendarCode, Guid.Empty));
        }
        /// <summary>
        /// Add less than SyncDate filter to <seealso cref="_itemsFilterCollection"/>
        /// </summary>
        /// <param name="localLastSyncDate">Sync date.</param>
        private void AddLessThanSyncDateFilter(DateTime localLastSyncDate)
        {
            if (!_userConnection.GetIsFeatureEnabled("IsLessThanSyncDateInterval"))
            {
                return;
            }
            var lessThanSyncDateInterval = SysSettings.GetValue(_userConnection, "LessThanSyncDateInterval", 1);
            var lessThanSyncDate         = localLastSyncDate.AddDays(lessThanSyncDateInterval);
            var ffilter = new Exchange.SearchFilter.IsLessThan(Exchange.ItemSchema.LastModifiedTime,
                                                               lessThanSyncDate);

            LogError($"LessThanSyncDate filter adedd, filter date '{lessThanSyncDate}', interval {lessThanSyncDateInterval}");
            _itemsFilterCollection.Add(ffilter);
        }
            public void PickUpContactEmail(string contactEmail, UserConnection userConnection)
            {
                ContactEmail = contactEmail;
                if (ContactEmail.IsNullOrEmpty())
                {
                    ContactEmail = ContactUtilities.GetLastAddContactEmail(userConnection, ContactId);
                }
                bool notifyOnlyContact = SystemSettings.GetValue(userConnection, "AutoNotifyOnlyContact", false);

                if (ContactEmail.IsNullOrEmpty() && !notifyOnlyContact)
                {
                    ContactEmail = ParentActivitySender;
                }
            }
        /// <summary>
        /// Creates job to handle broken trigger emails.
        /// <param name="userConnection">The user connection.</param>
        /// </summary>
        public void CreateJob(UserConnection userConnection)
        {
            var periodInMinutes = (int)CoreSysSettings.GetValue(userConnection, "TriggerEmailFailoverJobInterval");

            if (periodInMinutes <= 0)
            {
                return;
            }
            string userName      = userConnection.CurrentUser.Name;
            string workspaceName = userConnection.Workspace.Name;
            string jobGroupName  = MailingSchedulerUtilities.BulkEmailJobGroupName;

            AppScheduler.ScheduleMinutelyJob <TriggerEmailFailoverHandler>(jobGroupName, workspaceName, userName,
                                                                           periodInMinutes, parameters: null, isSystemUser: true,
                                                                           misfireInstruction: AppSchedulerMisfireInstruction.RescheduleNowWithRemainingRepeatCount);
        }
        /// <summary>
        /// Gets case data by given case record identifier.
        /// </summary>
        /// <param name="caseId">Case record identifier.</param>
        /// <returns>Case data.</returns>
        protected virtual CaseData GetCaseData(Guid caseId)
        {
            var    esq = new EntitySchemaQuery(UserConnection.EntitySchemaManager, SchemaName);
            string contactIdColumnName            = esq.AddColumn("Contact.Id").Name;
            string categoryIdColumnName           = esq.AddColumn("Category.Id").Name;
            string contactEmailColumnName         = esq.AddColumn("Contact.Email").Name;
            string titleColumnName                = esq.AddColumn("ParentActivity.Title").Name;
            string parentActivityIdColumnName     = esq.AddColumn("ParentActivity.Id").Name;
            string parentActivitySenderColumnName = esq.AddColumn("ParentActivity.Sender").Name;
            string recipientColumnName            = esq.AddColumn("ParentActivity.Recepient").Name;
            string ccColumnName  = esq.AddColumn("ParentActivity.CopyRecepient").Name;
            string bccColumnName = esq.AddColumn("ParentActivity.BlindCopyRecepient").Name;
            var    @case         = esq.GetEntity(UserConnection, caseId);
            var    data          = new CaseData();

            if (@case == null)
            {
                return(data);
            }
            data.ContactId            = @case.GetTypedColumnValue <Guid>(contactIdColumnName);
            data.CategoryId           = @case.GetTypedColumnValue <Guid>(categoryIdColumnName);
            data.Title                = @case.GetTypedColumnValue <string>(titleColumnName);
            data.ParentActivitySender = @case
                                        .GetTypedColumnValue <string>(parentActivitySenderColumnName)
                                        .ExtractEmailAddressIf();
            data.PickUpContactEmail(@case.GetTypedColumnValue <string>(contactEmailColumnName), UserConnection);
            data.PickUpRecipient(IncindentRegistrationMailboxFilter
                                 .GetRecipientWithoutIncindent(@case.GetTypedColumnValue <string>(recipientColumnName)), UserConnection);
            if (!UserConnection.GetIsFeatureEnabled("CasesOnlyRespondToSender"))
            {
                data.CC  = @case.GetTypedColumnValue <string>(ccColumnName);
                data.BCC = @case.GetTypedColumnValue <string>(bccColumnName);
            }
            if (SystemSettings.GetValue(UserConnection, "AutoNotifyOnlyContact", false))
            {
                data.Recipient = data.ContactEmail;
                data.CC        = data.BCC = default(string);
            }
            data.ParentActivityId        = @case.GetTypedColumnValue <Guid>(parentActivityIdColumnName);
            data.ParentActivityRecipient = @case.GetTypedColumnValue <string>(recipientColumnName);
            data.ParentActivityInReplyTo = data.ParentActivityId.IsNotEmpty()
                                ? GetInReplyToProperty(data.ParentActivityId)
                                : string.Empty;
            return(data);
        }
Esempio n. 14
0
        public string GetIncrementValueVsMask(string sysSettingName, string sysSettingMaskName)
        {
            string sysSettingsCodeMask = (string)CoreSysSettings.GetValue(UserConnection, sysSettingMaskName);
            var    coreSysSettings     = new CoreSysSettings(UserConnection);
            string result = string.Empty;

            if (GlobalAppSettings.UseDBSequence)
            {
                var sequence = new CaseSequence(UserConnection, sysSettingName);
                result = string.Format(sysSettingsCodeMask, sequence.NextValue());
                return(result);
            }
            if (coreSysSettings.FetchFromDB("Code", sysSettingName))
            {
                int sysSettingsLastNumber = Convert.ToInt32(CoreSysSettings.GetDefValue(UserConnection, sysSettingName));
                ++sysSettingsLastNumber;
                CoreSysSettings.SetDefValue(UserConnection, sysSettingName, sysSettingsLastNumber);
                result = string.Format(sysSettingsCodeMask, sysSettingsLastNumber);
            }
            return(result);
        }
        /// <summary>
        /// Returns sequence number.
        /// </summary>
        /// <param name="entitySchema">Entity schema.</param>
        /// <param name="connection">User connection.</param>
        /// <returns>String that represents a generated sequence number.</returns>
        public virtual string GenerateSequenseNumber(EntitySchema entitySchema, UserConnection connection)
        {
            string entitySchemaName      = entitySchema.Name;
            string codeMaskSettingName   = entitySchemaName + "CodeMask";
            string lastNumberSettingName = entitySchemaName + "LastNumber";
            string sysSettingsCodeMask   = string.Empty;
            var    sysSettingsMaskItem   = new CoreSysSettings(connection)
            {
                UseAdminRights = false,
                Code           = codeMaskSettingName
            };

            if (!sysSettingsMaskItem.FetchFromDB("Code", codeMaskSettingName))
            {
                throw new ItemNotFoundException(codeMaskSettingName);
            }
            if (sysSettingsMaskItem.IsPersonal)
            {
                sysSettingsCodeMask = (string)CoreSysSettings.GetValue(connection, codeMaskSettingName);
            }
            else
            {
                sysSettingsCodeMask = (string)CoreSysSettings.GetDefValue(connection, codeMaskSettingName);
            }
            if (GlobalAppSettings.UseDBSequence)
            {
                var sequenceMap = new SequenceMap(connection);
                var sequence    = sequenceMap.GetByNameOrDefault(lastNumberSettingName);
                return(string.Format(sysSettingsCodeMask, sequence.GetNextValue()));
            }
            int sysSettingsLastNumber = Convert.ToInt32(CoreSysSettings.GetDefValue(connection, lastNumberSettingName));

            ++sysSettingsLastNumber;
            CoreSysSettings.SetDefValue(connection, lastNumberSettingName, sysSettingsLastNumber);
            return(string.Format(sysSettingsCodeMask, sysSettingsLastNumber));
        }
Esempio n. 16
0
 /// <summary><see cref="ExchangeClient"/> ctor.</summary>
 /// <param name="userConnection">An instance of the user connection.</param>
 /// <param name="credentials">An instance of the user credentials.</param>
 public ExchangeClient(UserConnection userConnection, Credentials credentials)
     : this(userConnection) {
     _credentials = credentials;
     ServicePointManager.ServerCertificateValidationCallback += ValidateRemoteCertificate;
     _ignoreSslWarnings = (bool)SysSettings.GetValue(userConnection, "IgnoreExchangeSSLWarnings", false);
 }
Esempio n. 17
0
 /// <summary>
 /// Gets default language from system setting.
 /// </summary>
 /// <returns>Default language identifier.</returns>
 public Guid GetDefault()
 {
     return(SystemSettings.GetValue(_userConnection, "DefaultMessageLanguage", default(Guid)));
 }
 /// <summary>
 /// Gets support mailbox from system setting.
 /// </summary>
 /// <returns>Support mailbox.</returns>
 public string GetMailboxFromSystemSetting()
 {
     return(SystemSettings.GetValue <string>(_userConnection, "SupportServiceEmail", string.Empty));
 }