123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Xml;
- using System.IO;
- using System.Data;
- using System.Collections;
- namespace IControls_FireManager
- {
-
- public static class _File
- {
-
- public static string ProgramPath = Environment.CurrentDirectory + "\\";
-
- public static string ProgramFileName_Config = "Program_Configuration.xml";
- public static string ProgramFileName_DevType= "DevType.xml";
- public static string ProgramFileName_FieldSetting = "FieldSetting.xml";
-
- public static string ProgramFileName_Receiver = "Receiver.xml";
-
- public static string ProgramFileName_Log_Error = "Log_Error.txt";
-
-
-
-
-
- public static bool Read_ProgramConfiguration()
- {
- try
- {
-
- string FilePath = ProgramPath + ProgramFileName_Config;
-
-
-
-
-
- _Data.Program_Version = _Xml.Get_Value(new XmlTextReader(FilePath), "Program", "Version");
-
-
-
-
- _Data.Project_Path = _Xml.Get_Value(new XmlTextReader(FilePath), "Project", "Path");
- _Data.Project_ExcelOpenCheck = _Xml.Get_Value(new XmlTextReader(FilePath), "Project", "ExcelOpenCheck");
- _Data.Project_MapGroupIDTypeNumber = _Xml.Get_Value(new XmlTextReader(FilePath), "Project", "MapGroupIDTypeNumber");
-
-
-
-
- _Data.DB_IP = _Xml.Get_Value(new XmlTextReader(FilePath), "Database", "IP");
-
- _Data.DB_ID = _Xml.Get_Value(new XmlTextReader(FilePath), "Database", "ID");
-
- _Data.DB_PassWord = _Xml.Get_Value(new XmlTextReader(FilePath), "Database", "PassWord");
-
-
-
-
-
-
- _Data.Style_PanelVisualStyle = _Style.Get_PanelVisualStyle(_Xml.Get_Value(new XmlTextReader(FilePath), "Janus", "PanelVisualStyle"));
- _Data.Style_VisualStyle = _Style.Get_VisualStyle(_Xml.Get_Value(new XmlTextReader(FilePath), "Janus", "VisualStyle"));
- _Data.Style_Office2007ColorScheme = _Style.Get_Office2007ColorScheme(_Xml.Get_Value(new XmlTextReader(FilePath), "Janus", "Office2007ColorScheme"));
-
-
- return true;
- }
- catch (Exception e)
- {
-
- _Event.DebugView_SendMessage_Write(e.ToString());
- return false;
- }
- }
-
-
- public static void Write_ProgramConfiguration()
- {
-
- string FilePath = ProgramPath + ProgramFileName_Config;
-
- TextWriter streamWriter = new StreamWriter(FilePath);
-
- XmlTextWriter writer = new XmlTextWriter(streamWriter);
- try
- {
- StringBuilder strPacket = new StringBuilder();
-
-
- strPacket.Append(_Xml.Set_XMLHeader());
- strPacket.Append(_Xml.Set_XMLComment(_Text.XML_Comment_1th));
-
-
- strPacket.Append(_Xml.Set_BodyHeader(Xml_Body_Type.Program_Configuration, true));
-
- strPacket.Append(_Xml.Set_XMLComment(_Text.XML_Comment_2th));
- strPacket.Append(_Xml.Set_Body("Program", null,
- "Version=" + _Data.Program_Version, true));
-
- strPacket.Append(_Xml.Set_XMLComment(_Text.XML_Comment_3th));
- strPacket.Append(_Xml.Set_Body("Project", null,
- "Path=" + _Data.Project_Path +
- ";ExcelOpenCheck=" + _Data.Project_ExcelOpenCheck +
- ";MapGroupIDTypeNumber=" + _Data.Project_MapGroupIDTypeNumber, true));
-
- strPacket.Append(_Xml.Set_XMLComment(_Text.XML_Comment_4th));
- strPacket.Append(_Xml.Set_Body("Database", null,
- "IP=" + _Data.DB_IP +
- ";ID=" + _Data.DB_ID +
- ";PassWord=" + _Data.DB_PassWord, true));
-
-
- strPacket.Append(_Xml.Set_XMLComment(_Text.XML_Comment_5th));
- strPacket.Append(_Xml.Set_Body("Janus", null,
- "PanelVisualStyle=" + _Data.Style_PanelVisualStyle.ToString() +
- ";VisualStyle=" + _Data.Style_VisualStyle.ToString() +
- ";Office2007ColorScheme=" + _Data.Style_Office2007ColorScheme.ToString(), true));
-
-
- strPacket.Append(_Xml.Set_BodyHeader(Xml_Body_Type.Program_Configuration, false));
-
-
- writer.WriteRaw(strPacket.ToString());
- writer.Close();
- }
- catch (Exception e)
- {
-
- _Event.DebugView_SendMessage_Write(e.ToString());
- if (writer != null)
- writer.Close();
- }
- }
-
-
-
-
-
- public static void Write_Receiver_XML(string ProjectPath)
- {
-
- string FilePath = ProjectPath + "\\" + _Text.DEFALUT_FOLDER_TEMP + "\\" + ProgramFileName_Receiver;
-
- TextWriter streamWriter = new StreamWriter(FilePath);
-
- XmlTextWriter writer = new XmlTextWriter(streamWriter);
- try
- {
- StringBuilder strPacket = new StringBuilder();
-
- strPacket.Append(_Xml.Set_XMLHeader());
- strPacket.Append(_Xml.Set_XMLComment(_Text.XML_Comment_6th));
-
- strPacket.Append(_Xml.Set_BodyHeader(Xml_Body_Type.FIRE_Receiver, true));
-
- strPacket.Append(_Xml.Set_XMLComment(_Text.XML_Comment_7th));
-
- string TempId = null;
- foreach (string RECEIVER_ID in _Data.LIST_XMLRECEIVER_ID)
- TempId = TempId + RECEIVER_ID + _Text.Blank;
- if(TempId != null)
- TempId = TempId.TrimEnd();
- strPacket.Append(_Xml.Set_Body("Receiver", null,
- "ID=" + TempId, true));
-
-
- strPacket.Append(_Xml.Set_BodyHeader(Xml_Body_Type.FIRE_Receiver, false));
-
- writer.WriteRaw(strPacket.ToString());
- writer.Close();
-
- _Event.DebugView_SendMessage_Write(_Text.FieldSetting_Xml_Save);
- }
- catch (Exception e)
- {
-
- _Event.DebugView_SendMessage_Write(e.ToString());
- }
- }
-
- public static bool Read_Receiver_XML(string ProjectPath)
- {
- try
- {
-
- string FilePath = ProjectPath + "\\" + _Text.DEFALUT_FOLDER_TEMP + "\\" + ProgramFileName_Receiver;
-
-
-
- string Temp_ID = _Xml.Get_Value(new XmlTextReader(FilePath), "Receiver", "ID");
-
- if (Temp_ID == null) return false;
-
- string[] Temp_ID_Array = _Convert.String_to_ArrayString(_Text.BlankChar, Temp_ID);
- foreach(string ID in Temp_ID_Array)
- {
- if (_Data.LIST_XMLRECEIVER_ID.Contains(ID) == false && ID.Trim().Length != 0)
- _Data.LIST_XMLRECEIVER_ID.Add(ID);
- }
-
- return true;
- }
- catch
- {
- return false;
- }
- }
-
-
-
-
- private static void Create_Page_ID_Order(string RECEIVER_ID)
- {
- int PAGE_ID_Order = 0;
-
-
- foreach (string PAGE_ID in ((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).LIST_PAGE_ID)
- {
- if (PAGE_ID == _Data.CREATE_PAGE_ID(RECEIVER_ID,_Text.Main))
- {
- ((_Page)((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).HASH_PAGE[PAGE_ID]).ID = PAGE_ID_Order++.ToString();
- break;
- }
- }
-
-
- foreach (string PAGE_ID in ((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).LIST_PAGE_ID)
- {
- if (PAGE_ID != _Data.CREATE_PAGE_ID(RECEIVER_ID, _Text.Main))
- {
- ((_Page)((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).HASH_PAGE[PAGE_ID]).ID = PAGE_ID_Order++.ToString();
- }
- }
- }
-
- public static string Create_Page_ID_Order(string RECEIVER_ID, string JumpPageName)
- {
- foreach (string PAGE_ID in ((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).LIST_PAGE_ID)
- {
- if (((_Page)((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).HASH_PAGE[PAGE_ID]).NodeText == JumpPageName)
- return ((_Page)((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).HASH_PAGE[PAGE_ID]).ID;
- }
- return null;
- }
-
- public static string Read_Page_ID_Order(ArrayList Result, string JumpPageID)
- {
- foreach (_FieldSetting FieldSetting in Result)
- {
- if (FieldSetting.ID == JumpPageID)
- return FieldSetting.Name;
- }
- return null;
- }
-
-
- public static string Create_Device_Oper_ID(string PictureBox_Device_Oper_ID, string Receiver_ID)
- {
- if (PictureBox_Device_Oper_ID == null || PictureBox_Device_Oper_ID.Length == 0)
- return null;
- string[] Datas = PictureBox_Device_Oper_ID.Split('-');
- return Datas[0] + _Convert.String_to_Int_TwoType(Receiver_ID) + Datas[1] + Datas[2] + Datas[3] + Datas[4];
- }
-
-
- public static string Read_Device_Oper_ID(string XML_Device_Oper_ID)
- {
- if (XML_Device_Oper_ID == null || XML_Device_Oper_ID.Length == 0 || XML_Device_Oper_ID == _Text.Blank)
- return null;
-
- string result = null;
- result = result + XML_Device_Oper_ID[0].ToString();
- result = result + XML_Device_Oper_ID[1].ToString();
- result = result + "-";
- result = result + XML_Device_Oper_ID[4].ToString();
- result = result + XML_Device_Oper_ID[5].ToString();
- result = result + "-";
- result = result + XML_Device_Oper_ID[6].ToString();
- result = result + "-";
- result = result + XML_Device_Oper_ID[7].ToString();
- result = result + XML_Device_Oper_ID[8].ToString();
- result = result + XML_Device_Oper_ID[9].ToString();
- result = result + "-";
- result = result + XML_Device_Oper_ID[10].ToString();
- return result;
- }
-
- public static void Write_FieldSetting_XML(string RECEIVER_ID, string ProjectPath)
- {
-
- string FilePath = ProjectPath + "\\" + ProgramFileName_FieldSetting;
-
- TextWriter streamWriter = new StreamWriter(FilePath);
-
- XmlTextWriter writer = new XmlTextWriter(streamWriter);
- try
- {
- StringBuilder strPacket = new StringBuilder();
-
- strPacket.Append(_Xml.Set_XMLHeader());
-
-
- strPacket.Append(_Xml.Set_BodyHeader(Xml_Body_Type.FIRE_FieldSetting, true));
-
-
-
-
- Create_Page_ID_Order(RECEIVER_ID);
-
-
- for (int i = 0; i < ((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).LIST_PAGE_ID.Count; i++)
- {
- foreach (string PAGE_ID in ((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).LIST_PAGE_ID)
- {
- if (((_Page)((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).HASH_PAGE[PAGE_ID]).ID == i.ToString())
- {
- _Page Page = ((_Page)((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).HASH_PAGE[PAGE_ID]);
-
- strPacket.Append(_Xml.Set_Body_NotEnd("Field", null,
- "Receiver_ID=" + Page.Receiver_ID +
- ";ID=" + Page.ID +
- ";Name=" + Page.NodeText +
- ";IMAGE=" + Page.PictureBoxItem_BackGround.FileName, true));
-
- foreach (string ICON_ID in Page.LIST_ICON_ID)
- {
- if (((_PictureBoxItem)Page.HASH_ICON[ICON_ID]).ItemType == Item_Type.Device)
- {
- _PictureBoxItem PictureBoxItem = ((_PictureBoxItem)Page.HASH_ICON[ICON_ID]);
-
- string temp_Device_ID = Create_Device_Oper_ID(PictureBoxItem.Device_Oper_ID, Page.Receiver_ID);
- strPacket.Append(_Xml.Set_Body("Device", null,
- "ID=" + temp_Device_ID +
- ";Xposition=" + PictureBoxItem.Location.X +
- ";Yposition=" + PictureBoxItem.Location.Y +
- ";DevIconID=" + PictureBoxItem.Device_Icon_ID, true));
- }
- }
-
- foreach (string ICON_ID in Page.LIST_ICON_ID)
- {
- if (((_PictureBoxItem)Page.HASH_ICON[ICON_ID]).ItemType == Item_Type.Button)
- {
- _PictureBoxItem PictureBoxItem = ((_PictureBoxItem)Page.HASH_ICON[ICON_ID]);
-
- string temp_JumpField_ID =null;
- if (PictureBoxItem.Button_JumpPageName != null
- && PictureBoxItem.Button_JumpPageName.Length != 0
- && PictureBoxItem.Button_JumpPageName != _Text.None)
- {
-
- temp_JumpField_ID = Create_Page_ID_Order(RECEIVER_ID,PictureBoxItem.Button_JumpPageName);
-
-
- }
-
- temp_JumpField_ID = _Data.Get_Verify_ID(temp_JumpField_ID);
- strPacket.Append(_Xml.Set_Body("Button", null,
- "ID=" + "B" + PictureBoxItem.Name +
- ";Xposition=" + PictureBoxItem.Location.X +
- ";Yposition=" + PictureBoxItem.Location.Y +
- ";Image=" + PictureBoxItem.FileName +
- ";NAME=" + _Text.Null +
- ";JumpField=" + temp_JumpField_ID +
- ";Width=" + PictureBoxItem.Image.Size.Width +
- ";Height=" + PictureBoxItem.Image.Size.Height, true));
- }
- }
-
- strPacket.Append("</Field>\r\n");
- break;
- }
- }
- }
-
-
- strPacket.Append(_Xml.Set_BodyHeader(Xml_Body_Type.FIRE_FieldSetting, false));
-
- writer.WriteRaw(strPacket.ToString());
- writer.Close();
-
- _Event.DebugView_SendMessage_Write(_Text.FieldSetting_Xml_Save);
- }
- catch (Exception e)
- {
-
- _Event.DebugView_SendMessage_Write(e.ToString());
- }
- }
-
- public static ArrayList Read_FieldSetting_XML(string ProjectPath)
- {
- try
- {
-
- string FilePath = ProjectPath + "\\" + ProgramFileName_FieldSetting;
-
- ArrayList Result = new ArrayList();
-
- XmlDocument xmldoc = new XmlDocument();
-
- xmldoc.Load(FilePath);
- XmlElement Page = xmldoc.DocumentElement;
- XmlNodeList Fields = Page.ChildNodes;
- foreach (XmlNode Field in Fields)
- {
- _FieldSetting FieldSetting = new _FieldSetting();
- FieldSetting.Receiver_ID = Field.Attributes["Receiver_ID"].Value.ToString();
- FieldSetting.ID = Field.Attributes["ID"].Value.ToString();
- FieldSetting.Name = Field.Attributes["Name"].Value.ToString();
- FieldSetting.IMAGE = Field.Attributes["IMAGE"].Value.ToString();
- XmlNodeList nodes = Field.ChildNodes;
- foreach (XmlNode node in nodes)
- {
- if (node.Name == "Device")
- {
- _FieldSetting_Device FieldSetting_Device = new _FieldSetting_Device();
- FieldSetting_Device.ID = node.Attributes["ID"].Value.ToString();
- FieldSetting_Device.Xposition = node.Attributes["Xposition"].Value.ToString();
- FieldSetting_Device.Yposition = node.Attributes["Yposition"].Value.ToString();
- FieldSetting_Device.DevIconID = node.Attributes["DevIconID"].Value.ToString();
- FieldSetting.Device.Add(FieldSetting_Device);
- }
- else if (node.Name == "Button")
- {
- _FieldSetting_Button FieldSetting_Button = new _FieldSetting_Button();
- FieldSetting_Button.ID = node.Attributes["ID"].Value.ToString();
- FieldSetting_Button.Xposition = node.Attributes["Xposition"].Value.ToString();
- FieldSetting_Button.Yposition = node.Attributes["Yposition"].Value.ToString();
- FieldSetting_Button.Image = node.Attributes["Image"].Value.ToString();
- FieldSetting_Button.NAME = node.Attributes["NAME"].Value.ToString();
- FieldSetting_Button.JumpField = node.Attributes["JumpField"].Value.ToString();
- FieldSetting_Button.Width = node.Attributes["Width"].Value.ToString();
- FieldSetting_Button.Height = node.Attributes["Height"].Value.ToString();
- FieldSetting.Button.Add(FieldSetting_Button);
- }
- }
- Result.Add(FieldSetting);
- }
- return Result;
- }
- catch (Exception e)
- {
-
- _Event.DebugView_SendMessage_Write(e.ToString());
- return null;
- }
- }
-
-
-
-
- public static _DevTypeXML Read_DevType_By_FileName(string filename)
- {
- foreach (string DevTypeID in _Data.LIST_XMLDEVTYPE_ID)
- {
- if (((_DevTypeXML)_Data.HASH_XMLDEVTYPE[DevTypeID]).FILENAME == filename)
- return ((_DevTypeXML)_Data.HASH_XMLDEVTYPE[DevTypeID]);
- }
- return null;
- }
-
- public static _DevTypeXML Read_DevType_FileName_by_IconID(string IconID)
- {
- foreach (string XMLDEVTYPE_ID in _Data.LIST_XMLDEVTYPE_ID)
- {
- if (((_DevTypeXML)_Data.HASH_XMLDEVTYPE[XMLDEVTYPE_ID]).ID == IconID)
- return ((_DevTypeXML)_Data.HASH_XMLDEVTYPE[XMLDEVTYPE_ID]);
- }
- return null;
- }
-
- public static bool Read_DevType_XML(string ProjectPath)
- {
- try
- {
-
- string FilePath = ProjectPath + "\\" + ProgramFileName_DevType;
-
- string xml = File.ReadAllText(FilePath);
- System.IO.StringReader reader = new StringReader(xml);
-
- DataSet ds = new DataSet();
-
- ds.ReadXml(reader, XmlReadMode.Auto);
-
- DataRowCollection rows = ds.Tables[1].Rows;
-
- foreach (DataRow row in rows)
- {
- _DevTypeXML DevType = new _DevTypeXML();
- DevType.ID = row["ID"].ToString();
- DevType.FILENAME = row["IMAGE"].ToString();
- DevType.NAME = row["NAME"].ToString();
-
-
- if (_Hash.Add(_Data.HASH_XMLDEVTYPE, DevType.ID, DevType) == true)
- {
- _Data.LIST_XMLDEVTYPE_ID.Add(DevType.ID);
- }
- }
- return true;
- }
- catch (Exception e)
- {
-
- _Event.DebugView_SendMessage_Write(e.ToString());
- return false;
- }
- }
-
-
-
- public static void Create_ProjectFolder(string ProjectPath, string ProjectName)
- {
-
-
-
-
-
- string TargetPath_Project = ProjectPath + "\\" + ProjectName;
- string TargetPath_Temp = ProjectPath + "\\" + ProjectName + "\\" + _Text.DEFALUT_FOLDER_TEMP;
-
- Create_Folder(ProjectPath, ProjectName);
- Create_Folder(TargetPath_Project, _Text.DEFALUT_FOLDER_TEMP);
-
- string SourcePath_Temp = ProgramPath + "\\" + _Text.DEFAULT_PROJECT_NAME + "\\" + _Text.DEFALUT_FOLDER_TEMP;
-
-
- Copy_Folder(SourcePath_Temp, TargetPath_Temp);
- }
-
-
-
- public static void Create_ReceiverFolder(string ProjectPath, string ProjectName, string RECEIVER_ID)
- {
- try
- {
-
-
-
-
-
-
-
-
-
-
-
- string ReiceiverFolderName = _Text.DEFAULT_FOLDER_RECEIVER_PREFIX + RECEIVER_ID;
-
- string TargetPath_Project = ProjectPath + "\\" + ProjectName;
- string TargetPath_Receiver = ProjectPath + "\\" + ProjectName + "\\" + ReiceiverFolderName;
- string TargetPath_DB = ProjectPath + "\\" + ProjectName + "\\" + ReiceiverFolderName + "\\" + _Text.DEFAULT_FOLDER_DB;
- string TargetPath_Mapview = ProjectPath + "\\" + ProjectName + "\\" + ReiceiverFolderName + "\\" + _Text.DEFAULT_FOLDER_MAPVIEW;
-
- Create_Folder(TargetPath_Project, ReiceiverFolderName);
- Create_Folder(TargetPath_Receiver, _Text.DEFAULT_FOLDER_DB);
- Create_Folder(TargetPath_Receiver, _Text.DEFAULT_FOLDER_MAPVIEW);
- Create_Folder(TargetPath_Mapview, _Text.DEFAULT_FOLDER_FIELD);
- Create_Folder(TargetPath_Mapview, _Text.DEFAULT_FOLDER_SYMBOL);
- Create_Folder(TargetPath_Mapview, _Text.DEFAULT_FOLDER_XML);
-
- string SourcePath_Receiver = ProgramPath + "\\" + _Text.DEFAULT_PROJECT_NAME + "\\" + _Text.DEFAULT_FOLDER_RECEIVER_1;
- string SourcePath_DB = ProgramPath + "\\" + _Text.DEFAULT_PROJECT_NAME + "\\" + _Text.DEFAULT_FOLDER_RECEIVER_1 + "\\" + _Text.DEFAULT_FOLDER_DB;
- string SourcePath_Mapview = ProgramPath + "\\" + _Text.DEFAULT_PROJECT_NAME + "\\" + _Text.DEFAULT_FOLDER_RECEIVER_1 + "\\" + _Text.DEFAULT_FOLDER_MAPVIEW;
-
- Copy_Folder(SourcePath_Receiver, TargetPath_Receiver);
- Copy_Folder(SourcePath_DB, TargetPath_DB);
- Copy_Folder(SourcePath_Mapview, TargetPath_Mapview);
- Copy_Folder(SourcePath_Mapview + "\\" + _Text.DEFAULT_FOLDER_FIELD, TargetPath_Mapview + "\\" + _Text.DEFAULT_FOLDER_FIELD);
- Copy_Folder(SourcePath_Mapview + "\\" + _Text.DEFAULT_FOLDER_SYMBOL, TargetPath_Mapview + "\\" + _Text.DEFAULT_FOLDER_SYMBOL);
- Copy_Folder(SourcePath_Mapview + "\\" + _Text.DEFAULT_FOLDER_XML, TargetPath_Mapview + "\\" + _Text.DEFAULT_FOLDER_XML);
- }
- catch (Exception e)
- {
-
- _Event.DebugView_SendMessage_Write(e.ToString());
- }
- }
-
-
-
-
- public static bool Create_Folder(string path, string foldername)
- {
- try
- {
-
- if (!System.IO.Directory.Exists(path + "\\" + foldername))
- {
- System.IO.Directory.CreateDirectory(path + "\\" + foldername);
- }
- return true;
- }
- catch (Exception e)
- {
-
- _Event.DebugView_SendMessage_Write(e.ToString());
- return false;
- }
- }
-
- public static bool Delete_Folder(string path, string foldername)
- {
- try
- {
- System.IO.Directory.Delete(path + "\\" + foldername, true);
-
- return true;
- }
- catch
- {
-
-
- return false;
- }
- }
-
- public static string Get_Folder(string path)
- {
- try
- {
- string result = null;
- string [] Directories = null;
- Directories = System.IO.Directory.GetDirectories(path);
- foreach(string Directorie in Directories)
- {
- result = result + Directorie.Replace(path,_Text.Null) + _Text.SemiColon;
- }
- if(result!=null)
- result = result.TrimEnd(_Convert.Split_Key);
- return result;
- }
- catch (Exception e)
- {
-
- _Event.DebugView_SendMessage_Write(e.ToString());
- return null;
- }
- }
-
- public static string Get_FolderNameList(string path)
- {
- try
- {
- string result = null;
- string[] Files = null;
- Files = System.IO.Directory.GetDirectories(path);
- foreach (string File in Files)
- {
- result = result + File.Replace(path + "\\", _Text.Null) + _Text.SemiColon;
- }
- if (result != null)
- result = result.TrimEnd(_Convert.Split_Key);
- return result;
- }
- catch (Exception e)
- {
-
- _Event.DebugView_SendMessage_Write(e.ToString());
- return null;
- }
- }
-
- public static string Get_FileNameList(string path)
- {
- try
- {
- string result = null;
- string[] Files = null;
- Files = System.IO.Directory.GetFiles(path);
- foreach (string File in Files)
- {
- result = result + File.Replace(path + "\\", _Text.Null) + _Text.SemiColon;
- }
- if (result != null)
- result = result.TrimEnd(_Convert.Split_Key);
- return result;
- }
- catch (Exception e)
- {
-
- _Event.DebugView_SendMessage_Write(e.ToString());
- return null;
- }
- }
-
- public static void Copy_Folder(string sourcePath, string targetPath)
- {
-
- string[] files = System.IO.Directory.GetFiles(sourcePath);
-
- foreach (string file in files)
- {
- string fileName = System.IO.Path.GetFileName(file);
- string destfile = System.IO.Path.Combine(targetPath, fileName);
-
- if (!File.Exists(destfile))
- System.IO.File.Copy(file, destfile, true);
- }
- }
-
-
-
-
- public static FileInfo Read_FileInfo(string path)
- {
- try
- {
- FileInfo Info = new FileInfo(path);
- return Info;
- }
- catch (Exception e)
- {
-
- _Event.DebugView_SendMessage_Write(e.ToString());
- return null;
- }
- }
-
-
-
-
- public static void Write_Log(string txt)
- {
- try
- {
- string path = ProgramPath + ProgramFileName_Log_Error;
- if (!File.Exists(path))
- {
-
- string createText = txt + "\r\n";
- File.WriteAllText(path, createText);
- }
- else
- {
-
-
- string appendText = txt + "\r\n";
- File.AppendAllText(path, appendText);
- }
- }
- catch (Exception e)
- {
-
- _Event.DebugView_SendMessage_Write(e.ToString());
- }
- }
-
- public static void Delete_Log()
- {
- try
- {
- string path = ProgramPath + ProgramFileName_Log_Error;
- if (File.Exists(path))
- {
- File.Delete(path);
- }
- }
- catch (Exception e)
- {
-
- _Event.DebugView_SendMessage_Write(e.ToString());
- }
- }
- }
- }
|