/// <summary>
        /// Writes the module's settings.  This method is called when a project is saved.  Populate the modules settings into the ModuleSettingsWriter settings.
        /// </summary>
        /// <param name="settings">The settings which will be written out</param>
        /// <returns>A Task that represents the OnWriteStateAsync method</returns>
        protected override Task OnWriteSettingsAsync(ModuleSettingsWriter settings)
        {
            foreach (string key in _moduleSettings.Keys)
            {
                settings.Add(key, _moduleSettings[key]);
            }

            return(Task.FromResult(0));
        }
Exemplo n.º 2
0
        protected override async Task OnWriteSettingsAsync(ModuleSettingsWriter settings)
        {
            foreach (var key in Settings.Keys)
            {
                settings.Add(key, Settings[key]);
            }

            try {
                await CheckForLastest();
            } catch {
                // ignored
            }
        }
Exemplo n.º 3
0
        protected override Task OnWriteSettingsAsync(ModuleSettingsWriter settings)
        {
            // todo daro Methond is only called when project is dirty.
            // todo daro OnWriteSettingsAsync is called twice on creating a project.
            if (_uriByWorklistName.Count <= 0)
            {
                return(base.OnWriteSettingsAsync(settings));
            }

            List <string> worklistLayerUris = new List <string>(_uriByWorklistName.Count);

            worklistLayerUris.AddRange(_uriByWorklistName.Select(pair => $"{pair.Key}:{pair.Value}"));

            settings.Add("worklistLayerUris", StringUtils.Concatenate(worklistLayerUris, "#"));

            return(base.OnWriteSettingsAsync(settings));
        }
        /// <summary>
        /// If a api key value has been set write  it to the project settings.
        /// </summary>
        /// <param name="settings"></param>
        /// <returns></returns>
        protected override Task OnWriteSettingsAsync(ModuleSettingsWriter settings)
        {
            //if (API_KEY != null)
            //{
            //    if (API_KEY.API_KEY_Value != "")
            //    {
            //        settings.Add("planet_api_key", API_KEY.API_KEY_Value);
            //    }
            //    if (IsTrial == true)
            //    {
            //        settings.Add("IsTrial", "true");
            //    }
            //    if (API_KEY.EMAIL_Value != "")
            //    {
            //        settings.Add("planet_email", API_KEY.EMAIL_Value);
            //    }
            //    if (API_KEY.organizationId_Value != "")
            //    {
            //        settings.Add("planet_organizationId", API_KEY.organizationId_Value);
            //    }
            //    if (API_KEY.programId_Value != "")
            //    {
            //        settings.Add("planet_programId", API_KEY.programId_Value);
            //    }
            //    //foreach (string key in _moduleSettings.Keys)
            //    //{
            //    //    settings.Add(key, _moduleSettings[key]);
            //    //}

            //}
            //else
            //{
            //    settings.Add("planet_api_key", "");
            //    settings.Add("IsTrial", "");
            //    settings.Add("planet_email", "");
            //    settings.Add("planet_organizationId", "");
            //    settings.Add("planet_programId", "");
            //}
            return(Task.FromResult(0));
        }
Exemplo n.º 5
0
 protected override Task OnWriteSettingsAsync(ModuleSettingsWriter settings)
 {
     //settings.Add("seqnum_startvalue", _svalue);
     //settings.Add("seqnum_incvalue", _ivalue);
     return(base.OnWriteSettingsAsync(settings));
 }
Exemplo n.º 6
0
 protected override Task OnWriteSettingsAsync(ModuleSettingsWriter settings)
 {
     settings.Add(CONFIGURATION_KEY, Configurations);
     return(base.OnWriteSettingsAsync(settings));
 }
Exemplo n.º 7
0
        protected override Task   OnWriteSettingsAsync(ModuleSettingsWriter settings)
        {
            try
            {
                if (ConnectionItems.Count > 0)
                {
                    string fullString = ""; //= String.Join<ConnectionItem>(String.Empty, ConnectionItems.ToArray());
                    foreach (ConnectionItem item in ConnectionItems)
                    {
                        string   tst2 = new System.Net.NetworkCredential(string.Empty, item.pass).Password;
                        string[] ss   = { item.name, item.server, item.userid, tst2 };
                        fullString = fullString + ";" + string.Join(",", ss);
                    }

                    string tst      = new System.Net.NetworkCredential(string.Empty, _Hpass).Password;
                    byte[] plaintxt = UnicodeEncoding.ASCII.GetBytes(fullString);
                    //string password = new System.Net.NetworkCredential(string.Empty, _Hpass).Password;
                    byte[] entropy = new byte[20];
                    using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider())
                    {
                        rng.GetBytes(entropy);
                    }
                    string     contentPath = System.IO.Path.Combine(Project.Current.HomeFolderPath, "Data.dat");
                    byte[]     ciphertext  = System.Security.Cryptography.ProtectedData.Protect(plaintxt, null, DataProtectionScope.CurrentUser);
                    FileStream fStream     = new FileStream(contentPath, FileMode.OpenOrCreate);
                    string     encryt      = UnicodeEncoding.ASCII.GetString(ciphertext, 0, ciphertext.Length);
                    // Write the encrypted data to a stream.
                    if (fStream.CanWrite && ciphertext != null)
                    {
                        fStream.Write(ciphertext, 0, ciphertext.Length);
                        settings.Add("Setting3", ciphertext.Length.ToString());
                        //if (_moduleSettings.ContainsKey("Setting3"))
                        //{
                        //    _moduleSettings.tr
                        //}
                        //foreach (string key in _moduleSettings.Keys)
                        //{
                        //    if (key == "Setting3")
                        //    {
                        //        settings.Add(key, ciphertext.Length.ToString());
                        //    }
                        //}

                        //length = ciphertext.Length;
                        fStream.Close();
                    }
                    //settings.Add(key, UnicodeEncoding.ASCII.GetString(ciphertext,0,ciphertext.Length));
                }
                foreach (string key in _moduleSettings.Keys)
                {
                    if (key == "Setting3")
                    {
                        //try
                        //{
                        //    string fullString = ""; //= String.Join<ConnectionItem>(String.Empty, ConnectionItems.ToArray());
                        //    foreach (ConnectionItem item in ConnectionItems)
                        //    {
                        //        string tst2 = new System.Net.NetworkCredential(string.Empty, item.pass).Password;
                        //        string[] ss = { item.name,item.server,item.userid, tst2 };
                        //        fullString = fullString + ";" + string.Join(",",ss);
                        //    }

                        //    string tst = new System.Net.NetworkCredential(string.Empty, _Hpass).Password;
                        //    byte[] plaintxt = UnicodeEncoding.ASCII.GetBytes(fullString);
                        //    //string password = new System.Net.NetworkCredential(string.Empty, _Hpass).Password;
                        //    byte[] entropy = new byte[20];
                        //    using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider())
                        //    {
                        //        rng.GetBytes(entropy);
                        //    }
                        //    string contentPath = System.IO.Path.Combine(Project.Current.HomeFolderPath, "Data.dat");
                        //    byte[] ciphertext = System.Security.Cryptography.ProtectedData.Protect(plaintxt, null, DataProtectionScope.CurrentUser);
                        //    FileStream fStream = new FileStream(contentPath, FileMode.OpenOrCreate);
                        //    string encryt = UnicodeEncoding.ASCII.GetString(ciphertext, 0, ciphertext.Length);
                        //    // Write the encrypted data to a stream.
                        //    if (fStream.CanWrite && ciphertext != null)
                        //    {
                        //        fStream.Write(ciphertext, 0, ciphertext.Length);
                        //        settings.Add(key, ciphertext.Length.ToString());
                        //        //length = ciphertext.Length;
                        //        fStream.Close();
                        //    }
                        //    //settings.Add(key, UnicodeEncoding.ASCII.GetString(ciphertext,0,ciphertext.Length));

                        //    settings.Add(key, ciphertext.Length.ToString());
                        //}
                        //catch (Exception sss)
                        //{
                        //    string ss =sss.Message;
                        //    throw;
                        //}
                    }
                    else
                    {
                        settings.Add(key, _moduleSettings[key]);
                    }
                }
            }
            catch (Exception ex)
            { MessageBox.Show("Error in OnReadSettingsAsync:  " + ex.Message.ToString(), "Error"); }

            return(Task.FromResult(0));
        }
        /// <summary>
        /// Writes the module's settings.  This method is called when a project is saved.  Populate the modules settings into the ModuleSettingsWriter settings.
        /// </summary>
        /// <param name="settings">The settings which will be written out</param>
        /// <returns>A Task that represents the OnWriteStateAsync method</returns>
        protected override Task OnWriteSettingsAsync(ModuleSettingsWriter settings)
        {
          foreach (string key in _moduleSettings.Keys)
          {
            settings.Add(key, _moduleSettings[key]);
          }

          return Task.FromResult(0);
        }