private void lnkSave_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (isSaveed == false) { if (MapConfiged) { frmDFileDialog f = new frmDFileDialog(); //f.InitialDirectory = Application.StartupPath + "\\MapGis\\MapConfigFiles"; //f.DefaultExt = "shz"; //f.Filter = "三恒科技图形系统配置文件|*.shz"; if (f.ShowDialog() == DialogResult.OK) { //ConfigXml.Save(f.FileName); string filename = f.SafeFileName; byte[] xmlbytes = new FileChanger().XmlToBytes(ConfigXml); if (dpicbll.ExitsFileName(filename)) { dpicbll.UpdateFile(filename, xmlbytes, FileID); } else { dpicbll.AddFile(filename, xmlbytes, FileID); } this.isSaveed = true; } } else { MessageBox.Show("底图尚未配置!", "提示", MessageBoxButtons.OK); } } }
private void tsmiOpen_Click(object sender, EventArgs e) { frmDFileDialog openfileDlg = new frmDFileDialog(false); //openfileDlg.Multiselect = false; //openfileDlg.InitialDirectory = Application.StartupPath + "\\MapGis\\MapConfigFiles"; //openfileDlg.Filter = "三恒科技图形系统文件|*.shz"; if (openfileDlg.ShowDialog() == DialogResult.OK) { pnlInOut.Visible = true; if (!IsOut) { this.picInOut_Click(this, new EventArgs()); } if (dpicbll.ExitsFileName(openfileDlg.SafeFileName)) { DataTable bufferdt = dpicbll.GetXmlByFileName(openfileDlg.SafeFileName); byte[] xmlbytes = (byte[])bufferdt.Rows[0][0]; FileChanger filechanger = new FileChanger(); ConfigXml = filechanger.BytesToXml(xmlbytes); LoadMapConfig(filechanger.BytesToXml(xmlbytes)); this.isSaveed = false; } else { MessageBox.Show("您所选择的文件不存在!", "提示", MessageBoxButtons.OK); } } }
protected override void OnBeforeDelete() { List <TbDetailJenisKegiatanRow> detail = Connection.List <TbDetailJenisKegiatanRow>(x => x.SelectTableFields().Where(string.Format("IdJenisKegiatan = {0}", Row.Id))); if (detail.Count > 0) { foreach (var item in detail) { if (item.NamaFile != null) { FileChanger.Delete(item.NamaFile); } if (item.Dokumentasi != null) { var resultFile = Newtonsoft.Json.JsonConvert.DeserializeObject <List <FileNameResult> >(item.Dokumentasi); foreach (var doc in resultFile) { FileChanger.Delete(doc.Filename); } } } this.Connection.Execute(string.Format("DELETE dbo.TbDetailJenisKegiatan WHERE IdJenisKegiatan = {0} ", this.Row.Id)); } }
protected override void AfterSave() { #region detail if (this.Row.tbDetailJenisInformasiRow.Count > 0) { string idIn = ""; int i = 0; foreach (TbDetailJenisInformasiRow detailRow in this.Row.tbDetailJenisInformasiRow) { setFolder = this.Row.KodeRt + "/" + "Informasi/" + this.Row.JenisInformasi + "/" + detailRow.Judul + "/"; FileChanger.CreateFolder(setFolder); detailRow.IdJenisInformasi = this.Row.Id; detailRow.DibuatOleh = this.Row.DibuatOleh; source = detailRow.NamaFile; if (source != null) { var splt = source.Split('/'); destination = setFolder + splt[splt.Length - 1]; FileChanger.Move(source, destination); detailRow.NamaFile = destination; } if (detailRow.Id != null) { this.Connection.UpdateById(detailRow); } else { int insertId = (int)this.Connection.InsertAndGetID(detailRow); //set accountRow.Id detailRow.Id = (int)insertId; } i++; idIn += detailRow.Id.ToString(); if (i < this.Row.tbDetailJenisInformasiRow.Count) { idIn += ","; } } this.Connection.Execute(string.Format("DELETE dbo.TbDetailJenisInformasi WHERE Id Not In ({0}) and IdJenisInformasi = {1}", idIn, this.Row.Id)); } else { this.Connection.Execute(string.Format("DELETE dbo.TbDetailJenisInformasi WHERE IdJenisInformasi = {0} ", this.Row.Id)); } #endregion }
protected override void OnBeforeDelete() { List <TbDetailJenisInformasiRow> detail = Connection.List <TbDetailJenisInformasiRow>(x => x.SelectTableFields().Where(string.Format("IdJenisInformasi = {0}", Row.Id))); if (detail.Count > 0) { foreach (var item in detail) { if (item.NamaFile != null) { FileChanger.Delete(item.NamaFile); } } this.Connection.Execute(string.Format("DELETE dbo.TbDetailJenisInformasi WHERE IdJenisInformasi = {0} ", this.Row.Id)); } }
protected override void BeforeSave() { #region header setFolder = this.Row.KodeRt + "/" + "Questioner/" + this.Row.Judul + "/"; FileChanger.CreateFolder(setFolder); if (this.Row.FileName != null) { source = Row.FileName; var splt = source.Split('/'); destination = setFolder + splt[splt.Length - 1]; FileChanger.Move(source, destination); this.Row.FileName = destination; } #endregion }
public static void ChangeFiles(InputData input) { var files = Dir.GetFiles(input); var changer = ChangingFile.GetChange(input.Modifier); Action act = new FileChanger(changer); act = new TimeMeasurer(act); act = new CheckPermission(act); foreach (var file in files) { changer.FileForChange = file; act.Act(); file.Save(); } }
protected override void OnBeforeDelete() { List <TbDetailPemiluRow> detail = Connection.List <TbDetailPemiluRow>(x => x.SelectTableFields().Where(string.Format("IdPemilu = {0}", Row.Id))); if (detail.Count > 0) { foreach (var item in detail) { this.Connection.Execute(string.Format("DELETE dbo.TbPollingPemilu WHERE IdDetailPemilu = {0} ", item.Id)); if (item.FileName != null) { FileChanger.Delete(item.FileName); } } this.Connection.Execute(string.Format("DELETE dbo.TbDetailPemilu WHERE IdPemilu = {0} ", this.Row.Id)); } if (Row.FileName != null) { FileChanger.Delete(Row.FileName); } }
internal void UserChoise() { while (true) { Console.WriteLine("Choose your action and write in console"); Console.WriteLine(); Console.WriteLine("\t If your wont delete smt in file write:"); Console.WriteLine("change"); Console.WriteLine(); Console.WriteLine("\t If your wont count words in file write:"); Console.WriteLine("count"); Console.WriteLine(); Console.WriteLine("\t If your wont wrap smt in file write:"); Console.WriteLine("wrap"); Console.WriteLine(); Console.WriteLine("\t If your wont to see files write:"); Console.WriteLine("file"); Console.WriteLine(); Console.WriteLine("if your wont to exit push q"); choise = Console.ReadLine(); switch (choise) { case "change": FileChanger test = new FileChanger(); test.Delete(); break; case "count": Word test1 = new Word(); break; case "wrap": Letters test2 = new Letters(); break; case "file": FileExplorer test3 = new FileExplorer(); test3.ProcessDirectory(); test3.SeeDirectories(); break; case "q": Console.WriteLine("Your decided exit"); break; default: Console.WriteLine("Invalid input"); break; } Console.ReadLine(); if (choise == "q") { break; } } }
protected override void AfterSave() { #region detail if (this.Row.tbDetailJenisKegiatanRow.Count > 0) { string idIn = ""; int i = 0; foreach (TbDetailJenisKegiatanRow detailRow in this.Row.tbDetailJenisKegiatanRow) { setFolder = this.Row.KodeRt + "/" + "Kegiatan/" + this.Row.JenisKegiatan + "/" + detailRow.NamaKegiatan + "/"; FileChanger.CreateFolder(setFolder); detailRow.IdJenisKegiatan = this.Row.Id; detailRow.DibuatOleh = this.Row.DibuatOleh; source = detailRow.NamaFile; if (source != null) { var splt = source.Split('/'); destination = setFolder + splt[splt.Length - 1]; FileChanger.Move(source, destination); detailRow.NamaFile = destination; } if (detailRow.Dokumentasi != null && detailRow.Dokumentasi != "[]") { string currentPath = ""; var resultFile = Newtonsoft.Json.JsonConvert.DeserializeObject <List <FileNameResult> >(detailRow.Dokumentasi); foreach (var item in resultFile) { source = item.Filename; var splt = source.Split('/'); destination = setFolder + splt[splt.Length - 1]; FileChanger.Move(source, destination); currentPath = splt[splt.Length - 2] + "/"; if (splt.Length > 2) { currentPath = splt[splt.Length - 5] + "/" + splt[splt.Length - 4] + "/" + splt[splt.Length - 3] + "/" + splt[splt.Length - 2] + "/"; } } detailRow.Dokumentasi = detailRow.Dokumentasi.Replace(currentPath, setFolder); } if (detailRow.Id != null) { this.Connection.UpdateById(detailRow); } else { int insertId = (int)this.Connection.InsertAndGetID(detailRow); //set accountRow.Id detailRow.Id = (int)insertId; } i++; idIn += detailRow.Id.ToString(); if (i < this.Row.tbDetailJenisKegiatanRow.Count) { idIn += ","; } } this.Connection.Execute(string.Format("DELETE dbo.TbDetailJenisKegiatan WHERE Id Not In ({0}) and IdJenisKegiatan = {1}", idIn, this.Row.Id)); } else { this.Connection.Execute(string.Format("DELETE dbo.TbDetailJenisKegiatan WHERE IdJenisKegiatan = {0}", this.Row.Id)); } #endregion }