internal SubjectResp AddSubjectAction(SubjectData subject, int c_id, int t_id) { using (var db = new ForumContext()) { Forum category; category = (from e in db.Forum where e.CategoryID == c_id select e).Include(d => d.Topics).FirstOrDefault(); FTopic topic; topic = (from e in category.Topics where e.TopicID == t_id select e).FirstOrDefault(); if (topic.Subjects == null) { topic.Subjects = new List <FSubject>(); } var sub = new FSubject() { Title = subject.Title, Text = subject.Text }; topic.Subjects.Add(sub); db.Entry(category).State = EntityState.Modified; db.SaveChanges(); } return(new SubjectResp()); }
public async Task AddSubject(Subject subject) { var subjectData = new SubjectData { SubjectDataId = subject.Id, Name = subject.Name }; foreach (var student in subject.Students) { var studentData = await _database.Students.SingleAsync(data => data.StudentDataId == student.Id.ToString()); subjectData.StudentSubjectData.Add(new StudentSubjectData { StudentDataId = studentData.StudentDataId, StudentData = studentData, SubjectDataId = subject.Id, SubjectData = subjectData }); } await _database.Subjects.AddAsync(subjectData); _database.SaveChanges(); }
internal TopicData GetTopicDataApi(int id) { var local = new TopicData { Subjects = new List <SubjectData>() }; using (ForumContext db = new ForumContext()) { FTopic topic; topic = (from e in db.Topic where e.TopicID == id select e).Include(d => d.Subjects).FirstOrDefault(); local.TopicID = topic.TopicID; local.Title = topic.Title; foreach (var sub in topic.Subjects) { var s = new SubjectData { SubjectID = sub.SubjectID, Title = sub.Title, Author = sub.Author, Text = sub.Text }; local.Subjects.Add(s); } } return(local); }
public SubjectData Get(int id) { SubjectData sub = new SubjectData(); sub = CPManagementService.GetSubject(id); return(sub); }
Validate(SubjectData subjectData, ExecutionContext executionContext, ImportMessage message) { _logger.LogInformation($"Validating: {message.DataFileName}"); await _importStatusService.UpdateStatus(message.Release.Id, message.DataFileName, IStatus.STAGE_1); return(await ValidateCsvFile(subjectData.DataBlob, false) .OnSuccessDo(async() => await ValidateCsvFile(subjectData.MetaBlob, true)) .OnSuccess( async() => { await using var dataFileStream = await _fileStorageService.StreamBlob(subjectData.DataBlob); var dataFileTable = DataTableUtils.CreateFromStream(dataFileStream); await using var metaFileStream = await _fileStorageService.StreamBlob(subjectData.MetaBlob); var metaFileTable = DataTableUtils.CreateFromStream(metaFileStream); return await ValidateMetaHeader(metaFileTable.Columns) .OnSuccess(() => ValidateMetaRows(metaFileTable.Columns, metaFileTable.Rows)) .OnSuccess(() => ValidateObservationHeaders(dataFileTable.Columns)) .OnSuccess( () => ValidateAndCountObservations(dataFileTable.Columns, dataFileTable.Rows, executionContext, message.Release.Id, message.DataFileName) .OnSuccess( result => { _logger.LogInformation( $"Validating: {message.DataFileName} complete"); return result; } ) ); })); }
public IHttpActionResult Update(SubjectModel subject) { u = credenciales.getUsuario(); c = credenciales.getUsuario(); var consulta = SubjectData.Actualizar(subject.SubjectId, subject.Clave, subject.Nombre, subject.Creditos, subject.CarreraId, subject.EspecialidadId, u); return(Ok(consulta)); }
public IHttpActionResult ShowCareer() { u = credenciales.getUsuario(); c = credenciales.getUsuario(); var consulta = SubjectData.ObtenerCarrera(u); return(Ok(consulta)); }
public IHttpActionResult Showspeciality() { u = credenciales.getUsuario(); c = credenciales.getUsuario(); var consulta = SubjectData.ObtenerEspecialidad(u); return(Ok(consulta)); }
public CoursesController(ELearningPlatformContext context) { _context = context; _coursesData = new CoursesData(_context); _usersData = new UsersData(_context); _moduleData = new ModuleData(_context); _subjectData = new SubjectData(_context); }
} = true; //space out sample requests so they don't all fall on the same 'tick' public void Add(ISampleSubject subject, int interval, int sampleSize, SamplingOptions samplingOptions = SamplingOptions.MEAN_COUNT, int intervalDeviation = -1) { if (!_subjects2data.ContainsKey(subject)) { SubjectData sd = new SubjectData(subject, interval, sampleSize, samplingOptions, intervalDeviation); _subjects2data[subject] = sd; } }
public IHttpActionResult Show() { u = credenciales.getUsuario(); c = credenciales.getUsuario(); var consulta = SubjectData.Mostrar(u); return(Ok(consulta)); }
/// <summary> /// Initializes a new instance of the <see cref="RwsSubjectListItem"/> class. /// </summary> /// <param name="clinData">The clinical data.</param> public RwsSubjectListItem(ClinicalData clinData) { StudyOid = clinData.StudyOID; MetadataVersionOid = clinData.MetaDataVersionOID; SubjectData = clinData.SubjectData.First(); SubjectKey = SubjectData.SubjectKey; SiteRef = SubjectData.SiteRef; LocationOid = SiteRef.LocationOID; }
//если будет добавляться логика, необходимо будет разнести для простоты тестов private async Task <TableDataResponse> CreateResponseAsync(List <Route> routes, List <Subject> subjects, List <FederalDistrict> fedDistrics) { var response = new TableDataResponse(); var cityNames = await GetCityNamesDictAsync(routes); foreach (var fedDist in fedDistrics) { var fedData = new FederalDistrictData { Name = fedDist.Name }; foreach (var subj in subjects.Where(x => x.ParentRegionId == fedDist.Id)) { var subjData = new SubjectData { Name = subj.Name }; foreach (var route in routes.Where(x => x.ParentRegionId == subj.Id)) { subjData.InsideRegionData.Add(new InsideRegionData { CityFrom = cityNames[route.CityFromId], CityTo = cityNames[route.CityToId], HiddenId = route.Id, MenAdult = route.MenAdult, MenKid = route.MenKid, MenSenior = route.MenSenior, WomenAdult = route.WomenAdult, WomenKid = route.WomenKid, WomenSenior = route.WomenSenior }); } subjData.MenAdult = subjData.InsideRegionData.Sum(x => x.MenAdult); subjData.MenKid = subjData.InsideRegionData.Sum(x => x.MenKid); subjData.MenSenior = subjData.InsideRegionData.Sum(x => x.MenSenior); subjData.WomenAdult = subjData.InsideRegionData.Sum(x => x.WomenAdult); subjData.WomenKid = subjData.InsideRegionData.Sum(x => x.WomenKid); subjData.WomenSenior = subjData.InsideRegionData.Sum(x => x.WomenSenior); fedData.SubjectData.Add(subjData); } fedData.MenAdult = fedData.SubjectData.Sum(x => x.MenAdult); fedData.MenKid = fedData.SubjectData.Sum(x => x.MenKid); fedData.MenSenior = fedData.SubjectData.Sum(x => x.MenSenior); fedData.WomenAdult = fedData.SubjectData.Sum(x => x.WomenAdult); fedData.WomenKid = fedData.SubjectData.Sum(x => x.WomenKid); fedData.WomenSenior = fedData.SubjectData.Sum(x => x.WomenSenior); response.FederalDistrictData.Add(fedData); } return(response); }
public ActionResult AddSubject(PSubjectData subject) { var new_subject = new SubjectData() { Title = subject.Title }; //_forum.AddSubject(new_subject); return(RedirectToAction("Index", "Topic")); }
public static void Add2List(this SubjectData subjectData, ref List <SubjectData> subjectDataList) { if (subjectData.IsNotNull()) { if (subjectDataList == null) { subjectDataList = new List <SubjectData>(); } subjectDataList.Add(subjectData); } }
public static bool HasAnySubjectEntityAncestorInAnySubsents(this SubjectData subjectData, IEnumerable <XElement> subsents) { foreach (var se in subjectData.SubjectEssences) { if (se.Entity.Ancestors().Intersect(subsents).Any()) { return(true); } } return(false); }
public List <double> GetSubjectSamples(ISampleSubject subject) { if (!_subjects2data.ContainsKey(subject)) { return(null); } SubjectData sd = _subjects2data[subject]; return(sd.Samples); }
public SubjectData GetSubjectData(ISampleSubject subject) { if (!_subjects2data.ContainsKey(subject)) { return(null); } SubjectData sd = _subjects2data[subject]; return(sd); }
public string Predict(SubjectData subjectData) { if (model == null) { Train(); } var prediction = model.Predict(subjectData); return(prediction.PredictedLabels); }
public DataTable GetAllCombo() { try { SubjectData dao = new SubjectData(); return(dao.GetAllCombo()); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return(null); }
public ActionResult AddSubject(PostData subject) { var id = 1; var new_subject = new SubjectData() { Title = "Primul subiect", Text = "blablabla" }; _forum.AddSubject(new_subject, id, 1); return(RedirectToAction("Index", "Topic")); }
public DataTable GetSOTIET(string maMh) { try { SubjectData dao = new SubjectData(); return(dao.GetSOTIET(maMh)); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return(null); }
public double ProvideSample(ISampleSubject subject, double sample, long interval = -1) { if (!_subjects2data.ContainsKey(subject)) { return(0); } SubjectData sd = _subjects2data[subject]; sd.AddSample(sample, interval); SampleProvided?.Invoke(this, subject); return(sd.Average); }
private SubjectData ParseDataSource(string line) { string[] components = line.Split('\t'); SubjectData ret = new SubjectData(); ret.SubjectName = components[0]; ret.AStar = Convert.ToSingle(components[1]); ret.A = Convert.ToSingle(components[2]); ret.B = Convert.ToSingle(components[3]); ret.C = Convert.ToSingle(components[4]); ret.D = Convert.ToSingle(components[5]); ret.E = Convert.ToSingle(components[6]); ret.Other = Convert.ToSingle(components[7]); ret.Students = Convert.ToInt32(components[8]); return(ret); }
public SubjectData GetSubject(int id) { SubjectData sub = new SubjectData(); Subject subject = new Subject(); using (var repositoriesContainer = new LmPlatformRepositoriesContainer()) { subject = repositoriesContainer.SubjectRepository.GetBy(new Query <Subject>(e => e.Id == id) .Include(e => e.SubjectGroups)); } sub.Id = subject.Id; sub.Name = subject.Name; sub.ShortName = subject.ShortName; return(sub); }
public void AddDataToFile(SubjectData subjectData, string subjectClass) { try { string line = ""; using (var fs = new FileStream(this.dataPath, FileMode.Open, FileAccess.Read)) { using (StreamReader r = new StreamReader(fs)) { while ((line = r.ReadLine()) != null) { if (line.Contains(subjectClass) && line.Contains(subjectData.SubjectName)) { r.Close(); fs.Close(); return; } } r.Close(); } fs.Close(); } using (var fs = new FileStream(this.dataPath, FileMode.Append, FileAccess.Write)) { using (StreamWriter w = new StreamWriter(fs)) { line = "0," + subjectClass + "," + subjectData.SubjectName; w.WriteLine(line); w.Flush(); w.Close(); } fs.Close(); } Task.Run(() => { Train(); }); } catch (Exception x) { throw x; } }
public ActionResult GetSubjectBacklogs(string YearOfJoining, string Department, string Year, string Semester, string Section, string SubjectName) { SubjectData subjectData = new SubjectData(); // List<SubjectDataPerSem> subjectDataPerSem = new List<SubjectDataPerSem>(); int yoj; int year; int sem; if (int.TryParse(YearOfJoining, out yoj) && int.TryParse(Year, out year) && int.TryParse(Semester, out sem)) { try { using (DataContext dbcontext = context) { List <SubjectDataPerSem> subjectDataPerSem = (from stu in dbcontext.Students join m in dbcontext.Marks on stu.Id equals m.StudentId join sub in dbcontext.Subject on m.SubjectId equals sub.Id join std in dbcontext.Standard on m.StandardId equals std.Id where stu.Yearofjoin == yoj && std.Year == year && stu.Dept == Department && std.Sem == sem && stu.Section == Section && sub.Name == SubjectName && m.Grade.ToLower() == "f" group new { m, stu, std, sub } by stu.Hallticket into joined select new SubjectDataPerSem { HallTicket = joined.Min(x => x.stu.Hallticket), GradeInSubject = joined.Min(x => x.m.Grade), GradePointInSubject = joined.Min(x => x.m.GradePoint), }).ToList <SubjectDataPerSem>(); if (subjectDataPerSem.Count() > 0) { double TotalAverage = subjectDataPerSem.Average((x) => x.GradePointInSubject); subjectData.TotalAverage = TotalAverage; subjectData.subjectDataPerSem = subjectDataPerSem; } } } catch (Exception ex) { return(Ok(new { mess = ex.Message })); } } return(Ok(new { data = subjectData })); }
public async Task SplitDataFile( ImportMessage message, SubjectData subjectData) { await using var dataFileStream = await _fileStorageService.StreamBlob(subjectData.DataBlob); var dataFileTable = DataTableUtils.CreateFromStream(dataFileStream); if (dataFileTable.Rows.Count > message.RowsPerBatch) { _logger.LogInformation($"Splitting Datafile: {message.DataFileName}"); await SplitFiles(message, subjectData, dataFileTable); _logger.LogInformation($"Split of Datafile: {message.DataFileName} complete"); } else { _logger.LogInformation($"No splitting of datafile: {message.DataFileName} was necessary"); } }
private async Task ProcessSubject( ImportMessage message, StatisticsDbContext statisticsDbContext, ContentDbContext contentDbContext, SubjectData subjectData) { var subject = _releaseProcessorService.CreateOrUpdateRelease(subjectData, message, statisticsDbContext, contentDbContext); await using var metaFileStream = await _fileStorageService.StreamBlob(subjectData.MetaBlob); var metaFileTable = DataTableUtils.CreateFromStream(metaFileStream); _importerService.ImportMeta(metaFileTable, subject, statisticsDbContext); await statisticsDbContext.SaveChangesAsync(); await _fileImportService.ImportFiltersAndLocations(message, statisticsDbContext); await statisticsDbContext.SaveChangesAsync(); }
public Subject CreateOrUpdateRelease(SubjectData subjectData, ImportMessage message, StatisticsDbContext statisticsDbContext, ContentDbContext contentDbContext) { var theme = CreateOrUpdateTheme(message, statisticsDbContext).Result; var topic = CreateOrUpdateTopic(message, statisticsDbContext, theme).Result; var publication = CreateOrUpdatePublication(message, statisticsDbContext, topic).Result; var release = CreateOrUpdateRelease(message, statisticsDbContext, publication).Result; RemoveSubjectIfExisting(message, statisticsDbContext); var subject = CreateSubject(message.SubjectId, subjectData.DataBlob.FileName, subjectData.Name, release, statisticsDbContext); if (!UpdateReleaseFileReferenceLinks(message, contentDbContext, release, subject)) { throw new Exception( "Unable to create release file links when importing : Check file references are correct"); } return(subject); }
void Start() { // Build base trial list int[,] trials = new int[totalTrials,tasksPerTrial]; int trialIndex = 0; for (int i = 0; i < totalTrials; i++) { for (int j = 0; j < tasksPerTrial; j++) { trials[i,j] = trialIndex; trialIndex++; } } // Randomize trial order System.Random r = new System.Random(); for (int i = totalTrials - 1; i > 0; i--) { int j = r.Next(i + 1); // Debug.Log("swapping trial " + i + " with trial " + j); for (int k = 0; k < tasksPerTrial; k++) { int temp = trials[i,k]; trials[i,k] = trials[j,k]; trials[j,k] = temp; } } // Randomize task order for (int i = 0; i < totalTrials; i++) { // Debug.Log ("randomizing trial " + i); for (int j = tasksPerTrial - 1; j > 0; j--) { int k = r.Next (j + 1); // Debug.Log("swapping task " + j + " with task " + k); int temp = trials[i,j]; trials[i,j] = trials[i,k]; trials[i,k] = temp; } } // Flatten ordering and save in trialList trialList = new int[totalTrials * tasksPerTrial]; for (int i = 0; i < totalTrials; i++) { for (int j = 0; j < tasksPerTrial; j++) { int index = i * tasksPerTrial + j; trialList[index] = trials[i,j]; } } // Setup subject data subjectData = CreateEmptySubjectData(tasksPerTrial * totalTrials); }