Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagec#
using System;
using System.Collections.Generic;
using System.Linq;
using Alastri.RR.Ui;
using Alastri.RR.Service;

public class LabelFormat : ILabel
{   
    public string GetLabel(ShadingContext context)
    {
	List<string> parcels = context.GetParcels();
	List<string> ores = new List<string>(){ "hg", "mg", "lg" };
		
	double oreTonnes = 0;
		
	foreach(var parcel in parcels)
	{
		if(ores.Any(ore => parcel.StartsWith(ore)))
		{
			oreTonnes += context.GetReserveValue("DryTonnes", parcel);
		}
	}
		
	return oreTonnes.ToString("#,##0");
    }
}

...

Приобладающий расчетный компонент
Code Block
languagec#
using System;
using Alastri.RR.Ui;
using Alastri.RR.Service;

public class LabelFormat : ILabel
{         
    public string GetLabel(ShadingContext context)
    {
        var parcels = context.GetParcels();
		
	string majorityParcel = "";
        double majorityTonnes = -1e7;
        foreach (var parcel in parcels)
        {
            double t = context.GetReserveValue("DryTonnes", parcel);
            if (t > majorityTonnes)
            {
                majorityTonnes = t;
                majorityParcel = parcel;
            }
        }
	return majorityParcel;
    }
}
Коэффициент содержания руды
Code Block
languagec#
using System;
using System.Collections.Generic;
using System.Linq;
using Alastri.RR.Ui;
using Alastri.RR.Service;
 
public class LabelFormat : ILabel
{  
    public string GetLabel(ShadingContext context)
    {
        List<string> wasteList = new List<string>(){ "w", "lg1", "lg2", "lg3" };
        
        double oreTonnes = 0;
         
        foreach(var parcel in context.GetParcels())
        {
            if(!wasteList.Contains(parcel.ToLower()))
            {
                oreTonnes += context.GetReserveValue("DryTonnes", parcel);
            }
        }
        
	double allTonnes = context.GetReserveValue("DryTonnes");
		
        return allTonnes == 0 ? "0" : (oreTonnes / allTonnes).ToString("0.0%");
    }
}
Присвоение имен по

...

контролю содержания
Code Block
languagec#
using System;
using Alastri.RR.Ui;
using Alastri.RR.Service;

public class LabelFormat : ILabel
{        
    public string GetLabel(ShadingContext context)
    {
        string mine = context.GetLevelName("Mine");
        string pit = context.GetLevelName("Pit");
        string bench = context.GetLevelName("Bench");
        string blast = context.GetLevelName("Solid");
        string gradeBlock = context.GetSolidPropertyString("GradeBlock");

        if(context.ReservesDataSource.ToString() == "BlockModel")
        {
             return mine + "/" + pit + "/" + bench + "/" + blast;
        }
        else
        {
	     blast = blast.Split('_')[0];
             return mine + "/" + pit + "/" + bench + "/" + blast + "/" + gradeBlock;
        }
    }
}

...