/// <summary> /// Initializes a new instance of the <see cref="SequenceTransformerController"/> class. /// </summary> public SequenceTransformerController() { db = new LibiadaWebEntities(); dnaSequenceRepository = new GeneticSequenceRepository(db); commonSequenceRepository = new CommonSequenceRepository(db); elementRepository = new ElementRepository(db); }
private IEnumerable <TElement> GetAndWaitWebDriverElements() { var elementWaiter = new ElementWaitService <TDriver, TDriverElement>(); elementWaiter.WaitInternal(_by, new WaitToExistStrategy <TDriver, TDriverElement>()); var nativeElements = _mobileElement == null ? _by.FindAllElements(WrappedDriver) : _by.FindAllElements(_mobileElement); foreach (var nativeElement in nativeElements) { var elementRepository = new ElementRepository(); var wrappedDriver = ServicesCollection.Current.Resolve <TDriver>(); TDriverElement currentNativeElement; if (wrappedDriver is AndroidDriver <AndroidElement> ) { currentNativeElement = (TDriverElement)Activator.CreateInstance(typeof(AndroidElement), wrappedDriver, nativeElement.Id); } else { currentNativeElement = (TDriverElement)Activator.CreateInstance(typeof(IOSElement), wrappedDriver, nativeElement.Id); } yield return(elementRepository.CreateElementThatIsFound <TElement, TBy, TDriver, TDriverElement>(_by, currentNativeElement)); } }
public DataAccessService(TestContext testContext) { _elementRepository = new ElementRepository(testContext); if (_elementRepository.GetAllElements().Count() < 6) { _elementRepository.Add(new ElementDTO { Code = "Test1", Name = "Name 1" }); _elementRepository.Add(new ElementDTO { Code = "Test2", Name = "Name 2" }); _elementRepository.Add(new ElementDTO { Code = "Test3", Name = "Name 3" }); _elementRepository.Add(new ElementDTO { Code = "Test4", Name = "test", Active = true }); _elementRepository.Add(new ElementDTO { Code = "Test5", Name = "test", Active = false }); _elementRepository.Add(new ElementDTO { Code = "Test6", Name = "Name 6", Active = true }); } }
public TElement Create <TElement, TBy>(TBy by) where TBy : FindStrategy where TElement : Element { var elementRepository = new ElementRepository(); return(elementRepository.CreateElementThatIsFound <TElement>(by, null)); }
public void ElementsCanBeCreatedAndAddedToTheRepository() { ElementRepository repository = new ElementRepository(); SUT = new ElementFactory(ModelType.Full3D, repository); Assert.AreEqual(0, repository.Count); SUT.CreateLinearConstantSpring(node1, node2, 2); Assert.AreEqual(1, repository.Count); }
public UnitOfWork() { Items = new ItemRepository(); Merchants = new MerchantRepository(); Monsters = new MonsterRepository(); Routes = new RouteRepository(); Towns = new TownRepository(); Elements = new ElementRepository(); }
public TElement Create <TElement, TBy, TDriver, TDriverElement>(TBy by) where TElement : Element <TDriver, TDriverElement> where TBy : FindStrategy <TDriver, TDriverElement> where TDriver : AppiumDriver <TDriverElement> where TDriverElement : AppiumWebElement { var elementRepository = new ElementRepository(); return(elementRepository.CreateElementThatIsFound <TElement, TBy, TDriver, TDriverElement>(by, null)); }
/// <summary> /// Initializes a new instance of the <see cref="SequenceMixerController"/> class. /// </summary> public SequenceMixerController() { db = new LibiadaWebEntities(); sequenceRepository = new CommonSequenceRepository(db); dnaSequenceRepository = new GeneticSequenceRepository(db); musicSequenceRepository = new MusicSequenceRepository(db); literatureSequenceRepository = new LiteratureSequenceRepository(db); dataSequenceRepository = new DataSequenceRepository(db); elementRepository = new ElementRepository(db); }
public void Setup() { nodeFactory = new NodeFactory(ModelType.Truss2D); node1 = nodeFactory.CreateFor2DTruss(0, 0); node2 = nodeFactory.CreateFor2DTruss(0, 1); node3 = nodeFactory.CreateFor2DTruss(0, 2); SUT = new ElementRepository(); elementFactory = new ElementFactory(ModelType.Truss2D, SUT); spring1 = elementFactory.CreateLinearConstantSpring(node1, node2, 1); spring2 = elementFactory.CreateLinearConstantSpring(node2, node3, 2); }
//***********************************CreateDatabase*********************************** private void CreateDatabase(Document doc, List <Element> Elements, ElementRepository elementRepository, CSVDataRepository cSVDataRepository, string type) { var DictionaryData = GetParameterData(doc, Elements, type); List <string> Parameters = GetCompleteParameters(type); elementRepository.CreateElement(DictionaryData, Parameters); IReadOnlyList <DataElement> dataElement = elementRepository.ReadElement(); cSVDataRepository.Create(dataElement, type); }
private IEnumerable <TElement> GetAndWaitWebDriverElements() { if (_shouldCacheFoundElements && _cachedElements == null) { _cachedElements = GetAndWaitNativeElements().ToList(); } if (_shouldCacheFoundElements && _cachedElements != null) { foreach (var element in _cachedElements) { yield return(element); } } else { foreach (var element in GetAndWaitNativeElements()) { yield return(element); } } IEnumerable <TElement> GetAndWaitNativeElements() { foreach (var foundElement in _foundElements) { yield return(foundElement); } if (_parentElement != null) { var elementRepository = new ElementRepository(); foreach (var nativeElement in _by?.FindAllElements(_parentElement)) { var element = elementRepository.CreateElementThatIsFound <TElement>(_by, (WindowsElement)nativeElement); yield return(element); } } else { var elementRepository = new ElementRepository(); foreach (var nativeElement in _by?.FindAllElements(WrappedDriver)) { var element = elementRepository.CreateElementThatIsFound <TElement>(_by, nativeElement); yield return(element); } } } }
public void GetById_Found_ReturnsItem() { var person = new Mock <ProjectElement>(); person.Setup(p => p.Id).Returns("joe"); using (var tempFolder = new TemporaryFolder("ElementRepoTestFolder")) { var repo = new ElementRepository <ProjectElement>(tempFolder.Path, "elementGroupName", null, (folder, id, idChangedAction) => person.Object); repo.CreateNew("joe"); Assert.AreEqual(person.Object, repo.GetById("joe")); } }
public void CreateNew_WithId_CreatesElement() { var person = new Mock <ProjectElement>(); person.Setup(p => p.Id).Returns("joe"); using (var tempFolder = new TemporaryFolder("ElementRepoTestFolder")) { var repo = new ElementRepository <ProjectElement>(tempFolder.Path, "elementGroupName", null, (folder, id, idChangedAction) => person.Object); repo.CreateNew("joe"); Assert.IsTrue(repo.AllItems.Contains(person.Object)); } }
//***********************************DatabaseExportProgram*********************************** internal DatabaseExportProgram(UIApplication uiapp, UIDocument uidoc, Application app, Document doc) { // Collect model elements CollectRevitModelElements modelElements = new CollectRevitModelElements(); ElementRepository elementRepository = new ElementRepository(); CSVDataRepository cSVDataRepository = new CSVDataRepository(); // Create the structural framing database List <Element> StructuralFramingElements = modelElements.GetStructuralFramingElements(doc); if (StructuralFramingElements != null || StructuralFramingElements.Count > 0) { CreateDatabase(doc, StructuralFramingElements, elementRepository, cSVDataRepository, "Framing"); } // Create the structural column database List <Element> StructuralColumnElements = modelElements.GetStructuralColumnElements(doc); if (StructuralColumnElements != null || StructuralColumnElements.Count > 0) { CreateDatabase(doc, StructuralColumnElements, elementRepository, cSVDataRepository, "Column"); } // Create the structural foundation database List <Element> StructuralFoundationElements = modelElements.GetStructuralFoundationElements(doc); if (StructuralFoundationElements != null || StructuralFoundationElements.Count > 0) { CreateDatabase(doc, StructuralFoundationElements, elementRepository, cSVDataRepository, "Foundation"); } // Create the structural slab database List <Element> SlabElements = modelElements.GetSlabElements(doc); if (SlabElements != null || SlabElements.Count > 0) { CreateDatabase(doc, SlabElements, elementRepository, cSVDataRepository, "Slab"); } // Create the structural wall database List <Element> WallElements = modelElements.GetWallElements(doc); if (WallElements != null || WallElements.Count > 0) { CreateDatabase(doc, WallElements, elementRepository, cSVDataRepository, "Wall"); } }
public IActionResult Home(HomeModel homeModel) { ElementRepository elementRepository = new ElementRepository(); homeModel.ElementModels = elementRepository.SelectElements().Select(m => (ElementModel.ToElementModel(m))).ToList(); OutputStreams.WriteLine($"[HttpPost] Home: {String.Join(", ", homeModel.Symbols)}"); if (ModelState.IsValid == true) { List <Element> elements = homeModel.Symbols.Select(m => (Element.FromString(m))).ToList(); List <WebService> webServices = new List <WebService>(new WebService[] { new AFlowWebService(), new MaterialsProjectWebService() }); List <SearchResult> searchResults = new List <SearchResult>(); OutputStreams.WriteLine($"Elements: {String.Join(", ", elements)}"); foreach (WebService webService in webServices) { try { OutputStreams.WriteLine($"Searching {webService.BaseUrl}..."); List <SearchResult> webServiceSearchResults = webService.Search(elements); OutputStreams.WriteLine($"{webServiceSearchResults.Count} search results"); if (webServiceSearchResults.Count > 0) { searchResults.AddRange(webServiceSearchResults); } } catch (Exception exception) { OutputStreams.WriteLine(); OutputStreams.WriteLine(exception.Message); } } homeModel.SearchResults = searchResults.OrderBy(m => (m.Compound)).ThenByDescending(m => (m.BandGap)).ToList(); } return(View(homeModel)); }
public void GetData() { IElementRepository _ElementRepository; IInnonAnalyticsEngineEntities _dbcontext; _dbcontext = new InnonAnalyticsEngineEntities(); _ElementRepository = new ElementRepository(_dbcontext); IList <ElementDTO> list_element_dto = _ElementRepository.Get_Element_By_Element_Tag_Type(Common.Enums.TagType.point, false); // BlockingCollection<ElementDTO> entityQueue = new BlockingCollection<ElementDTO>(); try { _dbContext = new InnonAnalyticsEngineEntities(); // for (int j = 0; j < list_element_dto.Count(); j++) for (int j = 0; j < 1; j++) { IConnectorRepository _connector_rep = new ConnectorRepository(_dbContext); _dto_connector = _connector_rep.GetExistingConnectionById(list_element_dto[j].ConnectionInfo.ConnectionID); //Task[] taskArray = { Task.Factory.StartNew(() => GetRowsForEachTable(list_element_dto[j])) // //,Task.Factory.StartNew(() => GetRowsForEachTable(list_element_dto[1])) // //,Task.Factory.StartNew(() => GetRowsForEachTable(list_element_dto[2])) // }; Task[] taskArray = { Task.Factory.StartNew(() => { GetRowsForEachTable(list_element_dto[j]); } ) }; } } catch (Exception ex) { this.EventLog.WriteEntry("Error GetData " + "- Error" + ex.Message + " - Inner exception " + ex.InnerException, EventLogEntryType.Error); } }
public void Wait <TUntil, TElement>(TElement element, TUntil until) where TUntil : WaitStrategy where TElement : Element { try { if (element.ParentWrappedElement == null) { WaitInternal(element.By, until); } else { var elementRepository = new ElementRepository(); Element parentElement = elementRepository.CreateElementThatIsFound <Element>(element.By, element.ParentWrappedElement, true); WaitInternal(element.By, until, parentElement); } } catch (Exception ex) { OnElementNotFulfillingWaitConditionEvent?.Invoke(this, new ElementNotFulfillingWaitConditionEventArgs(ex)); throw; } }
/// <summary> /// The index. /// </summary> /// <returns> /// The <see cref="ActionResult"/>. /// </returns> public ActionResult Index() { using (var db = new LibiadaWebEntities()) { var matterRepository = new MatterRepository(db); var dnaSequenceRepository = new GeneticSequenceRepository(db); var commonSequenceRepository = new CommonSequenceRepository(db); var elementRepository = new ElementRepository(db); var matterIds = new long[] { 1332, 1333, 1339, 1330, 1337, 1342, 1331, 1338, 1340, 1943, 1945, 1334 }; DnaSequence[] sequences = db.DnaSequence.Include(d => d.Matter).Where(d => matterIds.Contains(d.MatterId)).ToArray(); for (int i = 0; i < sequences.Length; i++) { var newMatter = new Matter { Name = $"{sequences[i].Matter.Name} Cleaned of IS110", Description = sequences[i].Matter.Description, Nature = sequences[i].Matter.Nature, Group = sequences[i].Matter.Group, SequenceType = sequences[i].Matter.SequenceType }; var newSequence = new CommonSequence { Notation = sequences[i].Notation, Matter = newMatter, Description = sequences[i].Description, RemoteDb = sequences[i].RemoteDb, RemoteId = sequences[i].RemoteId }; var chain = commonSequenceRepository.GetLibiadaChain(sequences[i].Id); matterRepository.CreateOrExtractExistingMatterForSequence(newSequence); dnaSequenceRepository.Create(newSequence, false, elementRepository.ToDbElements(chain.Alphabet, Notation.Nucleotides, false), chain.Building); var sequenceId = sequences[i].Id; var subsequences = db.Subsequence.Include(s => s.Position).Include(s => s.SequenceAttribute).Where(s => s.SequenceId == sequenceId).ToList(); var subsequenceIds = subsequences.Select(s => s.Id); var subsequencesIdsToRemove = db.SequenceAttribute .Where(sa => subsequenceIds.Contains(sa.SequenceId) && sa.Value.Contains("IS110")) .Select(sa => sa.SequenceId) .Distinct() .ToArray(); subsequences.RemoveAll(s => subsequencesIdsToRemove.Contains(s.Id)); var newSubsequences = new Subsequence[subsequences.Count]; var newSequenceAttributes = new List <SequenceAttribute>(); var newPositions = new List <Position>(); for (int j = 0; j < subsequences.Count; j++) { newSubsequences[j] = new Subsequence { Id = db.GetNewElementId(), Feature = subsequences[j].Feature, SequenceId = newSequence.Id, Start = subsequences[j].Start, Length = subsequences[j].Length, RemoteId = subsequences[j].RemoteId, Partial = subsequences[j].Partial }; foreach (SequenceAttribute subsequenceAttribute in subsequences[j].SequenceAttribute.ToArray()) { newSequenceAttributes.Add(new SequenceAttribute { SequenceId = newSubsequences[j].Id, Attribute = subsequenceAttribute.Attribute, Value = subsequenceAttribute.Value }); } foreach (Position position in subsequences[j].Position.ToArray()) { newPositions.Add(new Position { SubsequenceId = newSubsequences[j].Id, Length = position.Length, Start = position.Start }); } } db.Subsequence.AddRange(newSubsequences); db.SequenceAttribute.AddRange(newSequenceAttributes); db.Position.AddRange(newPositions); db.SaveChanges(); } } return(View()); }
public void Setup() { SIL.Reporting.ErrorReport.IsOkToInteractWithUser = false; _tmpFolder = new TemporaryFolder("elementRepoTestFolder"); var peter = new Mock <Person>(); peter.Setup(p => p.Id).Returns("peter"); peter.Setup(p => p.GetComponentFiles()).Returns(new[] { ComponentFileTests.CreateComponentFile(_tmpFolder, peter.Object, "peterSong1.mp3"), ComponentFileTests.CreateComponentFile(_tmpFolder, peter.Object, "peterSong2.mp3"), }); var paul = new Mock <Person>(); paul.Setup(p => p.Id).Returns("paul"); paul.Setup(p => p.GetComponentFiles()).Returns(new[] { ComponentFileTests.CreateComponentFile(_tmpFolder, peter.Object, "paulSong1.mp3"), ComponentFileTests.CreateComponentFile(_tmpFolder, peter.Object, "paulSong2.mp3"), }); var mary = new Mock <Person>(); mary.Setup(p => p.Id).Returns("mary"); mary.Setup(p => p.GetComponentFiles()).Returns(new[] { ComponentFileTests.CreateComponentFile(_tmpFolder, peter.Object, "marySong1.mp3"), ComponentFileTests.CreateComponentFile(_tmpFolder, peter.Object, "marySong2.mp3"), }); _repo = new ElementRepository <Person>(_tmpFolder.Path, Person.kFolderName, new PersonFileType(null, null), (folder, id, idChangedAction) => { switch (id) { case "peter": return(peter.Object); case "paul": return(paul.Object); case "mary": return(mary.Object); } return(null); }); Directory.CreateDirectory(_tmpFolder.Combine(Person.kFolderName, "peter")); Directory.CreateDirectory(_tmpFolder.Combine(Person.kFolderName, "paul")); Directory.CreateDirectory(_tmpFolder.Combine(Person.kFolderName, "mary")); peter.Setup(p => p.FolderPath).Returns(_tmpFolder.Combine(Person.kFolderName, "peter")); paul.Setup(p => p.FolderPath).Returns(_tmpFolder.Combine(Person.kFolderName, "paul")); mary.Setup(p => p.FolderPath).Returns(_tmpFolder.Combine(Person.kFolderName, "mary")); _repo.CreateNew("peter"); _repo.CreateNew("paul"); _repo.CreateNew("mary"); _model = new ElementListViewModel <Person>(_repo); }
public async static void GetData() { IElementRepository _ElementRepository; IDatawareHouseMigrationLogRepository _DatawareHouseMigrationLogRepository; _dbcontext = new InnonAnalyticsEngineEntities(); _ElementRepository = new ElementRepository(_dbcontext); _DatawareHouseMigrationLogRepository = new DatawareHouseMigrationLogRepository(_dbcontext); IList <ElementDTO> list_element_dto = _ElementRepository.Get_Element_By_Element_Tag_Type(Common.Enums.TagType.point, false); //Get all element data migration history from [tblDatawareHouseMigrationLog] IList <DatawareHouseMigrationLogDTO> list_datawaredousemigrationLog_dto = _DatawareHouseMigrationLogRepository.get_Data_Migration_Logs(); Console.WriteLine("Total Table " + list_element_dto.Count(), EventLogEntryType.Information); try { _dbcontext = new InnonAnalyticsEngineEntities(); IConnectorRepository _connector_rep; ConnectorDTO _dto_connector; for (int j = 0; j < list_element_dto.Count(); j++) { default_to_dt = System.DateTime.Now; //One year back datetime //default_from_dt = Convert.ToDateTime(default_to_dt.AddYears(-1).ToShortDateString() + " 00:00:00"); Console.WriteLine(j + "Initialize " + list_element_dto[j].Element_Name); _connector_rep = new ConnectorRepository(_dbcontext); _dto_connector = _connector_rep.GetExistingConnectionById(list_element_dto[j].ConnectionInfo.ConnectionID); //If the element previously run than change the from datetime if (list_datawaredousemigrationLog_dto.Any(element => element.Element_ID == list_element_dto[j].ID)) { DateTime?_timestamp_to = list_datawaredousemigrationLog_dto.Where(element => element.Element_ID == list_element_dto[j].ID).OrderByDescending(t => t.Last_Run_Start).First().Timestamp_To; if (_timestamp_to.HasValue) { default_from_dt = Convert.ToDateTime(_timestamp_to.Value.AddMilliseconds(2).ToString("yyyy-MM-dd,HH:mm:ss.fff")); await Task.Factory.StartNew(() => { GetRowsForEachTable(list_element_dto[j], _dto_connector, j); }); } else { await Task.Run(() => { CheckLastRecordInsterted(list_element_dto[j].ID); }) .ContinueWith((z) => { GetRowsForEachTable(list_element_dto[j], _dto_connector, j); }); } //default_from_dt = Convert.ToDateTime(list_datawaredousemigrationLog_dto.Where(element => element.Element_ID == list_element_dto[j].ID).OrderByDescending(t => t.Last_Run_Start).First().Timestamp_To.AddMilliseconds(2).ToString("yyyy-MM-dd,HH:mm:ss.fff")); } else { // await Task.Factory.StartNew(() => { GetRowsForEachTable(list_element_dto[j]); }); await Task.Run(() => { CheckLastRecordInsterted(list_element_dto[j].ID); }) .ContinueWith((z) => { GetRowsForEachTable(list_element_dto[j], _dto_connector, j); }); } // Task.Run(() => { Delete_Duplicate(list_element_dto[j]); }); //Task[] taskArray = { Task.Factory.StartNew(() => { Delete_Duplicate(list_element_dto[j]); }) }; //Task.WaitAll(taskArray); } } catch (Exception ex) { Helper.WriteToFile("Error GetData " + "- Error" + ex.Message + " - Inner exception " + ex.InnerException); } }
/// <summary> /// Initializes a new instance of the <see cref="ElementFactory" /> class. /// </summary> /// <param name="elementRepository">The repository into which to add the new elements which are created by this factory.</param> internal ElementFactory(ModelType typeOfModel, ElementRepository elementRepository) { this.ModelType = typeOfModel; this.repository = elementRepository; }
public IActionResult Home() { ElementRepository elementRepository = new ElementRepository(); return(View(new HomeModel(elementRepository.SelectElements().Select(m => (ElementModel.ToElementModel(m))).ToList()))); }
public ExportPeoplCommand(ElementRepository <Person> people) : base("exportPeople", people.AllItems.ToArray()) { }
public ElementController(ElementRepository elementRepository) { _elementRepository = elementRepository; }
/// ------------------------------------------------------------------------------------ public ElementListViewModel(ElementRepository <T> repository) { _repository = repository; }
public void GetById_NotFound_ReturnsNull() { var repo = new ElementRepository <ProjectElement>(); Assert.IsNull(repo.GetById("foo")); }
public void TestSetup() { s_componentRoles = ApplicationContainer.ComponentRoles; _sessionRepo = GetMockedSessionRepo(); _informant = new SessionWorkflowInformant(_sessionRepo, s_componentRoles); }
/// <summary> /// Initializes a new instance of the <see cref="SequenceElementsController"/> class. /// </summary> public SequenceElementsController() { db = new LibiadaWebEntities(); elementRepository = new ElementRepository(db); sequenceRepository = new CommonSequenceRepository(db); }
public ExportSessionsCommand(ElementRepository <Session> sessions) : base("exportSessions", sessions.AllItems.ToArray()) { }
static void Main(string[] args) { try { Console.WriteLine("Initialization...... "); //Aggregate_Save obj = new Aggregate_Save(); //obj.Update_Hour_Aggregation(3628); // Interpolation.Get_Previous_and_Next_Good_Value(DateTime.Parse("2015-09-01 00:30:00"), 3575); //data_staus is used for the interpoliation of data string[] data_status = ConfigurationManagerHelper.AppSettings["bad_data_status"].ToString().Split(','); InnonAnalyticsEngineEntities _dbcontext = new InnonAnalyticsEngineEntities(); IElementRepository _ElementRepository = new ElementRepository(_dbcontext); //Get All Elements from the tblElement where Elemet Type is point (point has data) IList <ElementDTO> list_element_dto = _ElementRepository.Get_Element_By_Element_Tag_Type(Common.Enums.TagType.point, false); //list_element_dto = list_element_dto.Where(e => e.ID == 2366).ToList(); //GenerateMissingData(list_element_dto[0]); ITagRepository _TagRepository = new TagRepository(_dbcontext); //Get All non deleted tag type mapping IList <Tag_Type_Mapping_DTO> list_tag_type_dto = _TagRepository.Get_Tag_Type_Mapping(false); Console.WriteLine("Updating point dim "); IPoint_Dim_Service _Point_dim_service = new Point_Dim_Service(); _Point_dim_service.Update_Point_Dim(list_element_dto, list_tag_type_dto); Console.WriteLine("Start Data Migration "); IDatawareHouseMigrationLogRepository _DatawareHouseMigrationLogRepository = new DatawareHouseMigrationLogRepository(_dbcontext); //Get all element data migration history from [tblDatawareHouseMigrationLog] IList <DatawareHouseMigrationLogDTO> list_datawaredousemigrationLog_dto = _DatawareHouseMigrationLogRepository.get_Data_Migration_Logs(); //Creat an arry of tasks, Number of Point element found in tblElement table Task[] taskArray = new Task[list_element_dto.Count]; DateTime starttime = DateTime.Now; Console.WriteLine("Start " + starttime); //Initialize Connector Repository for getting the data connection info of each table IConnectorRepository _connector_rep = _connector_rep = new ConnectorRepository(_dbcontext); ConnectorDTO _dto_connector = new ConnectorDTO(); //running loop on each task in the task array () for (int i = 0; i < taskArray.Length; i++) { DateTime default_from_dt, default_to_dt = System.DateTime.Now;; taskArray[i] = Task.Factory.StartNew(() => { try { //First Step get database or data connector information of each points //The connection info is same as the previous we will not get the connector info again if (_dto_connector.ConnectionID != list_element_dto[i].ConnectionInfo.ConnectionID) { _dto_connector = _connector_rep.GetExistingConnectionById(list_element_dto[i].ConnectionInfo.ConnectionID); } //Console.WriteLine("No." + i + " " + _dto_connector.ConnectionID + " -- " + _dto_connector.ConnectionName); //Sec Step set from_date and to_date //If the element is not runing first time than change the from datetime (get last run datetime), All log save in the tbldatawaredousemigrationLog if (list_datawaredousemigrationLog_dto.Any(element => element.Element_ID == list_element_dto[i].ID)) { DateTime?_timestamp_to = list_datawaredousemigrationLog_dto.Where(element => element.Element_ID == list_element_dto[i].ID).OrderByDescending(t => t.Last_Run_Start).First().Timestamp_To; if (_timestamp_to.HasValue) { default_from_dt = Convert.ToDateTime(_timestamp_to.Value.AddMilliseconds(2).ToString("yyyy-MM-dd,HH:mm:ss.fff")); // GetRowsForEachTable(list_element_dto[j], _dto_connector, j); } else { default_from_dt = CheckLastRecordInsterted(list_element_dto[i].ID); // GetRowsForEachTable(list_element_dto[j], _dto_connector, j); } } else { default_from_dt = CheckLastRecordInsterted(list_element_dto[i].ID); //GetRowsForEachTable(list_element_dto[j], _dto_connector, j); } Console.WriteLine("No." + i + " " + list_element_dto[i].ID + " " + default_from_dt + " -- " + default_to_dt); //End sec //Third Get Raw Data; IList <RawDataDTO> list_RawDataDTO = new List <RawDataDTO>(); list_RawDataDTO = GetRawData(list_element_dto[i], default_from_dt, default_to_dt, _dto_connector, _dbcontext); //End Get Raw Data Console.WriteLine("Total Records " + list_RawDataDTO.Count()); //Save DataMirgrationLog tblDatawareHouseMigrationLog tbldatamigrationlog = SaveDataMigrationLog(list_element_dto[i], default_to_dt); //End if (list_RawDataDTO.Count > 0) { //Get Convert Raw data in to Point_Mesaure_Fact_DTO IList <Point_Measure_Fact> point_measure_fact_list_dto = Convert_Raw_Data_To_Point_Measure_Fact_DTO(list_element_dto[i], list_RawDataDTO); //End //Saving in to the Datawarehouse table Point_Measure_Fact Final_Insert_In_To_DatawareHouse_Table(point_measure_fact_list_dto); //End //Update DataMirgrationLog if (point_measure_fact_list_dto.Count > 0) { UpdateDataMigrationLog(tbldatamigrationlog, point_measure_fact_list_dto.Count(), point_measure_fact_list_dto.LastOrDefault().Timestamp_From); } //End } //Aggregation //Task aggregationtask = GetAggregation(list_element_dto[i]); //EndAggregation Console.WriteLine("Missing Data " + list_element_dto[i].Source_Element_Name_History); try { //Get Raw missing data if any thing accedently during the process than we need to get the missing data IList <RawDataDTO> list_Mising_RawDataDTO = GetRawMissingData(list_element_dto[i], _dto_connector); Console.WriteLine("Get Missing Data " + list_Mising_RawDataDTO.Count); if (list_Mising_RawDataDTO.Count > 0) { //Get Convert Raw data in to Point_Mesaure_Fact_DTO IList <Point_Measure_Fact> missing_point_measure_fact_list_dto = Convert_Raw_Data_To_Point_Measure_Fact_DTO(list_element_dto[i], list_Mising_RawDataDTO); //End //Saving in to the Datawarehouse table Point_Measure_Fact Final_Insert_In_To_DatawareHouse_Table(missing_point_measure_fact_list_dto); //End } //End End of Raw missing data saving } catch (Exception ex) { Console.WriteLine("Error in Missing Data " + ex.Message); } Console.WriteLine("Generate Missing Data "); try { IList <RawDataDTO> list_Genrated_Mising_RawDataDTO = GenerateMissingData(list_element_dto[i]); //Get Convert Raw data in to Point_Mesaure_Fact_DTO IList <Point_Measure_Fact> genrated_missing_point_measure_fact_list_dto = Convert_Raw_Data_To_Point_Measure_Fact_DTO(list_element_dto[i], list_Genrated_Mising_RawDataDTO); //End //Saving in to the Datawarehouse table Point_Measure_Fact Final_Insert_In_To_DatawareHouse_Table(genrated_missing_point_measure_fact_list_dto); //End } catch (Exception ex) { Helper.WriteToFile(ex.Message); } try { //Console.WriteLine("Deleting Data " + list_element_dto[i].Source_Element_Name_History); //Deleting Any Duplication Delete_Duplicate(list_element_dto[i]); //End } catch (Exception ex) { Console.WriteLine("Error in Delete duplicate Data " + ex.Message); } try { //Check interpolation Console.WriteLine("Interpolation"); bool Is_Read_For_Aggregation = Interpolation.InterPolateData(default_from_dt, default_to_dt, list_element_dto[i]); Console.WriteLine("End Interpolation"); //End Interpolation if (Is_Read_For_Aggregation) { Console.WriteLine("Aggregate Data Migration "); IAggregation_Service agr_service = new Aggregation_Service(); agr_service.Calculate_and_Save_Aggregation_WareHouse_By_ElementID(list_element_dto[i].ID); Console.WriteLine("End Aggregate Data Migration "); } } catch (Exception ex) { Console.WriteLine("Error in Aggregation Data " + ex.Message); } // aggregationtask.Wait(); } catch (Exception ex) { Console.WriteLine("Exception " + ex.Message); } }); taskArray[i].Wait(); } Console.WriteLine("End Min " + DateTime.Now.Subtract(starttime).TotalMinutes); Console.WriteLine("End Sec " + DateTime.Now.Subtract(starttime).TotalSeconds); Helper.WriteToFile("Finished Start Time " + starttime + ", End Time " + System.DateTime.Now + " -- " + " Total Min " + DateTime.Now.Subtract(starttime).TotalMinutes); } catch (Exception ex) { Console.WriteLine("Exception in mian " + ex.Message); } //Console.ReadLine(); }
public ElementsController(ElementRepository repo) { _repo = repo; }