Пример #1
0
        public void Initialize()
        {
            JiraSettings me = ModuleSettingsAccessor <JiraSettings> .GetSettings();

            if (string.IsNullOrEmpty(Id))
            {
                ModuleSettingsAccessor <JiraSettings> .SaveSettings();
            }
        }
Пример #2
0
        public void Initialize()
        {
            var me = Instance();

            if (string.IsNullOrEmpty(Id))
            {
                me.BaseUrl         = DefaultBaseUrl;
                me.MinSendLogLevel = LogLevel.None;
                ModuleSettingsAccessor <ObserveSettings> .SaveSettings();
            }
        }
        public override BaseActionType[] GetActions(AbstractUserContext userContext, EntityActionType[] types)
        {
            List <BaseActionType> actions = new List <BaseActionType>(base.GetActions(userContext, types));

            actions.Add(new EditObjectAction(typeof(AzureAppInsightsSettings), "Edit Settings", null, "Edit Azure Insights", this,
                                             () =>
            {
                MetricsForAzureAppInsights.SetInstrumentationKey(ModuleSettingsAccessor <AzureAppInsightsSettings> .Instance.InstrumentationKey);
                ModuleSettingsAccessor <AzureAppInsightsSettings> .SaveSettings();
            }));
            return(actions.ToArray());
        }
Пример #4
0
        public override void BeforeSave()
        {
            CRM2011Connection specifiedConnection = connection;

            if (specifiedConnection == null)
            {
                // If 'connection' is null, this might be an import.
                log.Debug("sConnection is null, fetching by ID");
                specifiedConnection = CRM2011Connection.GetCRMConnectionById(connectionId);
                if (specifiedConnection != null)
                {
                    Connection = specifiedConnection;
                }
            }
            // If a connection exists at this point, make sure this entity name doesn't already exist for this connection:
            if (specifiedConnection != null)
            {
                SetNamesFromSelectedName();
                log.Debug($"Checking whether entity already exists with connection_id '{specifiedConnection.connectionId}' and crm_entity_name '{CRMEntityName}'.");
                ORM <CRM2011Entity> orm = new ORM <CRM2011Entity>();
                var conditions          = new List <WhereCondition>
                {
                    new FieldWhereCondition("connection_id", QueryMatchType.Equals, specifiedConnection.connectionId),
                    new FieldWhereCondition("crm_entity_name", QueryMatchType.Equals, this.CRMEntityName)
                };
                if (!string.IsNullOrWhiteSpace(this.entityId))
                {
                    // (if ID is the same, this is an edit)
                    conditions.Add(new FieldWhereCondition("entity_id", QueryMatchType.DoesNotEqual, this.entityId));
                }
                CRM2011Entity otherEntity = orm.Fetch(conditions.ToArray()).FirstOrDefault();
                log.Debug($"entity: {otherEntity?.CRMEntityDisplayName ?? "(null)"}");
                if (otherEntity != null)
                {
                    throw new InvalidOperationException("This entity already exists for this connection.");
                }
            }

            if (specifiedConnection == null)
            {
                // If the ID is missing, this might be an import. Check for a matching name:
                log.Debug("sConnection is null, fetching by name");
                specifiedConnection = CRM2011Connection.GetCRMConnectionForName(connectionName);
            }
            if (specifiedConnection == null)
            {
                // If no connection was found by ID or by name, create one:
                log.Debug("sConnection is null, creating");
                specifiedConnection = new CRM2011Connection()
                {
                    ConnectionName  = connectionName,
                    OrganisationUrl = organisationUrl,
                    Domain          = domain,
                    UserName        = userName,
                    Password        = password
                };
                // Add new connection to settings:
                CRM2011Connection[] oldConnections = ModuleSettingsAccessor <CRM2011Settings> .Instance.Connections;
                ModuleSettingsAccessor <CRM2011Settings> .Instance.Connections = oldConnections.Concat(new[] { specifiedConnection }).ToArray();
                log.Debug($"about to save new connections...");
                ModuleSettingsAccessor <CRM2011Settings> .SaveSettings();

                specifiedConnection = CRM2011Connection.GetCRMConnectionForName(connectionName);
                if (specifiedConnection == null)
                {
                    throw new EntityNotFoundException("CRMConnection was not created successfully.");
                }
                log.Debug("new connections saved.");
            }
            if (specifiedConnection != null)
            {
                // Update our data to match the connection's data:
                log.Debug("sConnection exists, updating data to match it...");
                Connection      = specifiedConnection;
                connectionId    = specifiedConnection.connectionId;
                connectionName  = specifiedConnection.ConnectionName;
                organisationUrl = specifiedConnection.OrganisationUrl;
                domain          = specifiedConnection.Domain;
                userName        = specifiedConnection.UserName;
                password        = specifiedConnection.Password;
            }

            SetNamesFromSelectedName();

            base.BeforeSave();

            AddOrUpdateCRMEntity();
        }
Пример #5
0
 public static void SaveSettings()
 {
     ModuleSettingsAccessor <SCOIntegrationSettings> .SaveSettings();
 }
Пример #6
0
        private void EnsureCustomSettingsObject()
        {
            ModuleSettingsAccessor <RollbarSettings> .GetSettings();

            ModuleSettingsAccessor <RollbarSettings> .SaveSettings();
        }
Пример #7
0
        private void EnsureCustomSettingsObject()
        {
            ModuleSettingsAccessor <GoogleDriveSettings> .GetSettings();

            ModuleSettingsAccessor <GoogleDriveSettings> .SaveSettings();
        }