Esempio n. 1
0
        public void RefreshList(GCInterfaceCollection ilist)
        {
            RefreshDetail(null);
            this.listViewInterface.Items.Clear();

            interfaceList = ilist;
            if (interfaceList == null)
            {
                return;
            }

            bool res = false;

            foreach (GCInterface gcInterface in interfaceList)
            {
                InterfaceRec ic          = gcInterface.InterfaceRec;
                string       statusInfor = gcInterface.Status.ToString();
                if (gcInterface.Status == AdapterStatus.Unknown)
                {
                    res = true;
                }
                ListViewItem i = this.listViewInterface.Items.Add(statusInfor);
                i.SubItems.Add(ic.Name);
                i.SubItems.Add(ic.DeviceName);
                i.SubItems.Add(DataHelper.GetDirectionName(ic.Direction));
                i.SubItems.Add(DataHelper.GetTypeName(ic.Type));
                i.SubItems.Add(ic.Folder);
                i.SubItems.Add(ic.LastBackupDateTime);
                i.SubItems.Add(ic.LastBackupDir);
                i.Tag = gcInterface;
            }

            if (res)
            {
                Program.Log.Write(LogType.Warning, "{Interface} Some interface in the list don't have a NT service.");
                Program.Log.Write(LogType.Error, GCError.LastErrorInfor);
                Program.Log.Write(GCError.LastError);
            }

            NotifySelectionChange(this, EventArgs.Empty);
            listCtrl.Refresh();
        }
Esempio n. 2
0
        public override void Refresh()
        {
            base.SetStatus("Refreshing interface list.");

            GCInterfaceCollection interfaceList = _interfaceManager.QueryInterfaceList();

            _interfaceView.RefreshList(interfaceList);

            if (interfaceList != null)
            {
                Program.Log.Write("{Interface} Refresh interface list succeed : " + interfaceList.Count.ToString() + " items.");
            }
            else
            {
                Program.Log.Write(LogType.Warning, "{Interface} Refresh interface list failed : " + GCError.LastErrorInfor);
                Program.Log.Write(GCError.LastError);

                MessageBox.Show(frmMain, "Refresh interface list failed.\r\n\r\n" + GCError.LastErrorInfor,
                                "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            base.ClearStatus();
        }
Esempio n. 3
0
        public void UpdateInterfaceByDevice()
        {
            GCDevice device = _deviceView.GetSelectedDevice();

            if (device == null)
            {
                return;
            }

            base.SetStatus("Updating interfaces by device.");

            if (!_interfaceMgt.HasInterface(device.DeviceID))
            {
                MessageBox.Show(frmMain, "There is no interface based on this device.",
                                "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
                goto exit;
            }

            GCInterfaceCollection iList      = _interfaceMgt.QueryInterfaceList(false);
            GCInterfaceCollection ulist      = new GCInterfaceCollection();
            StringBuilder         sbNameList = new StringBuilder();

            foreach (GCInterface i in iList)
            {
                if (i.Device.DeviceID != device.DeviceID)
                {
                    continue;
                }
                sbNameList.Append(i.InterfaceName + ",");
                ulist.Add(i);
            }

            if (MessageBox.Show(frmMain, "The following interface(s) will be stopped, and the executable files of the interface(s) will be over-written. Do you want to continue?\r\n\r\n"
                                + sbNameList.ToString().TrimEnd(','), "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                goto exit;
            }

            frmMain.Cursor = Cursors.WaitCursor;
            foreach (GCInterface i in ulist)
            {
                // stop interfaces
                Program.Log.Write(string.Format("Stopping interface {0}.", i.InterfaceName));
                _interfaceMgt.StopInterface(i);

                // copy files (*.exe, *.dll), not including sub folder
                string   iFolder = ConfigHelper.GetFullPath(Path.Combine(_interfaceMgt.InterfacesFolder, i.InterfaceName));
                string   dFolder = ConfigHelper.GetFullPath(device.FolderPath);
                string[] fList   = Directory.GetFiles(dFolder, "*.exe");
                foreach (string fName in fList)
                {
                    string fn       = Path.GetFileName(fName);
                    string fromPath = Path.Combine(dFolder, fn);
                    string toPath   = Path.Combine(iFolder, fn);
                    Program.Log.Write(string.Format("Copy {0} to {1}", fromPath, toPath));
                    File.Copy(fromPath, toPath, true);
                }
                fList = Directory.GetFiles(dFolder, "*.dll");
                foreach (string fName in fList)
                {
                    string fn       = Path.GetFileName(fName);
                    string fromPath = Path.Combine(dFolder, fn);
                    string toPath   = Path.Combine(iFolder, fn);
                    Program.Log.Write(string.Format("Copy {0} to {1}", fromPath, toPath));
                    File.Copy(fromPath, toPath, true);
                }

                // modify DeviceDir (four exe from HYS to CSH.HYSIM)
                string dirFilePath = Path.Combine(iFolder, DeviceDirManager.IndexFileName);
                Program.Log.Write(string.Format("Updating file {0}.", dirFilePath));
                string dirFileContent = File.ReadAllText(dirFilePath);
                dirFileContent = dirFileContent.Replace("HYS.Adapter.Composer.exe", "HYS.IM.Adapter.Composer.exe");
                dirFileContent = dirFileContent.Replace("HYS.Adapter.Config.exe", "HYS.IM.Adapter.Config.exe");
                dirFileContent = dirFileContent.Replace("HYS.Adapter.Monitor.exe", "HYS.IM.Adapter.Monitor.exe");
                dirFileContent = dirFileContent.Replace("HYS.Adapter.Service.exe", "HYS.IM.Adapter.Service.exe");
                File.WriteAllText(dirFilePath, dirFileContent);
            }
            frmMain.Cursor = Cursors.Default;

            MessageBox.Show(frmMain, "Updating interface(s) success. Please switch to the Interface View and click the Refresh button to apply the change.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

exit:
            base.ClearStatus();
        }