public static void Load(String path) { if (File.Exists(path)) { Map.Clear(); string line = String.Empty; using (StreamReader sr = new StreamReader(path)) { while ((line = sr.ReadLine()) != null) { if (String.IsNullOrWhiteSpace(line)) { continue; } int separator = line.IndexOf("=>"); if (separator == -1) { MessageBox.Show("Invalid Category Mapping format: " + line); } String originalCategory = line.Substring(0, separator).ToLower().Trim(); String newCategory = line.Substring(line.IndexOf("=>") + 2).Trim(); CategoryMap cm = new CategoryMap(originalCategory, newCategory); if (Map.ContainsKey(originalCategory) == false) { Map.Add(originalCategory, cm); } } } } }
protected void AddTest(Test Test) { this.Test = Test; Test.PrepareFinalize(); Test.CategoryList.ForEach(x => { if (!CategoryMap.ContainsKey(x.Name)) { CategoryMap.Add(x.Name, new List <Test>() { Test }); } else { CategoryMap[x.Name].Add(Test); } }); _reporterList.ForEach(x => x.AddTest()); UpdateReportStatus(Test.Status); }
public BuildCompressedMetaBlock(MetaBlock.Compressed metaBlock) { InitializeComponent(); var blocks = new CategoryMap <BlockSwitchTrackerCustom>(category => new BlockSwitchTrackerCustom(metaBlock, category, allItems)); var data = metaBlock.Data; foreach (var command in data.InsertCopyCommands) { blocks[Category.InsertCopy].Advance(); for (int literal = 0; literal < command.Literals.Count; literal++) { blocks[Category.Literal].Advance(); } if (command.CopyDistance.HasExplicitDistanceCode()) { blocks[Category.Distance].Advance(); } allItems.Add(new InsertCopyCommandItem(command, allItems.Count + 1)); } SuspendLayout(); checkBoxInsertCopy.Text = $"Insert&&Copy ({data.InsertCopyCommands.Count})"; checkBoxBlockSwitchL.Text = $"Block-Switch/L ({data.BlockSwitchCommands[Category.Literal].Count})"; checkBoxBlockSwitchI.Text = $"Block-Switch/I ({data.BlockSwitchCommands[Category.InsertCopy].Count})"; checkBoxBlockSwitchD.Text = $"Block-Switch/D ({data.BlockSwitchCommands[Category.Distance].Count})"; RefreshItems(); ResumeLayout(true); }
public void UpdateCategory(int deviceId, CategoryModel category) { if (category != null) { RootRepository.SecurityRepository.AssertDevicePermissions(deviceId); Rp.ExecuteAction(() => { CategoryMap categoryMap = (from cm in Context.CategoryMaps.Where(cm2 => cm2.IsActive) where cm.FKChildCategory == category.PKID && cm.FKParentCategory == null select cm).FirstOrDefault(); if (categoryMap != null) { HotelCategoryMap hotelCategoryMap = (from hcm in Context.HotelCategoryMaps.Where(hcm2 => hcm2.IsActive) where hcm.FKDevice == deviceId && hcm.FKCategoryMap == categoryMap.PKID select hcm).FirstOrDefault(); if (hotelCategoryMap != null) { hotelCategoryMap.FKImage = category.Image.PKID; Context.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId); } } }); } }
public int?GetCategory(int category) { if (CategoryMap.ContainsKey(category)) { return(CategoryMap[category]); } return(null); }
public void CanGenerateXmlMapping() { CategoryMap categoryMap = new CategoryMap(); XmlDocument xml = categoryMap.Generate(); StringWriter sw = new StringWriter(); XmlTextWriter xw = new XmlTextWriter(sw); xml.WriteTo(xw); Debug.WriteLine(sw.ToString()); }
public override void ChangeCategory(UIElement elem) { foreach (var btn in CategoryMap.Keys) { btn.Selected = false; } InventoryButton.Selected = false; UIButton button = (UIButton)elem; button.Selected = true; SetMode((elem == InventoryButton) ? 2 : 1); if (elem == InventoryButton) { if (CurrentCategory != CurrentInventory && LotController.ObjectHolder.DonateMode) { UIAlert.Alert(GameFacade.Strings.GetString("f114", "2"), GameFacade.Strings.GetString("f114", "3"), true); } CurrentCategory = CurrentInventory; } else { if (!CategoryMap.ContainsKey(button)) { return; } CurrentCategory = UICatalog.Catalog[CategoryMap[button]]; } Catalog.SetCategory(CurrentCategory); int total = Catalog.TotalPages(); OldSelection = -1; ProductCatalogSlider.MaxValue = total - 1; ProductCatalogSlider.Value = 0; InventoryCatalogRoommateSlider.MaxValue = total - 1; InventoryCatalogRoommateSlider.Value = 0; InventoryCatalogVisitorSlider.MaxValue = total - 1; InventoryCatalogVisitorSlider.Value = 0; ProductCatalogNextPageButton.Disabled = (total == 1); InventoryCatalogRoommateNextPageButton.Disabled = (total == 1); InventoryCatalogVisitorNextPageButton.Disabled = (total == 1); ProductCatalogPreviousPageButton.Disabled = true; InventoryCatalogRoommatePreviousPageButton.Disabled = true; InventoryCatalogVisitorPreviousPageButton.Disabled = true; return; }
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) { var category = new CategoryMap(); var author = new AuthorMap(); var topic = new TopicMap(); _cryptographyConfiguration = new CryptographyConfiguration( new AesEncryptionProvider(new PassphraseKeyGenerator("SuperSecretPass", new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 })), new DefaultHmacProvider(new PassphraseKeyGenerator("UberSuperSecure", new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }))); base.ApplicationStartup(container, pipelines); }
public override void ChangeCategory(UIElement elem) { QueryPanel.InInventory = false; foreach (var btn in CategoryMap.Keys) { btn.Selected = false; } UIButton button = (UIButton)elem; button.Selected = true; if (!CategoryMap.ContainsKey(button)) { return; } CurrentCategory = UICatalog.Catalog[CategoryMap[button]]; Catalog.SetCategory(CurrentCategory); var isRoof = CategoryMap[button] == 6; RoofShallowBtn.Visible = isRoof; RoofSteepBtn.Visible = isRoof; RoofSlider.Visible = isRoof; RoofSlider.Value = 1.25f - LotController.vm.Context.Architecture.RoofPitch; int total = Catalog.TotalPages(); OldSelection = -1; SubtoolsSlider.MaxValue = total - 1; SubtoolsSlider.Value = 0; NextPageButton.Disabled = (total == 1); if (LotController.CustomControl != null) { LotController.CustomControl.Release(); LotController.CustomControl = null; } PreviousPageButton.Disabled = true; var showsubtools = CategoryMap[button] != 10; SubToolBg.Visible = showsubtools; SubtoolsSlider.Visible = showsubtools; PreviousPageButton.Visible = showsubtools; NextPageButton.Visible = showsubtools; return; }
protected void AddTest(Test Test) { EndTime = DateTime.Now; this.Test = Test; Test.PrepareFinalize(); Test.CategoryList.ForEach(x => { if (!CategoryMap.ContainsKey(x.Name)) { CategoryMap.Add(x.Name, new List <Test>() { Test }); } else { CategoryMap[x.Name].Add(Test); } }); Test.ExceptionList.ForEach(x => { var ex = ExceptionUtil.GetExceptionHeadline(x); if (!ExceptionMap.ContainsKey(ex)) { ExceptionMap.Add(ex, new List <Test>() { Test }); } else { ExceptionMap[ex].Add(Test); } }); _reporterList.ForEach(x => { x.AddTest(Test); }); UpdateReportStatus(Test.Status); }
/// <summary> /// </summary> protected override void ProcessRecord() { GetCategoryMap(); List <ShellFolderItem> items = GetControlPanelItemByCategory(AllControlPanelItems); if (_nameSpecified) { items = GetControlPanelItemByName(items, _categorySpecified); } else if (_canonicalNameSpecified) { items = GetControlPanelItemByCanonicalName(items, _categorySpecified); } List <ControlPanelItem> results = new List <ControlPanelItem>(); foreach (ShellFolderItem item in items) { string name = item.Name; string path = item.Path; string description = (string)item.ExtendedProperty("InfoTip"); string canonicalName = (string)item.ExtendedProperty("System.ApplicationName"); canonicalName = canonicalName != null ? canonicalName.Substring(0, canonicalName.IndexOf("\0", StringComparison.OrdinalIgnoreCase)) : null; int[] categories = (int[])item.ExtendedProperty("System.ControlPanel.Category"); string[] cateStrings = new string[categories.Length]; for (int i = 0; i < categories.Length; i++) { string catStr = (string)LanguagePrimitives.ConvertTo(categories[i], typeof(string), CultureInfo.InvariantCulture); Dbg.Assert(CategoryMap.ContainsKey(catStr), "the category should be contained in CategoryMap"); cateStrings[i] = CategoryMap[catStr]; } ControlPanelItem controlPanelItem = new ControlPanelItem(name, canonicalName, cateStrings, description, path); results.Add(controlPanelItem); } // Sort the results by Canonical Name results.Sort(CompareControlPanelItems); foreach (ControlPanelItem controlPanelItem in results) { WriteObject(controlPanelItem); } }
protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Conventions.Remove <PluralizingTableNameConvention>(); var postMap = new PostMap(modelBuilder); postMap.Map(); var categoryMap = new CategoryMap(modelBuilder); categoryMap.Map(); var tagMap = new TagMap(modelBuilder); tagMap.Map(); base.OnModelCreating(modelBuilder); }
public static IList <String> UpdateCategories(String collection) { CategoryMap.Load("Category.Map.txt"); IList <String> newCategories = new List <String>(); String originalCollection = collection.Trim(); String matchingString = String.Empty; if (CategoryMap.HasMapping(originalCollection.ToLower(), out matchingString)) { String newCategory = CategoryMap.GetMapping(originalCollection); if (String.IsNullOrEmpty(newCategory) == false) { newCategories.Add(newCategory); } } else { newCategories.Add(originalCollection); } return(newCategories); }
public CompressedHeader( CategoryMap <BlockTypeInfo> blockTypes, DistanceParameters distanceParameters, IList <LiteralContextMode> literalCtxModes, ContextMap literalCtxMap, ContextMap distanceCtxMap, IList <LiteralTree> literalTrees, IList <InsertCopyTree> insertCopyTrees, IList <DistanceTree> distanceTrees ) { this.BlockTypes = blockTypes; this.DistanceParameters = distanceParameters; this.LiteralCtxModes = literalCtxModes.ToArray(); this.LiteralCtxMap = literalCtxMap; this.DistanceCtxMap = distanceCtxMap; this.LiteralTrees = literalTrees.ToArray(); this.InsertCopyTrees = insertCopyTrees.ToArray(); this.DistanceTrees = distanceTrees.ToArray(); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { var _repCountry = DependencyResolver.Current.GetService <ICountryRepository>(); var _repCategory = DependencyResolver.Current.GetService <ICategoryRepository>(); var _repYear = DependencyResolver.Current.GetService <IYearRepository>(); var _repMonth = DependencyResolver.Current.GetService <IMonthRepository>(); //Countries and Provinces List <CountryModel> lstCountries = new List <CountryModel>(); lstCountries.Add(new CountryModel { Id = 0, Name = "Country" }); lstCountries.AddRange(CountryMap.Map(_repCountry.GetList().ToList())); List <ProvinceModel> lstProvinces = new List <ProvinceModel>(); lstProvinces.Add(new ProvinceModel { Id = 0, Name = "State" }); ///Categories /// List <CategoryModel> lstCategories = new List <CategoryModel>(); lstCategories.Add(new CategoryModel { Id = 0, CategoryName = "Categories", LanguageId = 1 }); List <YearModel> lstYears = new List <YearModel>(); lstCategories.AddRange(CategoryMap.Map(_repCategory.GetList(x => x.LanguageId == 1).ToList())); ///Years lstYears.Add(new YearModel { Id = 0, Year = "Years", LanguageId = 1 }); lstYears.AddRange(YearMap.Map(_repYear.GetList(x => x.LanguageId == 1).ToList())); List <MonthModel> lstMonths = new List <MonthModel>(); lstMonths.Add(new MonthModel { Id = 0, Month = "Months", LanguageId = 1 }); lstMonths.AddRange(MonthMap.Map(_repMonth.GetList(x => x.LanguageId == 1).ToList())); List <DisciplineModel> lstDisciplines = new List <DisciplineModel>(); lstDisciplines.Add(new DisciplineModel { Id = 0, DisciplineName = "Discipline", LanguageId = 1 }); List <SortByModel> lstSort = new List <SortByModel>(); lstSort.Add(new SortByModel { Id = 0, OrderBy = "Sort By" } ); lstSort.Add(new SortByModel { Id = 1, OrderBy = "Ascending" }); lstSort.Add(new SortByModel { Id = 2, OrderBy = "Descending" }); List <SexModel> lstSex = new List <SexModel>(); lstSex.Add(new SexModel { Id = 0, Sex = "Sex" }); lstSex.Add(new SexModel { Id = 1, Sex = "Male" }); lstSex.Add(new SexModel { Id = 2, Sex = "Female" }); var controller = (filterContext.Controller as LeonniApplicationController); if (controller != null) { controller.Categories = new SelectList(lstCategories, "Id", "CategoryName"); controller.Countries = new SelectList(lstCountries, "Name", "Name"); controller.Years = new SelectList(lstYears, "Id", "Year"); controller.Months = new SelectList(lstMonths, "Id", "Month"); controller.Provinces = new SelectList(lstProvinces, "Id", "Name"); controller.Sorts = new SelectList(lstSort, "Id", "OrderBy"); controller.Disciplines = new SelectList(lstDisciplines, "Id", "DisciplineName"); controller.Sexs = new SelectList(lstSex, "Sex", "Sex"); } else { throw new Exception("Always derieve controller from LeonniApplicationController"); } base.OnActionExecuting(filterContext); }
public void CategoryMapTests() { CategoryMap map = new CategoryMap(); }
private static ContextMap ReadContextMap(IBitReader reader, Category category, CategoryMap <BlockTypeInfo> blockTypes) { return(ContextMap.Deserialize(reader, blockTypes[category])); }
public Boolean RunImport(Options options) { var importPortfolio = options.ImportPortfolio; var retVal = false; var checkStatus = false; var badSubItemType = false; var subItemKeys = new List <String>(); try { if (Properties.Settings.Default.Properties["ImportPortfolio"] != null) { importPortfolio = Properties.Settings.Default.ImportPortfolio; } var goodToGo = true; var xlsxDataTable = new DataTable(); using (var wb = new XLWorkbook(options.XlsxDataFileName)) { NLogger.Info("Processing workbook {0}", options.XlsxDataFileName); var wsData = wb.Worksheets.ToList().Find(w => w.Name.IsEqualTo(options.XlsxDataSheetName, true)); if (wsData == null) { NLogger.Error("Unable to find a Data worksheet named {0}", options.XlsxDataSheetName); goodToGo = false; } if (goodToGo) { xlsxDataTable = wsData.ToDataTable(); } } if (!goodToGo) { return(false); } var xlsxMapTable = new DataTable(); using (var wb = new XLWorkbook(options.XlsxMapFileName)) { var wsMap = wb.Worksheets.ToList().Find(w => w.Name.IsEqualTo(options.XlsxMapSheetName, true)); if (wsMap == null) { NLogger.Error("Unable to find a Map worksheet named {0}", options.XlsxMapSheetName); goodToGo = false; } if (goodToGo) { xlsxMapTable = wsMap.ToDataTable(); } } if (!goodToGo) { return(false); } // // Datatables are easier to use than worksheets so just convert it to a datatable // if (!xlsxDataTable.Rows.HasItems()) { NLogger.Error("Either there was no rows on {0} or we had an error converting the Data worksheet to a datatable.", options.XlsxDataSheetName); return(false); } if (!xlsxMapTable.Rows.HasItems()) { NLogger.Error("Either there was no rows on {0} or we had an error converting the Map worksheet to a datatable.", options.XlsxMapSheetName); return(false); } // // Build our map list // var dataColumns = new DataColumns(); foreach (DataRow row in xlsxMapTable.Rows) { var columnMap = new CategoryMap { ColumnName = row.Field <String>(0), ColumnLetter = row.Field <String>(1), CategoryName = row.Field <String>(2), ColumnFlagType = row.Field <String>(3) }; if (columnMap.ColumnName.IsNullOrEmpty()) { continue; } if (columnMap.CategoryName.IsTrimEqualTo("status", true)) { checkStatus = true; } dataColumns.Add(columnMap); } // // OK lets log into OPPM // var oppm = new Oppm(options.OppmUser, options.OppmPassword, options.OppmHost, options.UseSsl); if (options.UseCert) { oppm = new Oppm(options.OppmUser, options.OppmPassword, options.OppmHost, options.UseCert, Certificate); } var loggedin = oppm.Login(); if (!loggedin) { NLogger.Error("Unable to log into {0} with {1}", options.OppmHost, options.OppmUser); return(false); } NLogger.Info("Successful login with {0}", options.OppmUser); // // Check to make sure all the categories exists and we have an item name column // if (!(dataColumns.ItemNameMapExits || dataColumns.UciMapExits)) { NLogger.Error("Unable to find a ItemName either by marking the row with a Yes or UCI (blank mapping) in the mapping worksheet: {0}", options.XlsxMapSheetName); return(false); } // // Now check to make sure all the categories exists // var categoryInfoList = new List <psPortfoliosCategoryInfo>(); var valueListDictionary = new Dictionary <String, List <String> >(); var badCategoryList = new List <String>(); foreach (var categoryMap in dataColumns.CategoryMapList) { if (categoryMap.IsItemNameMap || categoryMap.CategoryName.IsNullOrEmpty()) { continue; // A blank mapping uses this column as the name } var portfolioCategoryInfo = oppm.SeCategory.GetCategoryInfo(categoryMap.CategoryName); if (portfolioCategoryInfo != null) { categoryInfoList.Add(portfolioCategoryInfo); if (portfolioCategoryInfo.ValueListName.IsNotNullOrEmpty()) { categoryMap.ValueListName = portfolioCategoryInfo.ValueListName; var values = oppm.SeValueList.GetValueListText(categoryMap.ValueListName); if (valueListDictionary.ContainsKey(categoryMap.ValueListName)) { continue; } valueListDictionary.Add(categoryMap.ValueListName, values); } continue; } badCategoryList.Add(categoryMap.CategoryName); } // // Now check the values list values // var valueListCategories = dataColumns.CategoryMapList.FindAll(x => x.ValueListName.IsNotNullOrEmpty()); var badValuesList = new List <String>(); if (valueListCategories.HasItems()) { foreach (DataRow row in xlsxDataTable.Rows) { foreach (var valueListCategory in valueListCategories) { // Get our category value for a value list category var value = row[valueListCategory.DataColumnNumber].ToString(); if (value.IsNullOrEmpty()) { continue; } if (!valueListDictionary.ContainsKey(valueListCategory.ValueListName)) { continue; // should never happen } // Get our value list values var validValueList = valueListDictionary[valueListCategory.ValueListName]; if (validValueList.Contains(value)) { continue; } var badValueString = String.Format("ValueList {0} on Category {1} does not contain value: {2}", valueListCategory.ValueListName, valueListCategory.CategoryName, value); if (badValuesList.Contains(badValueString)) { continue; } badValuesList.Add(badValueString); } } } // // Now check to see if // if (options.SubItemType.IsNotNullOrEmpty()) { badSubItemType = !oppm.SeValueList.HasValue("Dynamic List Types", options.SubItemType); subItemKeys = dataColumns.GetSubItemKeys; } // // See if we have bad values for the value list categories // var foundError = false; // // Did we get any bad categories // if (badCategoryList.HasItems()) { foreach (var badCategory in badCategoryList) { NLogger.Warn("Category {0} doesn't exists.", badCategory); } NLogger.Warn("Correct category mapping errors in the Map worksheet: {0}", options.XlsxMapSheetName); foundError = true; } // // Did we get any bad values // if (badValuesList.HasItems()) { foreach (var value in badValuesList) { NLogger.Warn(value); } NLogger.Warn("Correct value list values in the Data worksheet: {0}", options.XlsxDataSheetName); foundError = true; } // // Bad subitem type list value -- didn't find it in Dynamic List Types // if (badSubItemType) { NLogger.Warn("Unable to find {0} subitem type in Dynamic List Types valuelist", options.SubItemType); foundError = true; } if (options.SubItemType.IsNotNullOrEmpty() && !subItemKeys.HasItems()) { NLogger.Warn("SubItem loading required at least one SubItemKey column to be defined on the map sheet for {0}", options.SubItemType); foundError = true; } // // The user needs to fix the errors we found. // if (foundError) { return(false); } // // Look for our import portfolio. If we don't find it create it. // var msg = "Found"; var importPortfolioId = oppm.SeItem.GetItemIdByName(importPortfolio); if (importPortfolioId.IsNullOrEmpty()) { var importPortfolioInfo = new psPortfoliosItemInfo { Name = importPortfolio, Status = psOPEN_CLOSED_STATUS.OCSTS_OPEN, PortfolioType = psPORTFOLIO_TYPE.PTYP_PROJECTS, Description = "This is the import portfolio that was created by OppmUtility", IsContainerRoot = true, CalculationLevel = psCALCULATION_LEVEL.CL_NOT_CALCULATED }; var psReturnValues = oppm.SePorfolio.AddPortfolio(importPortfolioInfo); if (psReturnValues == wsPortfoliosPortfolio.psRETURN_VALUES.ERR_OK) { importPortfolioId = oppm.SeItem.GetItemIdByName(importPortfolio); } msg = "Created "; } if (importPortfolioId.IsNullOrEmpty()) { NLogger.Fatal("Unable to create import portfolio {0}", importPortfolio); return(false); } NLogger.Info("{0} import porfolio {1}", msg, importPortfolio); // // OK lets do some work // var rowCnt = 1; var itemNameUciMap = dataColumns.GetItemNameUciMap; var categories = dataColumns.CategoryMapList.Where(x => x.IsItemNameMap != true && x.CategoryName.IsNotNullOrEmpty()).Select(x => x.CategoryName).ToList(); NLogger.Trace("itemNameUciMap = {0}", itemNameUciMap); foreach (DataRow row in xlsxDataTable.Rows) { var itemNameUciValue = row.Field <String>(itemNameUciMap.DataColumnNumber); NLogger.Trace("itemNameUciValue = {0}", itemNameUciValue); var status = wsPortfoliosItem.psOPEN_CLOSED_STATUS.OCSTS_OPEN; var importItemCellInfoList = new List <Cell.psPortfoliosCellInfo>(); var importSubItemCellInfoList = new List <SubItem.psPortfoliosCellInfo>(); var subItemID = String.Empty; foreach (var categoryMap in dataColumns.CategoryMapList) { //var columnValue = row.Field<String>(categoryMap.DataColumnNumber); //NLogger.Trace("categoryMap = {0}", categoryMap.ToString()); if (categoryMap.IsItemNameMap || categoryMap.UseUciMap) { continue; //we already got the name } if (categoryMap.ColumnFlagType.IsEqualTo("UseAsSubItemId", true)) { subItemID = row.Field <String>(categoryMap.DataColumnNumber); continue; } // // check to see if we need to set the item status. // NLogger.Trace("categoryMap.CategoryName = {0}", categoryMap.CategoryName); if (checkStatus && categoryMap.CategoryName.IsTrimEqualTo("status", true)) { var columnStatus = row.Field <String>(categoryMap.DataColumnNumber); if (columnStatus.IsTrimEqualTo("CLOSED", true)) { status = wsPortfoliosItem.psOPEN_CLOSED_STATUS.OCSTS_CLOSED; } if (columnStatus.IsTrimEqualTo("CANDIDATE", true)) { status = wsPortfoliosItem.psOPEN_CLOSED_STATUS.OCSTS_CANDIDATE; } continue; } // // Find our category create our cellinfo and add it to the cellinfo list depending if item or subitem. // var portfolioCategoryInfo = categoryInfoList.Find(x => x.Name.IsTrimEqualTo(categoryMap.CategoryName, true)); if (portfolioCategoryInfo == null) { NLogger.Trace("portfolioCategoryInfo is null"); continue; } NLogger.Trace("portfolioCategoryInfo.Name = {0}", portfolioCategoryInfo.Name); //if (portfolioCategoryInfo.ValueListName.IsNotNullOrEmpty() && columnValue.IsNullOrEmpty()) continue; if (options.SubItemType.IsNotNullOrEmpty()) { importSubItemCellInfoList.Add(HelperFunctions.BuildSubItemCellInfo(portfolioCategoryInfo, row.Field <String>(categoryMap.DataColumnNumber))); NLogger.Trace("importSubItemCellInfoList = {0}", "Added"); continue; } importItemCellInfoList.Add(HelperFunctions.BuildItemCellInfo(portfolioCategoryInfo, row.Field <String>(categoryMap.DataColumnNumber))); NLogger.Trace("importItemCellInfoList = {0}", "Added"); } // // Make sure we have a set of subitem keys // /* * if (importItemCellInfoList.HasItems()) * { * var validKeyCount = 0; * foreach (var subItemKey in subItemKeys) * { * var cell = importItemCellInfoList.Find(x => x.CategoryName.IsTrimEqualTo(subItemKey, true)); * if (cell == null || cell.CellDisplayValue.IsNullOrEmpty()) continue; * validKeyCount++; * } * if (!validKeyCount.Equals(subItemKeys.Count)) * { * NLogger.Warn("Invalid subItem key on line {0} for item {1}", rowCnt++, itemNameUciValue); * } * } */ // // Check to see if we need to add the item. // var msgOne = String.Format("Process row {0} out of {1} ", rowCnt++, xlsxDataTable.Rows.Count); msgOne = String.Format(itemNameUciMap.IsItemNameMap ? "{0} with ItemName {1}" : "{0} with {2} {1}", msgOne, itemNameUciValue, itemNameUciMap.CategoryName); NLogger.Info(msgOne); if (!options.Commit) { continue; } // // OK lets get our item that we want to write this data to. // NLogger.Trace("Check Existance for {0}", itemNameUciValue); wsPortfoliosItem.psPortfoliosItemInfo itemInfo = null; // if we are using item name if (itemNameUciMap.IsItemNameMap) { itemInfo = oppm.SeItem.GetItemInfoByName(itemNameUciValue); if (itemInfo == null) { if (!options.NewItem) { NLogger.Info("Item {0} doesn't exists", itemNameUciValue); continue; } // Create a new item. var itemId = oppm.SeItem.AddNewEx(itemNameUciValue, importPortfolio); itemInfo = oppm.SeItem.GetItemInfo(itemId); NLogger.Info("Added {0} to portfolio {1} with id {2}", itemInfo.Name, importPortfolio, itemInfo.ProSightID); } } // if we are using uci if (itemNameUciMap.UseUciMap) { itemInfo = oppm.SeItem.GetItemInfo(itemNameUciMap.CategoryName, itemNameUciValue); if (itemInfo == null) { NLogger.Info("UCI {0} doesn't exists", itemNameUciValue); continue; } } // We didn't find the item -- bummer! if (itemInfo == null) { NLogger.Warn("Unable to find an item base on either the ItemName or UCI for row {0}", rowCnt - 1); continue; } // // See if the status has changed // if (checkStatus && itemInfo.Status != status) { NLogger.Trace("Checking status of {0}", itemInfo.Name); itemInfo.Status = status; oppm.SeItem.UpdateEx(itemInfo, 32); } // // If subitem type is null then update our import item cells. // if (options.SubItemType.IsNullOrEmpty()) { // Process it as an Item NLogger.Trace("Doing Item UpdateMultipleCellsEx"); var updateStatusList = oppm.SeCell.UpdateMultipleCellsEx(itemInfo.ProSightID, importItemCellInfoList); NLogger.Info("Update item cells on {0}", itemNameUciValue); if (!updateStatusList.HasItems()) { continue; } // // Let see if the update when well // NLogger.Trace("Logging update status"); foreach (var portfolioCellUpdateStatus in updateStatusList) { NLogger.Warn("On item {0}, the following cell didn't update {1}. Error {2}", itemNameUciValue, portfolioCellUpdateStatus.CategoryName, portfolioCellUpdateStatus.ErrorText); } // // Do the next item cell import // continue; } // // Process subitem cells based on the subItemKeys // NLogger.Trace("Doing subitem SyncSubItemsAsOfToday"); // // Get our subitems base on the type from our current item. // var asOf = DateTime.Now; var subItemInfos = oppm.SeSubItem.GetSubItemListAsOf(String.Empty, itemInfo.ProSightID.ToString(CultureInfo.InvariantCulture), options.SubItemType, 0, categories, false, DateTime.Now); NLogger.Info("Updating {0} subItemInfos on {1}", subItemInfos.Count, itemInfo.Name); // // Check for an existing subitme based on the subitems keys // var doSubItemSync = true; SubItem.psPortfoliosSubItemInfo foundKeyedSubItem = null; var subItemUciList = new List <String>(subItemInfos.Select(x => x.SubItemUCI)); if (subItemID.IsNotNullOrEmpty()) { NLogger.Trace("Doing UseAsSubItemID Sync"); doSubItemSync = false; var subItemInfo = subItemInfos.Find(x => x.SubItemUCI.IsTrimEqualTo(subItemID, true)); if (subItemInfo != null) { NLogger.Trace("Found subItemInfo {0}", subItemInfo.SubItemUCI); foundKeyedSubItem = subItemInfo; } } else { foreach (var subItemUci in subItemUciList) { var subItemInfo = subItemInfos.Find(x => x.SubItemUCI.IsTrimEqualTo(subItemUci, true)); var subItemKeyValueList = new MapList(); foreach (var subItemKey in subItemKeys) { var subItemKeyMap = new SubKeyMap { Category = subItemKey, KeyValue = String.Empty, CellValue = String.Empty }; var subItemKeyCategory = subItemInfo.CategoryValues.ToList().Find(x => x.CategoryName.IsTrimEqualTo(subItemKey, true)); if (subItemKeyCategory != null) { subItemKeyMap.KeyValue = subItemKeyCategory.CellDisplayValue.IsNotNullOrEmpty() ? subItemKeyCategory.CellDisplayValue : String.Empty; } var existItemKeyCategory = importSubItemCellInfoList.Find(x => x.CategoryName.IsTrimEqualTo(subItemKey, true)); if (existItemKeyCategory != null) { subItemKeyMap.CellValue = existItemKeyCategory.CellDisplayValue.IsNotNullOrEmpty() ? existItemKeyCategory.CellDisplayValue : String.Empty; } subItemKeyValueList.KeyMaps.Add(subItemKeyMap); } if (!subItemKeyValueList.CheckMap) { continue; } foundKeyedSubItem = subItemInfo; break; } } // // if we didn't find a matching subitem just add a new one // if (foundKeyedSubItem != null) { doSubItemSync = false; foreach (var subItemCell in foundKeyedSubItem.CategoryValues) { var importSubItemCell = importSubItemCellInfoList.Find(x => x.CategoryName.IsTrimEqualTo(subItemCell.CategoryName, true)); if (importSubItemCell == null) { continue; } if (!subItemCell.CellDisplayValue.IsNotEqualTo(importSubItemCell.CellDisplayValue, false)) { continue; } subItemCell.CellDisplayValue = importSubItemCell.CellDisplayValue; subItemCell.CellAsOf = DateTime.Now.ToString("MM/dd/yyyy"); doSubItemSync = true; } } else { var newSerialNumber = 1; if (subItemInfos.HasItems()) { newSerialNumber = subItemInfos.Max(x => x.SubItemSerial) + 1; } var newSubItem = new SubItem.psPortfoliosSubItemInfo { SubItemName = Guid.NewGuid().ToString(), SubItemSerial = newSerialNumber, CategoryValues = importSubItemCellInfoList.ToArray() }; subItemInfos.Add(newSubItem); } // // Sync the subitems as of today // if (!doSubItemSync) { NLogger.Trace("Update item cells on {0}", itemNameUciValue); continue; } var subItemUpdateStatuses = oppm.SeSubItem.SyncSubItemsAsOf(itemInfo.ProSightID, options.SubItemType, 0, subItemInfos, asOf, false); NLogger.Info("Update item cells on {0}", itemNameUciValue); if (!subItemUpdateStatuses.HasItems()) { continue; } // // Let see if the subitem sync when well // NLogger.Trace("Logging subItem update status"); foreach (var subItemUpdateStatus in subItemUpdateStatuses) { NLogger.Warn("On item {0}, the following subItem {1}. Error {2}", itemNameUciValue, subItemUpdateStatus.SubItemSerial, subItemUpdateStatus.ErrorText); } } retVal = true; } catch (Exception ex) { NLogger.Fatal(ex.Message); } return(retVal); }
public ReaderDataContext(Context wrapped, IMarkedBitReader reader) : base(wrapped) { this.readingTrackers = Header.BlockTypes.Select(info => new BlockSwitchTracker.Reading(info, reader)); this.BlockTrackers = readingTrackers.Select <BlockSwitchTracker>(tracker => tracker); }
public WriterDataContext(Context wrapped, BlockSwitchCommandMap blockSwitchCommands, IBitWriter writer) : base(wrapped) { this.BlockTrackers = Header.BlockTypes.Select <BlockSwitchTracker>(info => new BlockSwitchTracker.Writing(info, writer, blockSwitchCommands[info.Category])); }
private void PopulateViewBags() { //Countries and Provinces List <CountryModel> lstCountries = new List <CountryModel>(); lstCountries.Add(new CountryModel { Id = 1111, Name = "Country" } ); lstCountries.AddRange(CountryMap.Map(_repCountry.GetList().ToList())); ViewBag.Countries = new SelectList(lstCountries, "Name", "Name"); List <ProvinceModel> lstProvinces = new List <ProvinceModel>(); lstProvinces.Add(new ProvinceModel { Id = 0, Name = "State" }); ViewBag.Provinces = new SelectList(lstProvinces, "Id", "Name"); ///Categories /// List <CategoryModel> lstCategories = new List <CategoryModel>(); lstCategories.Add(new CategoryModel { Id = 1111, CategoryName = "Categories", LanguageId = CurrentLanguage.Id }); List <YearModel> lstYears = new List <YearModel>(); lstCategories.AddRange(CategoryMap.Map(_repCategory.GetList(x => x.LanguageId == CurrentLanguage.Id).ToList())); ViewBag.Categories = new SelectList(lstCategories, "Id", "CategoryName"); ///Years lstYears.Add(new YearModel { Id = 0, Year = "Years", LanguageId = CurrentLanguage.Id }); lstYears.AddRange(YearMap.Map(_repYear.GetList(x => x.LanguageId == CurrentLanguage.Id).ToList())); ViewBag.Years = new SelectList(lstYears, "Id", "Year"); List <MonthModel> lstMonths = new List <MonthModel>(); lstMonths.Add(new MonthModel { Id = 1111, Month = "Months", LanguageId = CurrentLanguage.Id }); lstMonths.AddRange(MonthMap.Map(_repMonth.GetList(x => x.LanguageId == CurrentLanguage.Id).ToList())); ViewBag.Months = new SelectList(lstMonths, "Id", "Month"); List <DisciplineModel> lstDisciplines = new List <DisciplineModel>(); lstDisciplines.Add(new DisciplineModel { Id = 1111, DisciplineName = "Discipline", LanguageId = CurrentLanguage.Id }); ViewBag.Disciplines = new SelectList(lstDisciplines, "Id", "DisciplineName"); List <SortByModel> lstSort = new List <SortByModel>(); lstSort.Add(new SortByModel { Id = 0, OrderBy = "Sort By" } ); lstSort.Add(new SortByModel { Id = 1, OrderBy = "Ascending" }); lstSort.Add(new SortByModel { Id = 2, OrderBy = "Descending" }); ViewBag.SortBy = new SelectList(lstSort, "Id", "OrderBy"); }