private AddrList DeviceToAddrList()
        {
            AddrList addrList = new AddrList();

            using (var db = new ICMDBContext())
            {
                var Devices = db.Devices.ToList();
                AddLog("总共有 {0} 笔资料需要输出", Devices.Count);

                foreach (var d in Devices)
                {
                    AddrList.devRow dev = addrList.dev.NewdevRow();
                    dev.ip    = d.ip;
                    dev.ro    = d.roomid;
                    dev.alias = d.Alias;
                    dev.group = d.group;
                    dev.mc    = d.mac;
                    dev.ty    = (byte)d.type;
                    dev.sm    = d.sm;
                    dev.gw    = d.gw;
                    dev.id    = d.cameraid;
                    dev.pw    = d.camerapw;
                    addrList.dev.AdddevRow(dev);
                }
                addrList.AcceptChanges();
            }
            return(addrList);
        }
Esempio n. 2
0
        private void SetDefaultValue()
        {
            DataRowView row = bindingSource.AddNew() as DataRowView;

            AddrList.devRow device = row.Row as AddrList.devRow;

            // set dynamic default values here+
            ipTextBox.Text         = device.ip = addrList.dev.GetDefaultIP();
            subnetMaskTextBox.Text = device.sm = addrList.dev.GetDefaultSubnetMask();
            gatewayTextBox.Text    = device.gw = addrList.dev.GetDefaultGateway();
            // set dynamic default values here-
        }
Esempio n. 3
0
        private void ExportAddressBook(IProgress <int> progress = null)
        {
            int processCount = 0;
            int reportedProgressPercentage = -1;

            using (var db = new ICMDBContext())
            {
                AddrList addrList = new AddrList();
                var      Devices  = db.Devices.ToList();
                AddLog("总共有 {0} 笔资料需要输出", Devices.Count);
                foreach (var d in Devices)
                {
                    AddrList.devRow dev = addrList.dev.NewdevRow();
                    dev.ip    = d.ip;
                    dev.ro    = d.roomid;
                    dev.alias = d.Alias;
                    dev.group = d.group;
                    dev.mc    = d.mac;
                    dev.ty    = (byte)d.type;
                    dev.sm    = d.sm;
                    dev.gw    = d.gw;
                    dev.id    = d.cameraid;
                    dev.pw    = d.camerapw;
                    addrList.dev.AdddevRow(dev);

                    if (progress != null)
                    {
                        int currentProgressPercentage = (++processCount * 99 / Devices.Count);
                        if (reportedProgressPercentage != currentProgressPercentage)
                        {
                            reportedProgressPercentage = currentProgressPercentage;
                            progress.Report(reportedProgressPercentage);
                        }
                    }
                }
                addrList.AcceptChanges();
                string filePath = Path.GetAddressBookTempXmlFilePath();
                ExportXml(addrList, filePath);
                AddLog("已输出至 {0}", Path.GetAddressBookTempXmlFilePath());
            }

            Thread.Sleep(500);
            if (progress != null)
            {
                progress.Report(100);
            }
        }