Пример #1
0
 public TrayMgr()
 {
     trayDataLoadArr = new TrayData[30];
     for (int i = 0; i < trayDataLoadArr.Length; i++)
     {
         trayDataLoadArr[i] = new TrayData();
     }
 }
Пример #2
0
        public static MedicineData GetMedicineData(TrayData tray, string pillId)
        {
            MedicineData medicine = null;

            medicine = tray.Cups.SelectMany(x => x.Medicines).FirstOrDefault(x => x.PillId.Contains(pillId));
            if (medicine == null)
            {
                medicine = tray.Cups.SelectMany(x => x.Medicines).FirstOrDefault(x => x.PillInfo != null &&
                                                                                 ((FragmentData)x.PillInfo).WholePill != null &&
                                                                                 ((FragmentData)x.PillInfo).WholePill.PillId == pillId);
            }
            return(medicine);
        }
Пример #3
0
        public static string CalculateColorIntakeTime(TrayData tray, int number, bool?isTray57 = false)
        {
            var result = "";
            var cup    = tray.Cups.FirstOrDefault(o => o.Number % (isTray57 == true ? 5 : 4) == number &&
                                                  !string.IsNullOrEmpty(o.IntakeTimeDescription));

            if (cup != null)
            {
                var listDoseDispense = new List <string> {
                    "a", "b", "c", "d", "e"
                };
                var isDoesDispen = listDoseDispense.Contains(cup.TimeSlotCode);
                result = isDoesDispen ? cup.TimeSlotColor : cup.IntakeTimeColor;
            }
            return(result ?? "black");
        }
Пример #4
0
    private void LoadChips()
    {
        WordsDatabase   wordsDatabase = ScrabbleLogicManager.Instance.WordsDatabase;
        TrayData        trayData      = ScrabbleLogicManager.Instance.Tray;
        List <ChipData> chipsData     = wordsDatabase.GetRandomChips(trayData.Size);

        //Debug.Log(chipsData.Count);
        //Debug.Log(_trayController.Slots.Count);

        for (int x = 0; x < chipsData.Count; x++)
        {
            ChipData currentChipData = chipsData[x];

            //Debug.Log(currentChipData.Letter);

            ChipController newInstance = GameObject.Instantiate(ScrabbleGame.Instance.chipPrefab);
            newInstance.ChipData          = currentChipData;
            _trayController.Slots[x].Chip = newInstance;

            newInstance.gameObject.SetActive(true);
        }
    }
Пример #5
0
    private void LoadTraySlots()
    {
        TrayData           trayData   = ScrabbleLogicManager.Instance.Tray;
        TraySlotController slotPrefab = _trayController.slotPrefab;
        float traySize        = ScrabbleConstants.TRAY_SLOT_DISTANCE * trayData.Size;
        float slotSize        = ScrabbleConstants.TRAY_SLOT_DISTANCE;
        float initialPosition = -(traySize / 2) + (slotSize / 2);
        float currentPosition = initialPosition;

        for (int x = 0; x < trayData.Size; x++)
        {
            TraySlotController newInstance = GameObject.Instantiate(slotPrefab);
            newInstance.transform.SetParent(_trayController.transform, true);
            //newInstance.transform.localPosition = Vector3.zero;
            newInstance.transform.localPosition = new Vector3(currentPosition, 0, 0);
            newInstance.gameObject.SetActive(true);

            currentPosition += ScrabbleConstants.TRAY_SLOT_DISTANCE;

            _trayController.Slots.Add(newInstance);
        }
    }
Пример #6
0
        /// <summary>
        /// The actual trayIconBuster
        /// </summary>
        /// <returns>The number of tray icons removed.</returns>
        public unsafe static uint RemovePhantomIcons()
        {
            bool            is64bitWindows    = Is64BitWindows();
            ToolBarButton64 tbb64             = new ToolBarButton64();
            ToolBarButton32 tbb32             = new ToolBarButton32();
            TrayData        td                = new TrayData();
            bool            foundSomeExe      = false;
            uint            totalRemovedCount = 0;
            uint            totalItemCount    = 0;

            // for safety reasons we perform two passes:
            // pass1 = search for my own NotifyIcon
            // pass2 = search phantom icons and remove them
            //         pass2 doesnt happen if pass1 fails
            lock (key) {                                // prevent concurrency problems
                for (int pass = 1; pass <= 2; pass++)
                {
                    for (int kind = 0; kind < 2; kind++)
                    {
                        IntPtr hWnd = IntPtr.Zero;
                        if (kind == 0)
                        {
                            // get the regular icon collection that exists on all Windows versions
                            FindNestedWindow(ref hWnd, "Shell_TrayWnd");
                            FindNestedWindow(ref hWnd, "TrayNotifyWnd");
                            FindNestedWindow(ref hWnd, "SysPager");
                            FindNestedWindow(ref hWnd, "ToolbarWindow32");
                        }
                        else
                        {
                            // get the hidden icon collection that exists since Windows 7
                            try {
                                FindNestedWindow(ref hWnd, "NotifyIconOverflowWindow");
                                FindNestedWindow(ref hWnd, "ToolbarWindow32");
                            } catch {
                                // fail silently, as NotifyIconOverflowWindow did not exist prior to Win7
                                break;
                            }
                        }
                        // create an object so we can exchange data with other process
                        using (LP_Process process = new LP_Process(hWnd)) {
                            IntPtr remoteButtonPtr;
                            if (is64bitWindows)
                            {
                                remoteButtonPtr = process.Allocate(tbb64);
                            }
                            else
                            {
                                remoteButtonPtr = process.Allocate(tbb32);
                            }
                            process.Allocate(td);
                            uint itemCount = (uint)SendMessage(hWnd, TB_BUTTONCOUNT,
                                                               IntPtr.Zero, IntPtr.Zero);
                            //log("There are "+itemCount+" tray icons (some of them hidden)");
                            uint removedCount = 0;
                            for (uint item = 0; item < itemCount; item++)
                            {
                                totalItemCount++;
                                // index changes when previous items got removed !
                                uint item2 = item - removedCount;
                                uint SOK   = (uint)SendMessage(hWnd, TB_GETBUTTON,
                                                               new IntPtr(item2), remoteButtonPtr);
                                if (SOK != 1)
                                {
                                    throw new ApplicationException("TB_GETBUTTON failed");
                                }
                                if (is64bitWindows)
                                {
                                    process.Read(tbb64, remoteButtonPtr);
                                    process.Read(td, tbb64.dwData);
                                }
                                else
                                {
                                    process.Read(tbb32, remoteButtonPtr);
                                    process.Read(td, tbb32.dwData);
                                }
                                IntPtr hWnd2 = td.hWnd;
                                if (hWnd2 == IntPtr.Zero)
                                {
                                    throw new ApplicationException("Invalid window handle");
                                }
                                using (LP_Process proc = new LP_Process(hWnd2)) {
                                    string filename = proc.GetImageFileName();
                                    if (pass == 1 && filename != null)
                                    {
                                        filename = filename.ToLower();
                                        if (filename.EndsWith(".exe"))
                                        {
                                            foundSomeExe = true;
                                            log("(kind=" + kind + ") found real icon created by: " + filename);
                                            break;
                                        }
                                    }
                                    // a phantom icon has no imagefilename
                                    if (pass == 2 && filename == null)
                                    {
                                        SOK = (uint)SendMessage(hWnd, TB_DELETEBUTTON,
                                                                new IntPtr(item2), IntPtr.Zero);
                                        if (SOK != 1)
                                        {
                                            throw new ApplicationException("TB_DELETEBUTTON failed");
                                        }
                                        removedCount++;
                                        totalRemovedCount++;
                                    }
                                }
                            }
                        }
                    }                     // next kind
                    // if I did not see myself, I will not run the second
                    // pass, which would try and remove phantom icons
                    if (totalItemCount != 0 && !foundSomeExe)
                    {
                        throw new ApplicationException(
                                  "Failed to find any real icon");
                    }
                }
            }             // release lock
            log(totalItemCount.ToString() + " icons found, " + totalRemovedCount + " icons removed");
            return(totalRemovedCount);
        }
Пример #7
0
        /// <summary>
        /// The actual trayIconBuster
        /// </summary>
        /// <returns>The number of tray icons removed.</returns>
        public static uint RemovePhantomIcons()
        {
            uint removedCount = 0;

            lock (key) {                                // prevent concurrency problems
                IntPtr hWnd = IntPtr.Zero;
                FindNestedWindow(ref hWnd, "Shell_TrayWnd");
                FindNestedWindow(ref hWnd, "TrayNotifyWnd");
                FindNestedWindow(ref hWnd, "SysPager");
                FindNestedWindow(ref hWnd, "ToolbarWindow32");
                // create an object so we can exchange data with other process
                using (LP_Process process = new LP_Process(hWnd)) {
                    ToolBarButton tbb             = new ToolBarButton();
                    IntPtr        remoteButtonPtr = process.Allocate(tbb);
                    TrayData      td = new TrayData();
                    process.Allocate(td);
                    uint itemCount = (uint)SendMessage(hWnd, TB_BUTTONCOUNT,
                                                       IntPtr.Zero, IntPtr.Zero);
                    log("There are " + itemCount + " tray icons (some of them hidden)");
                    bool foundSomeExe = false;
                    // for safety reasons we perform two passes:
                    // pass1 = search for my own NotifyIcon
                    // pass2 = search phantom icons and remove them
                    //         pass2 doesnt happen if pass1 fails
                    for (int pass = 1; pass <= 2; pass++)
                    {
                        for (uint item = 0; item < itemCount; item++)
                        {
                            // index changes when previous items got removed !
                            uint item2 = item - removedCount;
                            uint SOK   = (uint)SendMessage(hWnd, TB_GETBUTTON,
                                                           new IntPtr(item2), remoteButtonPtr);
                            if (SOK != 1)
                            {
                                throw new ApplicationException("TB_GETBUTTON failed");
                            }
                            process.Read(tbb, remoteButtonPtr);
                            process.Read(td, tbb.dwData);
                            if (td.hWnd == IntPtr.Zero)
                            {
                                throw new ApplicationException("Invalid window handle");
                            }
                            using (LP_Process proc = new LP_Process(td.hWnd)) {
                                string filename = proc.GetImageFileName();
                                if (pass == 1 && filename != null)
                                {
                                    filename = filename.ToLower();
                                    if (filename.EndsWith(".exe"))
                                    {
                                        foundSomeExe = true;
                                        log("found real icon created by: " + filename);
                                        break;
                                    }
                                }
                                // a phantom icon has no imagefilename
                                if (pass == 2 && filename == null)
                                {
                                    SOK = (uint)SendMessage(hWnd, TB_DELETEBUTTON,
                                                            new IntPtr(item2), IntPtr.Zero);
                                    if (SOK != 1)
                                    {
                                        throw new ApplicationException("TB_DELETEBUTTON failed");
                                    }
                                    removedCount++;
                                }
                            }
                        }
                        // if I did not see myself, I will not run the second
                        // pass, which would try and remove phantom icons
                        if (!foundSomeExe)
                        {
                            throw new ApplicationException(
                                      "Failed to find any real icon");
                        }
                    }
                }
                log(removedCount.ToString() + " icons removed");
            }
            return(removedCount);
        }
Пример #8
0
        void BindingDataToReport()
        {
            tray = _reportService.GetTrayNew();
            if (tray != null)
            {
                var cartonLabel = tray.Carton != null ? tray.Carton.Label : null;
                if (isPrint)
                {
                    labelId = Guid.NewGuid().ToString();
                }
                else
                {
                    labelId = cartonLabel != null ? cartonLabel.LabelId : Guid.Empty.ToString();
                }
                isMultiLocation = tray.Locations.Count > 1;
                var    models          = new List <SureMedRdlcReportOutsideInfo>();
                var    isMultiPatient  = tray.Patients.Count() > 1;
                var    patient         = tray.Patients.FirstOrDefault().Value;
                var    cupFirst        = tray.Cups.OrderBy(x => x.IntakeDateTime).FirstOrDefault();
                var    location        = tray.Locations.FirstOrDefault().Value;
                var    customerAdrress = location.Customer.Addresses.FirstOrDefault(o => ("Medication packing address").Equals(o.AddressType));
                Bitmap imagetemp       = null;
                if (patient.PhotoImage != null)
                {
                    imagetemp = (Bitmap)patient.PhotoImage.Clone();
                }
                var model = new SureMedRdlcReportOutsideInfo()
                {
                    PatientName  = isMultiPatient ? Linguist.Phrase("ErrorDataTitle") : patient.FullName.Length > 25 ? patient.FullName.Substring(0, 25): patient.FullName,
                    PatientPhoto = patient.PhotoImage != null && !isMultiPatient?Utils.imageToByteArray(imagetemp) : new byte[0],
                                       RoomBedInfo         = buildBedRoomInfo(patient, isMultiPatient),
                                       PatientId           = isMultiPatient ? Linguist.Phrase("ErrorDataTitle") : patient.PatientId,
                                       PatientIdWithPrefix = Linguist.Phrase("PatientIdWithColonTitle") + " " + patient.PatientId,
                                       StartDate           = cupFirst.IntakeDateTime.ToString(defaultFormatDate),
                                       PatientDob          = isMultiPatient
                        ? Linguist.Phrase("ErrorDataTitle")
                        : (patient.DateOfBirth != DateTime.MinValue ? Linguist.Phrase("DOBTitle") + patient.DateOfBirth.ToString(defaultFormatDate) : ""),
                                       Facility = isMultiPatient ? Linguist.Phrase("ErrorDataTitle") : cupFirst.Location.Institution.Name,
                                       DayOfWeekStartDatestr = isMultiPatient ? Linguist.Phrase("ErrorDataTitle") : cupFirst.IntakeDateTime.ToString("dddd") + " " + cupFirst.IntakeDateTime.ToString("MM/dd/yyyy"),
                                       DayOfWeek             = cupFirst.IntakeDateTime.ToString("dddd"),
                                       PackXofX        = Linguist.Phrase("PackTitle") + " " + (tray.SequenceTrayNumberByPatient <= 0 ? 1 : tray.SequenceTrayNumberByPatient) + " " + Linguist.Phrase("OfTitle") + " " + (tray.TotalTrayInBatchByPatient <= 0 ? 1 : tray.TotalTrayInBatchByPatient),
                                       PatientBigPhoto = patient.PhotoImage != null && !isMultiPatient?Utils.imageToByteArray(imagetemp) : new byte[0],
                                                             PharmacyInfo    = location.Customer.Name,
                                                             PharmacyAddress = customerAdrress != null?buildCustomerAddress(customerAdrress) : "",
                                                                                   BarcodeImage = Utils.CreateQRCode(labelId),
                                                                                   CompanyLogo  = tray.Batch.Order.CompanyLogo != null?Utils.imageToByteArray(tray.Batch.Order.CompanyLogo) : new byte[0],
                                                                                                      PromoLogo = tray.Batch.Order.Template1 != null?Utils.imageToByteArray(Utils.rotateInternalFunction(tray.Batch.Order.Template1, RotateFlipType.Rotate270FlipNone)) : new byte[0],
                                                                                                                      DateCreated    = Linguist.Phrase("DatePackedWithColonTitle") + " " + tray.DateCreated.ToString(defaultFormatDate),
                                                                                                                      IsMultiPatient = isMultiPatient,
                                                                                                                      Phone          = location.Customer.Phone1,
                                                                                                                      ExpireDate     = Linguist.Phrase("ExpireDateWithColonTitle") + " " + Helper.CalculateExpireDate(tray, cupFirst, Settings.Default.MinimumExpirePeriod).ToString(defaultFormatDate),
                                                                                                                      Unit           = patient.Unit,
                                                                                                                      Location       = isMultiLocation ? Linguist.Phrase("ErrorDataTitle") : tray.Locations.FirstOrDefault().Value.LocationId,
                                                                                                                      PhoneLabel     = Linguist.Phrase("PhoneWithColonTitle"),
                                                                                                                      Dea            = Linguist.Phrase("Dea#WithColonTitle"),
                                                                                                                      DeaValue       = location.Customer.DeaNumber,
                                                                                                                      CautionValue   = Linguist.Phrase("Warning") + Environment.NewLine + Linguist.Phrase("Caution"),
                                                                                                                      PatientStreet  = patient.Addresses.FirstOrDefault() != null?patient.Addresses.FirstOrDefault().Street                                                        : "",
                                                                                                                      PatientZipCode = patient.Addresses.FirstOrDefault() != null?patient.Addresses.FirstOrDefault().ZipPostalCode + " " + patient.Addresses.FirstOrDefault().City : ""
                };

                models.Add(model);
                ReportDataSource reportDataSource1 =
                    new Microsoft.Reporting.WinForms.ReportDataSource();
                reportDataSource1.Name  = "SureMedPlusCardOutsideInfoDataset";
                reportDataSource1.Value = models;
                this.reportViewer.LocalReport.DataSources.Add(reportDataSource1);
                buildDataSubReport();
            }
        }
Пример #9
0
        public unsafe void getTrayIcons()
        {
            bool showTrayIcons = Convert.ToBoolean(AppSettings["showTrayIcons"]);

            if (showTrayIcons)
            {
                new Thread(() =>
                {
                    while (this.Visible)
                    {
                        // Retreive window information
                        Thread.CurrentThread.IsBackground = true;
                        IntPtr systemTrayHandle           = GetSystemTrayHandle();

                        using (LP_Process process = new LP_Process(systemTrayHandle))
                        {
                            ToolBarButton tbb      = new ToolBarButton();
                            IntPtr remoteButtonPtr = process.Allocate(tbb);
                            TrayData td            = new TrayData();
                            process.Allocate(td);
                            uint count = (uint)SendMessage(systemTrayHandle, TB_BUTTONCOUNT, IntPtr.Zero, IntPtr.Zero);

                            for (uint i = 0; i < count; i++)
                            {
                                uint SOK = (uint)SendMessage(systemTrayHandle, TB_GETBUTTON, new IntPtr(i), remoteButtonPtr);
                                if (SOK != 1)
                                {
                                    break;
                                }
                                process.Read(tbb, remoteButtonPtr);
                                process.Read(td, tbb.dwData);
                                if (td.hWnd == IntPtr.Zero)
                                {
                                    throw new ApplicationException("Invalid window handle");
                                }
                                using (LP_Process proc = new LP_Process(td.hWnd))
                                {
                                    string filename = proc.GetImageFileName();
                                    if (filename != null)
                                    {
                                        filename = filename.ToLower();
                                        if (filename.EndsWith(".exe"))
                                        {
                                            if (!trayIcons.ContainsKey(filename))
                                            {
                                                lock (trayIcons)
                                                {
                                                    trayIcons.Add(filename, new Dictionary <IntPtr, GroupBox>());
                                                }

                                                // Add this window if it is not already being tracked
                                                if (!trayIcons[filename].ContainsKey(td.hWnd))
                                                {
                                                    // prepare group
                                                    GroupBox grp       = new GroupBox();
                                                    grp.Name           = filename;
                                                    grp.AccessibleName = filename;
                                                    grp.Tag            = filename;
                                                    grp.Height         = this.Height / 2;
                                                    grp.Width          = this.Height / 2;
                                                    grp.MouseDown     += (sender, e) =>
                                                    {
                                                    };
                                                    grp.MouseEnter += (sender, e) =>
                                                    {
                                                    };
                                                    grp.MouseLeave += (sender, e) =>
                                                    {
                                                    };
                                                    grp.Click += (sender, e) =>
                                                    {
                                                    };
                                                    //new ToolTip().SetToolTip(grp, process.MainWindowTitle);

                                                    // Build Icon as PictureBox Control
                                                    PictureBox ico = new PictureBox();

                                                    ico.Image = Bitmap.FromHicon((td.hIcon));
                                                    ico.BackgroundImageLayout = ImageLayout.Stretch;
                                                    ico.SizeMode = PictureBoxSizeMode.CenterImage;
                                                    ico.Height   = grp.Height;
                                                    ico.Width    = grp.Width;
                                                    ico.Enabled  = false;
                                                    grp.Controls.Add(ico);

                                                    lock (trayIcons)
                                                    {
                                                        // Add to tracked windows
                                                        trayIcons[filename].Add(td.hWnd, grp);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }).Start();
            }
        }
Пример #10
0
 public static DateTime CalculateExpireDate(TrayData tray, CupData cupFirst, int minimumExpirePeriod)
 {
     return(cupFirst.IntakeDateTime.AddDays(tray.MinimumExpirePeriod == 0
         ? minimumExpirePeriod
         : tray.MinimumExpirePeriod));
 }
Пример #11
0
        public static List <PillDispense> GetChargeAndExpireDate(TrayData tray)
        {
            var medicinesInTray = tray.Cups.SelectMany(x => x.Medicines).Where(x => x.PillInfo != null);
            var query           =
                (from x in medicinesInTray
                 group x
                 by x.PillId
                 into g
                 select new
            {
                PillId = g.Key,
                BcoRefill = g.SelectMany(x => x.BcoRefill),
                CartridgeDispense = g.SelectMany(x => x.CartridgeDispense),
                MdaDispense = g.SelectMany(x => x.MdaDispense)
            }).ToList();
            var dispenseList = new List <PillDispense>();

            foreach (var x in query)
            {
                var chargeList      = new List <string>();
                var expireDate      = DateTime.MaxValue;
                var isMultipleDay   = false;
                var expireDateCount = 0;
                foreach (var b in x.BcoRefill)
                {
                    chargeList.Add(b.ChargeNumber);
                    if (expireDate != b.ExpireDate)
                    {
                        ++expireDateCount;
                    }
                    if (expireDate > b.ExpireDate)
                    {
                        expireDate = b.ExpireDate;
                    }
                }

                foreach (var c in x.CartridgeDispense)
                {
                    chargeList.Add(c.ChargeNumber);
                    if (expireDate != c.ExpireDate)
                    {
                        ++expireDateCount;
                    }
                    if (expireDate > c.ExpireDate)
                    {
                        expireDate = c.ExpireDate;
                    }
                }

                foreach (var m in x.MdaDispense)
                {
                    chargeList.Add(m.ChargeNumber);
                    if (expireDate != m.ExpireDate)
                    {
                        ++expireDateCount;
                    }
                    if (expireDate > m.ExpireDate)
                    {
                        expireDate = m.ExpireDate;
                    }
                }
                var chargeListText =
                    string.Join(",",
                                chargeList.Distinct().ToArray().Take(3));
                dispenseList.Add(new PillDispense
                {
                    PillId           = x.PillId,
                    ChargeNumberList = chargeListText,
                    ExipreDate       = expireDate,
                    isMultipleExpDay = expireDateCount > 1 ? true : false
                });
            }
            return(dispenseList);
        }