Beispiel #1
0
        private void SetLoadBalancecaseRequestedCurrently(string workstationId, bool currentlyRequested)
        {
            LoadBalanceInfo foundInfo = FindLoadBalanceInfo(workstationId);

            if (!String.IsNullOrEmpty(foundInfo.workstationId))
            {
                lock (_workstationLoadListLock)
                {
                    foundInfo.caseRequestedCurrently = currentlyRequested;
                }
            }
        }
Beispiel #2
0
        private LoadBalanceInfo FindLoadBalanceInfo(string workstationId)
        {
            LoadBalanceInfo foundInfo = new LoadBalanceInfo();

            foreach (LoadBalanceInfo info in _workstationLoadBalanceList)
            {
                if (info.workstationId == workstationId)
                {
                    foundInfo = info;
                    break;
                }
            }

            return(foundInfo);
        }
Beispiel #3
0
        private void RemoveLoadBalanceWorkstation(string workstationId)
        {
            lock (_workstationLoadListLock)
            {
                LoadBalanceInfo foundInfo = FindLoadBalanceInfo(workstationId);

                if (!String.IsNullOrEmpty(foundInfo.workstationId))
                {
                    _workstationLoadBalanceList.Remove(foundInfo);

                    if (foundInfo.workstationId == _loadBalanceTimerSelectedWorkstation)
                    {
                        _loadBalanceTimerSelectedWorkstation = string.Empty;
                    }
                }
            }
        }
Beispiel #4
0
        private void IncrementLoadBalanceNumRequestedCases(string workstationId, bool currentlyRequested)
        {
            LoadBalanceInfo foundInfo = FindLoadBalanceInfo(workstationId);

            if (!String.IsNullOrEmpty(foundInfo.workstationId))
            {
                lock (_workstationLoadListLock)
                {
                    foundInfo.numCasesRequested++;
                    foundInfo.caseRequestedCurrently = currentlyRequested;

                    if (foundInfo.workstationId == _loadBalanceTimerSelectedWorkstation)
                    {
                        _loadBalanceTimerSelectedWorkstation = string.Empty;
                    }
                }
            }
        }
Beispiel #5
0
        private string GetNextLoadBalanceWorkstationId(string workstation)
        {
            string workstationId = string.Empty;

            //if there are more cases then Auto Select enabled workatations then
            // go ahead and select the case requesting workstations.
            if (_workstationLoadBalanceList.Count > 0)
            {
                if (caseList.List.CaseListTable.Count >= _workstationLoadBalanceList.Count)
                {
                    workstationId = workstation;
                }
                else  //else if there are more workstations than cases then start a timer and log
                //workstations hat request a case within the timer time window.  When the timer
                //expires select a workstation that should get the next case.
                {
                    lock (_workstationLoadListLock)
                    {
                        LoadBalanceInfo foundInfo = FindLoadBalanceInfo(workstation);

                        if (!string.IsNullOrEmpty(foundInfo.workstationId))
                        {
                            if (!string.IsNullOrEmpty(_loadBalanceTimerSelectedWorkstation))
                            {
                                //foundInfo.timerSelected = false;
                                //workstationId = foundInfo.workstationId;
                                workstationId = _loadBalanceTimerSelectedWorkstation;
                            }
                            else
                            {
                                foundInfo.requestedCaseWithinTimerWindow = true;

                                if (!_loadBalanceTimerSet)
                                {
                                    _loadBalanceCheckTimer.Change(2000, Timeout.Infinite);
                                    _loadBalanceTimerSet = true;
                                }
                            }
                        }
                    }
                }
            }
            return(workstationId);
        }
Beispiel #6
0
        private void AddLoadBalanceWorkstation(string workstationId)
        {
            lock (_workstationLoadListLock)
            {
                LoadBalanceInfo info = FindLoadBalanceInfo(workstationId);

                //if the workstation entry exist already then
                //reset its number of requested cases paramter
                if (String.IsNullOrEmpty(info.workstationId))
                {
                    info.workstationId = workstationId;
                    _workstationLoadBalanceList.Add(info);
                }

                foreach (LoadBalanceInfo lInfo in _workstationLoadBalanceList)
                {
                    lInfo.numCasesRequested = 0;
                }
            }
        }
Beispiel #7
0
        private void LoadBalanceCheckTimerCallback(object param)
        {
            bool            firstFoundInfo = false;
            LoadBalanceInfo selectedInfo   = null;

            lock (_workstationLoadListLock)
            {
                _loadBalanceTimerSet = false;

                //timer expired select the workstation that should get the next case
                foreach (LoadBalanceInfo info in _workstationLoadBalanceList)
                {
                    if (!info.caseRequestedCurrently && info.requestedCaseWithinTimerWindow)
                    {
                        // select workstation that has the least number of cases processed
                        if (!firstFoundInfo)
                        {
                            firstFoundInfo = true;
                            selectedInfo   = info;
                            continue;
                        }

                        if (selectedInfo.numCasesRequested > info.numCasesRequested)
                        {
                            selectedInfo = info;
                        }

                        info.requestedCaseWithinTimerWindow = false;
                    }
                }

                if (selectedInfo != null)
                {
                    _loadBalanceTimerSelectedWorkstation = selectedInfo.workstationId;
                }
            }
        }
Beispiel #8
0
        private LoadBalanceInfo FindLoadBalanceInfo(string workstationId)
        {
            LoadBalanceInfo foundInfo = new LoadBalanceInfo();

            foreach (LoadBalanceInfo info in _workstationLoadBalanceList)
            {
                if (info.workstationId == workstationId)
                {
                    foundInfo = info;
                    break;
                }
            }

            return foundInfo;
        }