예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        IpAddress.RemoveOverdueAddress();
        ConcurrentDictionary <string, Tuple <string, DateTime> > addresses = IpAddress.Get();
        StringBuilder sbAddress = new StringBuilder();

        if (addresses != null && addresses.Count > 0)
        {
            sbAddress.AppendFormat("已保存{0}台客户端的地址:", addresses.Count);
            int i = 0;
            foreach (string key in addresses.Keys)
            {
                Tuple <string, DateTime> value;
                if (addresses.TryGetValue(key, out value))
                {
                    i++;
                    sbAddress.AppendFormat("<br />({0}){1},{2},{3}", i, key, value.Item1, value.Item2);
                }
            }
        }
        else
        {
            sbAddress.Append("没有已报告的客户端地址。");
        }
        ltrAddress.Text = sbAddress.ToString();
    }
예제 #2
0
        private XmlElement IPADRESS_INFO(XmlDocument doc, DataTable data)
        {
            XmlElement ip_INFO = doc.CreateElement("IpAddress");

            List <PropertyInfo> P_List  = new List <PropertyInfo>();
            IpAddress           address = IpAddress.Get();

            P_List.AddRange(address.GetType().GetProperties());



            for (int i = 0; i < P_List.Count(); i++)
            {
                XmlElement tmp_Elm = doc.CreateElement(P_List[i].Name);

                string[] columnNames = data.Columns.Cast <DataColumn>()

                                       .Select(x => x.ColumnName)

                                       .ToArray();

                tmp_Elm.InnerText = columnNames[i].ToString();

                ip_INFO.AppendChild(tmp_Elm);
            }



            return(ip_INFO);
        }
예제 #3
0
        public static void Update(int id, string text)
        {
            IpAddress entity = IpAddress.Get(id);

            entity.IpAddressValue = text;
            Validate(entity);
            IpAddress.Update(entity);
        }
예제 #4
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            IpAddress.Get().ipAddress = ipAddress.Text;
            IpAddress.Get().port      = port.Text;

            //DataTable table = new DataTable("IPAddress");
            //table.Columns.Add(IpAddress.Get().ipAddress);

            //DataSet ds = new DataSet("IpSetting");
            //ds.Tables.Add(table);

            Thread thread = new Thread(Make_XMLFile);

            thread.Start();
        }
예제 #5
0
        private void Make_XMLFile()
        {
            try
            {
                string   xmlFileName = "Settings.xml";
                FileInfo fileInfo    = new FileInfo(Environment.CurrentDirectory + "\\xml\\" + xmlFileName);

                if (fileInfo.Exists) //xml파일 수정
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(Environment.CurrentDirectory + "\\xml\\" + xmlFileName);
                    XmlNode ipAddressNode = xmlDoc.SelectSingleNode("/descendant::Settings/IpAddress");
                    XmlNode portNode      = xmlDoc.SelectSingleNode("/descendant::Settings/Port");
                    ipAddressNode.InnerText = IpAddress.Get().ipAddress.ToString();
                    portNode.InnerText      = IpAddress.Get().port.ToString();
                    xmlDoc.Save(Environment.CurrentDirectory + "\\xml\\" + xmlFileName);
                }
                else //xml파일 생성
                {
                    XmlDocument xmlDoc = new XmlDocument();

                    XmlNode root = xmlDoc.CreateElement("Settings");
                    xmlDoc.AppendChild(root);

                    XmlNode ipAddressNode = xmlDoc.CreateElement("IpAddress");
                    XmlNode portNode      = xmlDoc.CreateElement("Port");

                    ipAddressNode.InnerText = IpAddress.Get().ipAddress.ToString();
                    portNode.InnerText      = IpAddress.Get().port.ToString();

                    root.AppendChild(ipAddressNode);
                    root.AppendChild(portNode);

                    xmlDoc.Save(Environment.CurrentDirectory + "\\xml\\" + xmlFileName);
                }

                MessageBox.Show("설정되었습니다.");

                this.Dispatcher.BeginInvoke(new Action(delegate
                {
                    Settings._Parent.Opacity = 1;
                    this.Close();
                }));
            }
            catch (Exception ex)
            {
                MessageBox.Show("오류: " + ex);
            }



            //DirectoryInfo DirInfoi = new DirectoryInfo(Environment.CurrentDirectory + "\\test");



            //while (DirInfoi.Exists == false)

            //{

            //    retryCnt--;

            //    DirInfoi.Create();

            //    DirInfoi = new DirectoryInfo(Environment.CurrentDirectory + "\\test");

            //}

            //if (retryCnt != 0)
            //{
            //    retryCnt = 5;

            //    DirInfoi = new DirectoryInfo(Environment.CurrentDirectory + "\\test");

            //    while (DirInfoi.Exists == false && retryCnt > 0)
            //    {

            //        DirInfoi.Create();
            //        DirInfoi = new DirectoryInfo(Environment.CurrentDirectory + "\\test");

            //    }



            //}
            //else
            //{

            //}
        }