Exemplo n.º 1
0
        /// <summary>
        /// Save the currently selected settings
        /// </summary>
        /// <param name="useEncryption"></param>
        public void SaveUserSettings(bool useEncryption)
        {
            UserSettingsVndb vndb = new UserSettingsVndb
            {
                Spoiler = (SpoilerLevel)SpoilerIndex
            };
            UserSettings settings = new UserSettings
            {
                SettingsVndb         = vndb,
                RequirePasswordEntry = useEncryption,
                MaxSexualRating      = (SexualRating)MaxSexualIndex,
                MaxViolenceRating    = (ViolenceRating)MaxViolenceIndex
            };

            try
            {
                UserSettingsHelper.SaveUserSettings(settings);
                App.UserSettings = settings;

                _windowManager.ShowMessageBox(App.ResMan.GetString("SettingsSavedMessage"), App.ResMan.GetString("SettingsSavedTitle"));
            }
            catch (Exception ex)
            {
                App.Logger.Error(ex, "Couldn't write to config file");
                SentryHelper.SendException(ex, null, SentryLevel.Error);
                throw;
            }
        }
Exemplo n.º 2
0
        /* Basic authentication
         * private async void SignIn(object parameter)
         * {
         *  this._username = this.Username;
         *  GetPassword(parameter);
         *
         *  SignedInUser.Username = this._username;
         *  SignedInUser.Password = this._password;
         *
         *  this._userService = new UserService();
         *
         *  if (SignedInUser.IsComplete())
         *  {
         *      ConfluenceToolWindow.AuthenticatedUser = await this._userService.GetAuthenticatedUserAsync();
         *      this._isAuthenticated = _userService.IsAuthenticated(ConfluenceToolWindow.AuthenticatedUser);
         *      //this.ErrorMessage = !this._isAuthenticated;
         *  }
         *  else
         *  {
         *      BindingExpression be = Username.GetBindingExpression(TextBox.TextProperty);
         *      be.UpdateSource();
         *  }
         *
         *  if (this._isAuthenticated)
         *  {
         *      this._parent.ShowAfterSignIn();
         *  }
         * }
         */

        private async void SignInOAuth(object parameter)
        {
            this._oAuthService = new OAuthService();

            IToken requestToken;
            string authorizationUrl;

            try
            {
                this._baseUrl = this.ProcessBaseUrlInput(this.BaseUrl);

                this._oAuthService.InitializeOAuthSession(this.BaseUrl);

                UserSettingsHelper.WriteToUserSettings("ConfluenceBaseUrl", this.BaseUrl);

                requestToken = await this._oAuthService.GetRequestToken();

                authorizationUrl = await this._oAuthService.GetUserAuthorizationUrlForToken(requestToken);

                System.Diagnostics.Process.Start(authorizationUrl);
                this._parent.ShowOAuthVerificationConfirmation(null, null, requestToken);
            }
            catch (OAuthException ex)
            {
                this.ErrorMessage = ex.Message;
            }
            catch (SecurityException ex)
            {
                this.ErrorMessage = ex.Message;
            }
            catch (Exception ex)
            {
                this.ErrorMessage = ex.Message;
            }
        }
        public void TryToSignIn()
        {
            this.StopLoading();

            try
            {
                string accessToken       = UserSettingsHelper.ReadStringFromUserSettings("JiraAccessToken");
                string accessTokenSecret = UserSettingsHelper.ReadStringFromUserSettings("JiraAccessTokenSecret");
                string baseUrl           = UserSettingsHelper.ReadStringFromUserSettings("JiraBaseUrl");

                if (accessToken != null && accessTokenSecret != null && baseUrl != null)
                {
                    this._oAuthService.ReinitializeOAuthSessionAccessToken(accessToken, accessTokenSecret, baseUrl);

                    this.InitializeServicesWithAuthenticationType(AuthenticationType.OAuth);
                    this.ShowProjects(null, null);
                }
                else
                {
                    this.ShowAuthentication();
                }
            }
            catch (Exception ex)
            {
                this.ShowAuthentication();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Do some final checks before main window is allowed to load
        /// </summary>
        private void StartupCheck()
        {
            CheckForUpdates();

            if (!IsNormalStart())
            {
                App.UserSettings = UserSettingsHelper.ReadUserSettings();
                var auth   = _enterPassVm();
                var isAuth = _windowManager.ShowDialog(auth);

                if (isAuth == true)
                {
                    App.UserSettings = UserSettingsHelper.ReadUserSettings();//read for any changed user settings
                    CheckForImportDb();
                }
                else
                {
                    Environment.Exit(0);//closed auth window
                }
            }
            else
            {
                CheckDbError();
            }
        }
Exemplo n.º 5
0
        public AuthenticationViewModel(IJiraToolWindowNavigatorViewModel parent,
                                       IOAuthService oAuthService,
                                       IBasicAuthenticationService basicService,
                                       IUserService userService)
        {
            this._parent = parent;

            this._baseUrl      = UserSettingsHelper.ReadStringFromUserSettings("JiraBaseUrl");
            this._baseUrlBasic = UserSettingsHelper.ReadStringFromUserSettings("JiraBaseUrl");
            this._username     = UserSettingsHelper.ReadStringFromUserSettings("JiraUsername");

            this._oAuthService = oAuthService;
            this._basicService = basicService;
            this._userService  = userService;

            SettingsManager settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider);

            this._userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            this.SignInOAuthCommand     = new DelegateCommand(SignInOAuth);
            this.SignInBasicCommand     = new DelegateCommand(SignInBasic);
            this.HowToSetupOAuthCommand = new DelegateCommand(HowToSetupOAuth);

            SetPanelTitles();
        }
Exemplo n.º 6
0
        private void SignOut(object parameter)
        {
            UserSettingsHelper.DeletePropertyFromUserSettings("ConfluenceAccessToken");
            UserSettingsHelper.DeletePropertyFromUserSettings("ConfluenceAccessTokenSecret");
            UserSettingsHelper.DeletePropertyFromUserSettings("ConfluenceBaseUrl");

            this._parent.ShowBeforeSignIn();
        }
Exemplo n.º 7
0
        private void OpenContentInBuildInTab(object sender)
        {
            string contentUrl = sender as string;

            IVsWindowFrame ppFrame;
            var            service = Package.GetGlobalService(typeof(IVsWebBrowsingService)) as IVsWebBrowsingService;

            service.Navigate((UserSettingsHelper.ReadFromUserSettings("ConfluenceBaseUrl")) + "/wiki" + contentUrl, 0, out ppFrame);
        }
Exemplo n.º 8
0
        // GET: Target
        public ActionResult Index()
        {
            var defaultColumnDisplayOrder = new StringCollection {
                "Name", "Base", "StartingMaterialMW", "VendorName", "VendorCatalogNumber", "Coupling", "Deprotection", "IncorporatedMW", "Formula"
            };
            var userSearchSettings = UserSettingsHelper.ModStructureSearchSettings;

            UserSettingsHelper.SetDefaultSearchSettings(userSearchSettings, defaultColumnDisplayOrder);
            return(View());
        }
Exemplo n.º 9
0
        public ActionResult DuplexBatches()
        {
            var defaultColumnDisplayOrder = new StringCollection {
                "DuplexBatchNumber", "PreparedDate", "Target.Name", "RunId", "DuplexId", "Unavailable"
            };
            var userSearchSettings = UserSettingsHelper.DuplexBatchSearchSettings;

            UserSettingsHelper.SetDefaultSearchSettings(userSearchSettings, defaultColumnDisplayOrder);
            return(View("DuplexBatches"));
        }
Exemplo n.º 10
0
        // GET: Duplex
        public ActionResult Index()
        {
            var defaultColumnDisplayOrder = new StringCollection {
                "DuplexId", "Target.Name", "SenseStrand.StrandId", "AntiSenseStrand.StrandId"
            };
            var userSearchSettings = UserSettingsHelper.DuplexSearchSettings;

            UserSettingsHelper.SetDefaultSearchSettings(userSearchSettings, defaultColumnDisplayOrder);
            return(View());
        }
Exemplo n.º 11
0
 private void InitializeAttributes()
 {
     this.AttributesList.Add(new MyAttribute("Type", UserSettingsHelper.ReadBoolFromUserSettings("TypeAttribute")));
     this.AttributesList.Add(new MyAttribute("Status", UserSettingsHelper.ReadBoolFromUserSettings("StatusAttribute")));
     this.AttributesList.Add(new MyAttribute("Created", UserSettingsHelper.ReadBoolFromUserSettings("CreatedAttribute")));
     this.AttributesList.Add(new MyAttribute("Updated", UserSettingsHelper.ReadBoolFromUserSettings("UpdatedAttribute")));
     this.AttributesList.Add(new MyAttribute("Assignee", UserSettingsHelper.ReadBoolFromUserSettings("AssigneeAttribute")));
     this.AttributesList.Add(new MyAttribute("Summary", UserSettingsHelper.ReadBoolFromUserSettings("SummaryAttribute")));
     this.AttributesList.Add(new MyAttribute("Priority", UserSettingsHelper.ReadBoolFromUserSettings("PriorityAttribute")));
 }
 private void WriteToUserSettingsIssueAttributes()
 {
     UserSettingsHelper.WriteToUserSettings("TypeAttribute", true);
     UserSettingsHelper.WriteToUserSettings("StatusAttribute", true);
     UserSettingsHelper.WriteToUserSettings("CreatedAttribute", false);
     UserSettingsHelper.WriteToUserSettings("UpdatedAttribute", false);
     UserSettingsHelper.WriteToUserSettings("AssigneeAttribute", false);
     UserSettingsHelper.WriteToUserSettings("SummaryAttribute", true);
     UserSettingsHelper.WriteToUserSettings("PriorityAttribute", true);
 }
Exemplo n.º 13
0
        // GET: Target
        public ActionResult Index()
        {
            var defaultColumnDisplayOrder = new StringCollection {
                "Name", "IsActive"
            };
            var userSearchSettings = UserSettingsHelper.SpeciesSearchSettings;

            UserSettingsHelper.SetDefaultSearchSettings(userSearchSettings, defaultColumnDisplayOrder);
            return(View());
        }
Exemplo n.º 14
0
        public ActionResult Batches()
        {
            var defaultColumnDisplayOrder = new StringCollection {
                "BatchNumber", "InitiatedDate", "SynthesisScale", "Purity", "Strand.Sequence", "Strand.MW", "Strand.Target.Name", "AmountPrepared", "Unavailable"
            };
            var userSearchSettings = UserSettingsHelper.StrandBatchSearchSettings;

            UserSettingsHelper.SetDefaultSearchSettings(userSearchSettings, defaultColumnDisplayOrder);
            return(View());
        }
Exemplo n.º 15
0
        // GET: SynthesisRequest
        public ActionResult Index()
        {
            var defaultColumnDisplayOrder = new StringCollection {
                "Id", "RequestDate", "Needed", "Status.Description"
            };
            var userSearchSettings = UserSettingsHelper.SynthesisRequestSearchSettings;

            UserSettingsHelper.SetDefaultSearchSettings(userSearchSettings, defaultColumnDisplayOrder);
            return(View());
        }
Exemplo n.º 16
0
        // GET: Strand
        public ActionResult Index()
        {
            var defaultColumnDisplayOrder = new StringCollection {
                "StrandId", "GenomeNumber", "GenomePosition", "Sequence", "MW", "BaseSequence", "ExtinctionCoefficient", "ColumnIdentity"
            };
            var userSearchSettings = UserSettingsHelper.StrandSearchSettings;

            UserSettingsHelper.SetDefaultSearchSettings(userSearchSettings, defaultColumnDisplayOrder);
            return(View());
        }
Exemplo n.º 17
0
        public ActionResult Index()
        {
            var defaultColumnDisplayOrder = new StringCollection {
                "Name", "Orientation.Name"
            };
            var userSearchSettings = UserSettingsHelper.ModifierTemplateSearchSettings;

            UserSettingsHelper.SetDefaultSearchSettings(userSearchSettings, defaultColumnDisplayOrder);
            return(View());
        }
Exemplo n.º 18
0
        private async void GetProjectsAsync()
        {
            this._parent.StartLoading();

            this.ProjectList.Clear();

            Task <ProjectList> projectTask = this._projectService.GetAllProjectsAsync();

            try
            {
                var projectList = await projectTask as ProjectList;

                this._projectCreatableList = await this._projectService.GetAllProjectsCreatableIssueTypesAsync();

                if (projectList.Count > 0)
                {
                    this.NoProjects = false;

                    foreach (Project p in projectList)
                    {
                        //Fetching Creatable IssueTypes for each project
                        foreach (ProjectCreatable pc in this._projectCreatableList.Projects)
                        {
                            if (p.Id.Equals(pc.Id))
                            {
                                p.CreatableIssueTypesList = pc.Issuetypes;
                            }
                        }
                        //end fetching

                        this.ProjectList.Add(p);
                    }
                }
                else
                {
                    this.NoProjects = true;
                }

                HideErrorMessages(this._parent);
            }
            catch (JiraException ex)
            {
                ShowErrorMessages(ex, this._parent);
            }
            catch (Newtonsoft.Json.JsonReaderException njex)
            {
                UserSettingsHelper.DeletePropertyFromUserSettings("JiraAccessToken");
                UserSettingsHelper.DeletePropertyFromUserSettings("JiraAccessTokenSecret");
                UserSettingsHelper.DeletePropertyFromUserSettings("JiraBaseUrl");

                this._parent.ShowAuthentication();
            }

            this._parent.StopLoading();
        }
Exemplo n.º 19
0
        private void SignOut(object parameter)
        {
            UserSettingsHelper.DeletePropertyFromUserSettings("JiraAccessToken");
            UserSettingsHelper.DeletePropertyFromUserSettings("JiraAccessTokenSecret");

            this._basicAuthenticationService.DeleteAuthenticationCredentials();

            this._parent.DisposeConnectionView();

            this._parent.ShowAuthentication();
        }
Exemplo n.º 20
0
        public ActionResult GetFirstPublisherEmail(string countryCode, PublisherStatus status)
        {
            //TODO move this to user settings, don't make during search!!
            UserSettingsHelper usHelper = new UserSettingsHelper();

            usHelper.Update(User.Identity.GetUserId(), countryCode);
            //TODO move this to user settings, don't make during search!!
            EmailHelper helper = new EmailHelper();

            return(Json(helper.GetEmailByPublisherCountryAndStatus(countryCode, status), JsonRequestBehavior.AllowGet));
        }
        public void ProcessCancelCreateIssueDialogSelection(MessageBoxResult result)
        {
            if (result == MessageBoxResult.Yes)
            {
                UserSettingsHelper.DeletePropertyFromUserSettings("JiraAccessToken");
                UserSettingsHelper.DeletePropertyFromUserSettings("JiraAccessTokenSecret");
                UserSettingsHelper.DeletePropertyFromUserSettings("JiraBaseUrl");

                this.ShowAuthentication();
            }
        }
Exemplo n.º 22
0
 internal static void OnAddinStartUp(UISolution solution)
 {
     //checks if the solution is linked to JIRA
     if (UserSettingsHelper.IsSolutionLinked(solution) && solution.LoadType != SolutionLoadType.Ask)
     {
         //solution is linked
         if (solution.LoadType == SolutionLoadType.Link)
         {
             LoadConfiguration(solution);
             InitializeAddIn();
         }
     }
     else
     {
         //solution is not linked, check if it is necessary to link it
         if (UserSettingsHelper.CanSolutionBeLinked(solution.FullName))
         {
             DialogResult result =
                 MessageBox.Show(
                     "JIRA Connector has detected a solution that hasn't been linked to JIRA. Would you like to link the solution to a JIRA project?\n Click 'YES' to link, 'NO' to never link the solution or 'CANCEL' to see this message next time this solution is opened.",
                     "JIRA Connector", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);
             if (result == DialogResult.No)
             {
                 solution.LoadType = SolutionLoadType.NeverLink;
                 UserSettingsHelper.SaveSolutionSettings(solution);
             }
             else if (result == DialogResult.Yes)
             {
                 LogManager.WriteMessage("Saving solution settings.");
                 solution.LoadType = SolutionLoadType.Link;
                 SolutionLinkSettings solutionSettings = new SolutionLinkSettings(solution);
                 DialogResult         settingsResult   = solutionSettings.ShowDialog();
                 if (settingsResult == DialogResult.OK)
                 {
                     //Settings were entered, initializing addin
                     LoadConfiguration(solution);
                     InitializeAddIn();
                 }
                 else
                 {
                     //User cancel settings, so we ask him next time he opens the solution
                     solution.LoadType = SolutionLoadType.Ask;
                 }
                 UserSettingsHelper.SaveSolutionSettings(solution);
             }
             else if (result == DialogResult.Cancel)
             {
                 solution.LoadType = SolutionLoadType.Ask;
                 UserSettingsHelper.SaveSolutionSettings(solution);
             }
         }
     }
 }
Exemplo n.º 23
0
        public IHttpActionResult Get()
        {
            try
            {
                var userSettings = new UserSettings
                {
                    TargetSearchSettings =
                        UserSettingsHelper.GetSearchSettings(UserSettingsHelper.TargetSearchSettings),

                    InstrumentSearchSettings =
                        UserSettingsHelper.GetSearchSettings(UserSettingsHelper.InstrumentSearchSettings),

                    SpeciesSearchSettings =
                        UserSettingsHelper.GetSearchSettings(UserSettingsHelper.SpeciesSearchSettings),

                    ModStructureSearchSettings =
                        UserSettingsHelper.GetSearchSettings(UserSettingsHelper.ModStructureSearchSettings),

                    ModifierTemplateSearchSettings =
                        UserSettingsHelper.GetSearchSettings(UserSettingsHelper.ModifierTemplateSearchSettings),

                    StrandSearchSettings =
                        UserSettingsHelper.GetSearchSettings(UserSettingsHelper.StrandSearchSettings),

                    DuplexSearchSettings =
                        UserSettingsHelper.GetSearchSettings(UserSettingsHelper.DuplexSearchSettings),

                    MaterialRequestSearchSettings =
                        UserSettingsHelper.GetSearchSettings(UserSettingsHelper.MaterialRequestSearchSettings),

                    SynthesisRequestSearchSettings =
                        UserSettingsHelper.GetSearchSettings(UserSettingsHelper.SynthesisRequestSearchSettings),

                    StrandBatchSearchSettings =
                        UserSettingsHelper.GetSearchSettings(UserSettingsHelper.StrandBatchSearchSettings),

                    DuplexBatchSearchSettings =
                        UserSettingsHelper.GetSearchSettings(UserSettingsHelper.DuplexBatchSearchSettings)
                };


                //material  Request Settings

                //synthesis request settings

                return(Ok(userSettings));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }
Exemplo n.º 24
0
 //TODO: Is this being used?
 public static void LoadUserSettings()
 {
     try
     {
         var settings = UserSettingsHelper.ReadUserSettings();
         App.UserSettings = settings;
     }
     catch (Exception ex)
     {
         App.Logger.Error(ex, "Couldn't load config file");
         throw;
     }
 }
Exemplo n.º 25
0
        protected Publisher GetPublisher(int?publisherId)
        {
            Publisher       result = new Publisher();
            PublisherHelper helper = new PublisherHelper();

            if (!publisherId.HasValue)
            {
                UserSettingsHelper usHelper     = new UserSettingsHelper();
                string             userLanguage = usHelper.GetUserLanguage(User.Identity.GetUserId());
                result = helper.GetFirstPublisherByCountryAndStatus(userLanguage, PublisherStatus.None);
            }
            else
            {
                result = helper.GetPublisher(publisherId.Value);
            }
            return(result);
        }
Exemplo n.º 26
0
        public ActionResult Unconfirmed(int?publisherId)
        {
            EmailHelper helper = new EmailHelper();
            Email       result = new Email();

            if (!publisherId.HasValue)
            {
                UserSettingsHelper usHelper     = new UserSettingsHelper();
                string             userLanguage = usHelper.GetUserLanguage(User.Identity.GetUserId());
                result = helper.GetEmailByPublisherCountryAndStatus(userLanguage, PublisherStatus.Subscribed);
            }
            else
            {
                result = helper.GetFirstPublisherEmail(PublisherStatus.Subscribed, publisherId.Value);
            }
            return(View(result));
        }
Exemplo n.º 27
0
        public IHttpActionResult Post([FromBody] UserSettings userSettings)
        {
            try
            {
                UserSettingsHelper.SetSearchSettings(userSettings.TargetSearchSettings,
                                                     UserSettingsHelper.TargetSearchSettings);

                UserSettingsHelper.SetSearchSettings(userSettings.InstrumentSearchSettings,
                                                     UserSettingsHelper.InstrumentSearchSettings);

                UserSettingsHelper.SetSearchSettings(userSettings.SpeciesSearchSettings,
                                                     UserSettingsHelper.SpeciesSearchSettings);

                UserSettingsHelper.SetSearchSettings(userSettings.ModStructureSearchSettings,
                                                     UserSettingsHelper.ModStructureSearchSettings);

                UserSettingsHelper.SetSearchSettings(userSettings.ModifierTemplateSearchSettings,
                                                     UserSettingsHelper.ModifierTemplateSearchSettings);

                UserSettingsHelper.SetSearchSettings(userSettings.StrandSearchSettings,
                                                     UserSettingsHelper.StrandSearchSettings);

                UserSettingsHelper.SetSearchSettings(userSettings.DuplexSearchSettings,
                                                     UserSettingsHelper.DuplexSearchSettings);

                //material  Request Settings
                UserSettingsHelper.SetSearchSettings(userSettings.MaterialRequestSearchSettings,
                                                     UserSettingsHelper.MaterialRequestSearchSettings);

                //synthesis  Request Settings
                UserSettingsHelper.SetSearchSettings(userSettings.SynthesisRequestSearchSettings,
                                                     UserSettingsHelper.SynthesisRequestSearchSettings);

                UserSettingsHelper.SetSearchSettings(userSettings.StrandBatchSearchSettings,
                                                     UserSettingsHelper.StrandBatchSearchSettings);

                UserSettingsHelper.SetSearchSettings(userSettings.DuplexBatchSearchSettings,
                                                     UserSettingsHelper.DuplexBatchSearchSettings);

                return(Ok());
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }
Exemplo n.º 28
0
        public IHttpActionResult PostByKey([FromUri] string key, [FromBody] IDictionary <string, object> columnDisplayOrder)
        {
            try
            {
                var settings = UserSettingsHelper.GetSearchSettings(key);
                if (settings != null)
                {
                    UserSettingsHelper.SetSearchSettings(columnDisplayOrder, settings);
                }

                return(Ok());
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }
Exemplo n.º 29
0
        public IHttpActionResult Get([FromUri] string key)
        {
            try
            {
                var settings = UserSettingsHelper.GetSearchSettings(key);
                if (settings == null)
                {
                    return(NotFound());
                }

                var coulumnDisplayOrder = UserSettingsHelper.GetSearchSettings(settings);
                return(Ok(coulumnDisplayOrder));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }
        private async void SignIn(object parameter)
        {
            try
            {
                IToken accessToken = await this._oAuthService.ExchangeRequestTokenForAccessToken(this._requestToken, OAuthVerificationCode);

                UserSettingsHelper.WriteToUserSettings("JiraAccessToken", accessToken.Token);
                UserSettingsHelper.WriteToUserSettings("JiraAccessTokenSecret", accessToken.TokenSecret);

                WriteToUserSettingsIssueAttributes();

                this._parent.ShowConnection(null, null);
                this._timer.Stop();
            }
            catch (OAuthException ex)
            {
                this._parent.SetErrorMessage(ex.Message);
            }
        }