コード例 #1
0
        /// <summary>
        /// Метод отложенной загрузки/проверки данных
        /// </summary>
        internal void DelayLoad()
        {
            if (m_bIsLoaded)
            {
                return;
            }

            // Проверка указанных данных:
            TargetFolder.CheckExistence(true);
            Prop_CourseNumber.CheckExistence(true);
            Prop_CourseBeginningDate.CheckExistence(true);
            Prop_GoalStatus.CheckExistence(true);
            Prop_TrainingDirection.CheckExistence(true);
            Prop_TrainingCenter.CheckExistence(true);
            // ... данные для типа инцидента и ролей загружаем полностью,
            // что бы сделать потом внутреннюю проверку:
            IncidentType.LoadObject(new string[] { "Props", "States" });
            Role_Trained.LoadObject(new string[] { "IncidentType" });
            Role_Manager.LoadObject(new string[] { "IncidentType" });

            // Проверка внутреннего соответствия:
            // ... тип инцидента для ролей должен совпадать с заданным в конфигурации:
            ObjectOperationHelper helperType;

            helperType = Role_Trained.GetInstanceFromPropScalarRef("IncidentType");
            if (helperType.ObjectID != IncidentType.ObjectID)
            {
                throw new InvalidOperationException(String.Format(
                                                        "Тип инцидента \"{0}\" для заданной роли itws:role-for-trained( id=\"{1}\" ) не соответствует типу инцидента itws:incident-type( id=\"{2}\" )",
                                                        helperType.ObjectID.ToString(),
                                                        Role_Trained.ObjectID.ToString(),
                                                        IncidentType.ObjectID.ToString()
                                                        ));
            }
            helperType = Role_Manager.GetInstanceFromPropScalarRef("IncidentType");
            if (helperType.ObjectID != IncidentType.ObjectID)
            {
                throw new InvalidOperationException(String.Format(
                                                        "Тип инцидента \"{0}\" для заданной роли itws:role-for-manager( id=\"{1}\" ) не соответствует типу инцидента itws:incident-type( id=\"{2}\" )",
                                                        helperType.ObjectID.ToString(),
                                                        Role_Manager.ObjectID.ToString(),
                                                        IncidentType.ObjectID.ToString()
                                                        ));
            }

            // ... все доп. свойства должны быть указаны в типе инцидента:
            XmlElement xmlProps = IncidentType.PropertyXml("Props");

            checkAuxPropExistence(xmlProps, "prop-for-course-number", Prop_CourseNumber);
            checkAuxPropExistence(xmlProps, "prop-for-course-beginning-date", Prop_CourseBeginningDate);
            checkAuxPropExistence(xmlProps, "prop-for-goal-status", Prop_GoalStatus);
            checkAuxPropExistence(xmlProps, "prop-for-training-direction", Prop_TrainingDirection);
            checkAuxPropExistence(xmlProps, "prop-for-training-center", Prop_TrainingCenter);
            checkAuxPropExistence(xmlProps, "prop-for-education-sum", Prop_Summ);

            // Фиксируем нужные нам для создания инцидента данные:
            // ... приоритет инцидента по умолчанию:
            EduIncident_DefaultPriority = (IncidentPriority)IncidentType.GetPropValue("DefaultPriority", XPropType.vt_i2);
            // ... начальное состояние инцидента; идентификатор объекта получаем
            // банальным XPath-запросом, опираясь на то, что свойство прогружено:
            XmlElement xmlDefaultState = (XmlElement)IncidentType.PropertyXml("States").SelectSingleNode("IncidentState[IsStartState='1']");

            if (null == xmlDefaultState)
            {
                throw new InvalidOperationException(String.Format(
                                                        "Для указанного типа инцидента (id={0}) неопределено стартовое состояние",
                                                        IncidentType.ObjectID.ToString()
                                                        ));
            }
            EduIncident_StartState.ObjectID = new Guid(xmlDefaultState.GetAttribute("oid"));
            // ...запланированное время для менеджера, по умолчанию:
            DefaultDuration_for_ManagerRole = (int)Role_Manager.GetPropValue("DefDuration", XPropType.vt_i4);
            // ...запланированное время для обучаемого, по умолчанию:
            DefaultDuration_for_TrainedRole = (int)Role_Trained.GetPropValue("DefDuration", XPropType.vt_i4);

            m_bIsLoaded = true;
        }