private void OnCLEMInitialiseActivity(object sender, EventArgs e) { // locate Land Type resource for this forage. LinkedLandItem = Resources.GetResourceItem(this, LandItemNameToUse, OnMissingResourceActionTypes.ReportErrorAndStop, OnMissingResourceActionTypes.ReportErrorAndStop) as LandType; if (UseAreaAvailable) { LinkedLandItem.TransactionOccurred += LinkedLandItem_TransactionOccurred; Area = LinkedLandItem.AreaAvailable; } else { ResourceRequestList = new List <ResourceRequest> { new ResourceRequest() { AllowTransmutation = false, Required = UseAreaAvailable ? LinkedLandItem.AreaAvailable : AreaRequested, ResourceType = typeof(Land), ResourceTypeName = LandItemNameToUse.Split('.').Last(), ActivityModel = this, Reason = UseAreaAvailable ?"Assign unallocated":"Assign", FilterDetails = null } }; CheckResources(ResourceRequestList, Guid.NewGuid()); gotLandRequested = TakeResources(ResourceRequestList, false); //Now the Land has been allocated we have an Area if (gotLandRequested) { //Assign the area actually got after taking it. It might be less than AreaRequested (if partial) Area = ResourceRequestList.FirstOrDefault().Provided; } } // set and enable first crop in the list for rotational cropping. int i = 0; foreach (var item in this.Children.OfType <CropActivityManageProduct>()) { item.ActivityEnabled = (i == CurrentCropIndex); item.FirstTimeStepOfRotation = Clock.StartDate.Year * 100 + Clock.StartDate.Month; i++; } }
/// <summary> /// Provides the description of the model settings for summary (GetFullSummary) /// </summary> /// <param name="formatForParentControl">Use full verbose description</param> /// <returns></returns> public override string ModelSummary(bool formatForParentControl) { string html = ""; html += "\n<div class=\"activityentry\">This crop uses "; Land parentLand = null; IModel clemParent = FindAncestor <ZoneCLEM>(); if (LandItemNameToUse != null && LandItemNameToUse != "") { if (clemParent != null && clemParent.Enabled) { parentLand = clemParent.FindInScope(LandItemNameToUse.Split('.')[0]) as Land; } } if (UseAreaAvailable) { html += "the unallocated portion of "; } else { if (parentLand == null) { html += "<span class=\"setvalue\">" + AreaRequested.ToString("0.###") + "</span> <span class=\"errorlink\">[UNITS NOT SET]</span> of "; } else { html += "<span class=\"setvalue\">" + AreaRequested.ToString("0.###") + "</span> " + parentLand.UnitsOfArea + " of "; } } if (LandItemNameToUse == null || LandItemNameToUse == "") { html += "<span class=\"errorlink\">[LAND NOT SET]</span>"; } else { html += "<span class=\"resourcelink\">" + LandItemNameToUse + "</span>"; } html += "</div>"; return(html); }