private void btnOk_Click(object sender, EventArgs e) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; if (Validation()) { Atend.Control.Common.DesignId = 0; string DesignFile = string.Format(@"{0}\DesignFile\AtendEmpty.dwg", Atend.Control.Common.fullPath); //ed.WriteMessage("111:{0}",DesignFile); string DatabaseFile = string.Format(@"{0}\DatabaseFile\AtendLocal.mdb", Atend.Control.Common.fullPath); //ed.WriteMessage("222:{0}", DatabaseFile); string Destination = string.Format(@"{0}\{1}", txtFilePath.Text, txtFileName.Text); //ed.WriteMessage("333:{0}", Destination); if (File.Exists(DesignFile) && File.Exists(DatabaseFile)) { if (Directory.Exists(string.Format(@"{0}\{1}", txtFilePath.Text, txtFileName.Text))) { Directory.Delete(string.Format(@"{0}\{1}", txtFilePath.Text, txtFileName.Text), true); } if (!Directory.Exists(string.Format(@"{0}\{1}", txtFilePath.Text, txtFileName.Text))) { Directory.CreateDirectory(string.Format(@"{0}\{1}", txtFilePath.Text, txtFileName.Text)); File.Copy(DesignFile, string.Format(@"{0}\{1}.DWG", Destination, txtFileName.Text)); File.Copy(DatabaseFile, string.Format(@"{0}\{1}.MDB", Destination, txtFileName.Text)); Atend.Global.Acad.DrawinOperation dOperation = new Atend.Global.Acad.DrawinOperation(); dOperation.AddFileToAtendFile(txtFullPath.Text, string.Format(@"{0}\{1}.DWG", Destination, txtFileName.Text)); dOperation.AddFileToAtendFile(txtFullPath.Text, string.Format(@"{0}\{1}.MDB", Destination, txtFileName.Text)); File.SetAttributes(string.Format(@"{0}\{1}.DWG", Destination, txtFileName.Text), FileAttributes.Normal); Atend.Control.Common.DesignName = txtFileName.Text + ".DWG"; Atend.Control.Common.DesignFullAddress = string.Format(@"{0}\{1}", txtFilePath.Text, txtFileName.Text); Atend.Control.Common.AccessPath = string.Format(@"{0}\{1}", Atend.Control.Common.DesignFullAddress, txtFileName.Text + ".MDB"); System.Diagnostics.Process.Start(string.Format(@"{0}\{1}.DWG", Destination, txtFileName.Text)); //////DocumentCollection _DocumentCollection = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager; //////if (File.Exists(string.Format(@"{0}\{1}.DWG", Destination, txtFileName.Text))) //////{ ////// _DocumentCollection.Open(string.Format(@"{0}\{1}.DWG", Destination, txtFileName.Text), false); //////} //////else //////{ ////// ed.WriteMessage("File was not exist : {0} \n", string.Format(@"{0}\{1}.DWG", Destination, txtFileName.Text)); //////} Atend.Base.Acad.AT_COUNTER.ReadAll(); } } }// else { AllowClosing = false; } }
private void btnSave_Click(object sender, EventArgs e) { //Atend.Base.Acad.AT_COUNTER.SaveAll(); Directory.CreateDirectory(string.Format(@"{0}\{1}", Atend.Control.Common.DesignFullAddress, "Data")); File.Copy(string.Format(@"{0}\{1}", txtPath.Text, txtName.Text.Replace(".ATNX", ".DWG")), string.Format(@"{0}\{1}\{2}", txtPath.Text, "Data", txtName.Text.Replace(".ATNX", ".DWG")), true); File.Copy(string.Format(@"{0}\{1}", txtPath.Text, txtName.Text.Replace(".ATNX", ".MDB")), string.Format(@"{0}\{1}\{2}", txtPath.Text, "Data", txtName.Text.Replace(".ATNX", ".MDB")), true); Atend.Global.Acad.DrawinOperation dOp = new Atend.Global.Acad.DrawinOperation(); dOp.AddFileToAtendFile(string.Format(@"{0}\{1}", txtPath.Text, txtName.Text), string.Format(@"{0}\{1}\{2}", txtPath.Text, "Data", txtName.Text.Replace(".ATNX", ".DWG"))); dOp.AddFileToAtendFile(string.Format(@"{0}\{1}", txtPath.Text, txtName.Text), string.Format(@"{0}\{1}\{2}", txtPath.Text, "Data", txtName.Text.Replace(".ATNX", ".MDB"))); //fs = File.Open(string.Format(@"{0}\{1}\{2}", txtPath.Text, "Data", txtName.Text.Replace(".ATNX", ".MDB")), FileMode.Open); //BinaryReader br = new BinaryReader(fs); //Atend.Base.Design.DDesignFile dDesignFile = new Atend.Base.Design.DDesignFile(); //dDesignFile.DesignCode = Atend.Control.Common.SelectedDesignCode; //dDesignFile.FileSize = Convert.ToInt64(br.BaseStream.Length); //dDesignFile.File = br.ReadBytes((Int32)br.BaseStream.Length); //if (!dDesignFile.Insert()) // MessageBox.Show("امکان ثبت اطلاعات نمی باشد", "خطا"); }
private void btnOk_Click(object sender, EventArgs e) { if (Validation()) { AllowToClose = true; long PRGCode = Atend.Base.Design.DDesign.SelectByID(Convert.ToInt32(gvDesign.Rows[gvDesign.CurrentRow.Index].Cells["Id"].Value.ToString())).PRGCode; int ID = Convert.ToInt32(gvDesign.Rows[gvDesign.CurrentRow.Index].Cells["Id"].Value.ToString()); Atend.Control.Common.DesignId = ID; string Destination = ""; if (txtFilePath.Text.LastIndexOf(@"\") == txtFilePath.Text.Length - 1) { //Destination = string.Format(@"{0}{1}", txtFilePath.Text, ID); Destination = string.Format(@"{0}{1}", txtFilePath.Text, PRGCode); } else { //Destination = string.Format(@"{0}\{1}", txtFilePath.Text, ID); Destination = string.Format(@"{0}\{1}", txtFilePath.Text, PRGCode); } Atend.Base.Design.DDesignFile df1 = Atend.Base.Design.DDesignFile.SelectByDesignId(ID); if (df1.Id != -1 && df1.File != null) { //ed.WriteMessage("____OPEN\n"); try { //ed.WriteMessage("________3\n"); if (df1.File != null) { if (Directory.Exists(Destination)) { Directory.Delete(Destination, true); } //Atend.Control.Common.DesignName = ID + ".DWG"; Atend.Control.Common.DesignName = PRGCode + ".DWG"; Atend.Control.Common.Edition = gvDesign.Rows[gvDesign.CurrentRow.Index].Cells[5].Value.ToString(); //Atend.Control.Common.DesignFullAddress = string.Format(@"{0}\{1}", txtFilePath.Text, ID); Atend.Control.Common.DesignFullAddress = string.Format(@"{0}\{1}", txtFilePath.Text, PRGCode); //Atend.Control.Common.AccessPath = string.Format(@"{0}\{1}", Atend.Control.Common.DesignFullAddress, ID + ".MDB"); Atend.Control.Common.AccessPath = string.Format(@"{0}\{1}", Atend.Control.Common.DesignFullAddress, PRGCode + ".MDB"); Directory.CreateDirectory(Destination); Stream st = new MemoryStream(); //st = File.Create(string.Format(@"{0}\{1}.ATNX", Destination, ID)); st = File.Create(string.Format(@"{0}\{1}.ATNX", Destination, PRGCode)); BinaryWriter binWriter = new BinaryWriter(st); binWriter.Write((byte[])df1.File); binWriter.Close(); } } catch (System.Exception ex) { ed.WriteMessage("OPEN ERROR : {0} \n", ex.Message); } } else { //ed.WriteMessage("____NEW\n"); string DesignFile = string.Format(@"{0}\DesignFile\AtendEmpty.dwg", Atend.Control.Common.fullPath); string DatabaseFile = string.Format(@"{0}\DatabaseFile\AtendLocal.mdb", Atend.Control.Common.fullPath); if (File.Exists(DesignFile) && File.Exists(DatabaseFile)) { try { if (Directory.Exists(Destination)) { Directory.Delete(Destination, true); } //string dis = Destination + string.Format(@"\{0}.ATNX", ID); string dis = Destination + string.Format(@"\{0}.ATNX", PRGCode); Directory.CreateDirectory(Destination); //File.Copy(DesignFile, string.Format(@"{0}\{1}.DWG", Destination, ID)); //File.Copy(DatabaseFile, string.Format(@"{0}\{1}.MDB", Destination, ID)); File.Copy(DesignFile, string.Format(@"{0}\{1}.DWG", Destination, PRGCode)); File.Copy(DatabaseFile, string.Format(@"{0}\{1}.MDB", Destination, PRGCode)); Atend.Global.Acad.DrawinOperation dOperation = new Atend.Global.Acad.DrawinOperation(); //dOperation.AddFileToAtendFile(dis, string.Format(@"{0}\{1}.DWG", Destination, ID)); //dOperation.AddFileToAtendFile(dis, string.Format(@"{0}\{1}.MDB", Destination, ID)); dOperation.AddFileToAtendFile(dis, string.Format(@"{0}\{1}.DWG", Destination, PRGCode)); dOperation.AddFileToAtendFile(dis, string.Format(@"{0}\{1}.MDB", Destination, PRGCode)); //File.SetAttributes(string.Format(@"{0}\{1}.DWG", Destination, ID), FileAttributes.Normal); File.SetAttributes(string.Format(@"{0}\{1}.DWG", Destination, PRGCode), FileAttributes.Normal); //Atend.Control.Common.DesignName = ID + ".DWG"; Atend.Control.Common.DesignName = PRGCode + ".DWG"; Atend.Control.Common.Edition = gvDesign.Rows[gvDesign.CurrentRow.Index].Cells[5].Value.ToString(); //Atend.Control.Common.DesignFullAddress = string.Format(@"{0}\{1}", txtFilePath.Text, ID); Atend.Control.Common.DesignFullAddress = string.Format(@"{0}\{1}", txtFilePath.Text, PRGCode); //Atend.Control.Common.AccessPath = string.Format(@"{0}\{1}", Atend.Control.Common.DesignFullAddress, ID + ".MDB"); Atend.Control.Common.AccessPath = string.Format(@"{0}\{1}", Atend.Control.Common.DesignFullAddress, PRGCode + ".MDB"); } catch (System.Exception ex) { ed.WriteMessage("NEW ERROR : {0} \n", ex.Message); } } }// end for new } else { AllowToClose = false; } }