예제 #1
0
 public void Init(string factorName, string factorDescription, string userInstruction, EntityStorage storage, FactorSettings factorSettings)
 {
     this.storage = storage;
     this.factorSettings = factorSettings;
     this.factorDescription = factorDescription;
     this.userInstruction = userInstruction;
     this.factorName = factorName;
     if (this.factorSettings.Data != null)
     {
         settings = (List<FixedClasses>)this.factorSettings.Data;
     }
     else
         settings = new List<FixedClasses>();
 }
예제 #2
0
 public void Init(string factorName, string factorDescription, string userInstruction, EntityStorage storage, FactorSettings factorSettings)
 {
     this.storage = storage;
     this.factorSettings = factorSettings;
     this.factorDescription = factorDescription;
     this.userInstruction = userInstruction;
     this.factorName = factorName;
     if (this.factorSettings.Data != null)
     {
         settings = (Dictionary<Teacher, List<int>>)this.factorSettings.Data;
     }
     else
         settings = new Dictionary<Teacher, List<int>>();
 }
예제 #3
0
        public static IEnumerable<FactorSettings> GetFactorSettings()
        {
            List<Type> factorTypes = GetFactorsTypes(PATH_TO_FACTORS).ToList();
            Dictionary<string, int> defaultFines = GetDefaultFines();
            List<FactorSettings> Factors = new List<FactorSettings>();

            foreach (Type factorType in factorTypes)
            {
                string pathToDll = factorType.Assembly.Location;

                IFactor factorInstance = (IFactor)Activator.CreateInstance(factorType);
                Guid? dataTypeGuid = factorInstance.GetDataTypeGuid();
                int defaultFine = defaultFines.ContainsKey(factorType.Name) ? defaultFines[factorType.Name] : 0;

                FactorSettings factorSettings = new FactorSettings(defaultFine, factorType, pathToDll, factorInstance.GetName(), dataTypeGuid);
                Factors.Add(factorSettings);
            }
            return Factors;
        }
예제 #4
0
        public static IEnumerable<FactorSettings> GetNewFactorSettings()
        {
            List<Type> baseFactorTypes = new List<Type>();
            foreach (FactorSettings factor in CurrentBase.Factors)
            {
                try
                {
                    IFactor factorInstance = factor.CreateInstance();
                    baseFactorTypes.Add(factorInstance.GetType());
                }
                catch (Exception ex)
                {

                }
            }

            List<Type> allFactorTypes = GetFactorsTypes(PATH_TO_FACTORS).ToList();
            Dictionary<string, int> defaultFines = GetDefaultFines();
            List<FactorSettings> Factors = new List<FactorSettings>();
            foreach (Type factorType in allFactorTypes)
            {
                bool isExistsFactor = false;
                foreach (Type baseFactorType in baseFactorTypes)
                {
                    if (baseFactorType.FullName == factorType.FullName)
                    {
                        isExistsFactor = true;
                        break;
                    }
                }
                if (!isExistsFactor)
                {
                    try
                    {
                        string pathToDll = factorType.Assembly.Location;

                        IFactor factorInstance = (IFactor)Activator.CreateInstance(factorType);
                        Guid? dataTypeGuid = factorInstance.GetDataTypeGuid();
                        int defaultFine = defaultFines.ContainsKey(factorType.Name) ? defaultFines[factorType.Name] : 0;

                        FactorSettings factorSettings = new FactorSettings(defaultFine, factorType, pathToDll, factorInstance.GetName(), dataTypeGuid);
                        Factors.Add(factorSettings);
                    }
                    catch (Exception ex)
                    {

                    }
                }
            }

            return Factors;
        }
예제 #5
0
 public static void InitFactorEditor(FactorSettings factorSettings, IFactorEditor editor)
 {
     IFactor factor = factorSettings.CreateInstance();
     EntityStorage copyStorage = ((IFactorFormData)factor).FilterStorage(GetDeepCopy());
     if(factorSettings.Data != null)
     {
         RestoreFactorsData(factorSettings, copyStorage);
     }
     editor.Init(
         factor.GetName(),
         factor.GetDescription(),
         ((IFactorFormData)factor).GetUserInstructions(),
         ((IFactorFormData)factor).FilterStorage(copyStorage),
         factorSettings);
 }
예제 #6
0
 public static void RestoreFactorsData(FactorSettings factorSettings, EntityStorage storage)
 {
     if (factorSettings.DataTypeGuid.Value.Equals(Guid.Parse("6CF3F58B-5FA2-464B-8FF5-5B8E1724E0C9")))
     {
         factorSettings.Data = RestoreLinks((IDictionary<Teacher, List<int>>)factorSettings.Data, storage);
         return;
     }
     if (factorSettings.DataTypeGuid.Value.Equals(Guid.Parse("FA8861A3-02A1-4638-AF20-DF29A61A50F5")))
     {
         factorSettings.Data = RestoreLinks((IDictionary<Teacher, List<ClassRoom>>)factorSettings.Data, storage);
         return;
     }
     if (factorSettings.DataTypeGuid.Value.Equals(Guid.Parse("37DCA975-0CB9-4DEC-9DAD-93CDBC0D0599")))
     {
         factorSettings.Data = RestoreLinks((List<FixedClasses>)factorSettings.Data, storage);
         return;
     }
 }
예제 #7
0
 public static void RestoreFactorsData(FactorSettings factorSettings)
 {
     RestoreFactorsData(factorSettings, CurrentBase.EStorage);
 }