public static string FontFamily(StyleItem item) { switch (item) { case StyleItem.ReportName: case StyleItem.Title: case StyleItem.SubTitle: case StyleItem.FooterText: return("Arial"); case StyleItem.SummaryLabel: case StyleItem.SummaryText: case StyleItem.TableHeader: case StyleItem.TableFooter: case StyleItem.SmallTableHeader: case StyleItem.SmallTableFooter: case StyleItem.TableText: case StyleItem.NotSoSmallTableText: case StyleItem.SmallTableText: return("Verdana"); default: return("Arial"); } }
private void InitBulletItems() { _itemList = new List <StyleItem>(); _curSelectedItemIndex = -1; _bulletCfgs = DatabaseManager.BulletDatabase.GetBulletStyleCfgs(); for (int i = 0; i < _bulletCfgs.Count; i++) { BulletStyleCfg cfg = _bulletCfgs[i]; GameObject item = ResourceManager.GetInstance().GetPrefab("Prefabs/Views/EditViews", "BulletStyleItem"); RectTransform itemTf = item.GetComponent <RectTransform>(); itemTf.SetParent(_itemContainerTf, false); // 初始化StyleItem结构 StyleItem styleItem = new StyleItem(); styleItem.btn = itemTf.Find("BtnBg").gameObject; styleItem.selectImgGo = itemTf.Find("SelectImg").gameObject; styleItem.selectImgGo.SetActive(false); // 设置子弹图像 Image bulletImg = itemTf.Find("BulletImg").GetComponent <Image>(); bulletImg.sprite = ResourceManager.GetInstance().GetSprite(cfg.packName, cfg.resName); bulletImg.SetNativeSize(); int itemIndex = i; // 添加事件监听 UIEventListener.Get(styleItem.btn).AddClick(() => { OnStyleItemClickHandler(itemIndex); }); _itemList.Add(styleItem); } }
private void AddStyle_SaveButton_Click(object sender, RoutedEventArgs e) { var saveChangesButton = sender as Button; //Get the Grid that contains the Stack Panel that also contains the info related to the new style var grid = (saveChangesButton.Parent as Grid).Parent as Grid; var groupNameLabel = grid.FindName("groupNameBox") as TextBox; var colorHexString = grid.FindName("colorHexVal") as Label; var newItem = new StyleItem() { GroupName = groupNameLabel.Text, HexColorString = colorHexString.Content.ToString() }; if (string.IsNullOrEmpty(newItem.GroupName)) { newItem.GroupName = "Input"; } //if the validation returns false it means that the new style that will be added doesn't exists if (viewModel.ValidateExistingStyle(newItem) == false) { viewModel.AddStyle(newItem); viewModel.ResetAddStyleControl(); AddStyleBorder.Visibility = Visibility.Collapsed; AddStyleButton.IsEnabled = true; } else { viewModel.IsWarningEnabled = true; } }
public static string FontWeight(StyleItem item) { switch (item) { case StyleItem.ReportName: case StyleItem.Title: case StyleItem.SubTitle: case StyleItem.SummaryLabel: case StyleItem.TableHeader: case StyleItem.TableFooter: case StyleItem.SmallTableHeader: case StyleItem.SmallTableFooter: return("Bold"); case StyleItem.FooterText: case StyleItem.SummaryText: case StyleItem.TableText: case StyleItem.NotSoSmallTableText: case StyleItem.SmallTableText: return("Normal"); default: return("Normal"); } }
public static ValueSelector ParseValue(string value) { bool inverted = false; string val = value.Trim(); if (val.StartsWith("!")) { val = value.Substring(1, value.Length - 1); inverted = true; } if (val.StartsWith("%") && val.EndsWith("%")) { string key = val.Remove(val.Length - 1, 1).Remove(0, 1); return(new ValueSelector( inverted, () => StyleManager.StyleOptions.First(x => x.Keyword == key).Value )); } if (val.StartsWith("(") && val.EndsWith(")") && StyleItem.TryParseExpression(value, out string v)) { val = v; } return(new ValueSelector(inverted, () => val)); }
//Creates a new style item and sets its properties from an existing style item public Task <StyleItem> CreateNewStyleItemAsync(StyleItem existingItem) { if (existingItem == null) { throw new System.ArgumentNullException(); } return(QueuedTask.Run(() => { StyleItem item = new StyleItem(); //Get object from existing style item object obj = existingItem.GetObject(); //New style item's properties are set from the existing item item.SetObject(obj); //Key, Name, Tags and Category for the new style item have to be set //These values are NOT populated from the object passed in to SetObject item.Key = "KeyOfTheNewItem"; item.Name = "NameOfTheNewItem"; item.Tags = "TagsForTheNewItem"; item.Category = "CategoryOfTheNewItem"; return item; })); }
//Create a CIMSymbol from style item selected in the results gallery list box and //apply this newly created symbol to the feature layer currently selected in Contents pane private async void ApplyTheSelectedSymbol(StyleItem selectedStyleItemToApply) { if (selectedStyleItemToApply == null || string.IsNullOrEmpty(selectedStyleItemToApply.Key)) { return; } await QueuedTask.Run(() => { //Get the feature layer currently selected in the Contents pane FeatureLayer ftrLayer = MappingModule.ActiveTOC.MostRecentlySelectedLayer as FeatureLayer; if (ftrLayer == null) { return; } //Create symbol from style item. CIMSymbol symbolFromStyleItem = selectedStyleItemToApply.GetObject() as CIMSymbol; //Set real world setting for created symbol = feature layer's setting //so that there isn't a mismatch between symbol and feature layer SymbolBuilder.SetRealWorldUnits(symbolFromStyleItem, ftrLayer.UsesRealWorldSymbolSizes); //Get simple renderer from feature layer CIMSimpleRenderer currentRenderer = ftrLayer.GetRenderer() as CIMSimpleRenderer; //Set current renderer's symbol reference = symbol reference of the newly created symbol currentRenderer.Symbol = SymbolBuilder.MakeSymbolReference(symbolFromStyleItem); //Update feature layer renderer with new symbol ftrLayer.SetRenderer(currentRenderer); }); }
public static string BorderStyle(StyleItem item, BorderLocation location) { switch (item) { case StyleItem.TableHeader: case StyleItem.SmallTableHeader: switch (location) { case BorderLocation.Bottom: return("Solid"); default: return("None"); } case StyleItem.TableFooter: case StyleItem.SmallTableFooter: switch (location) { case BorderLocation.Top: return("Solid"); default: return("None"); } default: return("None"); } }
public static string FontColor(StyleItem item) { switch (item) { case StyleItem.ReportName: case StyleItem.SummaryText: case StyleItem.TableText: case StyleItem.NotSoSmallTableText: case StyleItem.SmallTableText: return("Black"); case StyleItem.Title: case StyleItem.SubTitle: case StyleItem.SummaryLabel: case StyleItem.TableHeader: case StyleItem.TableFooter: case StyleItem.SmallTableHeader: case StyleItem.SmallTableFooter: return("MidnightBlue"); case StyleItem.FooterText: return("Gray"); default: return("Black"); } }
public static string BorderWidth(StyleItem item, BorderLocation location) { switch (item) { default: return("1pt"); } }
public static string BorderColor(StyleItem item, BorderLocation location) { switch (item) { default: return("Black"); } }
private void LoadStyles() { var style = Property.GetValue(Instance) as Style; var fe = Instance as FrameworkElement; if (style != null && fe != null) { // Add other applicable styles var targetType = fe.GetType(); try { foreach (var resource in ResourceHelper.GetResourcesRecursivelyIncludingApp <Style>(fe)) { try { var styleResource = resource.Value as Style; if (styleResource != null && styleResource.TargetType != null) { if ((targetType == styleResource.TargetType || targetType.IsSubclassOf(styleResource.TargetType))) { var resourceStyleItem = new StyleItem(styleResource, fe, StyleHelper.GetKeyString(resource.Key), StyleHelper.GetSource(resource.Owner), StyleScope.Local); _styleItems.Add(resourceStyleItem); } } } catch (Exception) { } } } catch (Exception) { } // Add the current style StyleItem styleItem = null; try { if (StyleHelper.TryGetStyleItem(fe, style, out styleItem)) { if (!_styleItems.Contains(styleItem)) { _styleItems.Add(styleItem); } } } catch (Exception) { } Styles.Refresh(); if (styleItem != null) { Styles.MoveCurrentTo(styleItem); } Styles.CurrentChanged += OnStyleSelectionChanged; } }
public OriginalStyleHelper AddCustomStyle(StyleItem item) { if (item == null || item.IsNullOrWhiteSpace()) { return(this); } return(this.AddCustomStyle(item.StyleName, item.Value)); }
public OriginalStyleHelper RemoveCustomStyle(StyleItem item) { if (item == null || item.IsNullOrWhiteSpace()) { return(this); } return(this.RemoveCustomStyle(item.StyleName)); }
public static string LineWidth(StyleItem item) { switch (item) { case StyleItem.NonBodyLine: default: return("1pt"); } }
public static string LineStyle(StyleItem item) { switch (item) { case StyleItem.NonBodyLine: default: return("Solid"); } }
public static string LineColor(StyleItem item) { switch (item) { case StyleItem.NonBodyLine: return("DimGray"); default: return("Black"); } }
/// <summary> /// Add scriptFileName's script url to Page.Items /// </summary> /// <param name="page">page</param> /// <param name="scriptItem">file name under App_Data/Script</param> public static void AddStyle(Page page, string styleFileName) { IEnumerable <XElement> styleList = StyleItem.GetStyleList(styleFileName); if (styleList != null) { foreach (XElement x in styleList) { PageHelpers.Add(page, "StyleList", x.Value); } } }
public void CommitRenaming() { if (IsRenaming) { IsRenaming = false; RaisePropertyChanged(() => Name); var styleItemUI = StyleItem.GetUI(styleArguments); if (styleItemUI != null) { StyleItem.UpdateUI(styleItemUI); } } }
public Task AddStyleItemAsync(StyleProjectItem style, StyleItem itemToAdd) { return(QueuedTask.Run(() => { if (style == null || itemToAdd == null) { throw new System.ArgumentNullException(); } //Add the item to style style.AddItem(itemToAdd); })); }
public Task RemoveStyleItemAsync(StyleProjectItem style, StyleItem itemToRemove) { return(QueuedTask.Run(() => { if (style == null || itemToRemove == null) { throw new System.ArgumentNullException(); } //Remove the item from style style.RemoveItem(itemToRemove); })); }
public void SetStyles(IHtmlFormattingStyle[] styles) { //clear any existing styles styleComboBox.Items.Clear(); styleTable.Clear(); //add the new styles foreach (IHtmlFormattingStyle style in styles) { StyleItem styleItem = new StyleItem(style); styleComboBox.Items.Add(styleItem); styleTable[style.ElementName] = styleItem; } }
public OriginalStyleHelper AddOrUpdateCustomStyle(StyleItem item) { if (item == null || item.IsNullOrWhiteSpace()) { return(this); } if (_customStyle.ContainsKey(item.StyleName)) { _customStyle[item.StyleName] = item.Value; } else { AddCustomStyle(item); } return(this); }
public OriginalStyleHelper AddDiffCustomStyle(StyleItem whenSuccess, StyleItem whenFailed, Func <bool> condition) { if (whenSuccess == null || whenFailed == null || whenSuccess.IsNullOrWhiteSpace() || whenFailed.IsNullOrWhiteSpace() || condition == null) { return(this); } if (condition()) { AddCustomStyle(whenSuccess); } else { AddCustomStyle(whenFailed); } _styleData = null; return(this); }
protected override void FillContent() { Table table = new Table(); TableRow row = null; TableCell cell; InnerQuickFormatting.EnsureChildControls(); Collection <StyleItem> items = new Collection <StyleItem>(); foreach (Control control in InnerQuickFormatting.Controls[1].Controls) { StyleItem item = control as StyleItem; items.Add(item); } int n = 0; foreach (StyleItem item in items) { row = new TableRow(); table.Rows.Add(row); cell = new TableCell(); cell.Attributes["class"] = "oae_quickformatting"; ButtonInPopup popupButton = new ButtonInPopup(item); RegisteredHandlers.Add(new Obout.Ajax.UI.HTMLEditor.Popups.RegisteredField("button_" + n.ToString(), popupButton)); n++; cell.Controls.Add(popupButton); cell.Style[HtmlTextWriterStyle.BackgroundColor] = "Transparent"; cell.Style[HtmlTextWriterStyle.FontSize] = "10pt"; cell.Style[HtmlTextWriterStyle.Padding] = "0px"; cell.Style[HtmlTextWriterStyle.FontFamily] = "Verdana"; cell.Style[HtmlTextWriterStyle.Color] = "Blue"; cell.Style[HtmlTextWriterStyle.Cursor] = "pointer"; row.Cells.Add(cell); } table.Attributes.Add("border", "0"); table.Attributes.Add("cellspacing", "0"); table.Attributes.Add("cellpadding", "0"); table.Style["background-color"] = "transparent"; Content.Add(table); }
public static string FontSize(StyleItem item) { switch (item) { case StyleItem.ReportName: return("16pt"); case StyleItem.Title: return("18pt"); case StyleItem.SubTitle: return("12pt"); case StyleItem.SummaryLabel: case StyleItem.SummaryText: return("10pt"); case StyleItem.TableHeader: case StyleItem.TableFooter: return("9pt"); case StyleItem.SmallTableHeader: case StyleItem.SmallTableFooter: return("7pt"); case StyleItem.FooterText: case StyleItem.TableText: return("8pt"); case StyleItem.NotSoSmallTableText: return("7pt"); case StyleItem.SmallTableText: return("6pt"); default: return("12pt"); } }
private static StyleItemDTO CreateStyleItem(IUnitOfWork db, long styleId, SizeDTO size) { var styleItem = new StyleItem() { StyleId = styleId, SizeId = size.Id, Size = size.Name, CreateDate = DateHelper.GetAppNowTime() }; db.StyleItems.Add(styleItem); db.Commit(); return(new StyleItemDTO() { StyleItemId = styleItem.Id, StyleId = styleItem.StyleId, Size = styleItem.Size, SizeId = styleItem.SizeId, }); }
private void DuplicateClick(object sender, RoutedEventArgs e) { StyleLayerListItem duplicateStyleItem = StyleItem.CloneDeep(); if (duplicateStyleItem == null) { return; } var parent = StyleItem.Parent as StyleLayerListItem; if (parent == null) { return; } parent.Children.Insert(0, duplicateStyleItem); parent.UpdateConcreteObject(); if (ParentViewModel.StyleItemViewModels.Count > 0) { ParentViewModel.StyleItemViewModels[0].IsSelected = true; } }
public async void ContentSnippets2() { #region Create new project using Pro's default settings //Get Pro's default project settings. var defaultProjectSettings = Project.GetDefaultProjectSettings(); //Create a new project using the default project settings await Project.CreateAsync(defaultProjectSettings); #endregion #region New project using a custom template file //Settings used to create a new project CreateProjectSettings projectSettings = new CreateProjectSettings() { //Sets the project's name Name = "New Project", //Path where new project will be stored in LocationPath = @"C:\Data\NewProject", //Sets the project template that will be used to create the new project TemplatePath = @"C:\Data\MyProject1\CustomTemplate.aptx" }; //Create the new project await Project.CreateAsync(projectSettings); #endregion #region Create project using template available with ArcGIS Pro //Settings used to create a new project CreateProjectSettings proTemplateSettings = new CreateProjectSettings() { //Sets the project's name Name = "New Project", //Path where new project will be stored in LocationPath = @"C:\Data\NewProject", //Select which Pro template you like to use TemplateType = TemplateType.Catalog //TemplateType = TemplateType.LocalScene //TemplateType = TemplateType.GlobalScene //TemplateType = TemplateType.Map }; //Create the new project await Project.CreateAsync(proTemplateSettings); #endregion #region Open project //Opens an existing project or project package await Project.OpenAsync(@"C:\Data\MyProject1\MyProject1.aprx"); #endregion #region Current project //Gets the current project var project = Project.Current; #endregion #region Get location of current project //Gets the location of the current project; that is, the path to the current project file (*.aprx) string projectPath = Project.Current.URI; #endregion #region Get the project's default gdb path var projGDBPath = Project.Current.DefaultGeodatabasePath; #endregion #region Save project //Saves the project await Project.Current.SaveAsync(); #endregion #region SaveAs project //Saves a copy of the current project file (*.aprx) to the specified location with the specified file name, //then opens the new project file await Project.Current.SaveAsAsync(@"C:\Data\MyProject1\MyNewProject1.aprx"); #endregion #region Close project //A project cannot be closed using the ArcGIS Pro API. //A project is only closed when another project is opened, a new one is created, or the application is shutdown. #endregion #region Adds item to the current project //Adding a folder connection string folderPath = "@C:\\myDataFolder"; var folder = await QueuedTask.Run(() => { //Create the folder connection project item var item = ItemFactory.Instance.Create(folderPath) as IProjectItem; //If it is succesfully added to the project, return it otherwise null return(Project.Current.AddItem(item) ? item as FolderConnectionProjectItem : null); }); //Adding a Geodatabase: string gdbPath = "@C:\\myDataFolder\\myData.gdb"; var newlyAddedGDB = await QueuedTask.Run(() => { //Create the File GDB project item var item = ItemFactory.Instance.Create(gdbPath) as IProjectItem; //If it is succesfully added to the project, return it otherwise null return(Project.Current.AddItem(item) ? item as GDBProjectItem : null); }); #endregion #region How to add a new map to a project await QueuedTask.Run(() => { //Note: see also MapFactory in ArcGIS.Desktop.Mapping var map = MapFactory.Instance.CreateMap("New Map", MapType.Map, MapViewingMode.Map, Basemap.Oceans); ProApp.Panes.CreateMapPaneAsync(map); }); #endregion #region Check if project needs to be saved //The project's dirty state indicates changes made to the project have not yet been saved. bool isProjectDirty = Project.Current.IsDirty; #endregion #region Get all the project items IEnumerable <Item> allProjectItems = Project.Current.GetItems <Item>(); foreach (var pi in allProjectItems) { //Do Something } #endregion #region Gets all the "MapProjectItems" IEnumerable <MapProjectItem> newMapItemsContainer = project.GetItems <MapProjectItem>(); await QueuedTask.Run(() => { foreach (var mp in newMapItemsContainer) { //Do Something with the map. For Example: Map myMap = mp.GetMap(); } }); #endregion #region Gets a specific "MapProjectItem" MapProjectItem mapProjItem = Project.Current.GetItems <MapProjectItem>().FirstOrDefault(item => item.Name.Equals("EuropeMap")); #endregion #region Gets all the "StyleProjectItems" IEnumerable <StyleProjectItem> newStyleItemsContainer = null; newStyleItemsContainer = Project.Current.GetItems <StyleProjectItem>(); foreach (var styleItem in newStyleItemsContainer) { //Do Something with the style. } #endregion #region Gets a specific "StyleProjectItem" var container = Project.Current.GetItems <StyleProjectItem>(); StyleProjectItem testStyle = container.FirstOrDefault(style => (style.Name == "ArcGIS 3D")); StyleItem cone = null; if (testStyle != null) { cone = testStyle.LookupItem(StyleItemType.PointSymbol, "Cone_Volume_3"); } #endregion #region Gets all the "GDBProjectItems" IEnumerable <GDBProjectItem> newGDBItemsContainer = null; newGDBItemsContainer = Project.Current.GetItems <GDBProjectItem>(); foreach (var GDBItem in newGDBItemsContainer) { //Do Something with the GDB. } #endregion #region Gets a specific "GDBProjectItem" GDBProjectItem GDBProjItem = Project.Current.GetItems <GDBProjectItem>().FirstOrDefault(item => item.Name.Equals("myGDB")); #endregion #region Gets all the "ServerConnectionProjectItem" IEnumerable <ServerConnectionProjectItem> newServerConnections = null; newServerConnections = project.GetItems <ServerConnectionProjectItem>(); foreach (var serverItem in newServerConnections) { //Do Something with the server connection. } #endregion #region Gets a specific "ServerConnectionProjectItem" ServerConnectionProjectItem serverProjItem = Project.Current.GetItems <ServerConnectionProjectItem>().FirstOrDefault(item => item.Name.Equals("myServer")); #endregion #region Gets all folder connections in a project //Gets all the folder connections in the current project var projectFolders = Project.Current.GetItems <FolderConnectionProjectItem>(); foreach (var FolderItem in projectFolders) { //Do Something with the Folder connection. } #endregion #region Gets a specific folder connection //Gets a specific folder connection in the current project FolderConnectionProjectItem myProjectFolder = Project.Current.GetItems <FolderConnectionProjectItem>().FirstOrDefault(folderPI => folderPI.Name.Equals("myDataFolder")); #endregion #region Remove a specific folder connection // Remove a folder connection from a project; the folder stored on the local disk or the network is not deleted FolderConnectionProjectItem folderToRemove = Project.Current.GetItems <FolderConnectionProjectItem>().FirstOrDefault(myfolder => myfolder.Name.Equals("PlantSpecies")); if (folderToRemove != null) { Project.Current.RemoveItem(folderToRemove as IProjectItem); } #endregion #region Gets a specific "LayoutProjectItem" LayoutProjectItem layoutProjItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("myLayout")); #endregion #region Gets all layouts in a project: //Gets all the layouts in the current project var projectLayouts = Project.Current.GetItems <LayoutProjectItem>(); foreach (var layoutItem in projectLayouts) { //Do Something with the layout } #endregion #region Gets a specific "GeoprocessingProjectItem" GeoprocessingProjectItem GPProjItem = Project.Current.GetItems <GeoprocessingProjectItem>().FirstOrDefault(item => item.Name.Equals("myToolbox")); #endregion #region Gets all GeoprocessingProjectItems in a project: //Gets all the GeoprocessingProjectItem in the current project var GPItems = Project.Current.GetItems <GeoprocessingProjectItem>(); foreach (var tbx in GPItems) { //Do Something with the toolbox } #endregion #region Search project for a specific item List <Item> _mxd = new List <Item>(); //Gets all the folder connections in the current project var allFoldersItem = Project.Current.GetItems <FolderConnectionProjectItem>(); if (allFoldersItem != null) { //iterate through all the FolderConnectionProjectItems found foreach (var folderItem in allFoldersItem) { //Search for mxd files in that folder connection and add it to the List<T> //Note:ArcGIS Pro automatically creates and dynamically updates a searchable index as you build and work with projects. //Items are indexed when they are added to a project. //The first time a folder or database is indexed, indexing may take a while if it contains a large number of items. //While the index is being created, searches will not return any results. _mxd.AddRange(folderItem.GetItems()); } } #endregion #region Get the Default Project Folder var defaultProjectPath = System.IO.Path.Combine( System.Environment.GetFolderPath( Environment.SpecialFolder.MyDocuments), @"ArcGIS\Projects"); #endregion }
/// <summary> /// Initializes a new ButtonInPopup /// </summary> public ButtonInPopup(StyleItem item) : base(HtmlTextWriterTag.Span) { _item = item; this.CssClass = item.CssClass; }
private void CreateOrUpdateListing(IDbFactory dbFactory, ITime time, ILogService log, MarketType market, string marketplaceId, ParentItemDTO product, bool canCreate, bool updateQty, bool updateStyleInfo, bool mapByBarcode, bool processOnlyStyle) { using (var db = dbFactory.GetRWDb()) { //var productImageUrl = product.ImageSource; if (!product.Variations.Any()) { log.Debug("No variations, productId=" + product.SourceMarketId + ", handle=" + product.SourceMarketUrl); } var skuList = product.Variations.Select(v => v.SKU).ToList(); var baseSKU = product.Variations.FirstOrDefault()?.SKU ?? ""; var skuParts = baseSKU.Split("-".ToCharArray()); var mainSKU = (skuList.Distinct().Count() > 1 && skuParts.Count() > 1) ? String.Join("-", skuParts.Take(skuParts.Count() - 1)) : baseSKU; _log.Info("Main SKU: " + mainSKU + ", variations: " + String.Join(", ", skuList)); //var firstMRSP = product.Variations.FirstOrDefault()?.ListPrice; //var firstBarcode = product.Variations.FirstOrDefault()?.Barcode; //Style Style existStyle = null; //Get by SKU/Name if (existStyle == null) { existStyle = db.Styles.GetAll().FirstOrDefault(s => s.StyleID == mainSKU); if (existStyle != null) { _log.Info("Style found by StyleID"); } } var isNewStyle = false; //Create new if (existStyle == null) { if (!canCreate) { _log.Info("Unable to find style for, SKU: " + mainSKU); return; } existStyle = new Style() { StyleID = mainSKU, CreateDate = time.GetAppNowTime(), }; db.Styles.Add(existStyle); isNewStyle = true; } else { } existStyle.DropShipperId = DSHelper.DefaultDSId; if (updateStyleInfo || isNewStyle) { existStyle.StyleID = mainSKU; existStyle.Description = product.Description; existStyle.Name = product.AmazonName; existStyle.Image = product.ImageSource; existStyle.Manufacturer = product.Department; existStyle.BulletPoint1 = product.SearchKeywords; existStyle.BulletPoint2 = product.Type; //existStyle.MSRP = firstMRSP; //existStyle.Price = product.Variations.Select(v => v.AmazonCurrentPrice).FirstOrDefault(); existStyle.UpdateDate = time.GetAppNowTime(); } db.Commit(); //if (!processOnlyStyle) { //Style Image var existStyleImages = db.StyleImages.GetAll().Where(si => si.StyleId == existStyle.Id).ToList(); if (!existStyleImages.Any() && !String.IsNullOrEmpty(product.ImageSource)) { var newImage = new StyleImage() { Image = product.ImageSource, IsDefault = true, Type = (int)StyleImageType.HiRes, StyleId = existStyle.Id, CreateDate = _time.GetAppNowTime() }; db.StyleImages.Add(newImage); db.Commit(); } } //StyleFeatures if (isNewStyle && !processOnlyStyle) { var existFeatures = db.StyleFeatureTextValues.GetAll().Where(tv => tv.StyleId == existStyle.Id).ToList(); var existDdlFeatures = db.StyleFeatureValues.GetAll().Where(tv => tv.StyleId == existStyle.Id).ToList(); var allFeatureValues = db.FeatureValues.GetAllAsDto().ToList(); var newFeatures = ComposeFeatureList(db, allFeatureValues, product.Type, product.SearchKeywords); newFeatures.Add(ComposeFeatureValue(db, "Product Type", product.Type)); //newFeatures.Add(ComposeFeatureValue(db, "Brand Name", product.Department)); foreach (var feature in newFeatures) { if (feature == null) { continue; } var existFeature = existFeatures.FirstOrDefault(f => f.FeatureId == feature.Id); var existDdlFeature = existDdlFeatures.FirstOrDefault(f => f.FeatureId == feature.Id); if (existFeature == null && existDdlFeature == null) { if (feature.Type == (int)FeatureValuesType.TextBox) { db.StyleFeatureTextValues.Add(new StyleFeatureTextValue() { FeatureId = feature.FeatureId, Value = StringHelper.Substring(feature.Value, 512), StyleId = existStyle.Id, CreateDate = _time.GetAppNowTime() }); } if (feature.Type == (int)FeatureValuesType.DropDown) { db.StyleFeatureValues.Add(new StyleFeatureValue() { FeatureId = feature.FeatureId, FeatureValueId = feature.FeatureValueId.Value, StyleId = existStyle.Id, CreateDate = _time.GetAppNowTime() }); } } } db.Commit(); } ParentItem existParentItem = null; //if (!processOnlyStyle) { //ParentItem existParentItem = db.ParentItems.GetAll().FirstOrDefault(pi => pi.Market == (int)market && (pi.MarketplaceId == marketplaceId || String.IsNullOrEmpty( marketplaceId)) && pi.SourceMarketId == product.SourceMarketId); if (existParentItem == null) { existParentItem = new ParentItem() { Market = (int)market, MarketplaceId = marketplaceId, ASIN = product.ASIN, SourceMarketId = product.SourceMarketId, CreateDate = time.GetAppNowTime(), }; db.ParentItems.Add(existParentItem); } existParentItem.AmazonName = product.AmazonName; existParentItem.Type = product.Type; existParentItem.Description = product.Description; existParentItem.ImageSource = product.ImageSource; existParentItem.SourceMarketUrl = product.SourceMarketUrl; existParentItem.SearchKeywords = product.SearchKeywords; existParentItem.UpdateDate = time.GetAppNowTime(); existParentItem.IsAmazonUpdated = true; existParentItem.LastUpdateFromAmazon = time.GetAppNowTime(); db.Commit(); product.Id = existParentItem.Id; } //if (!processOnlyStyle) { foreach (var variation in product.Variations) { //StyleItem var existStyleItem = db.StyleItems.GetAll() .FirstOrDefault(si => si.StyleId == existStyle.Id); // && (si.Color == variation.Color || String.IsNullOrEmpty(variation.Color))); var isNewStyleItem = false; if (existStyleItem == null) { if (!canCreate && !isNewStyle) { _log.Info("Unable to find StyleItem for styleId: " + existStyle.StyleID); return; } existStyleItem = new StyleItem() { StyleId = existStyle.Id, Size = variation.Size, Color = variation.Color, }; db.StyleItems.Add(existStyleItem); isNewStyleItem = true; } //TEMP: //if (updateQty || isNewStyle) //{ // existStyleItem.Quantity = variation.AmazonRealQuantity; // existStyleItem.QuantitySetDate = time.GetAppNowTime(); //} db.Commit(); variation.StyleItemId = existStyleItem.Id; //StyleItem Barcode if (!String.IsNullOrEmpty(variation.Barcode)) { var existBarcode = db.StyleItemBarcodes.GetAll().FirstOrDefault(b => b.Barcode == variation.Barcode); if (existBarcode == null) { _log.Info("Added new barcode: " + variation.Barcode); existBarcode = new StyleItemBarcode() { Barcode = variation.Barcode, CreateDate = time.GetAppNowTime(), }; db.StyleItemBarcodes.Add(existBarcode); } existBarcode.StyleItemId = existStyleItem.Id; existBarcode.UpdateDate = time.GetAppNowTime(); db.Commit(); } //if (!processOnlyStyle) { //Item var existItem = db.Items.GetAll().FirstOrDefault(v => v.SourceMarketId == variation.SourceMarketId && v.Market == (int)market && (v.MarketplaceId == marketplaceId || String.IsNullOrEmpty(marketplaceId))); if (existItem == null) { existItem = new Item() { ParentASIN = existParentItem.ASIN, ASIN = variation.ASIN, SourceMarketId = variation.SourceMarketId, Market = (int)market, MarketplaceId = marketplaceId, CreateDate = time.GetAppNowTime(), }; db.Items.Add(existItem); } existItem.StyleId = existStyle.Id; existItem.StyleItemId = existStyleItem.Id; existItem.Title = product.AmazonName; existItem.Barcode = variation.Barcode; existItem.Color = variation.Color; existItem.Size = variation.Size; existItem.SourceMarketUrl = variation.SourceMarketUrl; existItem.PrimaryImage = variation.ImageUrl; existItem.ListPrice = (decimal?)variation.ListPrice; existItem.UpdateDate = time.GetAppNowTime(); existItem.IsExistOnAmazon = true; existItem.LastUpdateFromAmazon = time.GetAppNowTime(); existItem.ItemPublishedStatus = variation.PublishedStatus; existItem.ItemPublishedStatusDate = variation.PuclishedStatusDate ?? time.GetAppNowTime(); db.Commit(); variation.Id = existItem.Id; //Listing var existListing = db.Listings.GetAll().FirstOrDefault(v => v.ListingId == variation.ListingId.ToString() && v.Market == (int)market && (v.MarketplaceId == marketplaceId || String.IsNullOrEmpty(marketplaceId))); if (existListing == null) { existListing = new Listing() { ItemId = existItem.Id, ASIN = variation.ASIN, ListingId = StringHelper.GetFirstNotEmpty(variation.ASIN, variation.ListingId), Market = (int)market, MarketplaceId = marketplaceId, CreateDate = time.GetAppNowTime(), }; db.Listings.Add(existListing); } existListing.SKU = variation.SKU; existListing.CurrentPrice = (decimal)(variation.AmazonCurrentPrice ?? 0); existListing.AmazonCurrentPrice = (decimal?)variation.AmazonCurrentPrice; existListing.AmazonCurrentPriceUpdateDate = time.GetAmazonNowTime(); existListing.PriceFromMarketUpdatedDate = time.GetAppNowTime(); existListing.RealQuantity = variation.AmazonRealQuantity ?? 0; existListing.AmazonRealQuantity = variation.AmazonRealQuantity ?? 0; existListing.AmazonRealQuantityUpdateDate = time.GetAppNowTime(); existListing.UpdateDate = time.GetAppNowTime(); existListing.IsRemoved = false; db.Commit(); variation.ListingEntityId = existListing.Id; } } } } }
//Create a CIMSymbol from style item selected in the results gallery list box and //apply this newly created symbol to the feature layer currently selected in Contents pane private async void ApplyTheSelectedSymbol(StyleItem selectedStyleItemToApply) { if (selectedStyleItemToApply == null || string.IsNullOrEmpty(selectedStyleItemToApply.Key)) return; await QueuedTask.Run(() => { //Get the feature layer currently selected in the Contents pane FeatureLayer ftrLayer = MappingModule.ActiveTOC.MostRecentlySelectedLayer as FeatureLayer; if (ftrLayer == null) return; //Create symbol from style item. CIMSymbol symbolFromStyleItem = selectedStyleItemToApply.GetObject() as CIMSymbol; //Set real world setting for created symbol = feature layer's setting //so that there isn't a mismatch between symbol and feature layer SymbolBuilder.SetRealWorldUnits(symbolFromStyleItem, ftrLayer.UsesRealWorldSymbolSizes); //Get simple renderer from feature layer CIMSimpleRenderer currentRenderer = ftrLayer.GetRenderer() as CIMSimpleRenderer; //Set current renderer's symbol reference = symbol reference of the newly created symbol currentRenderer.Symbol = SymbolBuilder.MakeSymbolReference(symbolFromStyleItem); //Update feature layer renderer with new symbol ftrLayer.SetRenderer(currentRenderer); }); }