Exemple #1
0
        private void btnSaveLog_Click(object sender, EventArgs e)
        {
            if (txtPortNumber.Text.Trim().Equals(""))
            {
                warningBox1.Text = StrNotEmpty;

                txtPortNumber.Focus();

                return;
            }

            //Kiểm tra trường Port Number có là số không
            if (!Common.IsItNumber(txtPortNumber.Text.Trim()))
            {
                warningBox1.Text = IsNumber;

                txtPortNumber.Focus();

                return;
            }
            if (ipAddressInput1.Text.Trim().Equals(""))
            {
                warningBox1.Text = StrNotEmpty;

                ipAddressInput1.Focus();

                return;
            }
            LablinkServiceConfig.SetIpAdress(ipAddressInput1.Text.Trim());
            LablinkServiceConfig.SetPortNumber(txtPortNumber.Text.Trim());
            LablinkServiceConfig.SaveConfig();
            warningBox1.Text = "";
        }
Exemple #2
0
        /// <summary>
        ///     Hàm dùng để đọc file App.config (nếu có)
        /// </summary>
        private void ReadFileConfig()
        {
            txtPort.Text          = LablinkServiceConfig.GetPort();
            txtInter.Text         = LablinkServiceConfig.GetTimerInternal();
            txtDelay.Text         = LablinkServiceConfig.GetDelayTime();
            txtDatabase.Text      = LablinkServiceConfig.GetDatabase();
            txtServer.Text        = LablinkServiceConfig.GetServer();
            txtUser.Text          = LablinkServiceConfig.GetUserId();
            txtPassword.Text      = LablinkServiceConfig.GetPassword();
            ipAddressInput1.Value = LablinkServiceConfig.GetIpAdress();
            txtPortNumber.Text    = LablinkServiceConfig.GetPortNumber();

            //Lấy về định dạng ngày tháng từ XML file
            if (!string.IsNullOrEmpty(LablinkServiceConfig.GetDateFormat()))
            {
                cboDateFormat.Text = LablinkServiceConfig.GetDateFormat();
            }

            //Lấy về loại định dạng xét nghiệm
            if (!String.IsNullOrEmpty(LablinkServiceConfig.GetTestTypeBarcode()))
            {
                switchTestTypeBarcode.Value = Boolean.Parse(LablinkServiceConfig.GetTestTypeBarcode());
            }

            //Lấy trạng thái thiết lập ghi log file
            if (!String.IsNullOrEmpty(LablinkServiceConfig.GetLogState()))
            {
                switchLogState.Value = Boolean.Parse(LablinkServiceConfig.GetLogState());
            }

            //RS232
            if (!String.IsNullOrEmpty(LablinkServiceConfig.GetRS232Status()))
            {
                sbtnRs232Service.Value = Boolean.Parse(LablinkServiceConfig.GetRS232Status());
            }

            //TCPIP
            if (!String.IsNullOrEmpty(LablinkServiceConfig.GetTCPIPStatus()))
            {
                sbtnTcpIpService.Value = Boolean.Parse(LablinkServiceConfig.GetTCPIPStatus());
            }

            //AutoUpdateStatusAfterSend
            if (!String.IsNullOrEmpty(LablinkServiceConfig.GetAutoUpdateOrderStatusAfterSend()))
            {
                AutoUpdateOrderStatusAfterSend.Checked =
                    Boolean.Parse(LablinkServiceConfig.GetAutoUpdateOrderStatusAfterSend());
            }

            if (!String.IsNullOrEmpty(LablinkServiceConfig.GetLogState()))
            {
                switchLogState.Value = Boolean.Parse(LablinkServiceConfig.GetLogState());
            }

            if (!String.IsNullOrEmpty(LablinkServiceConfig.GetFileStatus()))
            {
                sbtFileService.Value = Boolean.Parse(LablinkServiceConfig.GetFileStatus());
            }
        }
Exemple #3
0
 private void btnSaveGlobal_Click(object sender, EventArgs e)
 {
     if (CheckFormatDate())
     {
         LablinkServiceConfig.SetTCPIPStatus(sbtnTcpIpService.Value.ToString());
         LablinkServiceConfig.SetFileStatus(sbtFileService.Value.ToString());
         LablinkServiceConfig.SetRS232Status(sbtnRs232Service.Value.ToString());
         LablinkServiceConfig.SetDateFormat(cboDateFormat.Text);
         LablinkServiceConfig.SetAutoUpdateOrderStatusAfterSend(
             AutoUpdateOrderStatusAfterSend.Checked.ToString(CultureInfo.InvariantCulture));
         LablinkServiceConfig.SaveConfig();
     }
 }
Exemple #4
0
        private void btnSaveDatabase_Click(object sender, EventArgs e)
        {
            //Kiểm tra trường Server
            if (String.IsNullOrEmpty(txtServer.Text.Trim()))
            {
                warningBox1.Text = StrNotEmpty;


                txtServer.Focus();
                return;
            }
            //Kiểm tra trường Database
            if (String.IsNullOrEmpty(txtDatabase.Text.Trim()))
            {
                warningBox1.Text = StrNotEmpty;

                txtDatabase.Focus();

                return;
            }

            //Kiểm tra trường UserID
            if (String.IsNullOrEmpty(txtUser.Text.Trim()))
            {
                warningBox1.Text = StrNotEmpty;

                txtUser.Focus();

                return;
            }

            if (String.IsNullOrEmpty(txtPassword.Text.Trim()))
            {
                warningBox1.Text = StrNotEmpty;

                txtPassword.Focus();

                return;
            }
            LablinkServiceConfig.SetDatabase(txtDatabase.Text.Trim());
            LablinkServiceConfig.SetServer(txtServer.Text.Trim());
            LablinkServiceConfig.SetUserId(txtUser.Text.Trim());
            LablinkServiceConfig.SetPassword(txtPassword.Text.Trim());
            LablinkServiceConfig.SaveConfig();
            warningBox1.Text = "";
        }
Exemple #5
0
 /// <summary>
 ///     The main entry point for the application.
 /// </summary>
 private static void Main(string[] args)
 {
     Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
     //Thread.Sleep(10000);
     try
     {
         while (!Common.CheckConnection(Common.GetDefaultConnectionString()))
         {
             Thread.Sleep(5000);
             LablinkServiceConfig.RefreshConfig();
         }
         //Get Directory of exe file
         var servicesToRun = new ServiceBase[] { new MainService() };
         ServiceBase.Run(servicesToRun);
     }
     catch (Exception ex)
     {
     }
 }
Exemple #6
0
 private void btnSaveDevices_Click(object sender, EventArgs e)
 {
     LablinkServiceConfig.Devices = _devices;
     LablinkServiceConfig.SaveDeviceConfig();
 }
Exemple #7
0
 private void switchLogState_ValueChanged(object sender, EventArgs e)
 {
     LablinkServiceConfig.SetLogState(switchLogState.Value.ToString());
     LablinkServiceConfig.SaveConfig();
 }
Exemple #8
0
 private void sbtFileService_ValueChanged(object sender, EventArgs e)
 {
     LablinkServiceConfig.SetFileStatus(sbtFileService.Value.ToString());
     LablinkServiceConfig.SaveConfig();
 }
Exemple #9
0
 private void switchTestTypeBarcode_ValueChanged(object sender, EventArgs e)
 {
     LablinkServiceConfig.SetTestTypeBarcode(switchTestTypeBarcode.Value.ToString());
     LablinkServiceConfig.SaveConfig();
 }
Exemple #10
0
        private void btnSaveGeneral_Click(object sender, EventArgs e)
        {
            // Kiểm tra trường Port rỗng hay không
            if (String.IsNullOrEmpty(txtPort.Text.Trim()))
            {
                warningBox1.Text = StrNotEmpty;

                txtPort.Focus();
                return;
            }

            //Kiểm tra trường Port có là số không
            if (!Common.IsItNumber(txtPort.Text.Trim()))
            {
                warningBox1.Text = IsNumber;

                txtPort.Focus();

                return;
            }

            //Kiểm tra trường Timer Interval rỗng hay không
            if (String.IsNullOrEmpty(txtInter.Text.Trim()))
            {
                warningBox1.Text = StrNotEmpty;

                txtInter.Focus();

                return;
            }

            //Kiểm tra trường Timer Interval có là số không
            if (!Common.IsItNumber(txtInter.Text.Trim()))
            {
                warningBox1.Text = IsNumber;

                txtInter.Focus();
                tabAllConfig.SelectedTabIndex = 0;
                return;
            }

            //Kiểm tra trường Delay Time rỗng hay không
            if (String.IsNullOrEmpty(txtDelay.Text.Trim()))
            {
                warningBox1.Text = StrNotEmpty;

                txtDelay.Focus();

                return;
            }

            //Kiểm tra trường Delay Time có là số không
            if (!Common.IsItNumber(txtDelay.Text.Trim()))
            {
                warningBox1.Text = IsNumber;

                txtDelay.Focus();

                return;
            }
            LablinkServiceConfig.SetPort(txtPort.Text.Trim());
            LablinkServiceConfig.SetTimerInternal(txtInter.Text.Trim());
            LablinkServiceConfig.SetDelayTime(txtDelay.Text.Trim());
            LablinkServiceConfig.SaveConfig();
            warningBox1.Text = "";
        }
Exemple #11
0
        /// <summary>
        ///     Hàm khởi tạo Service
        ///     Khởi tạo Log, thiết bị, thiết lập cổng COM, và load dynamic các dll
        /// </summary>
        public MainService()
        {
            //Khởi tạo Log
            LogConfig();
            Log = LogManager.GetLogger(DeviceHelper.MainServiceLogger);
            Log.Trace(
                "\n-------------------------------------------------------------------------------------------------------------------------------");
            Log.Trace("Main Service Startup now!");

            //Xác định các thành phần sẽ được nạp
            string rs232Status = LablinkServiceConfig.GetRS232Status();

            _isRs232Enable = rs232Status.Equals("1") || rs232Status.ToUpper().Trim().Equals("TRUE");
            Log.Trace("RS232 Server is {0}", _isRs232Enable ? "Enabled!" : "Disable");

            string tcpipStatus = LablinkServiceConfig.GetTCPIPStatus();

            _isTcpIpServerEnable = tcpipStatus.Equals("1") || tcpipStatus.ToUpper().Trim().Equals("TRUE");
            Log.Trace("TCP/IP Server is {0}", _isTcpIpServerEnable ? "Enabled!" : "Disable");

            string fileWatcherService = LablinkServiceConfig.GetFileStatus();

            _isFileWatcherServerEnable = fileWatcherService.Equals("1") ||
                                         fileWatcherService.ToUpper().Trim().Equals("TRUE");
            Log.Trace("File Watcher Server is {0}", _isFileWatcherServerEnable ? "Enabled!" : "Disable");

            //Khai báo Label để khởi động đến khi thành công
label1:
            try
            {
                InitializeComponent();

                if (_isRs232Enable)
                {
                    _lablinkRs232 = new LablinkRs232(_colDevices, _colDevicesName);
                    AddComPortForRs232Server();
                    LoadDevices("COM");
                }

                if (_isTcpIpServerEnable)
                {
                    int port, timerinterval, delaytime;
                    try
                    {
                        port          = Convert.ToInt32(LablinkServiceConfig.GetPort());
                        timerinterval = Convert.ToInt32(LablinkServiceConfig.GetTimerInternal());
                        delaytime     = Convert.ToInt32(LablinkServiceConfig.GetDelayTime());
                    }
                    catch (Exception)
                    {
                        port          = 0;
                        timerinterval = 0;
                        delaytime     = 0;
                    }
                    _lablinkTcpIp               = new LablinkTcpIp(_colDevices, _colDevicesName);
                    _lablinkTcpIp.Port          = port;
                    _lablinkTcpIp.TimerInterval = timerinterval;
                    _lablinkTcpIp.DelayTime     = delaytime;
                    LoadDevices("TCP/IP");
                }

                if (_isFileWatcherServerEnable)
                {
                    _lablinkFileWatcher = new LablinkFileWatcherServer(_colDevices, _colDevicesName);
                    LoadFileWatcherDevice();
                }

                StartDebugMainServcies();
            }
            catch (Exception ex)
            {
                _tempString = string.Format("Error While Starting Service{0}Error Message:{1}", Crlf, ex);
                Log.Error(string.Format("{0}{1}{2}", _tempString, DeviceHelper.CRLF, ex));
                Thread.Sleep(5000);
                goto label1;
            }
        }
        //Insert vào Test_Info old run
        public static void InsertTestInfor(int testTypeId, string patientCode, DateTime testDate, ref string barcode,
                                           ref int testId)
        {
            //Lấy về mã BN làm XN
            object strpatientId =
                new Select(LPatientInfo.Columns.PatientId).From(LPatientInfo.Schema.Name).Where(LPatientInfo.Columns.Pid)
                .IsEqualTo(patientCode).ExecuteScalar();

            if (String.IsNullOrEmpty(strpatientId.ToString().Trim()))
            {
                strpatientId = -1;
            }
            int patientId = Convert.ToInt32(strpatientId);

            //Lấy về TestTypeOrder
            object strTestTypeOrder =
                new Select(TTestTypeList.Columns.IntOrder).From(TTestTypeList.Schema.Name).Where(
                    TTestTypeList.Columns.TestTypeId).IsEqualTo(testTypeId).ExecuteScalar();

            if (String.IsNullOrEmpty(strTestTypeOrder.ToString().Trim()))
            {
                strTestTypeOrder = 0;
            }
            int intTestTypeOrder = Convert.ToInt32(strTestTypeOrder);

            //Lấy về Barcode của XN được đăng ký:
            //object strBarcode =
            //    new Select(TTestInfo.Columns.Barcode).From(TTestInfo.Schema.Name).Where(TTestInfo.Columns.PatientId).
            //        IsEqualTo(patientId).ExecuteScalar();

            DateTime now     = DateTime.Now;
            var      mintick = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0, 000);
            var      maxtick = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59);


            object strBarcode =
                new Select(TTestInfo.Columns.Barcode).From(TTestInfo.Schema.Name).Where(TTestInfo.Columns.PatientId).
                IsEqualTo(patientId).And(TTestInfo.Columns.TestDate).IsBetweenAnd(mintick, maxtick)
                .ExecuteScalar();

            try
            {
                if (String.IsNullOrEmpty(strBarcode.ToString().Trim()))
                {
                    if (LablinkServiceConfig.GetTestTypeBarcode().Equals("False"))
                    {
                        barcode = testDate.ToString("yyMMdd") + VB6.Right("0000" + (GetMaxBarcode(testDate) + 1), 4);
                    }
                    else
                    {
                        barcode = testDate.ToString("yyMMdd") + VB6.Right("00" + intTestTypeOrder, 2) +
                                  VB6.Right("0000" + (GetMaxBarcode(testDate) + 1), 4);
                    }
                }
                else
                {
                    if (LablinkServiceConfig.GetTestTypeBarcode().Equals("False"))
                    {
                        barcode = testDate.ToString("yyMMdd") + VB6.Right("0000" + strBarcode, 4);
                    }
                    else
                    {
                        barcode = testDate.ToString("yyMMdd") + VB6.Right("00" + intTestTypeOrder, 2) +
                                  VB6.Right("0000" + strBarcode, 4);
                    }
                }
            }
            catch (Exception ex)
            {
                if (LablinkServiceConfig.GetTestTypeBarcode().Equals("False"))
                {
                    barcode = testDate.ToString("yyMMdd") + VB6.Right("0000" + (GetMaxBarcode(testDate) + 1), 4);
                }
                else
                {
                    barcode = testDate.ToString("yyMMdd") + VB6.Right("00" + intTestTypeOrder, 2) +
                              VB6.Right("0000" + (GetMaxBarcode(testDate) + 1), 4);
                }
            }

            //Insert vao DB
            //code old
            SpInsertTestInfor(testTypeId, patientId, barcode, testDate, ref testId);
            // SpInsertTestInfor(testTypeId, patientId, barcode, testDate);
        }