protected void ddlProject_SelectedIndexChanged(object sender, EventArgs e) { var currentProject = ddlProject.Text.ToString(); using (var Dc = new NatalieDbDataContext()) { var currentProjectID = (from pr in Dc.Projects where pr.ClientDescription + ' ' + pr.SetName == currentProject.ToString() select pr.ID).FirstOrDefault(); userproject["ProjectID"] = currentProjectID.ToString(); } }
protected void DisplayProjectList() { var availableProjects = new List <ListItem>(); using (var Dc = new NatalieDbDataContext()) { var currUser = (from u in Dc.Users where u.EmailAddress == Email select u).FirstOrDefault(); userproject["UserID"] = currUser.ID.ToString(); var userName = currUser.FullName; var userRole = currUser.IsAdmin; var existingDatabases = Dc.ExecuteQuery <string>("select name from sys.databases").ToList(); IEnumerable <UserProject> up = currUser.UserProjects; IEnumerable <Project> p = Dc.Projects; if (!userRole) { up = up.Where(dp => dp.GroupID == Group.ExportAdminGroup || dp.GroupID == Group.ExportUserGroup && existingDatabases.Contains(dp.Project.DatabaseName)) .Select(dp => dp); availableProjects = up.Select(dp => new ListItem { Text = dp.Project.ClientDescription + " " + dp.Project.SetName }).Distinct().ToList(); } else { p = p.Where(dp => existingDatabases.Contains(dp.DatabaseName)) .Select(dp => dp); availableProjects = p.Select(dp => new ListItem { Text = dp.ClientDescription + " " + dp.SetName }).Distinct().ToList(); } ddlProject.Items.Insert(0, new DevExpress.Web.ASPxEditors.ListEditItem { Text = "--Select a Model--", Value = string.Empty }); foreach (ListItem ap in availableProjects) { ddlProject.Items.Add(new DevExpress.Web.ASPxEditors.ListEditItem { Text = ap.ToString(), Value = ap.ToString() }); } } }
public ColumnProperty(NatalieDbDataContext parentContext, bool initialize = true) { ParentContext = parentContext; Initialize = initialize; InitEntity(); }
public override void Run() { State = WorkerState.Working; _parsedSkuExclusions = ParseSkuInclusionAndExclusions(SkuExclusions); _parsedSkuInclusions = ParseSkuInclusionAndExclusions(SkuInclusions); _delimiter = FieldDelimiter.GetDbValue().ToString(); //Create new context _currentDb = new NatalieDbDataContext(); var dlo = new DataLoadOptions(); dlo.LoadWith <TaxonomyInfo>(taxonomyInfo => taxonomyInfo.TaxonomyDatas); dlo.LoadWith <EntityInfo>(entityInfo => entityInfo.EntityDatas); dlo.LoadWith <SchemaInfo>(schemaInfo => schemaInfo.SchemaDatas); //dlo.AssociateWith<TaxonomyInfo>(taxonomyInfo => taxonomyInfo.TaxonomyDatas.Where(p => p.Active)); dlo.AssociateWith <EntityInfo>(entityInfo => entityInfo.EntityDatas.Where(p => p.Active)); dlo.AssociateWith <SchemaInfo>(schemaInfo => schemaInfo.SchemaDatas.Where(p => p.Active)); //dlo.AssociateWith<TaxonomyInfo>(taxonomyInfo => taxonomyInfo.SkuInfos.Where(p => p.Active)); _currentDb.LoadOptions = dlo; _currentDb.CommandTimeout = 2000; _currentDb.Connection.Open(); _currentDb.Connection.ChangeDatabase(NatalieTools.Instance.InstanceData.Dc.Connection.Database); _separator = NatalieTools.Instance.InstanceData.CurrentProject.ListSeparator; StatusMessage = "Init"; var fi = new FileInfo(ExportFileName); _baseFileName = fi.FullName.Replace(fi.Extension, string.Empty); //_taxonomyFile = new StreamWriter(_baseFileName + "_Classification.txt", false, Encoding.UTF8); //_taxonomyFile.WriteLine("ItemId{0}New Taxonomy{0}Node Type{0}Old Taxonomy", _delimiter); var exportTaxonomyIds = Taxonomies.Cast <ExtendedTaxonomyInfo>().Select(p => p.Taxonomy.ID).Distinct().ToList(); var exportTaxonomies = _currentDb.TaxonomyInfos.Where(p => exportTaxonomyIds.Contains(p.ID)).ToList(); var allExportTaxonomies = exportTaxonomies.SelectMany(p => p.AllChildren2).Union(exportTaxonomies).Distinct().ToList(); var exportGroups = allExportTaxonomies.GroupBy(GetTaxPrefix).ToList(); CurrentProgress = 0; MaximumProgress = exportGroups.Count(); foreach (var grp in exportGroups) { WriteTaxonomyToFile(grp.Select(g => g), grp.Key); CurrentProgress++; } //_taxonomyFile.Close(); StatusMessage = "Done!"; State = WorkerState.Ready; }