00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 using System;
00013 using System.Collections;
00014 using System.Collections.Generic;
00015 using Mcs.Epm.MicrosoftProject.mpFx.CalendarsWebService;
00016
00017 namespace Mcs.Epm.MicrosoftProject.mpFx
00018 {
00019
00020
00021
00022 public class Calendars : IEnumerable<Guid>
00023 {
00024 #region Instance Data
00025
00026 private Dictionary<Guid, string> _CalendarsCollection;
00027
00028 #endregion
00029
00030 #region Constructor
00031
00032
00033
00034
00035
00036 public Calendars(ProjectServer parent)
00037 {
00038 if (parent == null)
00039 {
00040 throw new ArgumentNullException("parent");
00041 }
00042
00043 Parent = parent;
00044 }
00045
00046 #endregion
00047
00048 #region Protected Properties
00049
00050 protected internal ProjectServer Parent { get; private set; }
00051
00052 #endregion
00053
00054 #region Public Properties
00055
00056
00057
00058
00059 public Dictionary<Guid, string> CalendarsCollection
00060 {
00061 get
00062 {
00063 if (_CalendarsCollection == null)
00064 {
00065 LoadCalendars();
00066 }
00067
00068 return _CalendarsCollection;
00069 }
00070 set
00071 {
00072 _CalendarsCollection = value;
00073 }
00074 }
00075
00076 #endregion
00077
00078 #region Public Methods
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 public IEnumerator<Guid> GetEnumerator()
00089 {
00090 if (_CalendarsCollection == null)
00091 {
00092 LoadCalendars();
00093 }
00094
00095 foreach (KeyValuePair<Guid, string> valuePair in CalendarsCollection)
00096 {
00097 yield return valuePair.Key;
00098 }
00099 }
00100
00101 #endregion
00102
00103 #region Private Methods
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 IEnumerator IEnumerable.GetEnumerator()
00114 {
00115 return ((IEnumerable<Guid>) this).GetEnumerator();
00116 }
00117
00118 #endregion
00119
00120 #region Internal Methods
00121
00122
00123
00124
00125 internal void LoadCalendars()
00126 {
00127 if (_CalendarsCollection == null)
00128 {
00129 _CalendarsCollection = new Dictionary<Guid, string>();
00130 }
00131 else
00132 {
00133 _CalendarsCollection.Clear();
00134 }
00135
00136 using (CalendarDataSet calendarDataSet = Parent.WebServices.Calendars.ListCalendars())
00137 {
00138 foreach (CalendarDataSet.CalendarsRow calendars in calendarDataSet.Calendars.Rows)
00139 {
00140 _CalendarsCollection.Add(calendars.CAL_UID, calendars.CAL_NAME);
00141 }
00142 }
00143 }
00144
00145 #endregion
00146 }
00147 }
00148 c