public CustomPropertyCells(string value, CustomPropertyType type) { var type_int = CustomPropertyTypeToInt(type); this.Value = value; this.Type = type_int; }
protected void UpdateBlacklist(bool fForceDB = false) { rptUsedProps.DataSource = Array.FindAll(CustomPropertyType.GetCustomPropertyTypes(Page.User.Identity.Name, fForceDB), cpt => cpt.IsFavorite); rptUsedProps.DataBind(); rptBlackList.DataSource = CustomPropertyType.GetCustomPropertyTypes(m_pf.BlacklistedProperties); rptBlackList.DataBind(); }
public PropertyData(string name, CustomPropertyType type, ValueObject value, int listID) { this.name = name; this.type = type; this.value = value; this.listID = listID; }
/// <summary> /// /// </summary> public void Edit() { IDataElement dataElement = Object as IDataElement; IDataItem dataItem = dataElement.Data as IDataItem; string currentString = null; if (dataItem != null) { currentString = dataItem.Value.ToString(); SelectCustomParameterValueForm form = new SelectCustomParameterValueForm(); form.CustomPropertyType = m_type; form.Value = currentString; if (DialogResult.OK == form.ShowDialog()) { //data m_type = form.CustomPropertyType; dataItem = DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.String, form.Value); dataElement.Data = dataItem; //display name dataElement.DisplayName.Value = GetDisplayNameFromDataItems(); Text = GetDisplayNameFromDataItems(); } } }
/// <summary> /// Recreates the combobox and propedit controls so that they exist for postback events. /// </summary> protected void RecreateControls() { if (plcHolderProps.Controls.Count > 0) // don't do this if we've already set them up. { return; } List <CustomPropertyType> lstAll = new List <CustomPropertyType>(CustomPropertyType.GetCustomPropertyTypes()); foreach (int idPropType in ActivePropTypes) { CustomPropertyType cpt = lstAll.Find(c => c.PropTypeID == idPropType); CustomFlightProperty cfp = new CustomFlightProperty(cpt); if (ExistingPropIDs.ContainsKey(idPropType)) { cfp.PropID = ExistingPropIDs[idPropType]; } InsertEditProp(cfp); lstAll.Remove(cpt); // since it's here, make sure it isn't in the list of available types; we'll bind this below. } // recreate combo box - huge viewstate, so we just recreate it each time. // This loses the selected value, so we have to grab that directly from the form. cmbPropsToAdd.DataSource = lstAll; cmbPropsToAdd.DataBind(); if (IsPostBack) { cmbPropsToAdd.SelectedValue = Request.Form[cmbPropsToAdd.UniqueID]; } }
public CustomPropertyCells(CellValueLiteral value, CustomPropertyType type) { var type_int = CustomPropertyTypeToInt(type); this.Value = value; this.Type = type_int; }
private void ComputeTotalsForCustomProperties(MySqlCommand comm, Profile pf) { try { using (MySqlDataReader dr = comm.ExecuteReader()) { while (dr.Read()) { CustomPropertyType cpt = new CustomPropertyType(dr); List <CustomPropertyType> lstCpt = new List <CustomPropertyType>(Restriction.PropertyTypes); if (!lstCpt.Exists(c => c.PropTypeID == cpt.PropTypeID)) { lstCpt.Add(cpt); } FlightQuery fq = new FlightQuery(Restriction) { PropertyTypes = lstCpt.ToArray() }; switch (cpt.Type) { case CFPPropertyType.cfpDecimal: if (cpt.IsBasicDecimal) { AddToList(new TotalsItem(cpt.Title, Convert.ToDecimal(dr["decTotal"], CultureInfo.InvariantCulture), TotalsItem.NumType.Decimal) { Query = fq }); } else { AddToList(new TotalsItem(cpt.Title, Convert.ToDecimal(dr["timeTotal"], CultureInfo.InvariantCulture), TotalsItem.NumType.Time) { Query = fq }); } break; case CFPPropertyType.cfpCurrency: AddToList(new TotalsItem(cpt.Title, Convert.ToDecimal(dr["decTotal"], CultureInfo.InvariantCulture), TotalsItem.NumType.Currency) { Query = fq }); break; default: case CFPPropertyType.cfpInteger: AddToList(new TotalsItem(cpt.Title, Convert.ToInt32(dr["intTotal"], CultureInfo.InvariantCulture)) { Query = fq }); break; } } } } catch (MySqlException ex) { throw new MyFlightbookException(String.Format(CultureInfo.InvariantCulture, "Exception in UserTotals Data Bind while reading custom property totals: {0}", comm.CommandText), ex, pf.UserName); } }
public void RemoveProperty(CustomPropertyType cpt) { if (cpt == null) { throw new ArgumentNullException(nameof(cpt)); } m_propertyTypes.Remove(cpt.PropTypeID); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { gvProps.DataSource = CustomPropertyType.GetCustomPropertyTypes(Page.User.Identity.IsAuthenticated ? Page.User.Identity.Name : null); gvProps.DataBind(); } }
private bool fHasBeenSetUp = false; // have we already been initialized for the user? protected void SetUpForUser() { if (fHasBeenSetUp) { return; } if (String.IsNullOrEmpty(Username)) { Username = Page.User.Identity.Name; } UserAircraft ua = new UserAircraft(Username); Aircraft[] rgac = ua.GetAircraftForUser(); Aircraft[] rgacActive = Array.FindAll(rgac, aircraft => !aircraft.HideFromSelection); // Hide inactive aircraft unless // (a) all aircraft are active, or // (b) the current query references inactive aircraft // (c) pnlshowAllAircraft is invisible (indicating that it has been clicked) bool fShowAll = !pnlShowAllAircraft.Visible || rgacActive.Length == rgac.Length || Array.Exists(Restriction.AircraftList, ac => ac.HideFromSelection); if (fShowAll) { pnlShowAllAircraft.Visible = false; } cklAircraft.DataSource = fShowAll ? rgac : rgacActive; cklAircraft.DataBind(); cklMakes.DataSource = MakeModel.ModelsForAircraft(rgac); cklMakes.DataBind(); cklCatClass.DataSource = CategoryClass.CategoryClasses(); cklCatClass.DataBind(); CustomPropertyType[] rgCpt = CustomPropertyType.GetCustomPropertyTypes(Username); List <CustomPropertyType> al = new List <CustomPropertyType>(); foreach (CustomPropertyType cpt in rgCpt) { if (cpt.IsFavorite) { al.Add(cpt); } } if (al.Count == 0) { pnlCustomProps.Visible = CustomPropsHeader.Visible = false; } else { cklCustomProps.DataSource = al; cklCustomProps.DataBind(); } fHasBeenSetUp = true; }
protected void ToForm() { CustomCurrency cc = Currency; hdnCCId.Value = cc.ID.ToString(CultureInfo.InvariantCulture); txtRuleName.Text = cc.DisplayName; cmbLimitType.SelectedValue = cc.CurrencyLimitType.ToString(); if (cc.EventType.IsIntegerOnly()) { decMinEvents.EditingMode = Controls_mfbDecimalEdit.EditMode.Integer; decMinEvents.IntValue = (int)cc.RequiredEvents; } else { decMinEvents.EditingMode = Controls_mfbDecimalEdit.EditMode.Decimal; decMinEvents.Value = cc.RequiredEvents; } cmbEventTypes.SelectedValue = ((int)cc.EventType).ToString(CultureInfo.InvariantCulture); SelectedTimespanType = cc.TimespanType; txtTimeFrame.Text = cc.TimespanType.IsAligned() ? string.Empty : cc.ExpirationSpan.ToString(CultureInfo.InvariantCulture); foreach (ListItem li in lstModels.Items) { li.Selected = cc.ModelsRestriction.Contains(Convert.ToInt32(li.Value, CultureInfo.InvariantCulture)); } foreach (ListItem li in lstAircraft.Items) { li.Selected = cc.AircraftRestriction.Contains(Convert.ToInt32(li.Value, CultureInfo.InvariantCulture)); } cmbCategory.SelectedValue = cc.CategoryRestriction; cmbCatClass.SelectedValue = cc.CatClassRestriction.ToString(); txtAirport.Text = cc.AirportRestriction; txtContainedText.Text = cc.TextRestriction; if (cc.PropertyRestriction != null) { HashSet <int> hsPropsChecked = new HashSet <int>(cc.PropertyRestriction); foreach (ListItem li in lstProps.Items) { int propID = Convert.ToInt32(li.Value, CultureInfo.InvariantCulture); li.Selected = cc.PropertyRestriction.Contains(propID); hsPropsChecked.Remove(propID); } // Add in any properties that were not found above! (I.e., blacklisted or otherwise not favorite) IEnumerable <CustomPropertyType> rgBlackListProps = CustomPropertyType.GetCustomPropertyTypes(hsPropsChecked); foreach (CustomPropertyType cpt in rgBlackListProps) { lstProps.Items.Add(new ListItem(cpt.Title, cpt.PropTypeID.ToString(CultureInfo.InvariantCulture)) { Selected = true }); } } btnAddCurrencyRule.Visible = cc.ID <= 0; // only show the add button if we're doing a new currency. }
protected void ShowCorrectEntryForPropertyType() { mfbDecEdit.Visible = txtString.Visible = mfbDateTime.Visible = mfbTypeInDate.Visible = false; int iCfp = Convert.ToInt32(cmbCustomPropertyTypes.SelectedValue, CultureInfo.InvariantCulture); btnAddProperty.Visible = (iCfp > 0); if (iCfp <= 0) { return; } CustomPropertyType cpt = SelectedPropertyType(iCfp); if (cpt == null) { return; } switch (cpt.Type) { case CFPPropertyType.cfpInteger: mfbDecEdit.Visible = true; mfbDecEdit.EditingMode = Controls_mfbDecimalEdit.EditMode.Integer; break; case CFPPropertyType.cfpDecimal: mfbDecEdit.Visible = true; mfbDecEdit.EditingMode = MyFlightbook.Profile.GetUser(Page.User.Identity.Name).UsesHHMM ? Controls_mfbDecimalEdit.EditMode.HHMMFormat : Controls_mfbDecimalEdit.EditMode.Decimal; break; case CFPPropertyType.cfpCurrency: mfbDecEdit.Visible = true; mfbDecEdit.EditingMode = Controls_mfbDecimalEdit.EditMode.Currency; break; case CFPPropertyType.cfpBoolean: break; case CFPPropertyType.cfpDate: mfbTypeInDate.Visible = true; break; case CFPPropertyType.cfpDateTime: mfbDateTime.Visible = true; break; case CFPPropertyType.cfpString: txtString.Visible = true; break; default: break; } }
protected void UpdateBlacklist(bool fForceDB = false) { rptUsedProps.DataSource = Array.FindAll(CustomPropertyType.GetCustomPropertyTypes(Page.User.Identity.Name, fForceDB), cpt => cpt.IsFavorite); rptUsedProps.DataBind(); List <CustomPropertyType> lstBlacklist = new List <CustomPropertyType>(CustomPropertyType.GetCustomPropertyTypes(m_pf.BlacklistedProperties)); lstBlacklist.Sort((cpt1, cpt2) => { return(cpt1.SortKey.CompareCurrentCultureIgnoreCase(cpt2.SortKey)); }); rptBlackList.DataSource = lstBlacklist; rptBlackList.DataBind(); }
/// <summary> /// A currency object that requires 3 landings in the previous 90 days /// </summary> /// <param name="szName">the name for the currency</param> public PassengerCurrency(string szName) : base(3, 90, false, szName) { Query = new FlightQuery() { DateRange = FlightQuery.DateRanges.Trailing90, HasLandings = true, PropertiesConjunction = GroupConjunction.None }; Query.PropertyTypes.Add(CustomPropertyType.GetCustomPropertyType((int)CustomPropertyType.KnownProperties.IDPropPilotMonitoring)); }
/// <summary> /// Computes the overall currency /// </summary> protected override void ComputeComposite() { // Compute currency according to 61.57(c)(1)-(5) and 61.57(e) // including each one's expiration. The one that expires latest is the expiration date if you are current, the one that // expired most recently is the expiration date since when you were not current. // 61.57(c)(1) (66-HIT in airplane, flight simulator, ATD, or FTD) OR an IPC. FlightCurrency fcIFR = fcIPCOrCheckride.OR(fcIFRApproach.AND(fcIFRHold)); CompositeCurrencyState = fcIFR.CurrentState; CompositeExpiration = fcIFR.ExpirationDate; if (fcIPCOrCheckride.IsCurrent() && fcIPCOrCheckride.ExpirationDate.CompareTo(CompositeExpiration) >= 0) { Query.HasHolds = Query.HasApproaches = false; Query.PropertiesConjunction = GroupConjunction.Any; Query.PropertyTypes.Clear(); foreach (CustomPropertyType cpt in CustomPropertyType.GetCustomPropertyTypes()) { if (cpt.IsIPC) { Query.PropertyTypes.Add(cpt); } } } if (CompositeCurrencyState == CurrencyState.NotCurrent) { // if more than 6 calendar months have passed since expiration, an IPC is required. // otherwise, just assume 66-HIT. if (DateTime.Compare(CompositeExpiration.AddCalendarMonths(6).Date, DateTime.Now.Date) > 0) { CompositeDiscrepancy = String.Format(CultureInfo.CurrentCulture, Resources.Currency.DiscrepancyTemplateIFR, fcIFRHold.Discrepancy, (fcIFRHold.Discrepancy == 1) ? Resources.Currency.Hold : Resources.Currency.Holds, fcIFRApproach.Discrepancy, (fcIFRApproach.Discrepancy == 1) ? Resources.Totals.Approach : Resources.Totals.Approaches); } else { CompositeDiscrepancy = Resources.Currency.IPCRequired; } } else { // Check to see if IPC is required by looking for > 6 month gap in IFR currency. // For now, we won't make you un-current, but we'll warn. // (IPC above, though, is un-current). CurrencyPeriod[] rgcpMissingIPC = fcIFR.FindCurrencyGap(fcIPCOrCheckride.MostRecentEventDate, 6); CompositeDiscrepancy = rgcpMissingIPC != null ? String.Format(CultureInfo.CurrentCulture, Resources.Currency.IPCMayBeRequired, rgcpMissingIPC[0].EndDate.ToShortDateString(), rgcpMissingIPC[1].StartDate.ToShortDateString()) : string.Empty; } }
private void AddProp(CustomPropertyType cpt, TableRow tr) { string szUnit = string.Empty; switch (cpt.Type) { case CFPPropertyType.cfpBoolean: szUnit = Resources.LogbookEntry.importUnitBoolean; break; case CFPPropertyType.cfpCurrency: case CFPPropertyType.cfpDecimal: case CFPPropertyType.cfpInteger: szUnit = Resources.LogbookEntry.importUnitNumber; break; case CFPPropertyType.cfpDate: case CFPPropertyType.cfpDateTime: szUnit = Resources.LogbookEntry.importUnitDate; break; case CFPPropertyType.cfpString: szUnit = Resources.LogbookEntry.importUnitText; break; default: break; } TableCell tc = new TableCell(); tr.Cells.Add(tc); tc.Style["padding"] = "5px"; Panel pTitle = new Panel(); tc.Controls.Add(pTitle); Label lTitle = new Label(); pTitle.Controls.Add(lTitle); lTitle.Style["font-weight"] = "bold"; lTitle.Text = cpt.Title; Panel pUnit = new Panel(); tc.Controls.Add(pUnit); pUnit.Controls.Add(new LiteralControl(szUnit)); Panel pDesc = new Panel(); tc.Controls.Add(pDesc); pDesc.Style["font-size"] = "smaller"; pDesc.Controls.Add(new LiteralControl(cpt.Description)); }
public override string CSVFromDataTable(DataTable dt) { // We ignore the data table passed in - we have our data from Matches, which was initialized in CanParse. IEnumerable <CustomPropertyType> rgcpt = CustomPropertyType.GetCustomPropertyTypes(); // Build up the list of RosterBuster objects first List <RosterBuster> lstRb = new List <RosterBuster>(); foreach (Match ctMatch in Matches) { GroupCollection gc = ctMatch.Groups; try { DateTime dtStart = Convert.ToDateTime(gc["StartDate"].Value, CultureInfo.CurrentCulture); DateTime dtEnd = Convert.ToDateTime(gc["EndDate"].Value, CultureInfo.CurrentCulture); int hStart = Convert.ToInt32(gc["startZ"].Value.Substring(0, 2), CultureInfo.InvariantCulture); int mStart = Convert.ToInt32(gc["startZ"].Value.Substring(2, 2), CultureInfo.InvariantCulture); int hEnd = Convert.ToInt32(gc["endZ"].Value.Substring(0, 2), CultureInfo.InvariantCulture); int mEnd = Convert.ToInt32(gc["endZ"].Value.Substring(2, 2), CultureInfo.InvariantCulture); DateTime dtStartUtc = new DateTime(dtStart.Year, dtStart.Month, dtStart.Day, hStart, mStart, 0, DateTimeKind.Utc); DateTime dtEndUtc = new DateTime(dtStart.Year, dtStart.Month, dtStart.Day, hEnd, mEnd, 0, DateTimeKind.Utc); if (dtEndUtc.CompareTo(dtStartUtc) < 0) { dtEndUtc = dtEndUtc.AddDays(1); } lstRb.Add(new RosterBuster() { FlightDate = dtStart, FlightNumber = gc["FlightNum"].Value, BlockOut = dtStartUtc, BlockIn = dtEndUtc, Route = gc["route"].Value, TimeZone = gc["Timezone"].Value }); } catch (FormatException) { } } using (DataTable dtDst = new DataTable()) { dtDst.Locale = CultureInfo.CurrentCulture; CSVImporter.InitializeDataTable(dtDst); foreach (RosterBuster rb in lstRb) { CSVImporter.WriteEntryToDataTable(rb.ToLogbookEntry(), dtDst); } return(CsvWriter.WriteToString(dtDst, true, true)); } }
public MRUPropertyTemplate(string szuser) : this() { m_propertyTypes.Clear(); CustomPropertyType[] rgTypes = CustomPropertyType.GetCustomPropertyTypes(szuser); foreach (CustomPropertyType cpt in rgTypes) { if (cpt.IsFavorite) { m_propertyTypes.Add(cpt.PropTypeID); } } }
/// <summary> /// /// </summary> /// <param name="dataElement"></param> /// <param name="executeEventHandler"></param> public ConditionDisplayParameterCustomPropertyValue(CustomPropertyType customPropertyType, IDataElement dataElement, RuleObject.OnExecuteHandler executeEventHandler, Workshare.Policy.PolicyType type) : base(Properties.Resources.IDS_EXPRESSION_PARAM_CUSTOMPROPERTYVALUE_DEFAULT, null, type) { AddExecuteEventHandler(executeEventHandler); m_type = customPropertyType; if (dataElement != null) { Object = dataElement; Text = GetDisplayName(); } }
public NightCurrency(string szName) : base(RequiredLandings, TimeSpan, false, szName) { NightTakeoffCurrency = new FlightCurrency(RequiredTakeoffs, TimeSpan, false, szName); Query = new FlightQuery() { DateRange = FlightQuery.DateRanges.Trailing90, HasNightLandings = true, PropertiesConjunction = GroupConjunction.None }; Query.PropertyTypes.Add(CustomPropertyType.GetCustomPropertyType((int)CustomPropertyType.KnownProperties.IDPropPilotMonitoring)); }
protected void Page_Load(object sender, EventArgs e) { if (!Enabled) { return; } rgCPT = CustomPropertyType.GetCustomPropertyTypes(Page.User.Identity.IsAuthenticated ? Page.User.Identity.Name : ""); // this is cached so we can do it on every call, postback or not if (!IsPostBack) { ListItem li; Boolean fFavorites = rgCPT[0].IsFavorite; if (fFavorites) { li = new ListItem(String.Format(CultureInfo.CurrentCulture, Resources.LogbookEntry.PropertyGroupSeparator, Resources.LocalizedText.FlightPropertiesFrequentlyUsed), "-1"); li.Attributes.Add("style", "font-weight: bold"); cmbCustomPropertyTypes.Items.Add(li); } foreach (CustomPropertyType cpt in rgCPT) { if (fFavorites && !cpt.IsFavorite) // transition to non-favorites { fFavorites = false; li = new ListItem(String.Format(CultureInfo.CurrentCulture, Resources.LogbookEntry.PropertyGroupSeparator, Resources.LocalizedText.FlightPropertiesOtherProperties), "-1"); li.Attributes.Add("style", "font-weight: bold"); cmbCustomPropertyTypes.Items.Add(li); } li = new ListItem(cpt.Title, cpt.PropTypeID.ToString(CultureInfo.InvariantCulture)); cmbCustomPropertyTypes.Items.Add(li); } if (FlightProperties == null) { FlightProperties = new List <CustomFlightProperty>(); } InitNewProperty(); } else { if (ViewState[szVSKeyCFP] != null) { FlightProperties = (List <CustomFlightProperty>)ViewState[szVSKeyCFP]; } } ShowCorrectEntryForPropertyType(); }
protected void Page_Init(object sender, EventArgs e) { if (!IsPostBack) { for (int i = 3; i <= 20; i++) { cmbFlightsPerPage.Items.Add(new ListItem(String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.PrintViewXPerPage, i), i.ToString(CultureInfo.InvariantCulture)) { Selected = (i == 15) }); } MyFlightbook.Profile pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name); List <CustomPropertyType> rgcptUser = new List <CustomPropertyType>(CustomPropertyType.GetCustomPropertyTypes(Page.User.Identity.Name)); rgcptUser.RemoveAll(cpt => !cpt.IsFavorite && !pf.BlacklistedProperties.Contains(cpt.PropTypeID)); List <CustomPropertyType> rgcptUserOptionalColumns = rgcptUser.FindAll(cpt => (cpt.Type == CFPPropertyType.cfpDecimal || cpt.Type == CFPPropertyType.cfpInteger) && !cpt.IsNoSum); rgcptUser.Sort((cpt1, cpt2) => { return(cpt1.Title.CompareCurrentCultureIgnoreCase(cpt2.Title)); }); cklProperties.DataSource = rgcptUser; cklProperties.DataBind(); expPropertiesToExclude.Visible = rgcptUser.Count > 0; // By default, exclude "Additional flight remarks" foreach (ListItem li in cklProperties.Items) { if (Convert.ToInt32(li.Value, CultureInfo.InvariantCulture) == (int)CustomPropertyType.KnownProperties.IDPropAdditionalFlightRemarks) { li.Selected = true; } } List <ListItem> lstOptionalColumnDropdowns = new List <ListItem>() { new ListItem(Resources.LocalizedText.PrintViewOptionalColumnNone, string.Empty), new ListItem(Resources.Makes.IsComplex, OptionalColumnType.Complex.ToString()), new ListItem(Resources.Makes.IsRetract, OptionalColumnType.Retract.ToString()), new ListItem(Resources.Makes.IsTailwheel, OptionalColumnType.Tailwheel.ToString()), new ListItem(Resources.Makes.IsHighPerf, OptionalColumnType.HighPerf.ToString()), new ListItem(Resources.Makes.IsTurboprop, OptionalColumnType.TurboProp.ToString()), new ListItem(Resources.Makes.IsTurbine, OptionalColumnType.Turbine.ToString()), new ListItem(Resources.Makes.IsJet, OptionalColumnType.Jet.ToString()), }; rgcptUserOptionalColumns.Sort((cpt1, cpt2) => { return(cpt1.Title.CompareCurrentCultureIgnoreCase(cpt2.Title)); }); foreach (CustomPropertyType cpt in rgcptUserOptionalColumns) { lstOptionalColumnDropdowns.Add(new ListItem(cpt.Title, cpt.PropTypeID.ToString(CultureInfo.InvariantCulture))); } foreach (DropDownList ddl in OptionalColumnDropDowns) { ddl.DataSource = lstOptionalColumnDropdowns; ddl.DataBind(); } } }
public TemplatePropTypeBundle(string szUser) : this() { UserProperties = CustomPropertyType.GetCustomPropertyTypes(szUser); // For serialization to work with propertytemplates, the objects need to actually be propertytemplates, not subclasses. List <PropertyTemplate> lst = new List <PropertyTemplate>(); IEnumerable <PropertyTemplate> rgpt = UserPropertyTemplate.TemplatesForUser(szUser, true); foreach (PropertyTemplate pt in rgpt) { lst.Add(new PropertyTemplate(pt)); } UserTemplates = lst.ToArray(); }
/// <summary> /// A currency object that requires 3 full-stop landings in the previous 90 days /// </summary> /// <param name="szName">the name for the currency</param> public TailwheelCurrency(string szName) : base(3, 90, false, szName) { Query = new FlightQuery() { DateRange = FlightQuery.DateRanges.Trailing90, HasNightLandings = true, HasFullStopLandings = true, FlightCharacteristicsConjunction = GroupConjunction.Any, IsTailwheel = true, PropertiesConjunction = GroupConjunction.None }; Query.PropertyTypes.Add(CustomPropertyType.GetCustomPropertyType((int)CustomPropertyType.KnownProperties.IDPropPilotMonitoring)); }
public static bool AddCustomProperty(DocumentProperties documentProperties, string name, CustomPropertyType type, object value) { try { documentProperties.Add(name, false, type, value); return true; } catch { return false; } }
public static IEnumerable <CustomRatingProgress> CustomRatingsForUser(string szUser) { if (szUser == null) { throw new ArgumentNullException(nameof(szUser)); } Profile pf = Profile.GetUser(szUser); // build a map of all histogrammable values for naming List <HistogramableValue> lst = new List <HistogramableValue>(LogbookEntryDisplay.HistogramableValues); foreach (CustomPropertyType cpt in CustomPropertyType.GetCustomPropertyTypes()) { HistogramableValue hv = LogbookEntryDisplay.HistogramableValueForPropertyType(cpt); if (hv != null) { lst.Add(hv); } } Dictionary <string, HistogramableValue> d = new Dictionary <string, HistogramableValue>(); foreach (HistogramableValue hv in lst) { d[hv.DataField] = hv; } // MUST use the pf.GetPreferenceForKey with one argument because you need the serialize/deserialize to get the correct type conversion. IEnumerable <CustomRatingProgress> rgProgressForUser = pf.GetPreferenceForKey <IEnumerable <CustomRatingProgress> >(szPrefKeyCustomRatings); if (rgProgressForUser == null) { return(Array.Empty <CustomRatingProgress>()); } foreach (CustomRatingProgress crp in rgProgressForUser) { crp.Username = szUser; foreach (CustomRatingProgressItem crpi in crp.ProgressItems) { crpi.FieldFriendlyName = d.TryGetValue(crpi.FieldName, out HistogramableValue hv) ? hv.DataName : crpi.FieldName; } List <CustomRatingProgressItem> lstItems = new List <CustomRatingProgressItem>(crp.ProgressItems); lstItems.Sort((crpi1, crpi2) => { return(crpi1.FARRef.CompareCurrentCultureIgnoreCase(crpi2.FARRef)); }); crp.ProgressItems = lstItems; } return(rgProgressForUser); }
protected void SegregateProperties(bool fStripDefault = false) { List <CustomPropertyType> lstRemainingProps = new List <CustomPropertyType>(); ActiveProperties.Clear(); ActivePropTypes.Clear(); PropertyTemplate ptMerged = PropertyTemplate.MergedTemplate(ActiveTemplates); // this is cached so we can do it on every call, postback or not CustomPropertyType[] rgCptAll = CustomPropertyType.GetCustomPropertyTypes(Page.User.Identity.IsAuthenticated ? Username : string.Empty); foreach (CustomPropertyType cpt in rgCptAll) { // see if this either has a value or is in one of the active templates. // if it doesn't have a value but is in a template, give it a value. CustomFlightProperty fp = Properties.Find(cfp => cfp.PropTypeID == cpt.PropTypeID); // To be included, it must be EITHER // a) in the merged set of templates OR // b) in the set of properties with a non-default value (fp != null && !fp.IsDefaultValue) OR // c) in the set of properties with a default value (fp != null && (!fStripDefault && fp.IsDefaultValue) bool fInclude = ptMerged.ContainsProperty(cpt.PropTypeID) || (fp != null && (!fStripDefault || !fp.IsDefaultValue)); if (fp == null) { fp = new CustomFlightProperty(cpt); } if (!fInclude) { lstRemainingProps.Add(cpt); } else { ActiveProperties.Add(fp); ActivePropTypes.Add(fp.PropTypeID); } } ActiveProperties.Sort((cfp1, cfp2) => { return(cfp1.PropertyType.SortKey.CompareCurrentCultureIgnoreCase(cfp2.PropertyType.SortKey)); }); ListItem li = cmbPropsToAdd.Items[0]; cmbPropsToAdd.Items.Clear(); cmbPropsToAdd.Items.Add(li); cmbPropsToAdd.SelectedValue = string.Empty; // reset the selection cmbPropsToAdd.DataSource = lstRemainingProps; cmbPropsToAdd.DataBind(); }
private PendingFlight(MySqlDataReader dr) : this() { User = dr["username"].ToString(); PendingID = dr["id"].ToString(); string jsonflight = dr["jsonflight"].ToString(); if (jsonflight != null) { JsonConvert.PopulateObject(jsonflight, this); } // Populating an object doesn't fully flesh out a custom property with its type foreach (CustomFlightProperty cfp in this.CustomProperties) { cfp.InitPropertyType(new CustomPropertyType[] { CustomPropertyType.GetCustomPropertyType(cfp.PropTypeID) }); } }
/// <summary> /// Updates the flight query with the requested flight properties /// </summary> private void CustomPropsFromForm() { if (cklCustomProps.SelectedIndex >= 0) { m_fq.PropertyTypes.Clear(); CustomPropertyType[] rgcptAll = CustomPropertyType.GetCustomPropertyTypes(); foreach (ListItem li in cklCustomProps.Items) { if (li.Selected) { m_fq.PropertyTypes.Add(Array.Find <CustomPropertyType>(rgcptAll, cpt => cpt.PropTypeID == Convert.ToInt32(li.Value, CultureInfo.InvariantCulture))); } } m_fq.PropertiesConjunction = (GroupConjunction)Enum.Parse(typeof(GroupConjunction), cmbPropertiesConjunction.SelectedValue); } }
protected void cmbPropsToAdd_SelectedIndexChanged(object sender, EventArgs e) { if (String.IsNullOrEmpty(cmbPropsToAdd.SelectedValue)) { return; } int idPropType = Convert.ToInt32(cmbPropsToAdd.SelectedValue, CultureInfo.InvariantCulture); CustomPropertyType[] rgCptAll = CustomPropertyType.GetCustomPropertyTypes(Page.User.Identity.IsAuthenticated ? Username : string.Empty); CustomPropertyType cpt = rgCptAll.First((cpt2) => { return(cpt2.PropTypeID == idPropType); }); if (cpt == null) { throw new MyFlightbookException(String.Format(CultureInfo.InvariantCulture, "Custom property type with id {0} not found!", idPropType)); } RefreshList(new CustomFlightProperty(cpt)); }
/// <summary> /// Updates the flight query with the requested flight properties /// </summary> private void CustomPropsFromForm() { if (cklCustomProps.SelectedIndex >= 0) { List <CustomPropertyType> lstCpt = new List <CustomPropertyType>(); CustomPropertyType[] rgcptAll = CustomPropertyType.GetCustomPropertyTypes(); foreach (ListItem li in cklCustomProps.Items) { if (li.Selected) { lstCpt.Add(Array.Find <CustomPropertyType>(rgcptAll, cpt => cpt.PropTypeID == Convert.ToInt32(li.Value, CultureInfo.InvariantCulture))); } } m_fq.PropertyTypes = lstCpt.ToArray(); } }
protected void UpdateLists() { UserPropertyTemplate pt = ActiveTemplate; List <CustomPropertyType> lstAll = new List <CustomPropertyType>(CustomPropertyType.GetCustomPropertyTypes()); List <CustomPropertyType> lstIncluded = lstAll.FindAll(cpt => pt.ContainsProperty(cpt)); IEnumerable <int> includedProps = lstIncluded.Select(cpt => cpt.PropTypeID); rptTemplateProps.DataSource = lstIncluded; rptTemplateProps.DataBind(); lstAll.RemoveAll(cpt => pt.ContainsProperty(cpt)); IEnumerable <int> availableProps = lstAll.Select(cpt => cpt.PropTypeID); rptAvailableProps.DataSource = lstAll; rptAvailableProps.DataBind(); hdnAvailableProps.Value = JsonConvert.SerializeObject(availableProps); hdnUsedProps.Value = JsonConvert.SerializeObject(includedProps); }
public override string CSVFromDataTable(DataTable dt) { if (dt == null) { throw new ArgumentNullException("dt"); } IEnumerable <CustomPropertyType> rgcpt = CustomPropertyType.GetCustomPropertyTypes(); using (DataTable dtDst = new DataTable()) { dtDst.Locale = dt.Locale; CSVImporter.InitializeDataTable(dtDst); foreach (DataRow dr in dt.Rows) { ForeFlight ltp = new ForeFlight(dr, dictAircraft, rgcpt); CSVImporter.WriteEntryToDataTable(ltp.ToLogbookEntry(), dtDst); } return(CsvWriter.WriteToString(dtDst, true, true)); } }
public static string CustomPropertyTypeToString(CustomPropertyType type) { switch (type) { case CustomPropertyType.Text: return Properties.Resources.CUSTOMPROPERTYTYPE_TEXT; //case CustomPropertyType.Date: // return Properties.Resources.CUSTOMPROPERTYTYPE_DATE; case CustomPropertyType.Number: return Properties.Resources.CUSTOMPROPERTYTYPE_NUMBER; case CustomPropertyType.YesNo: return Properties.Resources.CUSTOMPROPERTYTYPE_YESNO; default: { Utilities.ErrorMessage errorMessage = new Utilities.ErrorMessage( "TYPE_UNSUPPORTED", "Workshare.PolicyDesigner.Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly()); Logger.LogError(errorMessage.LogString); throw new ArgumentException(errorMessage.DisplayString); } } }
private void typeComboBox_SelectedIndexChanged(object sender, EventArgs e) { if (!m_initialising) { m_type = CustomPropertyTypeUtils.StringToCustomPropertyType(typeComboBox.SelectedItem.ToString()); ActivateValueEditorControl(String.Empty); } }
public static bool SetCustomProperty(DocumentProperties documentProperties, string name, CustomPropertyType type, object value) { DeleteCustomProperty(documentProperties, name); return AddCustomProperty(documentProperties, name, type, value); }