public Occurrence(Appointment appointment, Appointment masterAppointment, OccurrenceType occurrenceType, Interval interval) { Appointment = appointment; MasterAppointment = masterAppointment; OccurrenceType = occurrenceType; Interval = interval; }
public LinkedTypesOccurrence( [NotNull] IDeclaredElement element, OccurrenceType occurrenceKind, bool hasNameDerived) : base(element, occurrenceKind) { HasNameDerived = hasNameDerived; }
public static OccurrenceType CreateOccurrenceType() { OccurrenceType occurrenceType = new OccurrenceType { TypeName = "Test Occurrence Type", IsService = true, GenderPreference = GenderPreference.Everyone }; return(occurrenceType); }
private void BindOccurrenceTypes() { occurrence = new Occurrence( occurrenceID ); OccurrenceType type = new OccurrenceType( occurrence.OccurrenceTypeID ); OccurrenceTypeCollection types = new OccurrenceTypeCollection( type.GroupId ); ddlOccurrenceTypes.DataSource = types; ddlOccurrenceTypes.DataBind(); ddlOccurrenceTypes.Items.Insert (0, new ListItem("- select -", "-1" ) ); if ( Session[ SESS_LASTOCCTYPE ] != null ) { int occurrenceTypeID = int.Parse( (string) Session[ SESS_LASTOCCTYPE ] ); ddlOccurrenceTypes.SelectedValue = occurrenceTypeID.ToString(); BindOccurrencesByType( occurrenceTypeID ); } }
public void ddlFilterService_Changed(object sender, EventArgs e) { OccurrenceTypeCollection otc; OccurrenceCollection oc; ArrayList locations = new ArrayList(), occurrences = new ArrayList(), types = new ArrayList(); DateTime selectedServiceTime; int idNumber; bool searchAvailable = true; // // Get the list of occurrence types from the selected group. // try { otc = new OccurrenceTypeCollection(Convert.ToInt32(ddlFilterTypeGroup.SelectedValue)); } catch { otc = new OccurrenceTypeCollection(); } // // Get the current selected service time. // try { selectedServiceTime = DateTime.Parse(ddlFilterService.SelectedValue); } catch { selectedServiceTime = DateTime.MinValue; } foreach (OccurrenceType ot in otc) { oc = new OccurrenceCollection(ot.OccurrenceTypeId); foreach (Occurrence o in oc) { if (o.StartTime.Equals(selectedServiceTime) == true) { occurrences.Add(o); if (locations.Contains(o.LocationID) == false) { locations.Add(o.LocationID); } if (types.Contains(o.OccurrenceTypeID) == false) { types.Add(o.OccurrenceTypeID); } } } } // // Setup the basic attendance type list. // ddlFilterType.Items.Clear(); ddlFilterType.Items.Add(new ListItem("Show All", "-1")); ddlFilterType.SelectedIndex = 0; ddlFilterType.Enabled = true; // // Setup the basic occurrence list. // ddlFilterOccurrence.Items.Clear(); ddlFilterOccurrence.Items.Add(new ListItem("Show All", "-1")); ddlFilterOccurrence.SelectedIndex = 0; ddlFilterOccurrence.Enabled = true; // // Setup the basic room list. // ddlFilterLocation.Items.Clear(); ddlFilterLocation.Items.Add(new ListItem("Show All", "-1")); ddlFilterLocation.SelectedIndex = 0; ddlFilterLocation.Enabled = true; // // Add in all valid types. // foreach (int typeID in types) { OccurrenceType ot = new OccurrenceType(typeID); ddlFilterType.Items.Add(new ListItem(ot.TypeName, ot.OccurrenceTypeId.ToString())); if (!IsPostBack && this.Request.Params["typeID"] != null) { if (typeID == Convert.ToInt32(this.Request.Params["typeID"])) { ddlFilterType.SelectedIndex = (ddlFilterType.Items.Count - 1); ddlFilterType_Changed(null, null); searchAvailable = false; } } } // // Add in all valid choices. // foreach (Occurrence o in occurrences) { OccurrenceType ot = new OccurrenceType(o.OccurrenceTypeID); Location l = new Location(o.LocationID); ddlFilterOccurrence.Items.Add(new ListItem(String.Format("{0} / {1} / {2}", o.Name, ot.TypeName, l.LocationName), o.OccurrenceID.ToString())); if (searchAvailable && !IsPostBack && Request.Params["occurrenceID"] != null) { idNumber = Convert.ToInt32(Request.Params["occurrenceID"]); if (idNumber == o.OccurrenceID) { ddlFilterOccurrence.SelectedIndex = (ddlFilterOccurrence.Items.Count - 1); ddlFilterOccurrence_Changed(null, null); searchAvailable = false; } } } // // Add all valid locations. // foreach (int locationID in locations) { Location l = new Location(locationID); ddlFilterLocation.Items.Add(new ListItem(String.Format("{0} - {1}", l.BuildingName, l.LocationName), l.LocationId.ToString())); if (searchAvailable && !IsPostBack && Request.Params["locationID"] != null) { idNumber = Convert.ToInt32(Request.Params["locationID"]); if (locationID == idNumber) { ddlFilterLocation.SelectedIndex = (ddlFilterLocation.Items.Count - 1); ddlFilterLocation_Changed(null, null); searchAvailable = false; } } } dgAttendance_ReBind(null, null); }
public UnityEditorOccurrence([NotNull] IUnityYamlReference unityEventTargetReference, IDeclaredElement element, OccurrenceType occurrenceType) : base(unityEventTargetReference, element, occurrenceType) { myUnityEventTargetReference = unityEventTargetReference; }
/// <summary> /// User is ready to create a new service based on their selection. Do /// some basic error checking before creating anything. /// </summary> protected void btnCreate_Click(object sender, EventArgs e) { Dictionary <Location, List <OccurrenceType> > occurrenceData = new Dictionary <Location, List <OccurrenceType> >(); JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary <String, Object> data = (Dictionary <String, Object>)serializer.DeserializeObject(jsonData.Value); List <Int32> occurrenceIDs = new List <int>(); DateTime startDateTime = DateTime.Parse(tbStartDate.Text + " " + tbStartTime.Text); DateTime endDateTime = DateTime.Parse(tbEndDate.Text + " " + tbEndTime.Text); DateTime checkinStart = DateTime.Parse(tbCheckInStartDate.Text + " " + tbCheckInStartTime.Text); DateTime checkinEnd = DateTime.Parse(tbCheckInEndDate.Text + " " + tbCheckInEndTime.Text); // // Reset any status information. // lbErrors.Text = ""; lbStatus.Text = ""; // // Check if they have entered a service name. // if (String.IsNullOrEmpty(tbName.Text)) { lbErrors.Text += "Name is a required field and must be supplied.<br />"; } // // Check if they are trying to end before they start. // if (endDateTime <= startDateTime) { lbErrors.Text += "End-time for service cannot be before start-time.<br />"; } if (checkinEnd <= checkinStart) { lbErrors.Text += "End-time for check-in cannot be before start-time.<br />"; } // // Check if they checked the "Use For All" box but did not select // a profile. // if (cbUseForAll.Checked == true && ppProfile.ProfileID == -1) { lbErrors.Text += "You must select a tag if you wish to force all occurrences into that Tag.<br />"; } // // Check if they have designed a service or not. // if (data.Keys.Count == 0) { lbErrors.Text += "No rooms have been assigned.<br />"; } // // Walk each room and create a list of the attendance types that should // be created for the room. // foreach (String r in data.Keys) { Location location = new Location(Convert.ToInt32(r.Substring(11))); Dictionary <String, Object> room = (Dictionary <String, Object>)data[r]; Object[] ats = (Object[])room["ats"]; // // Check for empty room. // if (ats.Length == 0) { lbErrors.Text += "Location " + location.FullName + " is being used but no attendance types associated.<br />"; } occurrenceData.Add(location, new List <OccurrenceType>()); // // Walk each attendance type in this room and store the information // needed to create a new attendance type. // foreach (Dictionary <String, Object> at in ats) { OccurrenceType ot = new OccurrenceType(Convert.ToInt32(at["id"].ToString().Substring(3))); Location loc = null; // // Make sure the location is valid for this occurrence type. // foreach (Location l in ot.Locations) { if (l.LocationId == location.LocationId) { loc = l; break; } } if (loc == null) { lbErrors.Text += "Attendance type " + ot.TypeName + " is not valid for location " + location.FullName + "<br />"; continue; } // // Make sure there is a place will will link the occurrence to. // if (ot.SyncWithProfile == -1 && ot.SyncWithGroup == -1 && ppProfile.ProfileID == -1) { lbErrors.Text += "Attendance type " + ot.TypeName + " is not linked to a tag or group and no <i>Link To Tag</i> option has been specified.<br />"; continue; } occurrenceData[location].Add(ot); } } // // Check if there were errors, if so abort. // if (lbErrors.Text != "") { return; } // // Generate each occurrence. // try { foreach (Location loc in occurrenceData.Keys) { foreach (OccurrenceType ot in occurrenceData[loc]) { occurrenceIDs.Add(CreateOccurrence(ot, ppProfile.ProfileID, cbUseForAll.Checked, tbName.Text, loc, DateTime.Parse(tbStartDate.Text + " " + tbStartTime.Text), DateTime.Parse(tbEndDate.Text + " " + tbEndTime.Text), DateTime.Parse(tbCheckInStartDate.Text + " " + tbCheckInStartTime.Text), DateTime.Parse(tbCheckInEndDate.Text + " " + tbCheckInEndTime.Text), cbMembershipRequired.Checked)); } } } catch (System.Exception ex) { // // If something goes bad, try to delete all the occurrences we just created. // foreach (Int32 id in occurrenceIDs) { try { Occurrence oc = new Occurrence(id); oc.Delete(); } catch { } } throw ex; } // // Everything successful. // jsonData.Value = "{}"; lbStatus.Text = "Generated " + occurrenceIDs.Count.ToString() + " occurrences."; }
/// <summary> /// Generate a new occurrence in the database from the values given /// in the parameters. /// </summary> /// <param name="type">The OccurrenceType to use for this occurrence.</param> /// <param name="profileID">The profile to associate the occurrence with if it is not already linked in the occurrence type.</param> /// <param name="forceProfile">Force the occurrence to be associated with the profileID given.</param> /// <param name="name">The name of the occurrence.</param> /// <param name="location">The Location object to use for check-in.</param> /// <param name="startTime">The time the occurrence should start.</param> /// <param name="endTime">The time the occurrence should end.</param> /// <param name="checkinStart">The time that check-in should start.</param> /// <param name="checkinEnd">The time that check-in should end.</param> /// <param name="membershipRequired">If the membership required flag on the occurrence should be set.</param> /// <returns>The ID number of the new occurrence that was generated.</returns> private Int32 CreateOccurrence(OccurrenceType type, int profileID, Boolean forceProfile, String name, Location location, DateTime startTime, DateTime endTime, DateTime checkinStart, DateTime checkinEnd, Boolean membershipRequired) { Occurrence occurrence = null; // // Allow the occurrence to override if forceProfile is not true. // if (forceProfile == false) { if (type.SyncWithProfile != -1) { profileID = type.SyncWithProfile; } if (type.SyncWithGroup != -1) { profileID = -1; } } // // Create the appropriate type of occurrence object. // if (profileID != -1) { ProfileOccurrence pOccurrence = new ProfileOccurrence(); pOccurrence.ProfileID = profileID; occurrence = pOccurrence; } else if (type.SyncWithGroup != -1) { GroupOccurrence gOccurrence = new GroupOccurrence(); gOccurrence.GroupID = type.SyncWithGroup; occurrence = gOccurrence; } else { throw new ArgumentException("Occurrences must be tied to either a tag or group."); } // // Set all the common information. // occurrence.OccurrenceID = -1; occurrence.OccurrenceType = type; occurrence.Name = name; occurrence.Location = location.FullName; occurrence.LocationID = location.LocationId; occurrence.Description = ""; occurrence.StartTime = startTime; occurrence.EndTime = endTime; occurrence.CheckInStart = checkinStart; occurrence.CheckInEnd = checkinEnd; occurrence.MembershipRequired = membershipRequired; // // Save the new occurrence. // occurrence.Save(CurrentUser.Identity.Name); return(occurrence.OccurrenceID); }
public LinkedTypesOccurrence([NotNull] IDeclaredElement element, OccurrenceType occurrenceKind) : base(element, occurrenceKind) { }
/// <summary> /// This method retrieves a list of diplay items from the device server. /// </summary> /// <param name="eDisplayType">The type of display items to retrieve.</param> /// <param name="iDisplayCount">The number of display items to retrieve.</param> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ --------------------------------------------- // 10/10/08 jrf 9.50 Created. // private void GetDisplayItems(DisplayType eDisplayType, int iDisplayCount) { object objQuantity = null; object objOccurenceType = null; object objPeakNum = null; object objTimeOfOccurence = null; object objIDCode = null; object objValue = null; OccurrenceType eOccurenceType = OccurrenceType.Current; DisplayItemSettings ItemSettings; DisplayScale QuantityScale = DisplayScale.Units; string strValue = null; short sMaxStringLength = 80; short sResponse = DEVICE_SERVER_SUCCESS; short sDisplayProgress = 0; short sPeakNumber = 0; short sIDCode = 0; int iQuantity = 0; int iOccurenceType = 0; int iIndex = 0; Collection <DisplayItemSettings> colDisplayItemSettings = null; switch (eDisplayType) { case DisplayType.Normal: { colDisplayItemSettings = m_DisplaySchedule.NormalDisplay; break; } case DisplayType.Alternate: { colDisplayItemSettings = m_DisplaySchedule.AlternateDisplay; break; } default: { colDisplayItemSettings = m_DisplaySchedule.TestDisplay; break; } } //Find each display item's settings. for (int i = 1; i <= iDisplayCount; i++) { sResponse = VirtualDevice.GetDisplayItem((short)eDisplayType, (short)i, ref objQuantity, ref objOccurenceType, ref objValue, ref strValue, sMaxStringLength, ref objPeakNum, ref objTimeOfOccurence, ref objIDCode, sDisplayProgress); if (DEVICE_SERVER_SUCCESS == sResponse && null != objQuantity && null != objOccurenceType && null != objValue && null != strValue && null != objPeakNum && null != objTimeOfOccurence && null != objIDCode) { iQuantity = (int)Convert.ChangeType(objQuantity, typeof(int), CultureInfo.InvariantCulture); iOccurenceType = (int)Convert.ChangeType(objOccurenceType, typeof(int), CultureInfo.InvariantCulture); eOccurenceType = (OccurrenceType)iOccurenceType; sPeakNumber = (short)Convert.ChangeType(objPeakNum, typeof(short), CultureInfo.InvariantCulture); sIDCode = (short)Convert.ChangeType(objIDCode, typeof(short), CultureInfo.InvariantCulture); //Extract the scale from the quantity code. QuantityCode Quantity = QuantityCode.Create((uint)iQuantity); ElectricalQuantityCode ElectricalQuantity = Quantity as ElectricalQuantityCode; if (null != ElectricalQuantity) { if (ElectricalQuantityCode.ElectricalScale.Kilo == ElectricalQuantity.Scale) { QuantityScale = DisplayScale.Kilo; } //Now that we have the scale store the quantity in it's units value for the display schedule. ElectricalQuantity.Scale = ElectricalQuantityCode.ElectricalScale.Units; iQuantity = (int)ElectricalQuantity.Code; } ItemSettings = new DisplayItemSettings((uint)iQuantity, eOccurenceType); ItemSettings.DisplayOrder = (uint)i; ItemSettings.IDCode = (uint)sIDCode; ItemSettings.PeakNumber = (uint)sPeakNumber; if (null != ElectricalQuantity && ElectricalQuantity.IsEnergyQuantity) { iIndex = ENERGY; } else if (null != ElectricalQuantity && ElectricalQuantity.IsDemandQuantity && false == ElectricalQuantity.IsCumulativeQuantity) { iIndex = DEMAND; } else if (null != ElectricalQuantity && ElectricalQuantity.IsCumulativeQuantity) { iIndex = CUMULATIVE; } ItemSettings.LeadingZeroesDisplayed = m_ablnDisplayLeadingZeroes[iIndex]; ItemSettings.FloatingDecimalEnabled = m_ablnDisplayFloatingDecimal[iIndex]; ItemSettings.DigitCount = (uint)m_aiDisplayDigitCount[iIndex]; ItemSettings.DecimalDigitCount = (uint)m_aiDisplayDecimalDigitCount[iIndex]; //Only set the following values if we have an //energy or demand quantity if (null != ElectricalQuantity) { //Only set the scale if we have an electrical quantity. ItemSettings.Scale = QuantityScale; if (strValue.Contains("-")) { //Since we have a date reset the scale and set the date. //Scale and date are stored in the same location in the //display schedule. Resetting this value allows us to //know which one to use. ItemSettings.TOODateDisplayed = true; ItemSettings.Scale = DisplayScale.Units; ItemSettings.DateDisplay = m_eDisplayDateFormat; } if (strValue.Contains(":")) { ItemSettings.TOOTimeDisplayed = true; } ItemSettings.AnnunciatorEnabled = m_blnDisplayAnnunciatorEnabled; } else { //Only set the date if we don't have an electrical quantity ItemSettings.DateDisplay = m_eDisplayDateFormat; } colDisplayItemSettings.Add(ItemSettings); } } }