Exemplo n.º 1
0
 public void TestInitialize()
 {
     xmlImporter = new XmlImporter();
     firstArea   = new AreaEntity
     {
         Name = "Area_One",
     };
     secondArea = new AreaEntity
     {
         Name = "Area_Two",
     };
     firstTopic = new TopicEntity
     {
         Name         = "Topic_One",
         AreaEntityId = 2,
     };
     secondTopic = new TopicEntity
     {
         Name         = "Topic_Two",
         AreaEntityId = 2,
     };
     firstTypeReq = new TypeReqEntity
     {
         Name          = "TypeReq_One",
         TopicEntityId = 1,
     };
     secondTypeReq = new TypeReqEntity
     {
         Name          = "TypeReq_Two",
         TopicEntityId = 2,
     };
 }
Exemplo n.º 2
0
        private IGenericImporter CreateInterface(string importer)
        {
            //string[] filesArray = Directory.GetFiles(@".\\Assemblies", "*.dll");
            //var path = "IMMRequest.WebApi.Assemblies\\";
            var              path             = @"Assemblies\\";
            var              dllFile          = new FileInfo(path + $@"IMMRequest.{importer}DataImporter.dll");
            Assembly         myAssembly       = Assembly.LoadFile(dllFile.FullName);
            List <Type>      implementations  = this.GetTypesInAssembly <IGenericImporter>(myAssembly);
            IGenericImporter genericInterface = (IGenericImporter)Activator.CreateInstance(implementations.First(), new object[] { });

            return(genericInterface);
        }
Exemplo n.º 3
0
        private void importTopics(ICollection <Parameter> parameters, ref Tuple <int, int>[] result, IGenericImporter genericInterface)
        {
            try
            {
                ICollection <TopicEntity> importedTopicsCollection = genericInterface.GetTopics(parameters);
                List <TopicEntity>        importedTopics           = importedTopicsCollection.ToList();
                int totalTopics     = importedTopics.Count;
                int succesfulTopics = 0;

                foreach (TopicEntity importedTopic in importedTopics)
                {
                    try
                    {
                        topicLogic.Add(importedTopic);
                        succesfulTopics++;
                    }
                    catch (ArgumentException) { }
                }
                result[1] = new Tuple <int, int>(totalTopics, succesfulTopics);
            }
            catch (ArgumentException e)
            {
                throw new ArgumentException(e.Message);
            }
        }
Exemplo n.º 4
0
        private void importAreas(ICollection <Parameter> parameters, ref Tuple <int, int>[] result, IGenericImporter genericInterface)
        {
            try
            {
                string            test          = genericInterface.GetName();
                List <AreaEntity> importedAreas = genericInterface.GetAreas(parameters).ToList();
                int totalAreas     = importedAreas.Count;
                int succesfulAreas = 0;

                foreach (AreaEntity importedArea in importedAreas)
                {
                    try
                    {
                        areaLogic.Add(importedArea);
                        succesfulAreas++;
                    }
                    catch (ArgumentException e)
                    {
                        throw new ArgumentException(e.Message);
                    }
                }
                result[0] = new Tuple <int, int>(totalAreas, succesfulAreas);
            }
            catch (ArgumentException e)
            {
                throw new ArgumentException(e.Message);
            }
        }