public IActionResult Index() { IDataSource dataSource = new ProductSource(); IEnumerable <Product> productList = dataSource.GetProducts(); return(View(productList)); }
public IActionResult AddoUpdate(ProductSource model) { //待返回对象 var result = new ResponseModel(ResponseCode.Success, "保存服务源成功!"); var row = 0; try { //新增服务源 if (model.id == 0) { model.密码 = Strings.StrToMD5(model.密码); row = this.Add(model).Execute(); } //修改 else { row = this.Update(model).Columns("产品id", "名称", "服务地址", "授权码", "用户名", "授权方式") .Where("id", model.id).Execute(); } if (row < 1) { result.msg = "服务器内部异常!"; result.code = (int)ResponseCode.Error; } } catch (Exception ex) { LogError("保存服务源失败", ex); result.code = (int)ResponseCode.Error; result.msg = "服务器内部异常"; } return(Json(result)); }
public IHttpActionResult GetProductSource(int id) { ProductSource productSource = db.ProductSources.Find(id); if (productSource == null) { return(NotFound()); } return(Ok(productSource)); }
protected override void AfterSetUp() { _product = new ProductBuilder().Build(); _supplier1 = new SupplierBuilder().Build(); _supplier2 = new SupplierBuilder().Build(); _source1 = _product.AddSource(_supplier1, 10); _source2 = _product.AddSource(_supplier2, 12); Session.Save(_product); Flush(); }
private IAction CreateAction(ProductSource productSource) { var camera = CameraProvider.GetCamera(productSource.ProductName, CameraViewModel.Info, CameraViewModel.SelectedItem.Model); if (camera == null) { return(null); } return(CreateAction(camera, productSource)); }
public IHttpActionResult PutProductSource(int id, ProductSource productSource) { var model = db.ProductSources.Where(x => x.IsActive == true && x.Id == id).FirstOrDefault(); model.Source = productSource.Source; model.IsActive = true; model.UpdatedOn = System.DateTime.UtcNow; db.SaveChanges(); return(Ok(true)); }
private TrackerProductSourceViewModel CreateSourceViewModel(ProductSource productSource) { var lastPrice = productSource == null || _product?.Recent == null ? null : _product.Recent.FirstOrDefault(x => x.ProductSourceId == productSource.Id)?.Price; var vm = new TrackerProductSourceViewModel(_ui, productSource, lastPrice); vm.DeleteCommand.Executed.Subscribe(_ => Sources.Remove(vm)); return(vm); }
protected InstallActionBase(MainViewModel mainViewModel, ICameraProvider cameraProvider, IDownloaderProvider downloaderProvider, ProductSource productSource) : base(mainViewModel) { CameraProvider = cameraProvider; DownloaderProvider = downloaderProvider; ProductSource = productSource; var distroName = string.Format("Distro_{0}", SourceName); var distroDisplayName = Resources.ResourceManager.GetString(distroName); DisplayName = string.Format(ActionFormat, distroDisplayName); }
private IAction CreateAction(ProductSource productSource) { var types = new[] { typeof(ProductSource) }; var values = new object[] { productSource }; return(ServiceActivator.Create <TAction>(types, values)); }
public TrackerProductSourceViewModel(IUserInteraction ui, ProductSource productSource, decimal?lastPrice) { Id = productSource?.Id ?? Guid.NewGuid(); Agent = productSource?.AgentId; Argument = productSource?.AgentArgument; LastPrice = lastPrice; PropertiesAreInitialized = true; ShowInBrowserCommand = new ActionCommand(_ => { ui.ShowProductInBrowser(productSource); }); }
public bool GetSource(ProductSource user) { if (user.Id > 0) { var source = db.ProductSources.Where(x => x.Id == user.Id && x.IsActive == true).FirstOrDefault(); if (source.Source.Equals(user.Source)) { return(false); } } var data = db.ProductSources.Any(x => x.Source == user.Source && x.IsActive == true); return(data); }
protected IAction CreateAction(SoftwareCameraInfo camera, ProductSource productSource) { var types = new[] { typeof(SoftwareCameraInfo), typeof(ProductSource) }; var values = new object[] { camera, productSource }; return(ServiceActivator.Create <TAction>(types, values)); }
public void ShowProductInBrowser(ProductSource productSource) { if (productSource == null) { return; } var agentUrl = _agentRepo.FindById(productSource.AgentId).Url; var url = string.Format(agentUrl, productSource.AgentArgument); url = url.Replace("&", "^&"); Process.Start(new ProcessStartInfo("cmd", $"/c start {url}") { CreateNoWindow = true }); }
internal static async Task <Result> AddNewProduct(string gtin, string name, decimal?quantity, string unit) { if (string.IsNullOrWhiteSpace(gtin) || string.IsNullOrWhiteSpace(name)) { return new Result { Success = false, Error = "The name or gtin was not properly inserted" } } ; await ProductSource.AddProduct(name, gtin, quantity, unit); //await OutpanProductSource.AddProduct(name, gtin); return(new Result { Success = true }); } }
public IHttpActionResult PostProductSource(ProductSource productSource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var model = new ProductSource(); model.IsActive = true; model.Source = productSource.Source; model.CreatedOn = System.DateTime.UtcNow; model.UpdatedOn = System.DateTime.UtcNow; //var pageName = Request.RequestUri.LocalPath.getRouteName(); //Object obj = null; //var UserId = 0; //if (Request.Headers.Contains("Email")) //{ // var email = ((string[])(Request.Headers.GetValues("Email")))[0].ToString(); // UserId = db.Users.Where(x => x.IsActive == true && x.Email.Contains(email)).FirstOrDefault().Id; //} db.ProductSources.Add(model); //try //{ db.SaveChanges(); //} //catch (Exception ex) { obj = ex; } //finally //{ // if (obj == null) // { // var logTable = Newtonsoft.Json.JsonConvert.SerializeObject(productSource, new JsonSerializerSettings() // { // PreserveReferencesHandling = PreserveReferencesHandling.Objects, // Formatting = Formatting.Indented // }); // var flag = productSource.CreateLog(pageName, logTable, UserId); // } //} return(Ok(true)); }
public ProductSource GetCode(string sku) { ProductSource model = new ProductSource(); bool data = db.ProductSources.Any(x => x.Source == sku && x.IsActive == true); if (data == true) { model = db.ProductSources.Where(x => x.IsActive == true && x.Source == sku).FirstOrDefault(); } else { model.Source = sku; model.IsActive = true; db.ProductSources.Add(model); db.SaveChanges(); var list = db.ProductSources.Where(x => x.IsActive == true).ToList(); model = list.LastOrDefault(); } return(model); }
public IActionResult ResetPassword(BussinessSysPram model) { var result = new ResponseModel(ResponseCode.Success, "重置成功!"); try { if (model.productScoureid == 0) { result.code = (int)ResponseCode.Forbidden; result.msg = "缺少参数"; return(Json(result)); } //通过机构人员id查询账户 ProductSource ProductSource = new ProductSource() { 密码 = Strings.StrToMD5("123456") }; var count = this.Update(ProductSource).Columns("密码").Where("id", model.productScoureid).Execute(); if (count > 0) { result.code = (int)ResponseCode.Success; } else { result.code = (int)ResponseCode.Error; result.msg = "重置失败"; } } catch (Exception ex) { LogError("重置服务源密码操作失败", ex); result.code = (int)ResponseCode.Error; result.msg = "服务器内部异常"; } return(Json(result)); }
private void GetProductProperties(XmlNode node, ref ProductSource productSource) { foreach (XmlAttribute attribute in node.Attributes) { int tempInt; switch (attribute.Name) { case "Name": productSource.Name = attribute.Value; break; case "Category": productSource.Category = Categories.FirstOrDefault(x => x.Name.Equals(attribute.Value)); break; case "SubCategory": productSource.SubCategory = attribute.Value; break; case "RateType": productSource.RateType = attribute.Value; break; case "Rate": decimal tempDecimal; if (Decimal.TryParse(attribute.Value, out tempDecimal)) { productSource.Rate = tempDecimal; } else { productSource.Rate = null; } break; case "Overview": productSource.Overview = attribute.Value; break; case "DefaultWebsite": productSource.DefaultWebsite = attribute.Value; break; case "Width": if (int.TryParse(attribute.Value, out tempInt)) { productSource.Width = tempInt; } else { productSource.Width = null; } break; case "Height": if (int.TryParse(attribute.Value, out tempInt)) { productSource.Height = tempInt; } else { productSource.Height = null; } break; case "EnableTarget": { bool temp; if (Boolean.TryParse(attribute.Value, out temp)) { productSource.EnableTarget = temp; } } break; case "EnableLocation": { bool temp; if (Boolean.TryParse(attribute.Value, out temp)) { productSource.EnableLocation = temp; } } break; case "EnableRichMedia": { bool temp; if (Boolean.TryParse(attribute.Value, out temp)) { productSource.EnableRichMedia = temp; } } break; case "EnableRate": { bool temp; if (Boolean.TryParse(attribute.Value, out temp)) { productSource.EnableRate = temp; } } break; } } }
private int GetProductSourceOrder(ProductSource productSource) { return(GetSourceOrder(productSource.Source)); }
public UpdateAction(MainViewModel mainViewModel, ICameraProvider cameraProvider, IDownloaderProvider downloaderProvider, ProductSource productSource) : base(mainViewModel, cameraProvider, downloaderProvider, productSource) { }
public override void Apply(Product p, ImportRow r) { var features = new List <string>(); var images = new List <string>(); // select the option that this row refers, or use the default option // creates the named option if it does not exist. var optionName = (string)r[ProductColumnMappingTargets.OptionName] ?? ""; if (null == p.Options) { p.Options = new List <ProductOption>(); } var option = p.Options.FirstOrDefault(x => x.Name == optionName); if (null == option) { option = new ProductOption { Name = optionName, }; p.Options.Add(option); } // select the product source or use a default source var vendorName = (string)r[ProductColumnMappingTargets.Vendor] ?? ""; if (null == option.Sources) { option.Sources = new List <ProductSource>(); } var source = String.IsNullOrEmpty(vendorName) ? option.Sources.FirstOrDefault(x => x.Vendor == null) : option.Sources.FirstOrDefault(x => null != x.Vendor && x.Vendor.Value.Name == vendorName); if (null == source) { source = new ProductSource { Pricing = new ProductPricing(), Stock = new ProductStock(), Vendor = null, }; if (!String.IsNullOrEmpty(vendorName)) { var vendor = Vendors.FindVendorByName(vendorName); if (null == vendor) { vendor = new Vendor { Document = new Document() { Id = Document.For <Vendor>(vendorName.ToSlug()) }, Name = vendorName, }; Vendors.Save(vendor); source.Vendor = Reference.To(vendor); } } option.Sources.Add(source); } var pricing = source.Pricing ?? (source.Pricing = new ProductPricing()); var stock = source.Stock ?? (source.Stock = new ProductStock()); for (var i = 0; i < r.Layout.Length; i++) { var value = r.Values[i]; var target = r.Layout[i]; switch (target) { case ProductColumnMappingTargets.Enabled: p.Set(x => x.Enabled, (bool)value); break; case ProductColumnMappingTargets.Category: p.Set(x => x.Category, (Product.ParseCategory((string)value))); break; case ProductColumnMappingTargets.Name: p.Set(x => x.Name, (string)value); break; case ProductColumnMappingTargets.Manufacturer: p.Set(x => x.Manufacturer, (string)value); break; case ProductColumnMappingTargets.Brand: p.Set(x => x.Brand, (string)value); break; case ProductColumnMappingTargets.Description: p.Set(x => x.Description, (string)value); break; case ProductColumnMappingTargets.Details: p.Set(x => x.Details, (string)value); break; case ProductColumnMappingTargets.Warranty: p.Set(x => x.Warranty, (string)value); break; case ProductColumnMappingTargets.CountryOfOrigin: p.Set(x => x.CountryOfOrigin, (string)value); break; case ProductColumnMappingTargets.Model: p.Model = ((string)value); break; case ProductColumnMappingTargets.LeadTime: stock.Leadtime = (string)value; break; case ProductColumnMappingTargets.Feature: features.Add((string)value); break; case ProductColumnMappingTargets.Sku: p.Set(x => x.Sku, (string)value); break; case ProductColumnMappingTargets.Upc: p.Set(x => x.Upc, (string)value); break; case ProductColumnMappingTargets.PackageL: (p.PackageDimensions ?? (p.PackageDimensions = new ProductDimensions())).Length = (decimal?)value; break; case ProductColumnMappingTargets.PackageW: (p.PackageDimensions ?? (p.PackageDimensions = new ProductDimensions())).Width = (decimal?)value; break; case ProductColumnMappingTargets.PackageH: (p.PackageDimensions ?? (p.PackageDimensions = new ProductDimensions())).Height = (decimal?)value; break; case ProductColumnMappingTargets.PackageWeight: (p.PackageDimensions ?? (p.PackageDimensions = new ProductDimensions())).Weight = (decimal?)value; break; case ProductColumnMappingTargets.ProductL: (p.ProductDimensions ?? (p.ProductDimensions = new ProductDimensions())).Length = (decimal?)value; break; case ProductColumnMappingTargets.ProductW: (p.ProductDimensions ?? (p.ProductDimensions = new ProductDimensions())).Width = (decimal?)value; break; case ProductColumnMappingTargets.ProductH: (p.ProductDimensions ?? (p.ProductDimensions = new ProductDimensions())).Height = (decimal?)value; break; case ProductColumnMappingTargets.ProductWeight: (p.ProductDimensions ?? (p.ProductDimensions = new ProductDimensions())).Weight = (decimal?)value; break; case ProductColumnMappingTargets.Image: images.Add((string)value); break; case ProductColumnMappingTargets.SourceAdded: source.Added = (DateTime?)value; break; case ProductColumnMappingTargets.SourceUpdated: source.Updated = (DateTime?)value; break; case ProductColumnMappingTargets.Msrp: pricing.Msrp = (decimal?)value; break; case ProductColumnMappingTargets.Cost: pricing.Cost = ((decimal?)value).Value; break; case ProductColumnMappingTargets.ShippingFee: pricing.ShippingFee = (decimal?)value; break; case ProductColumnMappingTargets.ShippingCost: pricing.ShippingCost = (decimal?)value; break; case ProductColumnMappingTargets.OptionSku: option.Sku = (string)value; break; case ProductColumnMappingTargets.VendorPrice: pricing.Cost = ((decimal?)value) ?? 0; break; } } if (features.Count > 0) { p.Set(x => x.Features, features.Where(x => !String.IsNullOrWhiteSpace(x)).ToArray()); } if (images.Count > 0) { p.Set(x => x.Images, images.Where(x => !String.IsNullOrWhiteSpace(x)).ToArray()); } }
private void LoadOnlineStrategy(StorageFile listsSourceFile) { SlideHeaders.Clear(); Websites.Clear(); Strengths.Clear(); Categories.Clear(); ProductSources.Clear(); if (!listsSourceFile.ExistsLocal()) { return; } var document = new XmlDocument(); document.Load(listsSourceFile.LocalPath); var node = document.SelectSingleNode(@"/OnlineStrategy"); if (node == null) { return; } foreach (XmlNode childeNode in node.ChildNodes) { switch (childeNode.Name) { case "Header": foreach (XmlAttribute attribute in childeNode.Attributes) { switch (attribute.Name) { case "Value": if (!string.IsNullOrEmpty(attribute.Value) && !SlideHeaders.Contains(attribute.Value)) { SlideHeaders.Add(attribute.Value); } break; } } break; case "Site": foreach (XmlAttribute attribute in childeNode.Attributes) { switch (attribute.Name) { case "Value": if (!string.IsNullOrEmpty(attribute.Value) && !Websites.Contains(attribute.Value)) { Websites.Add(attribute.Value); } break; } } break; case "Strength": foreach (XmlAttribute attribute in childeNode.Attributes) { switch (attribute.Name) { case "Value": if (!string.IsNullOrEmpty(attribute.Value) && !Strengths.Contains(attribute.Value)) { Strengths.Add(attribute.Value); } break; } } break; case "PricingStrategy": foreach (XmlAttribute attribute in childeNode.Attributes) { switch (attribute.Name) { case "Value": if (!string.IsNullOrEmpty(attribute.Value) && !PricingStrategies.Contains(attribute.Value)) { PricingStrategies.Add(attribute.Value); } break; } } break; case "PositionColumn": foreach (XmlAttribute attribute in childeNode.Attributes) { switch (attribute.Name) { case "Value": if (!string.IsNullOrEmpty(attribute.Value) && !ColumnPositions.Contains(attribute.Value)) { ColumnPositions.Add(attribute.Value); } break; } } break; case "DefaultFormula": switch (childeNode.InnerText.ToLower().Trim()) { case "cpm": DefaultFormula = FormulaType.CPM; break; case "investment": DefaultFormula = FormulaType.Investment; break; case "impressions": DefaultFormula = FormulaType.Impressions; break; } break; case "LockedMode": { bool temp; if (Boolean.TryParse(childeNode.InnerText, out temp)) { LockedMode = temp; } } break; case "SpecialLinksEnable": { bool temp; if (Boolean.TryParse(childeNode.InnerText, out temp)) { SpecialLinksEnable = temp; } } break; case "SpecialButtonsGroupName": SpecialLinksGroupName = childeNode.InnerText; break; case "SpecialButtonsGroupLogo": if (string.IsNullOrEmpty(childeNode.InnerText)) { SpecialLinksGroupLogo = null; } else { SpecialLinksGroupLogo = new Bitmap(new MemoryStream(Convert.FromBase64String(childeNode.InnerText))); } break; case "Browser": SpecialLinkBrowsers.Add(childeNode.InnerText); break; case "SpecialButton": var specialLinkButton = new SpecialLinkButton(); GetSpecialButton(childeNode, ref specialLinkButton); if (!String.IsNullOrEmpty(specialLinkButton.Name) && !String.IsNullOrEmpty(specialLinkButton.Type) && specialLinkButton.Paths.Any()) { SpecialLinkButtons.Add(specialLinkButton); } break; case "Targeting": { var productInfo = new ProductInfo { Type = ProductInfoType.Targeting }; productInfo.Deserialize(childeNode); TargetingRecods.Add(productInfo); } break; case "RichMedia": { var productInfo = new ProductInfo { Type = ProductInfoType.RichMedia }; productInfo.Deserialize(childeNode); RichMediaRecods.Add(productInfo); } break; case "Category": var category = new Category(); GetCategories(childeNode, ref category); if (!string.IsNullOrEmpty(category.Name)) { Categories.Add(category); } break; case "Product": var productSource = new ProductSource(); GetProductProperties(childeNode, ref productSource); if (!string.IsNullOrEmpty(productSource.Name)) { ProductSources.Add(productSource); } break; case "Status": foreach (XmlAttribute attribute in childeNode.Attributes) { switch (attribute.Name) { case "Value": if (!Statuses.Contains(attribute.Value)) { Statuses.Add(attribute.Value); } break; } } break; case "DefaultHomeViewSettings": DefaultHomeViewSettings.Deserialize(childeNode); break; case "DefaultDigitalProductSettings": DefaultDigitalProductSettings.Deserialize(childeNode); break; case "DefaultDigitalProductPackageSettings": DefaultDigitalProductPackageSettings.Deserialize(childeNode); break; case "DefaultDigitalStandalonePackageSettings": DefaultDigitalStandalonePackageSettings.Deserialize(childeNode); break; case "DigitalControlsConfiguration": DefaultControlsConfiguration = JsonConvert.DeserializeObject <DigitalControlsConfiguration>(Encoding.Unicode.GetString(Convert.FromBase64String(childeNode.InnerText)), new JsonImageConverter()); break; } } }
public UpdateAction(MainViewModel mainViewModel, IDownloaderProvider downloaderProvider, SoftwareCameraInfo camera, ProductSource productSource) : base(mainViewModel, downloaderProvider, camera, productSource) { }