private EA.Element AddDataObjectToSwimlane(EA.Diagram diagram, EA.Package thePackage, string strInfoExchanged, string strActorName)
        {
            string strLogInfo = "Actor: " + strActorName + " info: " + strInfoExchanged;

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

            Swimlane oSwimlane = (Swimlane)m_Swimlanes[strActorName];

            int iL = (iActivityHorizDistBetweenActivities * (m_NoActivities - 1)) + iActivityHorizOffset;
            int iR = iL + iActivityWidth;
            int iT = (((oSwimlane.m_iB - oSwimlane.m_iT) / 2) + oSwimlane.m_iT) - (iActivityHeight / 2);
            int iB = iT + iActivityHeight;

            string strPos = "l=" + iL.ToString() + ";r=" + iR.ToString() + ";t=" + iT.ToString() + ";b=" + iB.ToString() + ";";

            EA.Element eElObj = AddDataObject(diagram, thePackage, strInfoExchanged, strActorName, strPos);
            if (eElObj == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, "Could not add actor \"" + strActorName + "\" info \"" + strInfoExchanged + "\" to activity diagram");
                return(null);
            }

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

            return(eElObj);
        }
        private int AddConnector(EA.Diagram diagram, EA.Element eaElSource, EA.Element eaElDest, string strText, string strControlType, string strPath = "")
        {
            string strLogInfo = "Connector for operation: " + strText;

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

            EA.Connector eConnector = eaElSource.Connectors.AddNew(strText, strControlType);
            if (eConnector == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(0);
            }

            // eConnector.Notes = strNotes;
            eConnector.SupplierID = eaElDest.ElementID;
            eConnector.Width      = 2;
            eConnector.Update();

            EA.DiagramLink eDiagramLink = diagram.DiagramLinks.AddNew(strText, strControlType);
            if (eDiagramLink == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(0);
            }

            eDiagramLink.ConnectorID = eConnector.ConnectorID;
            if (strPath != "")
            {
                eDiagramLink.Path = strPath;
            }
            eDiagramLink.Update();

            EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);
            return(0);
        }
        private EA.Element AddActivityToSwimlane(EA.Diagram diagram, EA.Package thePackage, string strActivityName, string strActorName, ImportFieldsValidator oFields)
        {
            string strLogInfo = "Add activity to swimlane. Actor: " + strActorName + " activity: " + strActivityName;

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

            Swimlane oSwimlane = (Swimlane)m_Swimlanes[strActorName];

            int iL = (iActivityHorizDistBetweenActivities * m_NoActivities) + iActivityHorizOffset;
            int iR = iL + iActivityWidth;
            int iT = (((oSwimlane.m_iB - oSwimlane.m_iT) / 2) + oSwimlane.m_iT) - (iActivityHeight / 2);
            int iB = iT + iActivityHeight;

            string strPos = "l=" + iL.ToString() + ";r=" + iR.ToString() + ";t=" + iT.ToString() + ";b=" + iB.ToString() + ";";

            EA.Element eElObj = AddActivity(diagram, thePackage, strActivityName, strActorName, strPos, oFields);

            if (eElObj == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(null);
            }

            m_NoActivities++;

            EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);
            return(eElObj);
        }
Exemplo n.º 4
0
        public EA.Package Add(string strNewPackageName, EA.Package eaPackage)
        {
            if (strNewPackageName == "")
            {
                string strErrInfo = "Package name is empty.";
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strErrInfo);
                return(null);
            }

            if (eaPackage == null)
            {
                string strErrInfo = "Must provide package.";
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strErrInfo);
                return(null);
            }

            string strLogInfo = "Package: " + strNewPackageName;

            EA.Package oNewPackage = (EA.Package)m_Packages[strNewPackageName];

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

            m_Packages[strNewPackageName] = eaPackage;

            return(eaPackage);
        }
Exemplo n.º 5
0
        private EA.DiagramObject AddDiagramInteractionFragment(EA.Diagram diagram, int iLinkedElementID, int iFirstObject, int iLastObject, int iFirstStep, int iLastStep)
        {
            string strLogInfo = "Diagram InteractionFragment for link ID: " + iLinkedElementID.ToString();

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

            int iLeft = (iFirstObject * m_iObjCenterOffset) - m_iLOffsetFromObjCenter;

            if (iLeft < 10)
            {
                iLeft = 10;
            }
            int iRight = (iLastObject * m_iObjCenterOffset) + m_iROffsetFromObjCenter;

            int iTop    = m_iTopOffset + (m_iHeightOneStep * iFirstStep);
            int iBottom = m_iTopOffset + (m_iHeightOneStep * (iLastStep + 1));

            string strPos = "l=" + iLeft.ToString() + ";r=" + iRight.ToString() + ";t=" + iTop + ";b=" + iBottom + ";";

            EA.DiagramObject diagramObj = diagram.DiagramObjects.AddNew(strPos, "");
            diagramObj.ElementID = iLinkedElementID;
            diagramObj.Update();
            diagram.DiagramObjects.Refresh();

            return(diagramObj);
        }
Exemplo n.º 6
0
        public int DisableCurrentShare()
        {
            try
            {
                ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from win32_share");
                ManagementBaseObject     outParams; ManagementClass mc = new ManagementClass("Win32_Share");

                foreach (ManagementObject mo in mc.GetInstances())
                {
                    if (mo["Name"].ToString() == "EAImages")
                    {
                        outParams = mo.InvokeMethod("Delete", null, null);
                        if (Convert.ToInt32(outParams.Properties["ReturnValue"].Value) == 0)
                        {
                            EAImporter.LogMsg(EAImporter.LogMsgType.Info, "Successfully removed existing EAImages share.");
                            return(0);
                        }

                        EAImporter.LogMsg(EAImporter.LogMsgType.Info, "Could not remove EAImages share. Error code:" + outParams.Properties["ReturnValue"].Value);
                        return(1);
                    }
                }
                //EAImporter.LogMsg(EAImporter.LogMsgType.Info, "Could not remove EAImages share - share EAImages does not exist or could not be found.");
                return(1);
            }
            catch (Exception ex)
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.Info, "Could not remove EAImages share. Exception:" + ex.Message);
            }

            return(1);
        }
Exemplo n.º 7
0
        /// <summary>
        /// AddInformationClass
        /// </summary>
        /// <param name="strPackageName"></param>
        /// <param name="strInfoClassName"></param>
        /// <param name="strInfoClassDescription"></param>
        private int AddInformationClass(EA.Package eaPackage, string strInfoClassName, string strInfoClassDescription, string strRequirements)
        {
            string strLogInfo = "Information Class: " + strInfoClassName;

            int iErrorCount = 0;

            EA.Element element1 = null;
            EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo);

            if (eaPackage == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, "cannot add infomation class- package does not exist " + strInfoClassName);
                iErrorCount++;
                return(iErrorCount);
            }

            if (m_InfoClasses[strInfoClassName] != null)
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo);
                return(iErrorCount);
            }

            try
            {
                element1 = eaPackage.Elements.GetByName(strInfoClassName);
            }
            catch (Exception ex)
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.MiscExceptions, ex.Message);
                // EAImporter.LogMsg(EAImporter.LogMsgType.MiscExceptions, m_Repository.Stereotypes.GetLastError() + " : " + ex.Message);
            }

            if (element1 == null)
            {
                element1       = eaPackage.Elements.AddNew(strInfoClassName, "Class");
                element1.Notes = strInfoClassDescription;
                element1.Update();

                EA.TaggedValue eaTgVal = element1.TaggedValues.AddNew("requirements", "TaggedValue");
                eaTgVal.Value = strRequirements;
                eaTgVal.Update();

                eaPackage.Elements.Refresh();
                EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);

                m_InfoClasses[strInfoClassName] = element1;
            }
            else
            {
                m_InfoClasses[strInfoClassName] = element1;

                EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo);
            }

            return(iErrorCount);
        }
        public bool ParseAndValidateField()
        {
            if (m_XElement == null)
            {
                return(true);
            }

            bool bSuccess = false;

            try
            {
                bool bFoundDoc = false;
                Value = "";

                if (!bFoundDoc)
                {
                    if (m_bIsArray)
                    {
                        IEnumerable <XElement> elValues = m_XElement.Elements(ValueName);

                        bSuccess = true;

                        foreach (XElement elValue in elValues)
                        {
                            AddArrayValue(elValue.Value);

                            if (elValue.Value == "")
                            {
                                bSuccess = false;
                            }
                        }
                    }
                    else
                    {
                        Value = m_XElement.Element(ValueName).Value;
                    }
                }

                if (Value != "")
                {
                    bSuccess = true;
                }
            }
            catch (Exception ex)
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.MiscExceptions, ex.Message);
            }

            if ((!bSuccess) && (!m_bRequired))
            {
                bSuccess = true;
            }

            return(bSuccess);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Import
        /// </summary>
        /// <param name="el"></param>
        public int Import(XElement el)
        {
            int iErrorCount = 0;

            if (el == null)
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.Info, "No actors to import ");
                return(iErrorCount);
            }

            foreach (XElement elDomain in el.Elements("Domain"))
            {
                ImportFieldsValidator oFieldsValidatorDomain = new ImportFieldsValidator();
                oFieldsValidatorDomain.Add(new FieldInfo("name", elDomain));

                int iErrCnt = oFieldsValidatorDomain.ParseAndValidateFields("Actor Category");
                if (iErrCnt != 0)
                {
                    iErrorCount = iErrorCount + iErrCnt;
                }
                else
                {
                    IEnumerable <XElement> elActors = elDomain.Elements("Actor");

                    foreach (XElement elActor in elActors)
                    {
                        Application.DoEvents();

                        ImportFieldsValidator oFieldsValidator = new ImportFieldsValidator();

                        oFieldsValidator.Add(new FieldInfo("name", elActor));
                        oFieldsValidator.Add(new FieldInfo("type", elActor));
                        oFieldsValidator.Add(new FieldInfo("description", elActor, "", false, false, true));
                        oFieldsValidator.Add(new FieldInfo("furtherInformation", elActor, "", false));

                        iErrCnt = oFieldsValidator.ParseAndValidateFields("Actor");

                        if (iErrCnt == 0)
                        {
                            oFieldsValidator.ReplaceImageLinks("UseCaseRepository/ActorLibrary" + "/" + oFieldsValidatorDomain["name"].Value + "/" + oFieldsValidator["name"].Value);

                            AddStereotype(elActor.Element("type").Value);

                            iErrorCount = iErrorCount + AddActor(EAImporter.m_Packages["UseCaseRepository/ActorLibrary" + "/" + oFieldsValidatorDomain["name"].Value], oFieldsValidator);
                        }
                        else
                        {
                            iErrorCount = iErrorCount + iErrCnt;
                        }
                    }
                }
            }

            return(iErrorCount);
        }
Exemplo n.º 10
0
        /// <summary>
        /// AddConnector
        /// </summary>
        /// <param name="diagram"></param>
        /// <param name="eElement"></param>
        /// <param name="strFullOpName"></param>
        /// <param name="strEvent"></param>
        /// <param name="iSupplierID"></param>
        /// <param name="iSeqNo"></param>
        private void AddConnector(EA.Diagram diagram, EA.Element eElement, string strFullOpName, string strEvent, int iSupplierID, int iSeqNo, string strNotes)
        {
            string strLogInfo = "Connector for operation: " + strFullOpName;

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

            EA.Connector eConnector = null;

            //for (short i = 0; i < eElement.Connectors.Count; i++)
            //{
            //    Application.DoEvents();

            //    eConnector = eElement.Connectors.GetAt(i);

            //    if (eConnector.Name == strFullOpName)
            //    {
            //        break;
            //    }
            //    else
            //    {
            //        eConnector = null;
            //    }
            //}

            if (eConnector == null)
            {
                eConnector       = eElement.Connectors.AddNew(strFullOpName, "Sequence");
                eConnector.Notes = strNotes;

                eConnector.SequenceNo       = iSeqNo;
                eConnector.SupplierID       = iSupplierID;
                eConnector.TransitionAction = "Call";
                eConnector.TransitionEvent  = "Synchronus";
                eConnector.TransitionGuard  = "params=;paramsDlg=param1;";
                eConnector.Update();

                eConnector.StartPointY = eConnector.StartPointY + 1;
                eConnector.Update();

                EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);
            }
            else
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo);
            }

            EA.DiagramLink eDiagramLink = diagram.DiagramLinks.AddNew(strEvent, "sequence");
            eDiagramLink.ConnectorID = eConnector.ConnectorID;
            eDiagramLink.Update();

            diagram.Update();
        }
        internal int AddInformationClass(EA.Package eaPackage, string strRequirementID, string strDescription)
        {
            string strLogInfo = "Requirement: " + strRequirementID;

            int iErrorCount = 0;

            EA.Element element1 = null;
            EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo);

            if (eaPackage == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, "cannot add requirement- package does not exist " + strRequirementID);
                iErrorCount++;
                return(iErrorCount);
            }

            if (m_Requirements[strRequirementID] != null)
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo);
                return(iErrorCount);
            }

            try
            {
                element1 = eaPackage.Elements.GetByName(strRequirementID);
            }
            catch (Exception ex)
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.MiscExceptions, ex.Message);
                // EAImporter.LogMsg(EAImporter.LogMsgType.MiscExceptions, m_Repository.Stereotypes.GetLastError() + " : " + ex.Message);
            }

            if (element1 == null)
            {
                element1       = eaPackage.Elements.AddNew(strRequirementID, "Class");
                element1.Notes = strDescription;
                element1.Update();
                eaPackage.Elements.Refresh();
                EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);

                m_Requirements[strRequirementID] = element1;
            }
            else
            {
                m_Requirements[strRequirementID] = element1;

                EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo);
            }

            return(iErrorCount);
        }
        private int AddSwimlane(EA.Diagram diagram, EA.Package thePackage, string strActorName)
        {
            string strLogInfo = "Swimlane: " + strActorName;

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

            Swimlane oSwimlane = (Swimlane)m_Swimlanes[strActorName];

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

            EA.Element eElObj = thePackage.Elements.AddNew(strActorName, "ActivityPartition");
            if (eElObj == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(1);
            }

            eElObj.Update();
            thePackage.Elements.Refresh();

            oSwimlane = new Swimlane();

            m_Swimlanes[strActorName] = oSwimlane;

            oSwimlane.m_iL = m_iSwimlaneHorizOffset;
            oSwimlane.m_iR = 500;
            oSwimlane.m_iT = (Swimlane.m_NoSwimlanes * m_iSwimlaneHeight) + m_iSwimlaneVertOffset;
            oSwimlane.m_iB = oSwimlane.m_iT + m_iSwimlaneHeight;

            string strPos = "l=" + oSwimlane.m_iL.ToString() + ";r=" + oSwimlane.m_iR.ToString() + ";t=" + oSwimlane.m_iT.ToString() + ";b=" + oSwimlane.m_iB.ToString() + ";";

            oSwimlane.m_eaDiagramObject = AddDiagramObject(diagram, eElObj.ElementID, strPos);
            if (oSwimlane.m_eaDiagramObject == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(1);
            }

            Swimlane.m_NoSwimlanes++;

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

            return(0);
        }
Exemplo n.º 13
0
        /// <summary>
        /// AddOperation
        /// </summary>
        /// <param name="eElement"></param>
        /// <param name="strOperationName"></param>
        /// <param name="strParamType"></param>
        private static void AddOperation(EA.Element eElement, string strOperationName, string strParamType)
        {
            string strLogInfo = "Operation: " + strOperationName + ":" + strParamType;

            EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo);
            // first see if operation name already exits
            bool bFound = false;

            for (short i = 0; i < eElement.Methods.Count; i++)
            {
                Application.DoEvents();

                EA.Method eOperationTst = eElement.Methods.GetAt(i);

                for (short j = 0; j < eOperationTst.Parameters.Count; j++)
                {
                    Application.DoEvents();

                    EA.Parameter eParamTst = eOperationTst.Parameters.GetAt(j);

                    if (eParamTst.Type == strParamType)
                    {
                        EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo);
                        bFound = true;
                        return;
                    }
                }
            }

            if (!bFound)
            {
                EA.Method eOperation = eElement.Methods.AddNew(strOperationName, "");
                eOperation.Update();
                eElement.Methods.Refresh();

                EA.Parameter eParam = eOperation.Parameters.AddNew(strParamType, "");
                eParam.Name = strParamType;
                eParam.Kind = "in";
                eParam.Type = strParamType;
                eParam.Update();
                eOperation.Update();
                eElement.Update();
                eElement.Methods.Refresh();

                EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// ImportDomains
        /// </summary>
        /// <param name="el"></param>
        public int Import(XElement el)
        {
            int iErrorCount = 0;

            if (el == null)
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.Info, "No domains to import");
                return(0);
            }

            IEnumerable <XElement> elDomains = el.Elements("Domain");

            foreach (XElement elDomain in elDomains)
            {
                Application.DoEvents();

                ImportFieldsValidator oFieldsValidator = new ImportFieldsValidator();

                oFieldsValidator.Add(new FieldInfo("name", elDomain, "name"));
                oFieldsValidator.Add(new FieldInfo("description", elDomain, "description", false, false, true));

                int iErrCnt = oFieldsValidator.ParseAndValidateFields("Actor Grouping/Domain");

                if (iErrCnt == 0)
                {
                    oFieldsValidator.ReplaceImageLinks("UseCaseRepository/DomainLibrary" + "/" + oFieldsValidator["name"].Value);

                    EAImporter.LogMsg(EAImporter.LogMsgType.Info, "Importing domain: " + oFieldsValidator["name"].Value);
                    if (EAImporter.m_Packages.Add("UseCaseRepository/DomainLibrary", oFieldsValidator["name"].Value, oFieldsValidator["description"].Value, elDomain) == null)
                    {
                        iErrorCount++;
                    }
                    ;
                    if (EAImporter.m_Packages.Add("UseCaseRepository/ActorLibrary", oFieldsValidator["name"].Value, "", elDomain) == null)
                    {
                        iErrorCount++;
                    }
                    ;
                }

                iErrorCount = iErrorCount + iErrCnt;
            }

            return(iErrorCount);
        }
Exemplo n.º 15
0
        internal static string Recurse(XElement XelCurr)
        {
            string strErrorInfo = "";

            bool bRecurse = true;

            while (bRecurse)
            {
                string strElName = "";
                try
                {
                    strElName = XelCurr.Element("Name").Value;
                }
                catch (Exception ex2)
                {
                    EAImporter.LogMsg(LogMsgType.MiscExceptions, ex2.Message);
                }

                if (strElName != "")
                {
                    strErrorInfo = XelCurr.Name + "(" + strElName + ")/" + strErrorInfo;
                }
                else
                {
                    strErrorInfo = XelCurr.Name + "/" + strErrorInfo;
                }

                if (XelCurr.Parent == null)
                {
                    bRecurse = false;
                }
                else
                {
                    XelCurr = XelCurr.Parent;
                }
            }

            if (strErrorInfo.Contains("{"))
            {
                strErrorInfo = strErrorInfo.Remove(strErrorInfo.IndexOf("{"), strErrorInfo.IndexOf("}") - strErrorInfo.IndexOf("{") + 1);
            }

            return(strErrorInfo);
        }
Exemplo n.º 16
0
        private EA.DiagramObject AddDiagramObject(EA.Diagram diagram, int iLinkedElementID, int iObjNo)
        {
            string strLogInfo = "diagram object for link ID: " + iLinkedElementID.ToString();

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

            EA.DiagramObject diagramObj;

            int    iL     = iObjNo * m_iObjCenterOffset;
            int    iR     = iL + m_iObjWidth;
            string strPos = "l=" + iL.ToString() + ";r=" + iR.ToString() + ";t=50;b=400;";

            diagramObj           = diagram.DiagramObjects.AddNew(strPos, "");
            diagramObj.ElementID = iLinkedElementID;
            diagramObj.Update();
            diagram.DiagramObjects.Refresh();

            return(diagramObj);
        }
Exemplo n.º 17
0
        /// <summary>
        /// AddStereotype
        /// </summary>
        /// <param name="strName"></param>
        private void AddStereotype(string strName)
        {
            string strLogInfo = "Stereotype: " + strName;

            EA.Stereotype Stereotype;

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

            try
            {
                // cannot lookup stereotypes by name so iterate through list
                for (short i = 0; i < EAImporter.m_Repository.Stereotypes.Count; i++)
                {
                    Application.DoEvents();
                    Stereotype = EAImporter.m_Repository.Stereotypes.GetAt(i);
                    if (Stereotype.Name == strName)
                    {
                        EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.MiscExceptions, EAImporter.m_Repository.Stereotypes.GetLastError() + " : " + ex.Message);
            }

            try
            {
                Stereotype       = EAImporter.m_Repository.Stereotypes.AddNew(strName, "actor");
                Stereotype.Notes = "UseCaseRepository";
                Stereotype.Update();
            }
            catch (Exception ex)
            {
                string strTemp = ex.Message;
                EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo);
                return;
            }

            EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);
        }
        private EA.DiagramObject AddDiagramObject(EA.Diagram diagram, int iLinkedElementID, string strPos)
        {
            string strLogInfo = "diagram object for link ID: " + iLinkedElementID.ToString();

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

            EA.DiagramObject diagramObj = diagram.DiagramObjects.AddNew(strPos, "");
            if (diagramObj == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(null);
            }

            diagramObj.ElementID = iLinkedElementID;
            diagramObj.Update();
            diagram.DiagramObjects.Refresh();

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

            return(diagramObj);
        }
        private EA.Element AddDataObject(EA.Diagram diagram, EA.Package thePackage, string strInfoExchanged, string strActorName, string strPos)
        {
            string strLogInfo = "Activity Info Exchanged: " + strInfoExchanged;

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

            EA.Element eElObj = thePackage.Elements.AddNew(strInfoExchanged, "Object");
            if (eElObj == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(null);
            }

            try
            {
                eElObj.ClassifierID = EAImporter.m_InfoModels.Get(strInfoExchanged).ElementID;
            }
            catch (Exception ex)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, "Information exchanged \"" + strInfoExchanged + "\" used in a sequence step is not defined in the Use Case or in the Repository");
                string Temp = ex.Message;
                return(null);
            }

            EA.TaggedValue eaTgVal = eElObj.TaggedValues.AddNew("ActorName", "TaggedValue");
            eaTgVal.Value = strActorName;
            eaTgVal.Update();

            eElObj.Update();

            if (AddDiagramObject(diagram, eElObj.ElementID, strPos) == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(null);
            }

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

            return(eElObj);
        }
Exemplo n.º 20
0
        private EA.Element AddObjIntfcInstance(EA.Diagram diagram, EA.Package thePackage, string strActorIntcName, int iActorIntefaceElID, ref int iDiagObjNo)
        {
            string strLogInfo = "Object for actor: " + strActorIntcName;

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

            EA.Element eElObj = null;

            try
            {
                eElObj = thePackage.Elements.GetByName(strActorIntcName);
            }
            catch (Exception ex)
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.MiscExceptions, ex.Message);
            }

            if (eElObj == null)
            {
                eElObj = thePackage.Elements.AddNew(strActorIntcName, "Object");
                //eElObj.Stereotype = "interface";
                eElObj.ClassifierID = iActorIntefaceElID;
                eElObj.Update();
                thePackage.Elements.Refresh();

                AddDiagramObject(diagram, eElObj.ElementID, iDiagObjNo);

                iDiagObjNo++;

                EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);
            }
            else
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo);
            }

            return(eElObj);
        }
Exemplo n.º 21
0
        public int CreateFolderForShare(string strTargetPath)
        {
            DisableCurrentShare();

            DirectoryInfo di;

            try
            {
                if (!Directory.Exists(strTargetPath))
                {
                    Directory.CreateDirectory(strTargetPath);
                }

                di = new DirectoryInfo(strTargetPath);
                DirectorySecurity dSecurity = di.GetAccessControl();
                dSecurity.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.NoPropagateInherit, AccessControlType.Allow));
                di.SetAccessControl(dSecurity);

                if (di != null)
                {
                    if (ShareFolder(strTargetPath, "EAImages", "Storage for EA image links") != 0)
                    {
                        EAImporter.LogMsg(EAImporter.LogMsgType.Info, "Successfully created EAImages share.");
                        return(1);
                    }
                }
            }
            catch (Exception ex)
            {
                LogError(LogErrorLevel.A, "Error sharing folders. Please make sure you run as Administrator. ERROR: " + ex.Message);

                return(1);
            }

            return(0);
        }
        /// <summary>
        /// ProcessSequences
        /// </summary>
        /// <param name="strParentPackageName"></param>
        /// <param name="el"></param>
        public int Import(string strParentPackageName, XElement el)
        {
            int iErrorCount = 0;

            if (el == null)
            {
                return(iErrorCount);
            }

            IEnumerable <XElement> elSequences = el.Elements("Scenario");

            foreach (XElement elSequence in elSequences)
            {
                Swimlane.m_NoSwimlanes = 0;
                Step.m_noSteps         = 0;
                m_NoActivities         = 0;

                m_LoadedSteps = new Hashtable();
                m_Swimlanes   = new Hashtable();

                Application.DoEvents();

                ImportFieldsValidator oFieldsValidator = new ImportFieldsValidator();

                oFieldsValidator.Add(new FieldInfo("name", elSequence));

                int iErrCnt = oFieldsValidator.ParseAndValidateFields("Scenario");

                iErrorCount = iErrorCount + iErrCnt;

                if (iErrCnt != 0)
                {
                    // assign temporary name to sequence to process steps for error reporting
                    oFieldsValidator["name"].Value = "DUMMY";
                }

                EAImporter.LogMsg(EAImporter.LogMsgType.Info, "Importing Activity: " + oFieldsValidator["name"].Value);

                EA.Package theActivityPackage = EAImporter.m_Packages.Add(strParentPackageName, oFieldsValidator["name"].Value, "", elSequence);

                string strPackageName = strParentPackageName + "/" + oFieldsValidator["name"].Value;

                EA.Package theStepsPackage = EAImporter.m_Packages.Add(strPackageName, "Activity", "");
                if (theStepsPackage != null)
                {
                    EA.Diagram diagram = EAImporter.AddDiagram(theStepsPackage, "Activity Diagram", "Activity");

                    IEnumerable <XElement> elSteps = elSequence.Elements("Step");

                    Step oStep = new Step();
                    oStep.m_strOperationName      = "INITIALSTATE";
                    m_LoadedSteps[Step.m_noSteps] = oStep;
                    Step.m_noSteps++;

                    foreach (XElement elStep in elSteps)
                    {
                        Application.DoEvents();

                        iErrorCount = iErrorCount + LoadStep(elStep);
                    }

                    if (iErrorCount == 0)
                    {
                        oStep = new Step();
                        oStep.m_strOperationName      = "FINALSTATE";
                        m_LoadedSteps[Step.m_noSteps] = oStep;
                        Step.m_noSteps++;

                        iErrorCount = iErrorCount + ProcessLoadedSteps(theStepsPackage, diagram);

                        // now extend swimlanes to cover all activities
                        foreach (DictionaryEntry deSwimlane in m_Swimlanes)
                        {
                            Swimlane oSwimlane = (Swimlane)deSwimlane.Value;

                            oSwimlane.m_eaDiagramObject.right = iActivityHorizOffset + (iActivityHorizDistBetweenActivities * (m_NoActivities - 1)) + iActivityWidth;
                            oSwimlane.m_eaDiagramObject.Update();
                            diagram.Update();
                        }
                    }
                }
                else
                {
                    iErrorCount++;
                }
            }

            return(iErrorCount);
        }
        private int ProcessLoadedSteps(EA.Package theStepsPackage, EA.Diagram diagram)
        {
            string strActorForNextActivity           = "";
            string strActorForThisActivity           = "";
            string strActorForInfoObj                = "";
            string strTypeForNextConnector           = "";
            string strOperationNameforNextTransition = "";

            EA.Element eaElActivityA = null;
            EA.Element eaElActivityB = null;
            EA.Element eaElInfoObj   = null;

            if (AddSwimlane(diagram, theStepsPackage, ((Step)m_LoadedSteps[1]).m_strPrimaryActor) != 0)
            {
                return(1);
            }

            eaElActivityA = AddActivityToSwimlane(diagram, theStepsPackage, "ActivityInitial", ((Step)m_LoadedSteps[1]).m_strPrimaryActor, null);
            if (eaElActivityA == null)
            {
                return(1);
            }

            strTypeForNextConnector = "ControlFlow";

            strActorForNextActivity           = ((Step)m_LoadedSteps[1]).m_strPrimaryActor;
            strOperationNameforNextTransition = "";

            for (int iStep = 1; iStep < Step.m_noSteps - 1; iStep++)
            {
                Step oStep     = (Step)m_LoadedSteps[iStep];
                Step oNextStep = (Step)m_LoadedSteps[iStep + 1];

                strActorForThisActivity = strActorForNextActivity;

                if (AddSwimlane(diagram, theStepsPackage, strActorForThisActivity) != 0)
                {
                    return(1);
                }

                if ((oStep.m_strOperationName != "REPEAT") && (oStep.m_strOperationName != "TIMER"))
                {
                    eaElActivityB = AddActivityToSwimlane(diagram, theStepsPackage, oStep.m_oFields["name"].Value, strActorForThisActivity, oStep.m_oFields);
                    if (eaElActivityB == null)
                    {
                        return(1);
                    }

                    oStep.m_eaElActivity = eaElActivityB;
                }
                else if (oStep.m_strOperationName == "REPEAT")
                {
                    eaElActivityB = AddActivityToSwimlane(diagram, theStepsPackage, "Repeat till: " + oStep.m_oFields["event"].Value, strActorForThisActivity, oStep.m_oFields);
                    if (eaElActivityB == null)
                    {
                        return(1);
                    }
                }
                else if (oStep.m_strOperationName == "TIMER")
                {
                    eaElActivityB = AddActivityToSwimlane(diagram, theStepsPackage, "Wait till: " + oStep.m_oFields["InformationExchanged"].Value + " name=" + oStep.m_oFields["name"].Value, strActorForThisActivity, oStep.m_oFields);
                    if (eaElActivityB == null)
                    {
                        return(1);
                    }
                }

                if (oStep.m_oFields["InformationExchanged"] != null)
                {
                    strActorForInfoObj = oStep.m_strSecondaryActor;

                    if (oStep.m_strOperationName != "TIMER")
                    {
                        if (AddSwimlane(diagram, theStepsPackage, strActorForInfoObj) != 0)
                        {
                            return(1);
                        }

                        eaElInfoObj = AddDataObjectToSwimlane(diagram, theStepsPackage, oStep.m_oFields["InformationExchanged"].Value, strActorForInfoObj);
                        if (eaElInfoObj == null)
                        {
                            return(1);
                        }
                    }
                }

                // Make connector 1
                string strMsg = "Make connector 1 from Activity: " + eaElActivityA.Name + " to Activity: " + eaElActivityB.Name + " operation: " + strOperationNameforNextTransition;
                EAImporter.LogMsg(EAImporter.LogMsgType.Info, strMsg);

                if (AddConnector(diagram, eaElActivityA, eaElActivityB, "", strTypeForNextConnector) != 0)
                {
                    return(1);
                }

                // Make connector 2
                if ((oStep.m_strOperationName != "TIMER") && (oStep.m_strOperationName != "REPEAT"))
                {
                    if (oStep.m_oFields["InformationExchanged"] != null)
                    {
                        strMsg = "Make connector 2 from Activity: " + eaElActivityB.Name + " to InfoObj: " + eaElInfoObj.Name + " operation: " + oStep.m_strOperationName;
                        EAImporter.LogMsg(EAImporter.LogMsgType.Info, strMsg);

                        string strOperation = oStep.m_strOperationName + "(" + oStep.m_oFields["InformationExchanged"].Value + ")";

                        if ((oStep.m_strOperationName == "READ") || (oStep.m_strOperationName == "GET"))
                        {
                            if (AddConnector(diagram, eaElInfoObj, eaElActivityB, strOperation, "ObjectFlow") != 0)
                            {
                                return(1);
                            }
                        }
                        else
                        {
                            if (AddConnector(diagram, eaElActivityB, eaElInfoObj, strOperation, "ObjectFlow") != 0)
                            {
                                return(1);
                            }
                        }
                    }
                }


                if (oStep.m_strOperationName == "REPEAT")
                {
                    int  iFirstStep = Convert.ToInt16(oStep.m_strFirstStep);
                    int  iLastStep  = Convert.ToInt16(oStep.m_strLastStep);
                    Step oFirstStep = ((Step)m_LoadedSteps[iFirstStep]);

                    int iLastPosition  = (((iLastStep + 1) * iActivityHorizDistBetweenActivities) + iActivityHorizOffset) + iActivityWidth / 2;
                    int iFirstPosition = ((iFirstStep * iActivityHorizDistBetweenActivities) + iActivityHorizOffset) + iActivityWidth / 2;

                    string strPath = iLastPosition.ToString() + ":" + "-30;" + iFirstPosition.ToString() + ":-30;";;

                    if (AddConnector(diagram, eaElActivityB, oFirstStep.m_eaElActivity, "", "ControlFlow", strPath) != 0)
                    {
                        return(1);
                    }
                }

                // now setup for next iteration

                //default:
                eaElActivityA                     = eaElActivityB;
                strTypeForNextConnector           = "ControlFlow";
                strActorForNextActivity           = oNextStep.m_strPrimaryActor;
                strOperationNameforNextTransition = oStep.m_strOperationName;

                if (oStep.m_strOperationName == "CREATE")
                {
                    if (oStep.m_oFields["Receiver"].Value == oNextStep.m_strPrimaryActor)
                    {
                        eaElActivityA           = eaElInfoObj;
                        strTypeForNextConnector = "ObjectFlow";
                    }
                }

                if (oNextStep.m_strOperationName == "TIMER")
                {
                    strActorForNextActivity = oNextStep.m_oFields["Producer"].Value;
                }

                if (oNextStep.m_strOperationName == "REPEAT")
                {
                    strActorForNextActivity = strActorForThisActivity;
                }
            }

            eaElActivityB = AddActivityToSwimlane(diagram, theStepsPackage, "ActivityFinal", strActorForThisActivity, null);
            if (eaElActivityB == null)
            {
                return(1);
            }

            string strMsg2 = "Make connector 1 from Activity: " + eaElActivityA.Name + " to Activity: " + eaElActivityB.Name + " operation: " + strOperationNameforNextTransition;

            EAImporter.LogMsg(EAImporter.LogMsgType.Info, strMsg2);

            if (AddConnector(diagram, eaElActivityA, eaElActivityB, "", strTypeForNextConnector) != 0)
            {
                return(1);
            }

            return(0);
        }
        private EA.Element AddActivity(EA.Diagram diagram, EA.Package thePackage, string strActivityName, string strActorName, string strPos, ImportFieldsValidator oFields)
        {
            string strLogInfo = "Activity: " + strActivityName;

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

            EA.Element eElObj = null;

            if (strActivityName.StartsWith("Repeat till"))
            {
                eElObj = thePackage.Elements.AddNew(strActivityName, "Decision");
            }
            else if (strActivityName.StartsWith("Wait till"))
            {
                eElObj = thePackage.Elements.AddNew(strActivityName, "Event");
            }
            else if (strActivityName == "ActivityInitial")
            {
                // eElObj = thePackage.Elements.AddNew("", "ActivityInitial"); // hmm does not seem to work
                eElObj = thePackage.Elements.AddNew(strActivityName, "Activity");
            }
            else if (strActivityName == "ActivityFinal")
            {
                //eElObj = thePackage.Elements.AddNew("", "ActivityFinal"); // hmm does not seem to work
                eElObj = thePackage.Elements.AddNew(strActivityName, "Activity");
            }
            else
            {
                eElObj = thePackage.Elements.AddNew(strActivityName, "Activity");
            }

            if (AddDiagramObject(diagram, eElObj.ElementID, strPos) == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(null);
            }

            if (oFields != null)
            {
                eElObj.Notes = oFields["description"].Value;

                EA.TaggedValue eaTgVal = eElObj.TaggedValues.AddNew("event", "TaggedValue");
                eaTgVal.Value = oFields["event"].Value;
                eaTgVal.Update();

                eaTgVal       = eElObj.TaggedValues.AddNew("number", "TaggedValue");
                eaTgVal.Value = oFields["number"].Value;
                eaTgVal.Update();

                eaTgVal       = eElObj.TaggedValues.AddNew("requirements", "TaggedValue");
                eaTgVal.Value = oFields["requirements"].Value;
                eaTgVal.Update();

                eaTgVal       = eElObj.TaggedValues.AddNew("ActorName", "TaggedValue");
                eaTgVal.Value = strActorName;
                eaTgVal.Update();

                eElObj.Update();
            }

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

            return(eElObj);
        }
Exemplo n.º 25
0
        /// <summary>
        /// ProcessSequences
        /// </summary>
        /// <param name="strParentPackageName"></param>
        /// <param name="el"></param>
        public int Import(string strParentPackageName, XElement el)
        {
            int iErrorCount = 0;

            if (el == null)
            {
                return(iErrorCount);
            }

            IEnumerable <XElement> elSequences = el.Elements("Scenario");

            foreach (XElement elSequence in elSequences)
            {
                Application.DoEvents();

                ImportFieldsValidator oFieldsValidator = new ImportFieldsValidator();

                oFieldsValidator.Add(new FieldInfo("name", elSequence));
                oFieldsValidator.Add(new FieldInfo("PrimaryActorName", elSequence.Element("PrimaryActor"), "name"));
                oFieldsValidator.Add(new FieldInfo("triggeringEvent", elSequence));
                oFieldsValidator.Add(new FieldInfo("preCondition", elSequence, "", true, false, false, true));
                oFieldsValidator.Add(new FieldInfo("postCondition", elSequence, "", true, false, false, true));
                oFieldsValidator.Add(new FieldInfo("number", elSequence));

                int iErrCnt = oFieldsValidator.ParseAndValidateFields("scenario conditions");

                iErrorCount = iErrorCount + iErrCnt;

                if (iErrCnt != 0)
                {
                    // assign temporary name to sequence to process steps for error reporting
                    oFieldsValidator["name"].Value = "DUMMY";
                }

                EAImporter.LogMsg(EAImporter.LogMsgType.Info, "Importing Sequence: " + oFieldsValidator["name"].Value);

                EA.Package theSeqPackage = EAImporter.m_Packages.Add(strParentPackageName, oFieldsValidator["name"].Value, "", elSequence);

                string strPackageName = strParentPackageName + "/" + oFieldsValidator["name"].Value;

                EA.Package theStepsPackage = EAImporter.m_Packages.Add(strPackageName, "Sequence", "");

                if (theStepsPackage != null)
                {
                    {
                        EA.Element elScenarioObj = theSeqPackage.Elements.AddNew("Scenario", "Object");
                        elScenarioObj.ClassifierID = EAImporter.m_ScenarioBaseClsID;
                        string strRunState = "";

                        strRunState = strRunState + oFieldsValidator["number"].GetRunStateString();
                        strRunState = strRunState + oFieldsValidator["name"].GetRunStateString();
                        strRunState = strRunState + oFieldsValidator["triggeringEvent"].GetRunStateString();
                        strRunState = strRunState + oFieldsValidator["preCondition"].GetRunStateString();
                        strRunState = strRunState + oFieldsValidator["postCondition"].GetRunStateString();

                        elScenarioObj.RunState = strRunState;
                        elScenarioObj.Update();
                    }

                    {
                        EA.Element elActor = EAImporter.m_Actors.GetActor(oFieldsValidator["PrimaryActorName"].Value);

                        if (elActor != null)
                        {
                            EA.Element elPrimActorObj = theSeqPackage.Elements.AddNew("PrimaryActor_" + oFieldsValidator["PrimaryActorName"].Value, "Object");
                            elPrimActorObj.ClassifierID = elActor.ElementID;
                            elPrimActorObj.Update();
                        }
                        else
                        {
                            EAImporter.LogError(EAImporter.LogErrorLevel.A, "\"PrimaryActorName\" missing from scenario" + oFieldsValidator["PrimaryActorName"].Value);
                            iErrorCount++;
                        }
                    }

                    EA.Diagram diagram = EAImporter.AddDiagram(theStepsPackage, "Sequence Diagram", "Sequence");

                    IEnumerable <XElement> elSteps = elSequence.Elements("Step");

                    int iSeqNo     = 0;
                    int iDiagObjNo = 0;
                    foreach (XElement elStep in elSteps)
                    {
                        Application.DoEvents();

                        iErrorCount = iErrorCount + ProcessSequenceStep(theStepsPackage, diagram, elStep, ref iSeqNo, ref iDiagObjNo);
                    }
                }
                else
                {
                    iErrorCount++;
                }
            }

            return(iErrorCount);
        }
Exemplo n.º 26
0
        private int ProcessModelObject(string strLinksFolder, EA.Package eAMainPackage, EA.Package eaPackage, EA.Diagram diagram, ImportFieldsValidator oFieldsValidator, int iBaseClassID, string strImportingData, string strObjName = "")
        {
            int iErrCnt = oFieldsValidator.ParseAndValidateFields(strImportingData);

            if (iErrCnt == 0)
            {
                oFieldsValidator.ReplaceImageLinks(strLinksFolder);

                string strLogInfo = "";

                if (strObjName == "")
                {
                    strLogInfo = strImportingData + ": " + (string)oFieldsValidator[oFieldsValidator.GetIDStrName()].Value;
                }
                else
                {
                    strLogInfo = strImportingData + ": " + strObjName;
                }

                EA.Element element1 = null;
                EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo);

                if (strObjName == "")
                {
                    element1 = eaPackage.Elements.AddNew((string)oFieldsValidator[oFieldsValidator.GetIDStrName()].Value, "Object");
                }
                else
                {
                    element1 = eaPackage.Elements.AddNew(strObjName, "Object");
                }
                if (oFieldsValidator.GetNotesStrName() != "")
                {
                    element1.Notes = oFieldsValidator[oFieldsValidator.GetNotesStrName()].Value;
                }
                element1.ClassifierID = iBaseClassID;

                string strRunState = "";

                foreach (DictionaryEntry deFieldIndo in oFieldsValidator.GetFields())
                {
                    FieldInfo oFieldInfo = (FieldInfo)deFieldIndo.Value;
                    if ((string)oFieldInfo.Value != "")
                    {
                        if (!oFieldInfo.bIsID && !oFieldInfo.bIsNote)
                        {
                            strRunState = strRunState + "@VAR;Variable=" + oFieldInfo.ValueName + ";Value=" + (string)oFieldInfo.Value + ";Op==;@ENDVAR;";
                        }
                        if (oFieldInfo.bIsNote)
                        {
                            strRunState = strRunState + "@VAR;Variable=" + oFieldInfo.ValueName + ";Value=See notes for this object;Op==;@ENDVAR;";
                        }
                    }
                }
                element1.RunState = strRunState;
                element1.Update();

                eaPackage.Elements.Refresh();

                AddUCComponentToDiagram(eAMainPackage, diagram, element1.ElementID);
            }

            return(iErrCnt);
        }
        public bool ReplaceImageLinks(string strImagePackagePath)
        {
            if (m_bIsNote)
            {
                while (Value.IndexOf("<img ") > 0)
                {
                    Regex           rgx1     = new Regex(@"<img.*?>");
                    MatchCollection matches1 = rgx1.Matches(Value);

                    foreach (Match match1 in matches1)
                    {
                        Regex           rgxSrc     = new Regex(@"(?<=src="").*?(?="")");
                        MatchCollection matchesSrc = rgxSrc.Matches(match1.Value);

                        Regex           rgxWidth     = new Regex(@"(?<=width="").*?(?="")");
                        MatchCollection matchesWidth = rgxWidth.Matches(match1.Value);

                        Regex           rgxHeight     = new Regex(@"(?<=height="").*?(?="")");
                        MatchCollection matchesHeight = rgxHeight.Matches(match1.Value);

                        Regex           rgxId     = new Regex(@"(?<=id="").*?(?="")");
                        MatchCollection matchesId = rgxId.Matches(match1.Value);

                        Regex           rgxAlign     = new Regex(@"(?<=align="").*?(?="")");
                        MatchCollection matchesAlign = rgxAlign.Matches(match1.Value);

                        Regex           rgxStyle     = new Regex(@"(?<=style="").*?(?="")");
                        MatchCollection matchesStyle = rgxStyle.Matches(match1.Value);

                        string strAlign = "";
                        if (matchesAlign.Count > 0)
                        {
                            strAlign = matchesAlign[0].Value;
                        }

                        string strStyle = "";
                        if (matchesStyle.Count > 0)
                        {
                            strStyle = matchesStyle[0].Value;
                        }

                        strStyle = strStyle.Replace(':', '#');

                        string strTargetPath = System.IO.Path.Combine(@"\\127.0.0.1\EAImages", strImagePackagePath);

                        string sourceFile     = System.IO.Path.Combine(EAImporter.m_strImportFilePath, matchesSrc[0].Value);
                        string strNewFileName = "W" + matchesWidth[0].Value + "_H" + matchesHeight[0].Value + "_ID" + matchesId[0].Value + "_AL" + strAlign + "_ST" + strStyle + "_" + matchesSrc[0].Value.Split('/')[1];
                        string destFile       = System.IO.Path.Combine(strTargetPath, strNewFileName);

                        try
                        {
                            if (!Directory.Exists(strTargetPath))
                            {
                                DirectoryInfo di = Directory.CreateDirectory(strTargetPath);
                            }
                        }
                        catch (Exception ex)
                        {
                            EAImporter.LogError(EAImporter.LogErrorLevel.A, "Could not create directory for images: " + ex.Message);
                            return(false);
                        }

                        sourceFile = sourceFile.Replace("%20", " ");
                        System.IO.File.Copy(sourceFile, destFile, true);

                        string strReplacement = "&#13;&#10;<a href=\"" + destFile + "\"><font color=\"#0000ff\"><u>" + "<Ctl Left Click with Mouse to View Image>" + "</u></font></a>&#13;&#10;";

                        Value = Value.Replace(match1.Value, strReplacement);

                        EAImporter.LogMsg(EAImporter.LogMsgType.Info, "Replacing image ref: " + match1.Value);
                        EAImporter.LogMsg(EAImporter.LogMsgType.Info, "Replacing image ref with: " + strReplacement);
                    }
                }
            }

            return(true);
        }
Exemplo n.º 28
0
        private int AddActor(EA.Package eaPackage, ImportFieldsValidator oFieldsValidator)
        {
            string strName       = oFieldsValidator["name"].Value;
            string strStereotype = oFieldsValidator["type"].Value;
            string strNotes      = oFieldsValidator["description"].Value;

            string strLogInfo = "Actor: " + strName;

            int iErrorCount = 0;

            EA.Element element1 = null;
            EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo);

            if (m_ActorsStruct[strName] != null)
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo);
                return(0);
            }

            if (eaPackage == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, "cannot add actor- package does not exist " + strName);
                return(1);
            }

            try
            {
                element1 = eaPackage.Elements.GetByName(strName);
            }
            catch (Exception ex)
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.MiscExceptions, ex.Message);
            }

            if (element1 == null)
            {
                element1 = eaPackage.Elements.AddNew(strName, "Actor");
                eaPackage.Update();
                eaPackage.Elements.Refresh();
                element1.Notes        = strNotes;
                element1.StereotypeEx = strStereotype;

                //EA.Element eIntfc = element1.Elements.AddNew(strName, "Interface");
                EA.Element eIntfc = element1.Elements.AddNew(strName, "Class");
                eIntfc.Update();
                element1.Update();
                element1.Elements.Refresh();

                EA.Element source = eIntfc;
                EA.Element target = element1;

                EA.Connector con = source.Connectors.AddNew("realizes", "Realization");

                con.SupplierID = target.ElementID;
                con.Update();
                source.Connectors.Refresh();

                EA.Connector con2 = source.Connectors.AddNew("", "Generalization");

                con2.SupplierID = EAImporter.m_iActorBaseClsID;
                con2.Update();
                source.Connectors.Refresh();

                ActorInformation oActorInfo = new ActorInformation();
                oActorInfo.m_eaEl             = element1;
                oActorInfo.m_oFieldsValidator = oFieldsValidator;

                m_ActorsStruct[strName] = oActorInfo;

                element1.Update();
                eIntfc.Update();

                EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);
            }
            else
            {
                ActorInformation oActorInfo = new ActorInformation();
                oActorInfo.m_eaEl             = element1;
                oActorInfo.m_oFieldsValidator = oFieldsValidator;
                m_ActorsStruct[strName]       = oActorInfo;

                EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo);
            }
            return(iErrorCount);
        }
Exemplo n.º 29
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);
        }