public int ParseAndValidateFields(string strParsingElementNote)
        {
            int iErrorCount = 0;

            foreach (DictionaryEntry deFieldIndo in m_Fields)
            {
                FieldInfo oFieldInfo = (FieldInfo)deFieldIndo.Value;
                //string strErrorInfo = strParsingElementNote + " field: " + oFieldInfo.ValueName;
                string strCurrElement = "";

                if (!oFieldInfo.ParseAndValidateField())
                {
                    if (oFieldInfo.XElement != null)
                    {
                        strCurrElement = " (" + EAImporter.Recurse(oFieldInfo.XElement) + ")";
                    }
                    else
                    {
                        //strErrorInfo = strErrorInfo + " in: EMPTY";
                    }

                    iErrorCount++;

                    EAImporter.LogError(EAImporter.LogErrorLevel.A, "\"" + oFieldInfo.ValueName + "\" missing or empty from " + strParsingElementNote + strCurrElement);
                }
            }

            m_ImportErrCnt = iErrorCount;
            return(m_ImportErrCnt);
        }
Esempio n. 2
0
        public EA.Package Add(string parentPackageName, string strNewPackageName, string strNotes = "", XElement CurrXEl = null)
        {
            string strLogInfo = "Package: " + strNewPackageName;

            EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo);

            if (parentPackageName == "")
            {
                string strErrInfo = "Parent package name is empty.";
                if (CurrXEl != null)
                {
                    strErrInfo = strErrInfo + "Processing element: " + EAImporter.Recurse(CurrXEl);
                }
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strErrInfo);
                return(null);
            }

            if (strNewPackageName == "")
            {
                string strErrInfo = "Package name is empty.";
                if (CurrXEl != null)
                {
                    strErrInfo = strErrInfo + "Processing element: " + EAImporter.Recurse(CurrXEl);
                }
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strErrInfo);
                return(null);
            }

            EA.Package oNewPackage = (EA.Package)m_Packages[parentPackageName + "/" + strNewPackageName];

            if (oNewPackage != null)
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo);
                return(oNewPackage);
            }

            if ((EA.Package)m_Packages[parentPackageName] == null)
            {
                string strErrInfo = "Add Failed- parent package does not exist";
                if (CurrXEl != null)
                {
                    strErrInfo = strErrInfo + "Processing element: " + EAImporter.Recurse(CurrXEl);
                }
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strErrInfo);
                return(null);
            }

            try
            {
                oNewPackage = ((EA.Package)m_Packages[parentPackageName]).Packages.GetByName(strNewPackageName);
            }
            catch (Exception ex)
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.MiscExceptions, ex.Message);
            }

            if (oNewPackage == null)
            {
                oNewPackage       = ((EA.Package)m_Packages[parentPackageName]).Packages.AddNew(strNewPackageName, "Nothing");
                oNewPackage.Notes = strNotes;
                oNewPackage.Update();

                m_Packages[parentPackageName + "/" + strNewPackageName] = oNewPackage;

                EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);
            }
            else
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo);
                m_Packages[parentPackageName + "/" + strNewPackageName] = oNewPackage;
                return(oNewPackage);
            }

            return(oNewPackage);
        }
Esempio n. 3
0
        private int ProcessSequenceStep(EA.Package theStepsPackage, EA.Diagram diagram, XElement elStep, ref int iSeqNo, ref int iDiagObjNo)
        {
            int    iErrorCount      = 0;
            string strOperationName = "";
            string strFirstStep     = "";
            string strLastStep      = "";

            ImportFieldsValidator oFieldsValidator = SequenceStepGetFields(elStep, ref strOperationName, ref strFirstStep, ref strLastStep);

            if (oFieldsValidator.ErrorCount == 0)
            {
                if (strOperationName == "REPEAT")
                {
                    EA.Element theFragment = theStepsPackage.Elements.AddNew("RepeatSteps", "InteractionFragment");
                    theFragment.Stereotype = "loop";
                    theFragment.Notes      = oFieldsValidator["event"].Value;
                    theFragment.Update();
                    theStepsPackage.Elements.Refresh();

                    int iFirstObject = 0;
                    int iLastObject  = iDiagObjNo - 1;
                    int iFirstStep   = int.Parse(strFirstStep) - 1;
                    int iLastStep    = int.Parse(strLastStep) - 1;

                    AddDiagramInteractionFragment(diagram, theFragment.ElementID, iFirstObject, iLastObject, iFirstStep, iLastStep);
                }
                else if (strOperationName == "TIMER")
                {
                    bool       bValid = true;
                    EA.Element eActorIntfc_Producer_Source = EAImporter.m_Actors.GetActorInterface(oFieldsValidator["Producer"].Value);
                    if (eActorIntfc_Producer_Source == null)
                    {
                        EAImporter.LogError(EAImporter.LogErrorLevel.A, "Invalid information producer \"" + oFieldsValidator["Producer"].Value + "\" for element:" + EAImporter.Recurse(elStep));
                        iErrorCount++;
                        bValid = false;
                    }

                    if (bValid)
                    {
                        // add operation to target actor interface
                        AddOperation(eActorIntfc_Producer_Source, strOperationName, oFieldsValidator["InformationExchanged"].Value);

                        EA.Element eElObjProducer = null;

                        eElObjProducer = AddObjIntfcInstance(diagram, theStepsPackage, oFieldsValidator["Producer"].Value, eActorIntfc_Producer_Source.ElementID, ref iDiagObjNo);

                        string strFullOpName = strOperationName + "(" + oFieldsValidator["InformationExchanged"].Value + ")";

                        AddConnector(diagram, eElObjProducer, strFullOpName, oFieldsValidator["event"].Value, eElObjProducer.ElementID, iSeqNo, oFieldsValidator["description"].Value);

                        EAImporter.m_Actors.MarkActorUseCaseRef(oFieldsValidator["Producer"].Value);
                    }
                }
                else
                {
                    bool       bValid = true;
                    EA.Element eActorIntfc_Producer_Source = EAImporter.m_Actors.GetActorInterface(oFieldsValidator["Producer"].Value);
                    if (eActorIntfc_Producer_Source == null)
                    {
                        EAImporter.LogError(EAImporter.LogErrorLevel.A, "Invalid information producer \"" + oFieldsValidator["Producer"].Value + "\" for element:" + EAImporter.Recurse(elStep));
                        iErrorCount++;
                        bValid = false;
                    }

                    EA.Element eActorIntfc_Receiver_Target = EAImporter.m_Actors.GetActorInterface(oFieldsValidator["Receiver"].Value);
                    if (eActorIntfc_Receiver_Target == null)
                    {
                        EAImporter.LogError(EAImporter.LogErrorLevel.A, "Invalid information receiver \"" + oFieldsValidator["Receiver"].Value + "\" for element:" + EAImporter.Recurse(elStep));
                        iErrorCount++;
                        bValid = false;
                    }
                    if (bValid)
                    {
                        // check if info objec exists:
                        if (EAImporter.m_InfoModels.Get(oFieldsValidator["InformationExchanged"].Value) == null)
                        {
                            EAImporter.LogError(EAImporter.LogErrorLevel.A, "Invalid information exchanged \"" + oFieldsValidator["InformationExchanged"].Value + "\" for element:" + EAImporter.Recurse(elStep));
                            iErrorCount++;
                        }
                        else
                        {
                            // add operation to target actor interface
                            AddOperation(eActorIntfc_Receiver_Target, strOperationName, oFieldsValidator["InformationExchanged"].Value);

                            EA.Element eElObjProducer = null;
                            EA.Element eElObjReceiver = null;

                            eElObjProducer = AddObjIntfcInstance(diagram, theStepsPackage, oFieldsValidator["Producer"].Value, eActorIntfc_Producer_Source.ElementID, ref iDiagObjNo);

                            eElObjReceiver = AddObjIntfcInstance(diagram, theStepsPackage, oFieldsValidator["Receiver"].Value, eActorIntfc_Receiver_Target.ElementID, ref iDiagObjNo);

                            string strFullOpName = strOperationName + "(" + oFieldsValidator["InformationExchanged"].Value + ")";

                            AddConnector(diagram, eElObjProducer, strFullOpName, oFieldsValidator["event"].Value, eElObjReceiver.ElementID, iSeqNo, oFieldsValidator["description"].Value);

                            EAImporter.m_Actors.MarkActorUseCaseRef(oFieldsValidator["Producer"].Value);
                            EAImporter.m_Actors.MarkActorUseCaseRef(oFieldsValidator["Receiver"].Value);
                        }
                    }
                }

                diagram.Update();

                theStepsPackage.Diagrams.Refresh();
                diagram.DiagramObjects.Refresh();

                iSeqNo++;
            }
            else
            {
                iErrorCount = iErrorCount + oFieldsValidator.ErrorCount;
            }

            return(iErrorCount);
        }