Esempio n. 1
0
        private void PrintMUBLabels_OnPrintMUBLabelSucceeded(object sender, PrintMUBAndTTLabelsEventArgs e)
        {
            try
            {
                _PrintMUBSucceed = true;
                var labelInfo = new Trinity.BE.Label
                {
                    UserId        = e.LabelInfo.UserId,
                    Label_Type    = EnumLabelType.MUB,
                    CompanyName   = e.LabelInfo.CompanyName,
                    MarkingNo     = e.LabelInfo.MarkingNo,
                    DrugType      = e.LabelInfo.DrugType,
                    NRIC          = e.LabelInfo.NRIC,
                    Name          = e.LabelInfo.Name,
                    Date          = DateTime.Now,
                    QRCode        = e.LabelInfo.QRCode,
                    LastStation   = e.LabelInfo.LastStation,
                    PrintCount    = e.LabelInfo.PrintCount,
                    ReprintReason = e.LabelInfo.ReprintReason
                };

                var dalLabel = new DAL_Labels();
                dalLabel.UpdateLabel(labelInfo);

                //// Update queue status is finished
                //var dalQueue = new DAL_QueueNumber();
                //dalQueue.UpdateQueueStatusByUserId(labelInfo.UserId, EnumStation.SSA, EnumStation.UHP, EnumQueueStatuses.Finished, "Printer MUB/TT Label");

                //DeleteQRCodeImageFileTemp();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in Trinity.SSA.JSCallCS.PrintMUBLabels_OnPrintMUBLabelSucceeded. Details:" + ex.Message);
            }
        }
Esempio n. 2
0
        public List <Trinity.BE.Label> GetAllMUBAndTTlabels()
        {
            if (_isFocusQueue)
            {
                Trinity.Device.Util.SmartCardReaderUtil.Instance.StopSmartCardMonitor();
                _isFocusQueue = false;
            }

            var dalMUBAndTTlabels = new DAL_Labels();

            return(dalMUBAndTTlabels.GetAllLabelsForMUBAndTT());
        }
Esempio n. 3
0
        private void PrintTTLabels_OnPrintTTLabelSucceeded(object sender, PrintMUBAndTTLabelsEventArgs e)
        {
            try
            {
                _PrintTTSucceed = true;
                var labelInfo = new Trinity.BE.Label
                {
                    UserId      = e.LabelInfo.UserId,
                    Label_Type  = EnumLabelType.TT,
                    CompanyName = e.LabelInfo.CompanyName,
                    MarkingNo   = e.LabelInfo.MarkingNo,
                    //DrugType = e.LabelInfo.DrugType,
                    NRIC          = e.LabelInfo.NRIC,
                    Name          = e.LabelInfo.Name,
                    Date          = DateTime.Now,
                    LastStation   = e.LabelInfo.LastStation,
                    PrintCount    = e.LabelInfo.PrintCount,
                    ReprintReason = e.LabelInfo.ReprintReason
                };

                var dalLabel = new DAL_Labels();
                var update   = dalLabel.UpdateLabel(labelInfo);
                if (update != null)
                {
                    var dalAppointment = new DAL_Appointments();
                    var dalQueue       = new DAL_QueueNumber();
                    var appointment    = dalAppointment.GetTodayAppointmentByUserId(labelInfo.UserId);
                    //var appointment = result.Data;

                    if (appointment != null)
                    {
                        var sskQueue = new DAL_QueueNumber().GetQueueDetailByAppointment(appointment, EnumStation.SSK);

                        dalQueue.UpdateQueueStatus(sskQueue.Queue_ID, EnumQueueStatuses.Finished, EnumStation.SSK);
                        dalQueue.UpdateQueueStatus(sskQueue.Queue_ID, EnumQueueStatuses.Processing, EnumStation.SSA);
                    }
                    //this._web.RunScript("$('#WaitingSection').hide();$('#CompletedSection').show(); ; ");
                    //this._web.RunScript("$('.status-text').css('color','#000').text('Please collect your labels');");

                    //DeleteQRCodeImageFileTemp();
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 4
0
        private void PrintMUBLabels_OnPrintMUBLabelSucceeded(object sender, PrintMUBAndTTLabelsEventArgs e)
        {
            Trinity.BE.Label labelInfo = new Trinity.BE.Label
            {
                UserId        = e.LabelInfo.UserId,
                Label_Type    = EnumLabelType.MUB,
                CompanyName   = e.LabelInfo.CompanyName,
                MarkingNo     = e.LabelInfo.MarkingNo,
                DrugType      = e.LabelInfo.DrugType,
                NRIC          = e.LabelInfo.NRIC,
                Name          = e.LabelInfo.Name,
                Date          = DateTime.Now,
                QRCode        = e.LabelInfo.QRCode,
                LastStation   = EnumStation.DUTYOFFICER,
                PrintCount    = e.LabelInfo.PrintCount,
                ReprintReason = e.LabelInfo.ReprintReason,
                PrintStatus   = EnumPrintStatus.Successful
            };

            // IsMUB = false: Print UB
            DAL_Labels dalLabel = new DAL_Labels();

            if (!e.LabelInfo.IsMUB)
            {
                //labelInfo.Label_Type = EnumLabelType.UB;
                //labelInfo.DrugType = e.LabelInfo.DrugType;
                //if (dalLabel.UpdateLabel(labelInfo) != null)
                //{
                //    string message = "Print MUB for " + e.LabelInfo.Name + " successful.";
                //    //MessageBox.Show(message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //}
            }
            else
            {
                dalLabel.UpdatePrinting(e.LabelInfo.UserId, EnumLabelType.MUB, EnumPrintStatus.Successful, EnumStation.DUTYOFFICER, DateTime.Today);
            }



            DeleteQRCodeImageFileTemp();
        }
Esempio n. 5
0
        public void SaveDrugTest(string UserId, bool COCA, bool BARB, bool LSD, bool METH, bool MTQL, bool PCP, bool KET, bool BUPRE, bool CAT, bool PPZ, bool NPS)
        {
            Session session = Session.Instance;

            Trinity.BE.User dutyOfficer = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];
            DAL_DrugResults dalDrug     = new DAL_DrugResults();

            dalDrug.UpdateDrugSeal(UserId, COCA, BARB, LSD, METH, MTQL, PCP, KET, BUPRE, CAT, PPZ, NPS, dutyOfficer.UserId);
            var dalQueue = new DAL_QueueNumber();

            dalQueue.UpdateQueueStatusByUserId(UserId, EnumStation.UT, EnumQueueStatuses.Finished, EnumStation.SSP, EnumQueueStatuses.Processing, "Waiting for SSP", EnumQueueOutcomeText.Processing);


            var    user          = new DAL_User().GetUserById(UserId);
            var    dalLabel      = new DAL_Labels();
            string MarkingNumber = dalLabel.GetMarkingNumber(user.UserId, DateTime.Today);

            if (string.IsNullOrEmpty(MarkingNumber))
            {
                MarkingNumber = new DAL_SettingSystem().GenerateMarkingNumber();
            }
            var myQueue = dalQueue.GetMyQueueToday(user.UserId);

            dalLabel.Insert(new Trinity.BE.Label
            {
                UserId      = UserId,
                Label_Type  = EnumLabelType.UB,
                CompanyName = CommonConstants.COMPANY_NAME,
                MarkingNo   = MarkingNumber,
                NRIC        = user.NRIC,
                Name        = user.Name,
                DrugType    = dalDrug.GetResultUTByNRIC(user.NRIC, DateTime.Today),
                Queue_ID    = myQueue.Queue_ID,
                LastStation = EnumStation.DUTYOFFICER
            });
        }
Esempio n. 6
0
        private void PrintTTLabels_OnPrintTTLabelFailed(object sender, PrintMUBAndTTLabelsEventArgs e)
        {
            try
            {
                _PrintTTSucceed = false;
                var labelInfo = new Trinity.BE.Label
                {
                    UserId        = e.LabelInfo.UserId,
                    Label_Type    = EnumLabelType.TT,
                    CompanyName   = e.LabelInfo.CompanyName,
                    MarkingNo     = e.LabelInfo.MarkingNo,
                    DrugType      = e.LabelInfo.DrugType,
                    NRIC          = e.LabelInfo.NRIC,
                    Name          = e.LabelInfo.Name,
                    Date          = DateTime.Now,
                    QRCode        = e.LabelInfo.QRCode,
                    LastStation   = e.LabelInfo.LastStation,
                    PrintCount    = e.LabelInfo.PrintCount,
                    ReprintReason = e.LabelInfo.ReprintReason,
                    PrintStatus   = e.LabelInfo.PrintStatus,
                    Message       = e.LabelInfo.Message
                };

                var dalLabel = new DAL_Labels();
                dalLabel.UpdateLabel(labelInfo);

                Trinity.SignalR.Client.Instance.SendToAllDutyOfficers(e.LabelInfo.UserId, "Cannot print TT Label", "User '" + labelInfo.UserId + "' cannot print TT label.", EnumNotificationTypes.Error);

                //DeleteQRCodeImageFileTemp();
                //LogOut();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in Trinity.SSA.JSCallCS.PrintTTLabels_OnPrintTTLabelFailed. Details:" + ex.Message);
            }
        }
Esempio n. 7
0
        public void Start()
        {
            Trinity.BE.User supervisee = _jsCallCS.getSuperviseeLogin();
            if (supervisee == null)
            {
                _jsCallCS.LogOut();
                return;
            }

            LabelInfo labelInfo = null;

            if (supervisee.Role.Equals(EnumUserRoles.USA, StringComparison.OrdinalIgnoreCase))
            {
                var dalLabel = new DAL_Labels();
                var lable    = dalLabel.GetByUserID(supervisee.UserId, EnumLabelType.MUB, DateTime.Today);
                if (lable == null)
                {
                    string MarkingNumber = new DAL_SettingSystem().GenerateMarkingNumber();
                    dalLabel.Insert(new Trinity.BE.Label
                    {
                        UserId      = supervisee.UserId,
                        Label_Type  = EnumLabelType.TT,
                        CompanyName = CommonConstants.COMPANY_NAME,
                        MarkingNo   = MarkingNumber,
                        NRIC        = supervisee.NRIC,
                        Name        = supervisee.Name,
                        LastStation = EnumStation.ALK
                    });
                    dalLabel.Insert(new Trinity.BE.Label
                    {
                        UserId      = supervisee.UserId,
                        Label_Type  = EnumLabelType.MUB,
                        CompanyName = CommonConstants.COMPANY_NAME,
                        MarkingNo   = MarkingNumber,
                        NRIC        = supervisee.NRIC,
                        Name        = supervisee.Name,
                        LastStation = EnumStation.ALK
                    });
                    lable = dalLabel.GetByUserID(supervisee.UserId, EnumLabelType.MUB, DateTime.Today);
                }
                labelInfo = new LabelInfo
                {
                    UserId      = lable.UserId,
                    Name        = lable.Name,
                    NRIC        = lable.NRIC,
                    Label_Type  = EnumLabelType.MUB,
                    Date        = DateTime.Now.ToString("dd/MM/yyyy"),
                    CompanyName = lable.CompanyName,
                    LastStation = EnumStation.ALK,
                    MarkingNo   = lable.MarkingNo,
                    DrugType    = "NA",
                    QRCode      = lable.QRCode
                };
            }
            else if (supervisee.Role.Equals(EnumUserRoles.Supervisee, StringComparison.OrdinalIgnoreCase))
            {
                var dalQueue = new DAL_QueueNumber();
                var myQueue  = dalQueue.GetMyQueueToday(supervisee.UserId);
                if (myQueue == null)
                {
                    _web.ShowMessage("Please register for a queue number at " + EnumStation.ARK + " first.");
                    _jsCallCS.LogOut();
                    return;
                }
                else if (myQueue != null && myQueue.QueueDetails.Any(d => d.Station == EnumStation.ARK && d.Status == EnumQueueStatuses.Waiting))
                {
                    _web.ShowMessage("Please wait for your queue number to appear under the \"Now Serving\" list.");
                    _jsCallCS.LogOut();
                    return;
                }

                dalQueue.UpdateQueueStatusByUserId(supervisee.UserId, EnumStation.ARK, EnumQueueStatuses.Processing, EnumStation.ALK, EnumQueueStatuses.Processing, "Printing MUB/TT labels", EnumQueueOutcomeText.Processing);
                var    lable     = new DAL_Labels().GetByUserID(supervisee.UserId, EnumLabelType.MUB, DateTime.Today);
                string markingNo = lable.MarkingNo;
                labelInfo = new LabelInfo
                {
                    UserId      = lable.UserId,
                    Name        = lable.Name,
                    NRIC        = lable.NRIC,
                    Label_Type  = EnumLabelType.MUB,
                    Date        = DateTime.Now.ToString("dd/MM/yyyy"),
                    CompanyName = lable.CompanyName,
                    LastStation = EnumStation.ALK,
                    MarkingNo   = markingNo,
                    DrugType    = "NA",
                    QRCode      = lable.QRCode
                };
            }

            using (var ms = new System.IO.MemoryStream(labelInfo.QRCode))
            {
                System.IO.Directory.CreateDirectory(String.Format("{0}/Temp", CSCallJS.curDir));
                string fileName = String.Format("{0}/Temp/{1}", CSCallJS.curDir, "QRCode_" + supervisee.NRIC + ".png");
                if (System.IO.File.Exists(fileName))
                {
                    System.IO.File.Delete(fileName);
                }
                var bitmap = System.Drawing.Image.FromStream(ms);
                bitmap.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
            }
            //profile model
            _web.LoadPageHtml("SuperviseeParticulars.html", labelInfo);
            _main._isPrintingMUBTT = false;
            if (_main._timerCheckLogout != null)
            {
                if (_main._timerCheckLogout.Enabled)
                {
                    _main._timerCheckLogout.Stop();
                }
                _main._timerCheckLogout.Start();
            }
        }
Esempio n. 8
0
        //Mapping Template MUB and TT labels
        public void MappingTemplateMUBAndTTLabels(string json, string reason)
        {
            try
            {
                List <Trinity.BE.Label> lstLabel = JsonConvert.DeserializeObject <List <Trinity.BE.Label> >(json);

                foreach (var item in lstLabel)
                {
                    if (_isPrintFailMUB && _isPrintFailTT)
                    {
                        break;
                    }

                    DAL_User  dalUser   = new DAL_User();
                    string    userID    = dalUser.GetSuperviseeByNRIC(item.NRIC).UserId;
                    string    markingNo = new DAL_Labels().GetMarkingNoByUserId(userID);
                    LabelInfo labelInfo = new LabelInfo
                    {
                        UserId      = userID,
                        Name        = item.Name,
                        NRIC        = item.NRIC,
                        Label_Type  = EnumLabelType.MUB,
                        Date        = DateTime.Now.ToString("dd/MM/yyyy"),
                        CompanyName = CommonConstants.COMPANY_NAME,
                        LastStation = EnumStation.DUTYOFFICER,
                        MarkingNo   = markingNo,//new DAL_SettingSystem().GenerateMarkingNumber(),
                        //DrugType = "NA",
                        ReprintReason = reason,
                        IsMUB         = item.IsMUB,
                        IsTT          = item.IsTT
                    };

                    if (item.IsMUB)
                    {
                        byte[] byteArrayQRCode = null;
                        byteArrayQRCode  = CommonUtil.CreateLabelQRCode(labelInfo, "AESKey");
                        labelInfo.QRCode = byteArrayQRCode;

                        using (var ms = new System.IO.MemoryStream(byteArrayQRCode))
                        {
                            if (!Directory.Exists(CSCallJS.curDir + "\\Temp"))
                            {
                                Directory.CreateDirectory(CSCallJS.curDir + "\\Temp");
                            }
                            string fileName = String.Format("{0}/Temp/{1}", CSCallJS.curDir, "QRCode.png");
                            if (System.IO.File.Exists(fileName))
                            {
                                System.IO.File.Delete(fileName);
                            }

                            System.Drawing.Image bitmap = System.Drawing.Image.FromStream(ms);
                            bitmap.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
                        }
                        _web.LoadPageHtml("PrintingTemplates/MUBLabelTemplate.html", labelInfo);
                        Thread.Sleep(1000);
                    }
                    if (item.IsTT)
                    {
                        _printMUBAndTTLabel.StartPrintTT(labelInfo);
                        Thread.Sleep(500);
                    }
                }

                if (_isPrintFailMUB && _isPrintFailTT)
                {
                    MessageBox.Show("Unable to print MUB and TT labels", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (_isPrintFailMUB)
                {
                    MessageBox.Show("Unable to print MUB labels", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (_isPrintFailTT)
                {
                    MessageBox.Show("Unable to print TT labels", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Print all labels successfully", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                _isPrintFailMUB = false;
                _isPrintFailTT  = false;
            }
            catch (Exception e)
            {
            }
        }
Esempio n. 9
0
        private void GetMyQueueNumber()
        {
            // Get current user
            Session session = Session.Instance;

            Trinity.BE.User currentUser = (Trinity.BE.User)session[CommonConstants.USER_LOGIN];
            Trinity.BE.User supervisee  = null;
            if (currentUser.Role == EnumUserRoles.DutyOfficer)
            {
                supervisee = (Trinity.BE.User)session[CommonConstants.SUPERVISEE];
            }
            else
            {
                supervisee = currentUser;
            }
            DAL_Appointments _Appointment = new DAL_Appointments();

            Trinity.DAL.DBContext.Appointment appointment = new DAL_Appointments().GetAppointmentByDate(supervisee.UserId, DateTime.Today);
            var _dalQueue = new DAL_QueueNumber();

            Trinity.DAL.DBContext.Queue queueNumber = null;

            if (!_dalQueue.IsUserAlreadyQueue(supervisee.UserId, DateTime.Today))
            {
                if (appointment != null)
                {
                    if (string.IsNullOrEmpty(appointment.Timeslot_ID) && currentUser.Role == EnumUserRoles.Supervisee)
                    {
                        _web.ShowMessage("You have not selected a timeslot!");
                        BookAppointment();
                    }
                    else
                    {
                        queueNumber = _dalQueue.InsertQueueNumber(appointment.ID, appointment.UserId, EnumStation.ARK, currentUser.UserId);
                        var    dalLabel      = new DAL_Labels();
                        string MarkingNumber = dalLabel.GetMarkingNumber(supervisee.UserId, DateTime.Today);
                        if (string.IsNullOrEmpty(MarkingNumber))
                        {
                            MarkingNumber = new DAL_SettingSystem().GenerateMarkingNumber();
                        }
                        dalLabel.Insert(new Trinity.BE.Label
                        {
                            UserId      = supervisee.UserId,
                            Label_Type  = EnumLabelType.TT,
                            CompanyName = CommonConstants.COMPANY_NAME,
                            MarkingNo   = MarkingNumber,
                            NRIC        = supervisee.NRIC,
                            Name        = supervisee.Name,
                            LastStation = EnumStation.ARK,
                            Queue_ID    = queueNumber.Queue_ID
                        });
                        dalLabel.Insert(new Trinity.BE.Label
                        {
                            UserId      = supervisee.UserId,
                            Label_Type  = EnumLabelType.MUB,
                            CompanyName = CommonConstants.COMPANY_NAME,
                            MarkingNo   = MarkingNumber,
                            NRIC        = supervisee.NRIC,
                            Name        = supervisee.Name,
                            LastStation = EnumStation.ARK,
                            Queue_ID    = queueNumber.Queue_ID
                        });


                        Trinity.SignalR.Client.Instance.AppointmentReported(queueNumber.Queue_ID.ToString().Trim(), queueNumber.Appointment_ID.ToString().Trim());
                        Trinity.SignalR.Client.Instance.QueueInserted(queueNumber.Queue_ID.ToString().Trim());
                        APIUtils.FormQueueNumber.RefreshQueueNumbers();
                        this._web.ShowMessage("Your queue number is:" + queueNumber.QueuedNumber);
                    }
                }
                else
                {
                    queueNumber = _dalQueue.InsertQueueNumberFromDO(supervisee.UserId, EnumStation.ARK, currentUser.UserId);
                    var    dalLabel      = new DAL_Labels();
                    string MarkingNumber = dalLabel.GetMarkingNumber(supervisee.UserId, DateTime.Today);
                    if (string.IsNullOrEmpty(MarkingNumber))
                    {
                        MarkingNumber = new DAL_SettingSystem().GenerateMarkingNumber();
                    }

                    dalLabel.Insert(new Trinity.BE.Label
                    {
                        UserId      = supervisee.UserId,
                        Label_Type  = EnumLabelType.TT,
                        CompanyName = CommonConstants.COMPANY_NAME,
                        MarkingNo   = MarkingNumber,
                        NRIC        = supervisee.NRIC,
                        Name        = supervisee.Name,
                        LastStation = EnumStation.ARK,
                        Queue_ID    = queueNumber.Queue_ID
                    });
                    dalLabel.Insert(new Trinity.BE.Label
                    {
                        UserId      = supervisee.UserId,
                        Label_Type  = EnumLabelType.MUB,
                        CompanyName = CommonConstants.COMPANY_NAME,
                        MarkingNo   = MarkingNumber,
                        NRIC        = supervisee.NRIC,
                        Name        = supervisee.Name,
                        LastStation = EnumStation.ARK,
                        Queue_ID    = queueNumber.Queue_ID
                    });
                    Trinity.SignalR.Client.Instance.QueueInserted(queueNumber.Queue_ID.ToString().Trim());
                    APIUtils.FormQueueNumber.RefreshQueueNumbers();
                    this._web.ShowMessage("Your queue number is:" + queueNumber.QueuedNumber);
                }

                //if (appointment != null && string.IsNullOrEmpty(appointment.Timeslot_ID))
                //{
                //    var eventCenter = Trinity.Common.Common.EventCenter.Default;
                //    eventCenter.RaiseEvent(new Trinity.Common.EventInfo() { Name = EventNames.ALERT_MESSAGE, Message = "You have not selected the timeslot!\n Please go to Book Appointment page to select a timeslot." });
                //}
                //else if (appointment != null && !string.IsNullOrEmpty(appointment.Timeslot_ID))
                //{
                //    queueNumber = _dalQueue.InsertQueueNumber(appointment.ID, appointment.UserId, EnumStation.ARK, currentUser.UserId);
                //    if (queueNumber != null)
                //    {
                //        Trinity.SignalR.Client.Instance.AppointmentBookedOrReported(appointment.ID.ToString().Trim(), EnumAppointmentStatuses.Reported);
                //        Trinity.SignalR.Client.Instance.QueueInserted(queueNumber.Queue_ID.ToString().Trim());
                //        APIUtils.FormQueueNumber.RefreshQueueNumbers();
                //        var eventCenter = Trinity.Common.Common.EventCenter.Default;
                //        eventCenter.RaiseEvent(new Trinity.Common.EventInfo() { Name = EventNames.ALERT_MESSAGE, Message = "Your queue number is:" + queueNumber.QueuedNumber });
                //    }
                //    else
                //    {
                //        this._web.ShowMessage("Sorry all timeslots are fully booked!");
                //    }

                //}
                //else
                //{

                //}
            }
            else
            {
                this._web.ShowMessage("You already registered a queue number!\n Please wait for your turn.");
            }
            //if (appointment == null && currentUser.Role == EnumUserRoles.Supervisee)
            //{
            //    var eventCenter = Trinity.Common.Common.EventCenter.Default;
            //    eventCenter.RaiseEvent(new Trinity.Common.EventInfo() { Name = EventNames.ALERT_MESSAGE, Message = "You have no appointment today" });
            //}
            //else
            //{

            //}
        }