Ejemplo n.º 1
0
        protected override Task OnReadSettingsAsync(ModuleSettingsReader settings)
        {
            var configurationObject = settings.Get(CONFIGURATION_KEY);

            Configurations = configurationObject as string;
            return(base.OnReadSettingsAsync(settings));
        }
        /// <summary>
        /// Reads the module settings from a project.  This method is called when a project is opened if the project contains this module's settings.
        /// Use the <paramref name="settings"/> to obtain the module values.
        /// </summary>
        /// <param name="settings">Contains the module settings</param>
        /// <returns>A Task that represents the OnReadStateAsync method</returns>
        //protected override Task OnReadStateAsync(System.IO.Stream stream)
        protected override Task OnReadSettingsAsync(ModuleSettingsReader settings)
        {
            // set the flag
            hasSettings = true;

            // clear existing setting values
            _moduleSettings.Clear();

            if (settings == null)
            {
                return(Task.FromResult(0));
            }

            string[] keys = new string[] { "Setting1", "Setting2" };
            foreach (string key in keys)
            {
                object value = settings.Get(key);
                if (value != null)
                {
                    if (_moduleSettings.ContainsKey(key))
                    {
                        _moduleSettings[key] = value.ToString();
                    }
                    else
                    {
                        _moduleSettings.Add(key, value.ToString());
                    }
                }
            }

            return(Task.FromResult(0));
        }
Ejemplo n.º 3
0
        protected override async Task OnReadSettingsAsync(ModuleSettingsReader settings)
        {
            Settings.Clear();

            if (settings == null)
            {
                try {
                    await CheckForLastest();
                } catch {
                    // ignored
                }

                await base.OnReadSettingsAsync(null);

                return;
            }

            foreach (var key in _addinKeys)
            {
                var value = settings.Get(key);

                if (value != null)
                {
                    Settings[key] = value.ToString();
                }
            }

            EvergreenSettings.BetaChannel = Convert.ToBoolean(Settings["UICAddin.Evergreen.BetaChannel"]);

            try {
                await CheckForLastest();
            } catch {
                // ignored
            }
        }
Ejemplo n.º 4
0
        protected override Task OnReadSettingsAsync(ModuleSettingsReader settings)
        {
            // should never be null
            if (settings == null)
            {
                return(base.OnReadSettingsAsync(settings));
            }

            // no crashes when:
            // settings[""] = null;
            // settings = null;

            if (!(settings.Get("worklistLayerUris") is string uris))
            {
                return(base.OnReadSettingsAsync(settings));
            }

            foreach (string pair in uris.Trim().Split('#'))
            {
                string[] tokens = pair.Trim().Split(':');

                string worklistName = tokens[0];

                if (_uriByWorklistName.ContainsKey(worklistName))
                {
                    continue;
                }

                _uriByWorklistName.Add(worklistName, tokens[1]);
            }

            return(base.OnReadSettingsAsync(settings));
        }
Ejemplo n.º 5
0
        protected override Task OnReadSettingsAsync(ModuleSettingsReader settings)
        {
            try
            {
                // set the flag
                hasSettings = true;
                // clear existing setting values
                _moduleSettings.Clear();

                if (settings == null)
                {
                    return(Task.FromResult(0));
                }

                // Settings defined in the Property sheet’s viewmodel.
                string[] keys = new string[] { "Setting1", "Setting2", "Setting3" };

                foreach (string key in keys)
                {
                    object value = settings.Get(key);
                    if (value != null)
                    {
                        if (_moduleSettings.ContainsKey(key))
                        {
                            _moduleSettings[key] = value.ToString();
                        }
                        else
                        {
                            _moduleSettings.Add(key, value.ToString());
                        }
                    }
                }
                if (_moduleSettings["Setting3"] != "")
                {
                    string len;
                    _moduleSettings.TryGetValue("Setting3", out len);
                    string contentPath = System.IO.Path.Combine(Project.Current.HomeFolderPath, "Data.dat");
                    string projectPath = Project.Current.HomeFolderPath;
                    using (FileStream fStream = new FileStream(contentPath, FileMode.Open))
                    {
                        if (fStream.CanRead)
                        {
                            byte[] inBuffer = new byte[int.Parse(len)];
                            byte[] outBuffer;
                            string pass = "";
                            fStream.Read(inBuffer, 0, int.Parse(len));
                            byte[] entropy = new byte[20];
                            outBuffer = ProtectedData.Unprotect(inBuffer, null, DataProtectionScope.CurrentUser);
                            pass      = UnicodeEncoding.ASCII.GetString(outBuffer);

                            string[] conns = pass.TrimStart(';').Split(';');
                            foreach (string con in conns)
                            {
                                ConnectionItem coni  = new QProSapAddIn.ConnectionItem();
                                string[]       cells = con.Split(',');
                                for (int i = 0; i < cells.Length; i++)
                                {
                                    switch (i)
                                    {
                                    case 0:
                                        coni.name = cells[i];
                                        break;

                                    case 1:
                                        coni.server = cells[i];
                                        break;

                                    case 2:
                                        coni.userid = cells[i];
                                        break;

                                    case 3:
                                        SecureString ss = new SecureString();
                                        foreach (char cc in cells[i])
                                        {
                                            ss.AppendChar(cc);
                                        }
                                        coni.pass = ss;
                                        break;

                                    default:

                                        break;
                                    }
                                }
                                ConnectionItems.Add(coni);
                            }
                            foreach (char cc in pass)
                            {
                                _Hpass.AppendChar(cc);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            { MessageBox.Show("Error in OnReadSettingsAsync:  " + ex.Message.ToString(), "Error"); }


            return(Task.FromResult(0));
        }
        /// <summary>
        /// Reads the module settings from a project.  This method is called when a project is opened if the project contains this module's settings. 
        /// Use the <paramref name="settings"/> to obtain the module values.
        /// </summary>
        /// <param name="settings">Contains the module settings</param>
        /// <returns>A Task that represents the OnReadStateAsync method</returns>
        //protected override Task OnReadStateAsync(System.IO.Stream stream)
        protected override Task OnReadSettingsAsync(ModuleSettingsReader settings)
        {
          // set the flag
          hasSettings = true;

          // clear existing setting values
          _moduleSettings.Clear();

          if (settings == null)
            return Task.FromResult(0);

          string[] keys = new string[] {"Setting1", "Setting2"};
          foreach (string key in keys)
          {
            object value = settings.Get(key);
            if (value != null)
            {
              if (_moduleSettings.ContainsKey(key))
                _moduleSettings[key] = value.ToString();
              else
                _moduleSettings.Add(key, value.ToString());
            }
          }
 
          return Task.FromResult(0);
        }