/// <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)); }
protected override async Task OnWriteSettingsAsync(ModuleSettingsWriter settings) { foreach (var key in Settings.Keys) { settings.Add(key, Settings[key]); } try { await CheckForLastest(); } catch { // ignored } }
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)); }
protected override Task OnWriteSettingsAsync(ModuleSettingsWriter settings) { settings.Add(CONFIGURATION_KEY, Configurations); return(base.OnWriteSettingsAsync(settings)); }
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); }