Changeset 1095 for Scheduling/trunk/cs/bsdx0200GUISourceCode
- Timestamp:
- Feb 21, 2011, 9:21:24 AM (14 years ago)
- Location:
- Scheduling/trunk/cs/bsdx0200GUISourceCode
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
Scheduling/trunk/cs/bsdx0200GUISourceCode/CGAVDocument.cs
r1039 r1095 375 375 376 376 rAppointmentSchedule = CGSchedLib.CreateAssignedSlotSchedule(m_DocManager, (string) m_sResourcesArray[0], this.m_dStartDate, this.m_dEndDate, apptTypeIDs,/* */ this.m_ScheduleType, "0"); 377 CGSchedLib.OutputArray(rAppointmentSchedule, "rAppointmentSchedule"); 377 378 378 foreach (DataRow r in rAppointmentSchedule.Rows) 379 379 { -
Scheduling/trunk/cs/bsdx0200GUISourceCode/CGAppointments.cs
r1083 r1095 4 4 using System.Collections; 5 5 /// <summary> 6 /// This class was regenerated from Calendargrid.dll using Reflector.exe 7 /// by Sam Habiel for WorldVista. The original source code is lost. 6 /// Managers Appointment objects CGAppointment using an array list internally. 8 7 /// </summary> 8 /// <remarks> 9 /// Really needs to be refactored to use generics 10 /// </remarks> 9 11 [Serializable] 10 12 public class CGAppointments : IEnumerable, ICloneable … … 58 60 59 61 62 /// <summary> 63 /// Returns a deep copy of CGAppointments 64 /// </summary> 65 /// <returns></returns> 60 66 public object Clone() 61 67 { -
Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs
r1084 r1095 173 173 /// <summary> 174 174 /// Update schedule based on info in RPMS 175 /// <returns>Clears and repopluates m_appointments</returns> 175 176 /// </summary> 176 177 private bool RefreshDaysSchedule() … … 200 201 m_dLastRefresh = DateTime.Now; 201 202 203 //Clear appointments associated with this document 202 204 this.m_appointments.ClearAllAppointments(); 203 205 … … 205 207 rAppointmentSchedule = CGSchedLib.CreateAppointmentSchedule(m_DocManager, m_sResourcesArray, this.m_dStartDate, this.m_dEndDate); 206 208 207 // Datatable dumper into Debug Log (nice to know that this exists) 208 CGSchedLib.OutputArray(rAppointmentSchedule, "rAppointmentSchedule"); 209 210 209 // loop through datatable: Create CGAppointment and add to CGAppointments 211 210 foreach (DataRow r in rAppointmentSchedule.Rows) 212 211 { … … 422 421 try 423 422 { 424 if (this.m_DocManager.ConnectInfo.Connected == false)425 {426 m_DocManager.ConnectInfo.LoadConnectInfo();427 }428 429 423 ArrayList saryApptTypes = new ArrayList(); 430 int nApptTypeID = 0; 431 424 432 425 //Refresh Availability schedules 433 426 DataTable rAvailabilitySchedule; 434 427 rAvailabilitySchedule = CGSchedLib.CreateAvailabilitySchedule(m_DocManager, m_sResourcesArray, this.m_dStartDate, this.m_dEndDate, saryApptTypes,/**/ m_ScheduleType, "0"); 435 CGSchedLib.OutputArray(rAvailabilitySchedule, "rAvailabilitySchedule"); 436 428 429 ////NEW 430 //NOTE: This lock makes sure that availabilities aren't queried for slots when the array is an intermediate 431 //state. The other place that has this lock is SlotsAvailable function. 432 lock (this.m_pAvArray) 433 { 434 m_pAvArray.Clear(); 435 foreach (DataRow rTemp in rAvailabilitySchedule.Rows) 436 { 437 DateTime dStart = (DateTime)rTemp["START_TIME"]; 438 DateTime dEnd = (DateTime)rTemp["END_TIME"]; 439 440 //TODO: Fix this slots datatype problem 441 string sSlots = rTemp["SLOTS"].ToString(); 442 int nSlots = Convert.ToInt16(sSlots); 443 444 string sResourceList = rTemp["RESOURCE"].ToString(); 445 string sAccessRuleList = rTemp["ACCESS_TYPE"].ToString(); 446 string sNote = rTemp["NOTE"].ToString(); 447 448 int nApptTypeID; 449 450 if ((nSlots < -1000) || (sAccessRuleList == "")) 451 { 452 nApptTypeID = 0; 453 } 454 else 455 { 456 nApptTypeID = Int32.Parse(rTemp["ACCESS_TYPE"].ToString()); 457 } 458 459 AddAvailability(dStart, dEnd, nApptTypeID, nSlots, sResourceList, sAccessRuleList, sNote); 460 } 461 } 462 return true; 463 464 /* NOT USED 437 465 //Refresh Type Schedule 438 466 string sResourceName = ""; … … 442 470 sResourceName = m_sResourcesArray[j].ToString(); 443 471 DataTable dtTemp = CGSchedLib.CreateAssignedTypeSchedule(m_DocManager, sResourceName, this.m_dStartDate, this.m_dEndDate, m_ScheduleType); 444 CGSchedLib.OutputArray(dtTemp, "dtTemp"); 472 445 473 if (j == 0) 446 474 { … … 452 480 } 453 481 } 454 CGSchedLib.OutputArray(rTypeSchedule, "rTypeSchedule");455 482 456 483 DateTime dStart; … … 523 550 524 551 525 AddAvailability(dStart, dEnd, nApptTypeID, nSlots, false, sResourceList, sAccessRuleList, sNote);552 //AddAvailability(dStart, dEnd, nApptTypeID, nSlots, sResourceList, sAccessRuleList, sNote); 526 553 }//end foreach datarow rTemp 527 554 }//end lock 528 555 return true; 556 */ 529 557 } 530 558 catch (Exception ex) … … 552 580 /// <param name="sNote"></param> 553 581 /// <returns></returns> 554 public int AddAvailability(DateTime StartTime, DateTime EndTime, int nType, int nSlots, bool UpdateView,string sResourceList, string sAccessRuleList, string sNote)582 public int AddAvailability(DateTime StartTime, DateTime EndTime, int nType, int nSlots, string sResourceList, string sAccessRuleList, string sNote) 555 583 { 556 584 //adds it to the object array … … 588 616 int nIndex = 0; 589 617 nIndex = m_pAvArray.Add(pNewAv); 590 if (UpdateView == true) 591 { 592 this.UpdateAllViews(); 593 } 618 594 619 return nIndex; 595 620 } -
Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs
r1091 r1095 170 170 /// Encoding decision is complex. This is the order of priority: 171 171 /// - If the M DB runs in UTF-8, that's what we are going to use. 172 /// - If that's not so, /e sets the default encoding. If /e is a non-existent encoding, move forward.172 /// - If that's not so, /e sets the default encoding. If /e is a non-existent encoding, move to next step. 173 173 /// - If /e is not supplied or is not recognized, the default encoding is the Windows default Encoding for the user. 174 174 /// </remarks> … … 606 606 m_dsGlobal.Tables["ResourceGroup"].Columns["RESOURCE_GROUP"], //Parent 607 607 m_dsGlobal.Tables["GroupResources"].Columns["RESOURCE_GROUP"]); //Child 608 CGSchedLib.OutputArray(m_dsGlobal.Tables["GroupResources"], "GroupResources"); 608 609 609 m_dsGlobal.Relations.Add(dr); 610 610 -
Scheduling/trunk/cs/bsdx0200GUISourceCode/CGSchedLib.cs
r1011 r1095 19 19 /// scheduling application. 20 20 /// </summary> 21 public class CGSchedLib21 public static class CGSchedLib 22 22 { 23 public CGSchedLib()24 {25 26 }27 28 23 /// <summary> 29 24 /// Gets appointments from VISTA to display in Grid … … 53 48 } 54 49 55 public static void OutputArray(DataTable dt, string sName) 56 { 57 #if (DEBUG && OUTPUTARRAY) 58 Debug.Write("\n " + sName + " OutputArray:\n"); 59 if (dt == null) 60 return; 61 62 foreach (DataColumn c in dt.Columns) 63 { 64 Debug.Write(c.ToString()); 65 } 66 Debug.Write("\n"); 67 foreach (DataRow r in dt.Rows) 68 { 69 foreach (DataColumn c in dt.Columns) 70 { 71 Debug.Write(r[c].ToString()); 72 } 73 Debug.Write("\n"); 74 } 75 Debug.Write("\n"); 76 #endif 77 } 78 50 51 /// <summary> 52 /// Gets all Availabilities and Appointments, then substracts Appointments from availabilities. 53 /// </summary> 54 /// <param name="docManager">God Class</param> 55 /// <param name="saryResourceNames">Resource Array (ArrayList)</param> 56 /// <param name="StartTime">Self-Explanatory</param> 57 /// <param name="EndTime">Self-Explanatory</param> 58 /// <param name="saryApptTypes">Array of Access Type IDs</param> 59 /// <param name="stType"></param> 60 /// <param name="sSearchInfo"></param> 61 /// <returns></returns> 79 62 public static DataTable CreateAvailabilitySchedule(CGDocumentManager docManager, 80 63 ArrayList saryResourceNames, DateTime StartTime, DateTime EndTime, … … 95 78 96 79 string sResName; 80 //TODO: Optimize: no need to keep looping through resources. 97 81 // for each resource 98 82 for (int i = 0; i < nSize; i++) 99 83 { 100 84 sResName = saryResourceNames[i].ToString(); 101 //Gets all the slots (or Availabities, if you like)85 //Gets all the slots (or Availabities, or AV Blocks if you like) 102 86 rsSlotSchedule = CGSchedLib.CreateAssignedSlotSchedule(docManager, sResName, StartTime, EndTime, saryApptTypes,/**/ stType, sSearchInfo); 103 OutputArray(rsSlotSchedule, "rsSlotSchedule");87 104 88 //if we have slots 105 89 if (rsSlotSchedule.Rows.Count > 0 ) … … 107 91 // Get appointment count to substract from the slots 108 92 rsApptSchedule = CGSchedLib.CreateAppointmentSlotSchedule(docManager, sResName, StartTime, EndTime, stType); 109 OutputArray(rsApptSchedule, "rsApptSchedule"); 93 110 94 // Perform the substraction 111 95 rsTemp1 = CGSchedLib.SubtractSlotsRS2(rsSlotSchedule, rsApptSchedule, sResName); 112 OutputArray(rsTemp1, "rsTemp1"); 113 } 96 97 } 98 //otherwise, just return the slot schedule we have. 114 99 else 115 100 { 116 101 rsTemp1 = rsSlotSchedule; 117 OutputArray(rsTemp1, "rsTemp1"); 118 } 102 103 } 104 119 105 // if only one resource was passed in, its availablility is what we want 120 106 if (i == 0) 121 107 { 122 108 rsOut = rsTemp1; 123 OutputArray(rsOut, "rsOut"); 124 } 109 110 } 111 // if more than one resource, merge them together 125 112 else 126 113 { 127 114 rsOut = CGSchedLib.UnionBlocks(rsTemp1, rsOut); 128 OutputArray(rsOut, "United rsOut");129 115 } 130 116 } … … 133 119 134 120 121 /* NOT USED ANYMORE!!! 135 122 public static DataTable CreateAssignedTypeSchedule(CGDocumentManager docManager, string sResourceName, DateTime StartTime, DateTime EndTime, ScheduleType stType) 136 123 { 137 124 138 string sStart; 139 string sEnd; 140 //sStart = StartTime.ToString("M-d-yyyy"); 141 sStart = FMDateTime.Create(StartTime).DateOnly.FMDateString; 142 //sEnd = EndTime.ToString("M-d-yyyy"); 143 sEnd = FMDateTime.Create(EndTime).DateOnly.FMDateString; 144 // string sSource = (stType == ScheduleType.Resource ? "ST_RESOURCE" : "ST_CLINIC"); 145 string sSql = "BSDX TYPE BLOCKS OVERLAP^" + sStart + "^" + sEnd + "^" + sResourceName ;//+ "^" + sSource; 125 string sStart = FMDateTime.Create(StartTime).DateOnly.FMDateString; 126 string sEnd = FMDateTime.Create(EndTime).DateOnly.FMDateString; 127 string sSql = "BSDX TYPE BLOCKS OVERLAP^" + sStart + "^" + sEnd + "^" + sResourceName; 146 128 147 129 DataTable rs = docManager.RPMSDataTable(sSql, "AssignedTypeSchedule"); … … 176 158 177 159 dCol = new DataColumn(); 178 //dCol.DataType = Type.GetType("System.Int16"); 179 dCol.DataType = Type.GetType("System.Int32"); //MJL 11/17/2006 160 dCol.DataType = Type.GetType("System.Int32"); 180 161 dCol.ColumnName = "AvailabilityID"; 181 162 dCol.ReadOnly = true; … … 196 177 DateTime dStart; 197 178 DateTime dEnd; 198 // DataRow r; 199 DataRow rNew; 200 179 DataRow rNew; //Temporary Holding place for first or last row 180 181 // Get Last Date from final row 201 182 rNew = rs.Rows[rs.Rows.Count - 1]; 202 183 dLastEnd = (DateTime) rNew["EndTime"]; 184 // Get First Date from first row 203 185 rNew = rs.Rows[0]; 204 186 dStart = (DateTime) rNew["StartTime"]; … … 210 192 // then pad with a new block 211 193 194 // if First Row time is later than the StartTime param (should always be true) 195 // then make a new row whose time starts from StartTime and ends with dStart 212 196 if (dStart > StartTime) 213 197 { … … 222 206 } 223 207 224 //if first block start time is < StartTime then trim 208 //if first block start time is < StartTime then trim (shouldn't happen) 225 209 if (dStart < StartTime) 226 210 { … … 233 217 int nAvailabilityID; 234 218 219 //dStart holds the first date for the availabilities returned from RPMS 235 220 dEnd = dStart; 236 221 foreach (DataRow rEach in rs.Rows) … … 248 233 } 249 234 235 //dEnd now EndTime for AV Block 250 236 dEnd = (DateTime) rEach["EndTime"]; 251 237 252 if (dEnd > EndTime) 253 dEnd = EndTime; 238 // if dEnd is greater than endime, set dEnd to be the same as EndTime. 239 if (dEnd > EndTime) { dEnd = EndTime; } 240 241 254 242 nAppointmentTypeID = (int) rEach["AppointmentTypeID"]; 255 243 nAvailabilityID = (int) rEach["AvailabilityID"]; … … 275 263 rsCopy.Rows.Add(rNew); 276 264 } 277 OutputArray(rsCopy, "CreateAssignedTypeSchedule");265 278 266 return rsCopy; 279 267 } 280 281 public static DataTable CreateAssignedSlotSchedule(CGDocumentManager docManager, string sResourceName, DateTime StartTime, DateTime EndTime, ArrayList rsaryApptTypeIDs, /**/ ScheduleType stType, string sSearchInfo) 282 { 283 284 //Appointment type ids is now always "" so that all appointment types are returned. 268 */ 269 270 /// <summary> 271 /// Gets the Availability Slots from the Server 272 /// </summary> 273 /// <param name="docManager">God Class</param> 274 /// <param name="sResourceName">Resource for which to get slots</param> 275 /// <param name="StartTime"></param> 276 /// <param name="EndTime"></param> 277 /// <param name="rsaryApptTypeIDs">Access Type IDs to retrieve</param> 278 /// <param name="stType">Not used</param> 279 /// <param name="sSearchInfo">If performing a slot search (i.e. for empty appointments), has search info here. Used by Find Appointments</param> 280 /// <returns>DataTable with the following Columns: 281 /// D00030START_TIME^D00030END_TIME^I00010SLOTS^T00030RESOURCE^T00010ACCESS_TYPE^T00250NOTE^I00030AVAILABILITYID 282 /// </returns> 283 public static DataTable CreateAssignedSlotSchedule(CGDocumentManager docManager, string sResourceName, DateTime StartTime, 284 DateTime EndTime, ArrayList rsaryApptTypeIDs, /**/ ScheduleType stType, string sSearchInfo) 285 { 286 //Appointment type ids is now always "" so that all appointment types are returned. 285 287 string sApptTypeIDs = ""; 286 288 287 //The following code block is not used now, but keep for possible later use: 288 //Unpack the Appointment Type IDs 289 /* 290 */ 291 int nSize = rsaryApptTypeIDs.Count; 289 //flatten types by '|' 290 int nSize = rsaryApptTypeIDs.Count; //nSize is used to decide where to put the '|' sent in the RPC as we flatten sApptTypeIDs 292 291 for (int i=0; i < nSize; i++) 293 292 { … … 297 296 } 298 297 299 string sStart; 300 string sEnd; 301 //sStart = StartTime.ToString("M-d-yyyy"); smh 302 sStart = FMDateTime.Create(StartTime).DateOnly.FMDateString; 303 //sEnd = EndTime.ToString("M-d-yyyy@H:mm"); smh 304 sEnd = FMDateTime.Create(EndTime).FMDateString; 298 string sStart = FMDateTime.Create(StartTime).DateOnly.FMDateString; 299 string sEnd = FMDateTime.Create(EndTime).FMDateString; 305 300 string sSql = "BSDX CREATE ASGND SLOT SCHED^" + sResourceName + "^" + sStart + "^" + sEnd + "^" + sApptTypeIDs + "^" + sSearchInfo; //+ "^" + sSTType ; 306 307 301 DataTable dtRet = docManager.RPMSDataTable(sSql, "AssignedSlotSchedule"); 308 302 309 if (sResourceName == "") 310 { 311 return dtRet; 312 } 313 314 return dtRet; 303 return dtRet; 315 304 } 316 305 … … 370 359 } 371 360 361 /// <summary> 362 /// This gets a datatable which shows the appointments between start and end time, one row per appointment 363 /// </summary> 364 /// <param name="docManager"></param> 365 /// <param name="sResourceName"></param> 366 /// <param name="StartTime"></param> 367 /// <param name="EndTime"></param> 368 /// <param name="stType"></param> 369 /// <returns>DataTable with 4 columns: START_TIME, END_TIME, SLOTS, RESOURCE </returns> 372 370 public static DataTable CreateAppointmentSlotSchedule(CGDocumentManager docManager, string sResourceName, DateTime StartTime, DateTime EndTime, ScheduleType stType) 373 371 { 374 375 376 string sStart; 377 string sEnd; 378 //sStart = StartTime.ToString("M-d-yyyy"); 379 sStart = FMDateTime.Create(StartTime).DateOnly.FMDateString; 380 //sEnd = EndTime.ToString("M-d-yyyy"); 381 sEnd = FMDateTime.Create(EndTime).DateOnly.FMDateString; 382 383 string sSTType = (stType == ScheduleType.Resource ? "ST_RESOURCE" : "ST_CLINIC"); 372 //Change Dates to FM Format 373 string sStart = FMDateTime.Create(StartTime).DateOnly.FMDateString; 374 string sEnd = FMDateTime.Create(EndTime).DateOnly.FMDateString; 375 376 string sSTType = (stType == ScheduleType.Resource ? "ST_RESOURCE" : "ST_CLINIC"); 384 377 string sSql = "BSDX APPT BLOCKS OVERLAP^" + sStart + "^" + sEnd + "^" + sResourceName ;//+ "^" + sSTType; 385 378 379 //This gets you a table with 2 columns containing start and end time for each appt 380 //Each appt gets its own row 386 381 DataTable dtRet = docManager.RPMSDataTable(sSql, "AppointmentSlotSchedule"); 387 382 … … 390 385 391 386 //Create CDateTimeArray & load records from rsOut 392 int nRC; 393 nRC = dtRet.Rows.Count; 387 int nRC = dtRet.Rows.Count; // nRC is row count from Appointments table just retrieved 394 388 ArrayList cdtArray = new ArrayList(); 395 cdtArray.Capacity = (nRC * 2); 389 cdtArray.Capacity = (nRC * 2); //new ArrayList has capacity double that of appointment table 396 390 DateTime v; 397 391 int i = 0; 398 392 399 foreach (DataRow r in dtRet.Rows) 393 //for each row in the Appointment Table, ArrayList cdtArray gets 2 entries: Start and End times 394 foreach (DataRow r in dtRet.Rows) 400 395 { 401 396 v = (DateTime) r[dtRet.Columns["START_TIME"]]; … … 404 399 cdtArray.Add(v); 405 400 } 401 402 //Sort start and end times (for use in ScheduleFromArray method) 406 403 cdtArray.Sort(); 407 404 408 405 //Create a CTimeBlockArray and load it from rsOut 409 406 407 //Now, create a new ArrayList with the size of the appointment table to hold availabilities 410 408 ArrayList ctbAppointments = new ArrayList(nRC); 411 409 CGAvailability cTB; 412 410 i = 0; 411 //For each appointment, create an availability 413 412 foreach (DataRow r in dtRet.Rows) 414 413 { … … 421 420 //Create a TimeBlock Array from the data in the DateTime array 422 421 ArrayList ctbApptSchedule = new ArrayList(); 422 423 //Convert Appointments to Availabilities, where all appointments become squeezed together. 423 424 ScheduleFromArray(cdtArray, StartTime, EndTime, ref ctbApptSchedule); 424 425 //Find number of TimeBlocks in ctbApptSchedule that 426 //overlap the TimeBlocks in ctbAppointments 425 426 /*So far, we have the following: 427 * dtRet -> List of Appointments Start and End times, one row per appointment 428 * cdtArray -> Linear 1 dimensional Array of dtRet Start and End times, sorted 429 * ctbAppointments -> Arraylist of dtRet as Availabilities 430 * ctbApptSchedule -> Arraylist of dtRet as Availabilities with no overlapping boundaries 431 * (overlaps in appointments get converted into availabilties themselves: so 432 * 2 appts as 10:10-10:30 and 10:20-10:40 get converted into 10:10-10:20, 433 * 10:20-10:30, 10:30-10:40). 434 */ 435 436 //Find number of TimeBlocks in ctbApptSchedule that overlap the TimeBlocks in ctbAppointments 427 437 ArrayList ctbApptSchedule2 = new ArrayList(); 428 438 CGAvailability cTB2; 429 439 int nSlots = 0; 430 for (i=0; i< ctbApptSchedule.Count; i++) 440 for (i=0; i< ctbApptSchedule.Count; i++) //for each non-overlapping appts as availabilities 431 441 { 432 442 cTB = (CGAvailability) ctbApptSchedule[i]; 433 nSlots = BlocksOverlap(cTB, ctbAppointments); 443 //How many times does the non-overlapping part show up in an appointment slot? 444 nSlots = BlocksOverlap(cTB, ctbAppointments); 434 445 cTB2 = new CGAvailability(); 435 446 cTB2.Create(cTB.StartTime, cTB.EndTime, nSlots); … … 532 543 } 533 544 534 //BOOL CResourceLink::TimesOverlap(COleDateTime dStart1, COleDateTime dEnd1, COleDateTime dStart2, COleDateTime dEnd2) 545 /// <summary> 546 /// Does an appointment overlap with another appointment in the same day? 547 /// </summary> 548 /// <param name="dStart1">Start Time of First Appt</param> 549 /// <param name="dEnd1">End Time of First Appt</param> 550 /// <param name="dStart2">Start Time of Second Appt</param> 551 /// <param name="dEnd2">End Time of Second Appt</param> 552 /// <returns>true or false</returns> 553 /// <remarks>Draws 2 rectangles and sees if they overlap using minutes from 1980 as the start point</remarks> 535 554 public static bool TimesOverlap(DateTime dStart1, DateTime dEnd1, DateTime dStart2, DateTime dEnd2) 536 555 { … … 667 686 Debug.Assert(rs1 != null); 668 687 Debug.Assert(rs2 != null); 669 CGSchedLib.OutputArray(rs1, "UnionBlocks rs1");670 CGSchedLib.OutputArray(rs2, "UnionBlocks rs2");671 688 672 689 DataTable rsCopy; … … 798 815 } 799 816 800 public static void ScheduleFromArray(ArrayList cdtArray, DateTime dStartTime, DateTime dEndTime, ref ArrayList rTBArray) 817 /// <summary> 818 /// Converts an Array of Times like this: 819 /// 10:00 10:00 10:20 10:20 10:30 10:30 10:30 10:40 820 /// To an array of availabilities like this: 821 /// 12:00-10:00 10:00-10:20 10:20-10:30 10:30-10:40 822 /// Where the 12:00 comes from the start time 823 /// </summary> 824 /// <param name="cdtArray">ArrayList containing start and end times of Appointments combmined and sorted</param> 825 /// <param name="dStartTime">Start Time for Schedule</param> 826 /// <param name="dEndTime">End Time for Schedule</param> 827 /// <param name="rTBArray">Output of Availabilities: Pass Empty</param> 828 public static void ScheduleFromArray(ArrayList cdtArray, DateTime dStartTime, DateTime dEndTime, 829 ref ArrayList rTBArray) 801 830 { 802 831 int j = 0; … … 812 841 if (dStartTime.Ticks > 0) 813 842 { 814 if ((DateTime) cdtArray[0] > dStartTime) 843 // if first Array Entry greater than start time, then create an availability 844 // with the start time as dStartTime, and end time as the first array entry, and 0 slots 845 // then add this to the output array 846 if ((DateTime) cdtArray[0] > dStartTime) 815 847 { 816 848 cTB = new CGAvailability(); … … 818 850 rTBArray.Add(cTB); 819 851 } 852 853 // if first Array Entry less than start time (shouldn't happen), 854 // convert all input array's times less than the start time to all be the start time 820 855 if ((DateTime) cdtArray[0] < dStartTime) 821 856 { … … 829 864 830 865 //Trim the end if necessary 866 //If end time is passed, set all the times in the original array greater 867 //than the end time to be the end time (Shouldn't happen). 831 868 if (dEndTime.Ticks > 0) 832 869 { … … 839 876 840 877 //build the schedule in rTBArray 841 DateTime dTemp = new DateTime(); 878 DateTime dTemp = new DateTime(); //hold previous appt time. 842 879 DateTime dStart; 843 880 DateTime dEnd; 844 881 int k = 0; 845 for (j = 0; j < (cdtArray.Count -1); j++) //TODO: why minus 1? 882 //for each time in appointment array 883 for (j = 0; j < (cdtArray.Count -1); j++) // -1 b/c k below starts with j+1. 846 884 { 847 885 if ((DateTime) cdtArray[j] != dTemp) … … 849 887 dStart =(DateTime) cdtArray[j]; 850 888 dTemp = dStart; 889 890 //for each time in appointment array, starting with the next one 851 891 for (k = j+1; k < cdtArray.Count; k++) 852 892 { 853 893 dEnd = new DateTime(); 854 if ((DateTime) cdtArray[k] != dStart) 894 if ((DateTime) cdtArray[k] != dStart) //if the next time isn't the same 855 895 { 856 dEnd = (DateTime) cdtArray[k]; 896 dEnd = (DateTime) cdtArray[k]; // set the end to be the next time 857 897 } 858 if (dEnd.Ticks > 0) 898 if (dEnd.Ticks > 0) //make a new availability and add it to the output array. 859 899 { 860 900 cTB = new CGAvailability(); … … 863 903 break; 864 904 } 905 // if the end time is still empty, loop 865 906 } 866 907 } -
Scheduling/trunk/cs/bsdx0200GUISourceCode/CGView.cs
r1084 r1095 2329 2329 private void OnUpdateScheduleCallback(IAsyncResult itfAR) 2330 2330 { 2331 // if the view meanwhile closed, just return2332 if (this == null) return;2333 2334 2331 OnUpdateScheduleDelegate d = new OnUpdateScheduleDelegate(UpdateArrays); 2335 this.Invoke(d); 2332 2333 //try catch just in case that the view closed in the meantime. 2334 try 2335 { 2336 this.Invoke(d); 2337 } 2338 catch (InvalidOperationException) 2339 { 2340 return; 2341 } 2336 2342 } 2337 2343 -
Scheduling/trunk/cs/bsdx0200GUISourceCode/CalendarGrid.cs
r1083 r1095 799 799 foreach (CGAvailability availability in this.m_pAvArray) 800 800 { 801 if ( this.TimesOverlap(availability.StartTime, availability.EndTime, timeFromCell, time2))801 if (TimesOverlap(availability.StartTime, availability.EndTime, timeFromCell, time2)) 802 802 { 803 803 nAccessTypeID = availability.AvailabilityType; … … 842 842 foreach (CGAvailability availability in this.m_pAvArray) 843 843 { 844 if ( this.TimesOverlap(availability.StartTime, availability.EndTime, timeFromCell, time2))844 if (TimesOverlap(availability.StartTime, availability.EndTime, timeFromCell, time2)) 845 845 { 846 846 nAccessTypeID = availability.AvailabilityType; … … 894 894 } 895 895 896 private int MinSince80(DateTime d)896 private static int MinSince80(DateTime d) 897 897 { 898 898 DateTime time = new DateTime(1980, 1, 1, 0, 0, 0); … … 1153 1153 } 1154 1154 1155 private bool TimesOverlap(DateTime dStart1, DateTime dEnd1, DateTime dStart2, DateTime dEnd2) 1155 /// <summary> 1156 /// Do 2 time ranges overlap each other? 1157 /// </summary> 1158 /// <param name="dStart1">First Start Time</param> 1159 /// <param name="dEnd1">First End Time</param> 1160 /// <param name="dStart2">Second Start Time</param> 1161 /// <param name="dEnd2">Second End Time</param> 1162 /// <returns>True or False</returns> 1163 public static bool TimesOverlap(DateTime dStart1, DateTime dEnd1, DateTime dStart2, DateTime dEnd2) 1156 1164 { 1157 1165 long ticks = dEnd1.Ticks - dStart1.Ticks; … … 1165 1173 rect.Width = 1; 1166 1174 rectangle2.Width = 1; 1167 rect.Y = this.MinSince80(dStart1);1168 rect.Height = this.MinSince80(dEnd1) - rect.Y;1169 rectangle2.Y = this.MinSince80(dStart2);1170 rectangle2.Height = this.MinSince80(dEnd2) - rectangle2.Y;1175 rect.Y = MinSince80(dStart1); 1176 rect.Height = MinSince80(dEnd1) - rect.Y; 1177 rectangle2.Y = MinSince80(dStart2); 1178 rectangle2.Height = MinSince80(dEnd2) - rectangle2.Y; 1171 1179 return rectangle2.IntersectsWith(rect); 1172 1180 } -
Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj.user
r1071 r1095 37 37 </RemoteDebugMachine> 38 38 <StartAction>Project</StartAction> 39 <StartArguments>/s=1 72.16.16.108 /p=9250 /a=abeer12 /v=abc,4321</StartArguments>39 <StartArguments>/s=192.168.56.101 /p=9260 /a=shabiel12 /v=catdog.77</StartArguments> 40 40 <StartPage> 41 41 </StartPage> -
Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.sln
r1084 r1095 11 11 EndGlobalSection 12 12 GlobalSection(ProjectConfigurationPlatforms) = postSolution 13 {8C05C4F7-FE81-479F-87A0-44E04C7F6E0F}.Debug|Any CPU.ActiveCfg = Release|Any CPU14 {8C05C4F7-FE81-479F-87A0-44E04C7F6E0F}.Debug|Any CPU.Build.0 = Release|Any CPU13 {8C05C4F7-FE81-479F-87A0-44E04C7F6E0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 14 {8C05C4F7-FE81-479F-87A0-44E04C7F6E0F}.Debug|Any CPU.Build.0 = Debug|Any CPU 15 15 {8C05C4F7-FE81-479F-87A0-44E04C7F6E0F}.Release|Any CPU.ActiveCfg = Release|Any CPU 16 16 {8C05C4F7-FE81-479F-87A0-44E04C7F6E0F}.Release|Any CPU.Build.0 = Release|Any CPU 17 {DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}.Debug|Any CPU.ActiveCfg = Release|Any CPU18 {DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}.Debug|Any CPU.Build.0 = Release|Any CPU17 {DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 18 {DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}.Debug|Any CPU.Build.0 = Debug|Any CPU 19 19 {DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}.Release|Any CPU.ActiveCfg = Release|Any CPU 20 20 {DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}.Release|Any CPU.Build.0 = Release|Any CPU -
Scheduling/trunk/cs/bsdx0200GUISourceCode/DApptSearch.cs
r908 r1095 97 97 //Build AccessGroup table containing *active* AccessTypes and their Groups 98 98 m_dtTypes = m_dsGlobal.Tables["AccessGroupType"]; 99 CGSchedLib.OutputArray(m_dtTypes, "Access Group Type");100 99 //Create a view that is filterable on Access Group 101 100 m_dvTypes = new DataView(m_dtTypes); … … 657 656 int nAccessTypeID; 658 657 string sAccessType; 659 CGSchedLib.OutputArray(m_dtResult, "Result Grid"); 658 660 659 foreach (DataRow dr in m_dtResult.Rows) 661 660 { … … 674 673 } 675 674 } 676 CGSchedLib.OutputArray(m_dtResult, "Result Grid"); 675 677 676 678 677 m_dvResult = new DataView(m_dtResult);
Note:
See TracChangeset
for help on using the changeset viewer.