private void button2_Click(object sender, EventArgs e) { DialogResult ok = MessageBox.Show("Сохранить?", "Внимание!", MessageBoxButtons.OKCancel); if (ok == DialogResult.OK) { try { Settings s = new Settings(new Xor()); SaveParam param = new SaveParam(); param.from = from.Text; param.to = to.Text; param.smtp = smtpserver.Text; param.username = username.Text; param.subject = subject.Text; param.message = message.Text; param.password = password.Text; s.Save(param); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { this.Close(); } }
public void Open(string pathWhereToSave = "", string nameFileWithSettings = "\\settings") { if (pathWhereToSave == "") { pathWhereToSave = System.Windows.Forms.Application.StartupPath; } byte[] securesettings = File.ReadAllBytes(pathWhereToSave + nameFileWithSettings); saveParam = new SaveParam(abstractCrypto.Decoding(securesettings)); }
public void Save(SaveParam saveParam, string pathWhereToSave = "", string nameFileWithSettings = "\\settings") { if (pathWhereToSave == "") { pathWhereToSave = System.Windows.Forms.Application.StartupPath; } File.WriteAllBytes(pathWhereToSave + nameFileWithSettings, abstractCrypto.Encode(saveParam.ToString())); }
public IActionResult SavaRoleModular(SaveParam param) { //模块接口 var role = this.GetInstance <IRoles>(); //查询角色所有的模块 var result = role.RoleModularSava(param.roleid, param.modularids)?.Result; return(Json(result)); }
public IActionResult OnPostXml(SaveParam item) { var result = new Dictionary <string, object>(); try { if (string.IsNullOrEmpty(item.name.ToLower().Replace(".xml", ""))) { result.Add("msg", "xml文件名填写不正确"); result.Add("Issuccess", false); } else { var xmlPath = string.Format("map/{0}", item.name); using (var xmlWrite = System.IO.File.Create(xmlPath)) { xmlWrite.Write(Encoding.Default.GetBytes(item.xml)); } if (IFast.CheckMap(xmlPath)) { var map = BaseConfig.GetValue <SqlMap>("SqlMap", "map.json"); if (!map.Path.Exists(a => a.ToLower() == string.Format("map/{0}", item.name.ToLower()))) { var dic = new Dictionary <string, object>(); map.Path.Add(string.Format("map/{0}", item.name)); dic.Add("SqlMap", map); var json = BaseJson.ModelToJson(dic); System.IO.File.WriteAllText("map.json", json); } FastMap.InstanceMap(); result.Add("msg", "操作成功"); result.Add("Issuccess", true); } else { result.Add("msg", "操作失败"); result.Add("Issuccess", false); } } return(new JsonResult(result)); } catch (Exception ex) { BaseLog.SaveLog(ex.StackTrace, "xml"); result.Add("msg", ex.Message); result.Add("Issuccess", false); return(new JsonResult(result)); } }
/// <summary> /// 构造函数/初始化默认路径 /// </summary> public AppParam() { _saveParam = new SaveParam(); _saveDir = "d:\\FileSave";//默认保存文件路径 }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { if (lvFileList.SelectedItems.Count == 1) { UpdateFile uFile = lvFileList.SelectedItems[0].Tag as UpdateFile; sfdSaveFile.FileName = uFile.Name; if (sfdSaveFile.ShowDialog() == DialogResult.OK) { lu.SaveAs(uFile, sfdSaveFile.FileName); } MessageBox.Show("File saved.", "File Editor", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (lvFileList.SelectedItems.Count > 1) { if (fbdFolderSelect.ShowDialog() == DialogResult.OK) { SetState(true, lvFileList.SelectedItems.Count); bgWorker.DoWork += new DoWorkEventHandler(bgWorker2_DoWork); SaveParam param = new SaveParam(); param.uFiles = lvFileList.SelectedItems.OfType<ListViewItem>().Select(i => i.Tag as UpdateFile).ToList(); param.Path = fbdFolderSelect.SelectedPath; bgWorker.RunWorkerAsync(param); } } }