Changeset 1083 for Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs
- Timestamp:
- Jan 26, 2011, 6:01:39 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs
r1073 r1083 272 272 //sam: This is a test that duplicates RefreshDocument, but without the UpdateAllViews, 273 273 // as that has to be done synchornously. 274 //XXXXXX: Needs to be refactored obviously, but now for testing. 274 //XXX: Needs to be refactored obviously, but now for testing. 275 //XXX: Tested extensively enough. Less refactoring now. 2011-01-26 275 276 public void RefreshDocumentAsync() 276 277 { 278 Debug.WriteLine("IN REFERSH DOCUMENT ASYNC\n\n"); 279 277 280 bool bRet = false; 278 281 if (m_sResourcesArray.Count == 0) … … 423 426 m_DocManager.ConnectInfo.LoadConnectInfo(); 424 427 } 425 426 m_pAvArray.Clear();427 428 428 429 ArrayList saryApptTypes = new ArrayList(); … … 464 465 string sAccessRuleList; 465 466 466 467 foreach (DataRow rTemp in rAvailabilitySchedule.Rows) 468 { 469 //get StartTime, EndTime and Slots 470 dStart = (DateTime)rTemp["START_TIME"]; 471 dEnd = (DateTime)rTemp["END_TIME"]; 472 473 //TODO: Fix this slots datatype problem 474 string sSlots = rTemp["SLOTS"].ToString(); 475 nSlots = Convert.ToInt16(sSlots); 476 477 sResourceList = rTemp["RESOURCE"].ToString(); 478 sAccessRuleList = rTemp["ACCESS_TYPE"].ToString(); 479 480 string sNote = rTemp["NOTE"].ToString(); 481 482 if ((nSlots < -1000) || (sAccessRuleList == "")) 467 //smh: moved clear availabilities down here. 468 //smh: Temporary solution to make sure that people don't touch the availability table at the same time!!! 469 //NOTE: This lock makes sure that availabilities aren't queried for slots when the array is an intermediate 470 //state. The other place that has this lock is SlotsAvailable function. 471 lock (this.m_pAvArray) 472 { 473 m_pAvArray.Clear(); 474 475 foreach (DataRow rTemp in rAvailabilitySchedule.Rows) 483 476 { 484 nApptTypeID = 0; 485 } 486 else 487 { 488 foreach (DataRow rType in rTypeSchedule.Rows) 477 //get StartTime, EndTime and Slots 478 dStart = (DateTime)rTemp["START_TIME"]; 479 dEnd = (DateTime)rTemp["END_TIME"]; 480 481 //TODO: Fix this slots datatype problem 482 string sSlots = rTemp["SLOTS"].ToString(); 483 nSlots = Convert.ToInt16(sSlots); 484 485 sResourceList = rTemp["RESOURCE"].ToString(); 486 sAccessRuleList = rTemp["ACCESS_TYPE"].ToString(); 487 488 string sNote = rTemp["NOTE"].ToString(); 489 490 if ((nSlots < -1000) || (sAccessRuleList == "")) 489 491 { 490 491 dTypeStart = (DateTime)rType["StartTime"]; 492 dTypeEnd = (DateTime)rType["EndTime"]; 493 //if start & end times overlap, then 494 string sTypeResource = rType["ResourceName"].ToString(); 495 if ((dTypeStart.DayOfYear == dStart.DayOfYear) && (sResourceList == sTypeResource)) 492 nApptTypeID = 0; 493 } 494 else 495 { 496 foreach (DataRow rType in rTypeSchedule.Rows) 496 497 { 497 crRectA.Y = GetTotalMinutes(dStart); 498 crRectA.Height = GetTotalMinutes(dEnd) - crRectA.Top;499 crRectB.Y = GetTotalMinutes(dTypeStart);500 crRectB.Height = GetTotalMinutes(dTypeEnd) - crRectB.Top;501 bIsect = crRectA.IntersectsWith(crRectB);502 if ( bIsect == true)498 499 dTypeStart = (DateTime)rType["StartTime"]; 500 dTypeEnd = (DateTime)rType["EndTime"]; 501 //if start & end times overlap, then 502 string sTypeResource = rType["ResourceName"].ToString(); 503 if ((dTypeStart.DayOfYear == dStart.DayOfYear) && (sResourceList == sTypeResource)) 503 504 { 504 //TODO: This code: 505 // nApptTypeID = (int) rType["AppointmentTypeID"]; 506 //Causes this exception: 507 //Unhandled Exception: System.InvalidCastException: Specified cast is not valid. 508 string sTemp = rType["AppointmentTypeID"].ToString(); 509 nApptTypeID = Convert.ToInt16(sTemp); 510 break; 505 crRectA.Y = GetTotalMinutes(dStart); 506 crRectA.Height = GetTotalMinutes(dEnd) - crRectA.Top; 507 crRectB.Y = GetTotalMinutes(dTypeStart); 508 crRectB.Height = GetTotalMinutes(dTypeEnd) - crRectB.Top; 509 bIsect = crRectA.IntersectsWith(crRectB); 510 if (bIsect == true) 511 { 512 //TODO: This code: 513 // nApptTypeID = (int) rType["AppointmentTypeID"]; 514 //Causes this exception: 515 //Unhandled Exception: System.InvalidCastException: Specified cast is not valid. 516 string sTemp = rType["AppointmentTypeID"].ToString(); 517 nApptTypeID = Convert.ToInt16(sTemp); 518 break; 519 } 511 520 } 512 } 513 } //end foreach datarow rType514 } 515 516 AddAvailability(dStart, dEnd, nApptTypeID, nSlots, false, sResourceList, sAccessRuleList, sNote);517 }//end foreach datarow rTemp518 521 }//end foreach datarow rType 522 } 523 524 525 AddAvailability(dStart, dEnd, nApptTypeID, nSlots, false, sResourceList, sAccessRuleList, sNote); 526 }//end foreach datarow rTemp 527 }//end lock 519 528 return true; 520 529 } … … 531 540 } 532 541 542 /// <summary> 543 /// Adds Availability to Availability Array held by document 544 /// </summary> 545 /// <param name="StartTime">Self-Explan</param> 546 /// <param name="EndTime">Self-Explan</param> 547 /// <param name="nType"></param> 548 /// <param name="nSlots"></param> 549 /// <param name="UpdateView"></param> 550 /// <param name="sResourceList"></param> 551 /// <param name="sAccessRuleList"></param> 552 /// <param name="sNote"></param> 553 /// <returns></returns> 533 554 public int AddAvailability(DateTime StartTime, DateTime EndTime, int nType, int nSlots, bool UpdateView, string sResourceList, string sAccessRuleList, string sNote) 534 555 { … … 579 600 //TODO: Test that resource is not currently in list, that it IS a resource, etc 580 601 this.m_sResourcesArray.Add(sResource); 581 //SAM: removing: Remove UpdateAllViews: Redraws all the open views. But does not call server.582 //this.UpdateAllViews();583 }584 585 public void ClearResources()586 {587 this.m_sResourcesArray.Clear();588 602 } 589 603 … … 604 618 crRectB.Height = GetTotalMinutes(dSelEnd) - crRectB.Y; 605 619 606 // //loop thru m_pAvArray 607 // //Compare the start time and end time of eachblock 608 while (i < m_pAvArray.Count) 609 { 610 pAv = (CGAvailability)m_pAvArray[i]; 611 dStart = pAv.StartTime; 612 dEnd = pAv.EndTime; 613 if ((sResource == pAv.ResourceList) && 614 ((dSelStart.Date == dStart.Date) || (dSelStart.Date == dEnd.Date))) 615 { 616 crRectA.Y = (dStart.Date < dSelStart.Date) ? 0 : GetTotalMinutes(dStart); 617 crRectA.Height = (dEnd.Date > dSelEnd.Date) ? 1440 : GetTotalMinutes(dEnd); 618 crRectA.Height = crRectA.Height - crRectA.Y; 619 bIsect = crRectA.IntersectsWith(crRectB); 620 if (bIsect != false) 620 //NOTE: What's this lock? This lock makes sure that nobody is editing the availability array 621 //when we are looking at it. Since the availability array could potentially be updated on 622 //a different thread, we are can be potentially left stuck with an empty array. 623 // 624 //The other place that uses this lock is the RefershAvailabilitySchedule method 625 // 626 //This is a temporary fix until I figure out how to divorce the availbilities here from those drawn 627 //on the calendar. Appointments are cloned b/c they are in an object that supports that; and b/c I 628 //don't need to suddenly query them at runtime like I do with Availabilities. 629 630 lock (this.m_pAvArray) 631 { 632 //loop thru m_pAvArray 633 //Compare the start time and end time of eachblock 634 while (i < m_pAvArray.Count) 635 { 636 pAv = (CGAvailability)m_pAvArray[i]; 637 dStart = pAv.StartTime; 638 dEnd = pAv.EndTime; 639 if ((sResource == pAv.ResourceList) && 640 ((dSelStart.Date == dStart.Date) || (dSelStart.Date == dEnd.Date))) 621 641 { 622 nSlots = pAv.Slots; 623 if (nSlots < 1) 642 crRectA.Y = (dStart.Date < dSelStart.Date) ? 0 : GetTotalMinutes(dStart); 643 crRectA.Height = (dEnd.Date > dSelEnd.Date) ? 1440 : GetTotalMinutes(dEnd); 644 crRectA.Height = crRectA.Height - crRectA.Y; 645 bIsect = crRectA.IntersectsWith(crRectB); 646 if (bIsect != false) 624 647 { 625 nAvailableSlots = 0; 626 break; 627 } 628 if (nSlots < nAvailableSlots) 629 { 630 nAvailableSlots = nSlots; 631 sAccessType = pAv.AccessTypeName; 632 sAvailabilityMessage = pAv.Note; 633 634 } 635 } 636 } 637 i++; 638 } 648 nSlots = pAv.Slots; 649 if (nSlots < 1) 650 { 651 nAvailableSlots = 0; 652 break; 653 } 654 if (nSlots < nAvailableSlots) 655 { 656 nAvailableSlots = nSlots; 657 sAccessType = pAv.AccessTypeName; 658 sAvailabilityMessage = pAv.Note; 659 660 } 661 }//end if 662 }//end if 663 i++; 664 }//end while 665 }//end lock 666 639 667 if (nAvailableSlots == 999) 640 668 { … … 759 787 aCopy.HealthRecordNumber = rApptInfo.HealthRecordNumber; 760 788 aCopy.AccessTypeID = rApptInfo.AccessTypeID; 789 aCopy.WalkIn = bWalkin ? true : false; 761 790 762 791 string sSql = "BSDX ADD NEW APPOINTMENT^" + sStart + "^" + sEnd + "^" + sPatID + "^" + sResource + "^" + sLen + "^" + sNote + "^" + sApptID; … … 773 802 aCopy.AppointmentKey = nApptID; 774 803 this.m_appointments.AddAppointment(aCopy); 775 776 bool bRet = RefreshAvailabilitySchedule(); 777 778 UpdateAllViews(); 804 805 806 //Have make appointment from CGView responsible for requesting an update for the avialability. 807 //bool bRet = RefreshAvailabilitySchedule(); 808 809 //Sam: don't think this is needed as it is called from CGView. 810 //Make CGView responsible for all drawing. 811 //UpdateAllViews(); 779 812 780 813 return nApptID; … … 822 855 string sErrorID = r["ERRORID"].ToString(); 823 856 824 if (this.m_appointments.AppointmentTable.ContainsKey(nApptID)) 825 { 826 bool bRet = RefreshSchedule(); 827 UpdateAllViews(); 828 } 857 829 858 } 830 859
Note:
See TracChangeset
for help on using the changeset viewer.