Пример #1
0
        private static HttpClient GetClient(JiraCredentials credentials)
        {
            try
            {
                if (credentials == null)
                {
                    JiraSettings j = ModuleSettingsAccessor <JiraSettings> .GetSettings();

                    credentials = new JiraCredentials
                    {
                        JiraURL        = j.JiraURL,
                        Password       = j.Password,
                        User           = j.UserId,
                        JiraConnection = j.JiraConnection
                    };
                }

                HttpClient httpClient = new HttpClient {
                    BaseAddress = new Uri(credentials.JiraURL.TrimEnd('/') + BASEPATH)
                };
                httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8");

                httpClient.DefaultRequestHeaders.Authorization = new AuthenticationManager().GetAuthHeader(credentials);
                return(httpClient);
            }
            catch (Exception ex)
            {
                throw new LoggedException($"Error setting up connection to {credentials.JiraURL}", ex);
            }
        }
Пример #2
0
        public void Initialize()
        {
            JiraSettings me = ModuleSettingsAccessor <JiraSettings> .GetSettings();

            if (string.IsNullOrEmpty(Id))
            {
                ModuleSettingsAccessor <JiraSettings> .SaveSettings();
            }
        }
Пример #3
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());
        }
Пример #5
0
        public HttpClient GetClient(JiraCredentials credentials)
        {
            if (credentials == null)
            {
                JiraSettings j = ModuleSettingsAccessor <JiraSettings> .GetSettings();

                credentials          = new JiraCredentials();
                credentials.JiraURL  = j.JiraURL;
                credentials.Password = j.Password;
                credentials.User     = j.UserId;
            }

            HttpClient httpClient = new HttpClient {
                BaseAddress = new Uri(credentials.JiraURL)
            };

            httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8");

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationManager().GetAuthHeader(credentials);
            return(httpClient);
        }
Пример #6
0
        public void Initialize()
        {
            ProfilerService.DetailWriter = this;
            // When data dog is in place we want the logs written without
            // json being on new lines.
            Log.WRITE_LOG_FILE_DELIMITER = false;
            Log.WRITE_JSON_WITH_INDENTS  = true;

            // Setup the static client.
            TEL_CLIENT = new TelemetryClient();
            if (string.IsNullOrEmpty(ModuleSettingsAccessor <AzureAppInsightsSettings> .GetSettings().InstrumentationKey))
            {
                AzureAppInsightsLog.LOG.Warn("Instrumentation Key is NOT set in settings and should be configured.  /System/Settings/AzureAppInsights");
            }
            else
            {
                TEL_CLIENT.InstrumentationKey =
                    ModuleSettingsAccessor <AzureAppInsightsSettings> .GetSettings().InstrumentationKey;

                Dictionary <string, string> props = new Dictionary <string, string>();
                props["Version"] = Version.VERSION;
                TEL_CLIENT.TrackEvent("SHM Started", props);
            }
        }
Пример #7
0
        public static string RunScript(InputParameter InputVariables)
        {
            PythonSettings settings = ModuleSettingsAccessor <PythonSettings> .GetSettings();

            //var pypath = "C:\\Users\\Corey\\AppData\\Local\\Programs\\Python\\Python37-32\\";
            //var path = "C:\\Users\\Corey\\AppData\\Local\\Programs\\Python\\Python37-32\\python.exe";
            var     pypath  = settings.PythonScriptDirectory;
            var     path    = settings.PythonDirectory;
            Process process = new Process();

            process.StartInfo.FileName = "cmd.exe";
            List <string> newArgs = new List <string>();

            newArgs.Add(pypath + InputVariables.fileName);
            newArgs.AddRange(InputVariables.args);

            process.StartInfo.Arguments              = "/c" + path + " " + String.Join(" ", newArgs); // Note the /c command (*)
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError  = true;
            process.Start();
            //* Read the output (or the error)
            string output = process.StandardOutput.ReadToEnd();

            Console.WriteLine(output);
            if (output == "")

            {
                string err = process.StandardError.ReadToEnd();
                Console.WriteLine(err);
                process.WaitForExit();
                return(err);
            }
            process.WaitForExit();
            return(output);
        }
Пример #8
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();
        }
Пример #9
0
        private void SetBrandingExample()
        {
            ModuleSettingsAccessor <PortalSettings> .GetSettings().SloganText = "SDK Portal!";

            ModuleSettingsAccessor <DesignerSettings> .GetSettings().StudioSlogan = "Loan Rule Portal";
        }
 static public LogzSettings Instance()
 {
     return(ModuleSettingsAccessor <LogzSettings> .GetSettings());
 }
Пример #11
0
 public void Initialize()
 {
     // this will create it
     ModuleSettingsAccessor <DocusignSettings> .GetSettings();
 }
Пример #12
0
 public static void SaveSettings()
 {
     ModuleSettingsAccessor <SCOIntegrationSettings> .SaveSettings();
 }
Пример #13
0
 public static SCOIntegrationSettings GetSettings()
 {
     return(ModuleSettingsAccessor <SCOIntegrationSettings> .GetSettings());
 }
 public void Initialize()
 {
     // Read the Settings here
     ModuleSettingsAccessor <EquifaxSettings> .GetSettings();
 }
Пример #15
0
        private void EnsureCustomSettingsObject()
        {
            ModuleSettingsAccessor <GoogleDriveSettings> .GetSettings();

            ModuleSettingsAccessor <GoogleDriveSettings> .SaveSettings();
        }
Пример #16
0
 static public ObserveSettings Instance()
 {
     return(ModuleSettingsAccessor <ObserveSettings> .GetSettings());
 }
Пример #17
0
        private void EnsureCustomSettingsObject()
        {
            ModuleSettingsAccessor <RollbarSettings> .GetSettings();

            ModuleSettingsAccessor <RollbarSettings> .SaveSettings();
        }