public BarcodeAdditionForm(BarcodeDetailsForm bf)
        {
            InitializeComponent();
            ConnectionString = ConfigurationManager.ConnectionStrings["DBServerConnectionString"].ToString();
            brdao            = new BarcodeReaderDAO(ConnectionString);
            ldao             = new LaminatorDAO(ConnectionString);
            btdao            = new BarcodeTransactionDAO(ConnectionString);
            bcdf             = bf;
            udao             = new UserDAO(ConnectionString);
            DeviceIP         = Dns.GetHostEntry(Dns.GetHostName()).AddressList.AsEnumerable().Where(s => s.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).Select(s => s).First().ToString();
            PopulateBarcodeReaderDD();

            if (ChannelServices.RegisteredChannels.Count <IChannel>() <= 0)
            {
                ChannelServices.RegisterChannel(new ChannelSrvc(new HttpChannel(), true), true);
            }

            IEnumerable a = RemotingConfiguration.GetRegisteredWellKnownClientTypes().AsEnumerable();

            if (!RemotingConfiguration.GetRegisteredWellKnownClientTypes().AsEnumerable().Where(s => s.ObjectUrl == "http://" + ConfigurationManager.AppSettings["RemoteServerIP"].ToString() + ":" + ConfigurationManager.AppSettings["RemoteServerPort"] + "/ExcelReportUpdateUtility").Select(s => s).Any())
            {
                RemotingConfiguration.RegisterWellKnownClientType(new WellKnownClientTypeEntry(typeof(ExcelReportUpdateUtility), "http://" + ConfigurationManager.AppSettings["RemoteServerIP"].ToString() + ":" + ConfigurationManager.AppSettings["RemoteServerPort"] + "/ExcelReportUpdateUtility"));
            }

            eru = new ExcelReportUpdateUtility();
            eru.SetClientSystemIP(DeviceIP);
        }
Beispiel #2
0
        public COMPortUtility()
        {
            logger.Info("Barcode reading service started successfully.");

            COMPortNames = SerialPort.GetPortNames();
            if (!Int32.TryParse(ConfigurationManager.AppSettings.Get("SerialPortBaudRate"), out SerialPortBaudRate))
            {
                SerialPortBaudRate = 9600;
            }

            if (!Int32.TryParse(ConfigurationManager.AppSettings.Get("SerialPortReadTimeout"), out SerialPortReadTimeOut))
            {
                SerialPortReadTimeOut = 500;
            }

            if (!Enum.TryParse <Parity>(ConfigurationManager.AppSettings.Get("SerialPortParity"), out SerialPortParity))
            {
                SerialPortParity = Parity.None;
            }

            if (!Int32.TryParse(ConfigurationManager.AppSettings.Get("SerialDataBits"), out SerialPortDataBits))
            {
                SerialPortDataBits = 8;
            }

            if (!Enum.TryParse <StopBits>(ConfigurationManager.AppSettings.Get("SerialPortStopBits"), out SerialPortStopBits))
            {
                SerialPortStopBits = StopBits.One;
            }

            if (!Enum.TryParse <Handshake>(ConfigurationManager.AppSettings.Get("SerialPortHandShake"), out SerialPortHandshake))
            {
                SerialPortHandshake = Handshake.None;
            }

            SyncLock             = new Mutex(false, "COMPortDataReadMutex");
            COMPortReaderThreads = new Thread[COMPortNames.Length];

            int i = 0;

            foreach (string COMPortName in COMPortNames)
            {
                ParameterizedThreadStart pts = new ParameterizedThreadStart(InitializeCOMPort);
                COMPortReaderThreads[i] = new Thread(pts);
                COMPortReaderThreads[i].Start(COMPortName);
                i++;
            }

            foreach (Thread t in COMPortReaderThreads)
            {
                t.Join();
            }

            DBServerConnectionString = ConfigurationManager.ConnectionStrings["DBServerConnectionString"].ToString();
            btdao = new BarcodeTransactionDAO(DBServerConnectionString);
            brdao = new BarcodeReaderDAO(DBServerConnectionString);
        }