internal static CustomProperty ScannerProperty(string name, string value) { CustomProperty prop = new CustomProperty(); prop.Name = name; prop.Value = value; return prop; }
public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems) { CustomProperty cp = new CustomProperty(codon.Properties["name"]) { displayName = codon.Properties["displayName"], description = codon.Properties["description"] }; if (!string.IsNullOrEmpty(codon.Properties["runCustomTool"])) cp.runCustomTool = bool.Parse(codon.Properties["runCustomTool"]); return cp; }
CustomProperty GetCustomPropertyByKey(CustomProperty[] properties, string name) { foreach (CustomProperty cp in properties) { if (cp.Name == name) return cp; } return null; }
public object BuildItem(BuildItemArgs args) { Codon codon = args.Codon; CustomProperty cp = new CustomProperty(codon.Properties["name"]) { displayName = codon.Properties["displayName"], description = codon.Properties["description"] }; if (!string.IsNullOrEmpty(codon.Properties["runCustomTool"])) cp.runCustomTool = bool.Parse(codon.Properties["runCustomTool"]); return cp; }
private void buttonOK_Click(object sender, EventArgs e) { if (textBox1.Text=="") { MessageBox.Show("Please specify a name for the Custom Property that is to be added to the first Item!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (checkBox1.Checked && textBox2.Text=="") { MessageBox.Show("Please specify a name for the Custom Property that is to be added to the second Item!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Editor.Instance.SelectedItems[0].CustomProperties.ContainsKey(textBox1.Text)) { MessageBox.Show("The first Item (" + Editor.Instance.SelectedItems[0].Name + ") "+ "already has a Custom Property named \"" + textBox1.Text + "\". Please use another name!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } CustomProperty cp = new CustomProperty(); cp.name = textBox1.Text; cp.type = typeof(Item); cp.value = Editor.Instance.SelectedItems[1]; Editor.Instance.SelectedItems[0].CustomProperties.Add(cp.name, cp); if (checkBox1.Checked) { if (Editor.Instance.SelectedItems[1].CustomProperties.ContainsKey(textBox2.Text)) { MessageBox.Show("The second Item (" + Editor.Instance.SelectedItems[1].Name + ") " + "already has a Custom Property named \"" + textBox2.Text + "\". Please use another name!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Editor.Instance.SelectedItems[0].CustomProperties.Remove(cp.name); return; } cp = new CustomProperty(); cp.name = textBox2.Text; cp.type = typeof(Item); cp.value = Editor.Instance.SelectedItems[0]; Editor.Instance.SelectedItems[1].CustomProperties.Add(cp.name, cp); } MainForm.Instance.propertyGrid1.Refresh(); this.Hide(); }
/// <summary> /// Constructor /// </summary> public Workarea_customproperties() { _siteApi = new SiteAPI(); _commonApi = new CommonApi(); _customPropertyApi = new CustomProperty(); _customPropertyCore = new CustomPropertyBL(); _styleHelper = new StyleHelper(); _pageAction = string.Empty; _propertyId = 0; _language = -1; _pageType = string.Empty; _translate = false; _originalLanguage = 0; _currentPage = 1; _messageHelper = _commonApi.EkMsgRef; _enableMultiLanguage = _commonApi.EnableMultilingual; _appImgPath = _commonApi.AppImgPath; _imageIconPath = _commonApi.AppPath + RelativeIconPath; _commonApi.ContentLanguage = _language; }
private void GetNextProperty(Guid productId, ICollection <CustomProperty> customProperties, CreateCustomPropertyCommand.CustomProperty currentProperty, CustomProperty parentProperty = null) { var customProperty = new CustomProperty { Value = currentProperty.Value, Name = currentProperty.Name, ProductId = productId, ParentProperty = parentProperty }; customProperties.Add(customProperty); if (currentProperty.ChildProperties == null || !currentProperty.ChildProperties.Any()) { return; } foreach (var property in currentProperty.ChildProperties) { GetNextProperty(productId, customProperties, property, customProperty); } }
private void AddSuccessfullFlag(PromotionContext context) { var flag = context .Order .CustomProperties .FirstOrDefault(s => s.DeveloperId == HCC_KEY && s.Key == "freePromotions"); if (flag == null) { var itemF = new CustomProperty(HCC_KEY, "freePromotions", context.PromotionId.ToString()); context.Order.CustomProperties.Add(itemF); } else { var list = flag.Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); if (!list.Contains(context.PromotionId.ToString())) { list.Add(context.PromotionId.ToString()); flag.Value = string.Join(",", list); } } }
public static CustomProperty LoadCustomProperty(XElement xProperty) { CustomProperty property = new CustomProperty(); property.m_Name = xProperty.GetAttributeAs("name", ""); property.m_Type = xProperty.GetAttributeAs("type", "string"); // In some cases, value may be in the default attribute property.m_Value = xProperty.GetAttributeAs("default", ""); // A value attribute overrides a default attribute if (!string.IsNullOrEmpty(xProperty.Value)) { // Using inner text property.m_Value = xProperty.Value; } else { // Using value attribute property.m_Value = xProperty.GetAttributeAs <string>("value", property.m_Value); } return(property); }
public void SetSelectItem(RenderBase render) { if (render == null) { propGrid.SelectedObject = null; return; } XmlNode tmpXNode = DynamicObj.propXmlDoc.SelectSingleNode("Components/Component[@Name='" + render.Name + "']"); XmlNodeList tmpXPropLst = null; if (tmpXNode != null) { tmpXPropLst = tmpXNode.SelectNodes("Propertys/Property"); } CustomProperty cp = new CustomProperty(render, tmpXPropLst); tmpXNode = DynamicObj.propXmlDoc.SelectSingleNode("Components/Component[@Name='Base']"); if (tmpXNode != null) { tmpXPropLst = tmpXNode.SelectNodes("Propertys/Property"); cp.AddProperty(tmpXPropLst); } propGrid.SelectedObject = cp; }
/// <summary> /// /// </summary> /// <param name="cc"></param> public void LoadProperties(ContentControl cc) { collection.Clear(); if (File.Exists(this.DocPath)) { //SetOutputExtension(this.Content.ToString()); TextEditor te = this.Content as TextEditor; System.Text.RegularExpressions.MatchCollection ma = System.Text.RegularExpressions.Regex.Matches(te.Text, @"<#@ parameter name="".*?"" "); this.PropertyCollection.Clear(); List <string> pnList = new List <string>(); foreach (Match item in ma) { if (item.Success) { pnList.Add(item.Value.Substring(item.Value.IndexOf(@"""")).Replace(@"""", "")); } } if (pnList.Count > 0) { for (int i = 0; i < pnList.Count; i++) { CustomProperty cp = new CustomProperty(); cp.Category = "Parameters"; cp.Value = string.Empty; cp.Name = pnList[i]; cp.IsBrowsable = true; cp.ValueType = typeof(string); collection.Add(cp); } } } CustomProperty cpDocExt = new CustomProperty(); cpDocExt.Category = "Document Properties"; cpDocExt.Name = "DocExt"; cpDocExt.DefaultValue = this.docExt; cpDocExt.Value = this.docExt; cpDocExt.IsReadOnly = true; cpDocExt.IsBrowsable = true; cpDocExt.ValueType = typeof(string); CustomProperty cpDocType = new CustomProperty(); cpDocType.Category = "Document Properties"; cpDocType.Name = "DocType"; cpDocType.DefaultValue = this.docType; cpDocType.Value = this.docType; //cpDocType.IsReadOnly = true; cpDocType.IsBrowsable = true; cpDocType.ValueType = typeof(DocumentType); //CustomProperty cpDocChanged = new CustomProperty(); //cpDocChanged.Category = "Document Properties"; //cpDocChanged.Name = "DocChanged"; //cpDocChanged.DefaultValue = this.docChanged; //cpDocChanged.Value = this.docChanged; //cpDocChanged.IsReadOnly = true; //cpDocChanged.IsBrowsable = true; CustomProperty cpDocPath = new CustomProperty(); cpDocPath.Category = "Document Properties"; cpDocPath.Name = "DocPath"; cpDocPath.DefaultValue = this.docPath; cpDocPath.Value = this.docPath; cpDocPath.IsReadOnly = true; cpDocPath.IsBrowsable = true; cpDocPath.ValueType = typeof(string); collection.Add(cpDocType); collection.Add(cpDocPath); //collection.Add(cpDocChanged); collection.Add(cpDocExt); //var pg = new System.Windows.Forms.PropertyGrid(); DocPropertyGrid.PropertyValueChanged += new PropertyValueChangedEventHandler(DocPropertyGrid_PropertyValueChanged); DocPropertyGrid.SelectedObject = collection; WindowsFormsHost wfh = new WindowsFormsHost(); wfh.Child = DocPropertyGrid; cc.Content = wfh; }
protected override void OnExecute(Command command, ExecutionContext context, System.Drawing.Rectangle buttonRect) { Part part = Window.ActiveWindow.Scene as Part; Debug.Assert(part != null); Double stepSize = 0.001; string tessellateLoftResolutionPropertyName = "Loft Tessellation Resolution"; if (!part.Document.CustomProperties.ContainsKey(tessellateLoftResolutionPropertyName)) { CustomProperty.Create(part.Document, tessellateLoftResolutionPropertyName, stepSize); } CustomProperty property; if (part.Document.CustomProperties.TryGetValue(tessellateLoftResolutionPropertyName, out property)) { stepSize = (double)property.Value; } List <ITrimmedCurve> curves = new List <ITrimmedCurve>(Window.ActiveWindow.GetAllSelectedITrimmedCurves()); if (curves.Count < 3) { return; } Point startPoint = curves[0].StartPoint; if (curves[1].StartPoint != startPoint) { if (curves[1].StartPoint != startPoint) { curves[0] = CurveSegment.Create(curves[0].GetGeometry <Curve>(), Interval.Create(curves[0].Bounds.End, curves[0].Bounds.Start)); // TBD Figure out why we can't call ReverseCurves and debug } else { curves[1] = CurveSegment.Create(curves[1].GetGeometry <Curve>(), Interval.Create(curves[1].Bounds.End, curves[1].Bounds.Start)); } } for (int i = 2; i < curves.Count; i++) { if (curves[i].StartPoint != startPoint) { curves[i] = CurveSegment.Create(curves[i].GetGeometry <Curve>(), Interval.Create(curves[i].Bounds.End, curves[i].Bounds.Start)); } if (curves[i].StartPoint != startPoint) { return; } } double endZ = double.NegativeInfinity; foreach (ITrimmedCurve curve in curves) { if (curve.EndPoint.Z > endZ) { endZ = curve.EndPoint.Z; } } Plane startPlane = Plane.Create(Frame.Create(startPoint, Direction.DirX, Direction.DirY)); double cuttingZ = startPoint.Z; List <List <Point> > curveSteps = new List <List <Point> >(); List <List <Point> > insetSteps = new List <List <Point> >(); while (true) { cuttingZ -= stepSize; if (cuttingZ < endZ) { break; } Plane cuttingPlane = Plane.Create(Frame.Create(Point.Create(startPoint.X, startPoint.Y, cuttingZ), Direction.DirX, Direction.DirY)); List <Point> curvePoints = new List <Point>(); List <Point> planarPoints = new List <Point>(); foreach (ITrimmedCurve curve in curves) { ICollection <IntPoint <SurfaceEvaluation, CurveEvaluation> > surfaceIntersections = cuttingPlane.IntersectCurve(curve.GetGeometry <Curve>()); foreach (IntPoint <SurfaceEvaluation, CurveEvaluation> surfaceIntersection in surfaceIntersections) { Point point = surfaceIntersection.Point; curvePoints.Add(point); Point projectedPoint = startPlane.ProjectPoint(point).Point; Direction direction = (projectedPoint - startPoint).Direction; double length = CurveSegment.Create(curve.GetGeometry <Curve>(), Interval.Create(curve.Bounds.Start, surfaceIntersection.EvaluationB.Param)).Length; planarPoints.Add(startPoint + direction * length); break; // assume one intersection } } List <Point> insetPoints = new List <Point>(); for (int i = 0; i < planarPoints.Count; i++) { int ii = i == planarPoints.Count - 1 ? 0 : i + 1; ICollection <Point> pointCandidates = AddInHelper.IntersectSpheres(new Sphere[] { Sphere.Create(Frame.Create(startPoint, Direction.DirX, Direction.DirY), ((startPoint - curvePoints[i]).Magnitude + (startPoint - curvePoints[ii]).Magnitude) / 2), Sphere.Create(Frame.Create(curvePoints[i], Direction.DirX, Direction.DirY), (startPoint - curvePoints[i]).Magnitude), Sphere.Create(Frame.Create(curvePoints[ii], Direction.DirX, Direction.DirY), (startPoint - curvePoints[ii]).Magnitude) }); Point planarMidPoint = Point.Origin + (planarPoints[i] + planarPoints[ii].Vector).Vector / 2; Point insetPoint; foreach (Point point in pointCandidates) { Point testPoint = startPlane.ProjectPoint(point).Point; if ((testPoint - planarMidPoint).Magnitude < (insetPoint - planarMidPoint).Magnitude) { insetPoint = point; } } insetPoints.Add(insetPoint); } curveSteps.Add(curvePoints); insetSteps.Add(insetPoints); } for (int i = 0; i < curveSteps.Count - 1; i++) { for (int j = 0; j < curveSteps[i].Count; j++) { int jj = j == curveSteps[i].Count - 1 ? 0 : j + 1; ShapeHelper.CreatePolygon(new Point[] { curveSteps[i][j], curveSteps[i + 1][j], insetSteps[i][j] }, 0, null); ShapeHelper.CreatePolygon(new Point[] { curveSteps[i + 1][j], insetSteps[i][j], insetSteps[i + 1][j] }, 0, null); ShapeHelper.CreatePolygon(new Point[] { insetSteps[i][j], insetSteps[i + 1][j], curveSteps[i][jj] }, 0, null); ShapeHelper.CreatePolygon(new Point[] { insetSteps[i + 1][j], curveSteps[i][jj], curveSteps[i + 1][jj] }, 0, null); } } return; }
void slyceGridEntities_CellValueChanged(int row, int cell, int column, string columnHeader, ref object tag, object newValue) { if (slyceGridEntities.Columns[column].Tag is CustomNamespace) { CustomNamespace ns = (CustomNamespace)slyceGridEntities.Columns[column].Tag; Entity entity = (Entity)slyceGridEntities.Items[row].Tag; bool isChecked = (bool)newValue; if (isChecked) { ns.Entities.Add(entity); } else { ns.Entities.Remove(entity); } } else if (slyceGridEntities.Columns[column].Tag is CustomImplement) { CustomImplement ci = (CustomImplement)slyceGridEntities.Columns[column].Tag; Entity entity = (Entity)slyceGridEntities.Items[row].Tag; bool isChecked = (bool)newValue; if (isChecked) { ci.Entities.Add(entity); } else { ci.Entities.Remove(entity); } } else if (slyceGridEntities.Columns[column].Tag is CustomAttribute) { CustomAttribute ca = (CustomAttribute)slyceGridEntities.Columns[column].Tag; Entity entity = (Entity)slyceGridEntities.Items[row].Tag; bool isChecked = (bool)newValue; if (isChecked) { ca.Entities.Add(entity); } else { ca.Entities.Remove(entity); } } else if (slyceGridEntities.Columns[column].Tag is CustomProperty) { CustomProperty cp = (CustomProperty)slyceGridEntities.Columns[column].Tag; Entity entity = (Entity)slyceGridEntities.Items[row].Tag; bool isChecked = (bool)newValue; if (isChecked) { cp.Entities.Add(entity); } else { cp.Entities.Remove(entity); } } else if (slyceGridEntities.Columns[column].Tag is CustomFunction) { CustomFunction cm = (CustomFunction)slyceGridEntities.Columns[column].Tag; Entity entity = (Entity)slyceGridEntities.Items[row].Tag; bool isChecked = (bool)newValue; if (isChecked) { cm.Entities.Add(entity); } else { cm.Entities.Remove(entity); } } }
public CustomPropertyDescriptor(CustomProperty prop) : base(prop.Name, null) { this.prop = prop; }
private void AddPropertyChildren(ScriptProperty Property, CustomPropertyGridObject Obj, string path, bool isArray) { int index = 0; foreach (ScriptProperty Child in Property.Children) { object value = false; Type valueType = typeof(bool); string nodePath = path; if (isArray) { nodePath += "[" + index + "]"; } else { if (nodePath != "") { nodePath += "."; } nodePath += Child.Name; } switch (Child.TypeName) { case "Bool": { value = (Child.CurrentValue == "1"); valueType = typeof(bool); break; } case "String": { value = Child.CurrentValue; valueType = typeof(string); break; } case "Float": { value = float.Parse(Child.CurrentValue); valueType = typeof(float); break; } case "Int": { value = int.Parse(Child.CurrentValue); valueType = typeof(int); break; } case "Array": { if (Child.CurrentValue != "Null") { CustomPropertyGridObject SubChild = new CustomPropertyGridObject(); AddPropertyChildren(Child, SubChild, nodePath, true); value = SubChild; valueType = typeof(CustomPropertyGridObject); } else { value = null; valueType = typeof(object); } break; } case "Object": { if (Child.CurrentValue != "Null") { CustomPropertyGridObject SubChild = new CustomPropertyGridObject(); AddPropertyChildren(Child, SubChild, nodePath, false); value = SubChild; valueType = typeof(CustomPropertyGridObject); } else { value = null; valueType = typeof(object); } break; } } string DisplayName = Child.Name.Replace("_", " "); if (DisplayName.Length > 2 && DisplayName.Substring(0, 2) == "m ") { DisplayName = DisplayName.Substring(2); } if (DisplayName.Length > 0 && DisplayName[0] >= 'a' && DisplayName[0] <= 'z') { DisplayName = DisplayName.Substring(0, 1).ToUpper() + DisplayName.Substring(1); } bool bReadOnly = Child.bReadOnly; if (DisplayName.Length > 3 && Utils.ValidationHelper.IsUppercase(DisplayName)) { bReadOnly = true; } if (isArray) { DisplayName = "[" + index + "]"; } CustomProperty Prop = new CustomProperty(DisplayName, value, valueType, bReadOnly, true, nodePath); Prop.Changed += Property_Changed; Obj.Add(Prop); index++; } }
public static CustomProperty PropertyToGrid(Property p, IPCCObject pcc) { string cat = p.TypeVal.ToString(); CustomProperty pg; switch (p.TypeVal) { case Type.BoolProperty: pg = new CustomProperty(pcc.Names[p.Name], cat, (p.Value.IntValue == 1), typeof(bool), false, true); break; case Type.FloatProperty: byte[] buff = BitConverter.GetBytes(p.Value.IntValue); float f = BitConverter.ToSingle(buff, 0); pg = new CustomProperty(pcc.Names[p.Name], cat, f, typeof(float), false, true); break; case Type.ByteProperty: case Type.NameProperty: NameProp pp = new NameProp(); pp.name = pcc.GetName(p.Value.IntValue); pp.nameindex = p.Value.IntValue; pg = new CustomProperty(pcc.Names[p.Name], cat, pp, typeof(NameProp), false, true); break; case Type.ObjectProperty: ObjectProp ppo = new ObjectProp(); ppo.name = pcc.getObjectName(p.Value.IntValue); ppo.nameindex = p.Value.IntValue; pg = new CustomProperty(pcc.Names[p.Name], cat, ppo, typeof(ObjectProp), false, true); break; case Type.StructProperty: StructProp ppp = new StructProp(); ppp.name = pcc.GetName(p.Value.IntValue); ppp.nameindex = p.Value.IntValue; byte[] buf = new byte[p.Value.Array.Count()]; for (int i = 0; i < p.Value.Array.Count(); i++) buf[i] = (byte)p.Value.Array[i].IntValue; List<int> buf2 = new List<int>(); for (int i = 0; i < p.Value.Array.Count() / 4; i++) buf2.Add(BitConverter.ToInt32(buf, i * 4)); ppp.data = buf2.ToArray(); pg = new CustomProperty(pcc.Names[p.Name], cat, ppp, typeof(StructProp), false, true); break; default: pg = new CustomProperty(pcc.Names[p.Name], cat, p.Value.IntValue, typeof(int), false, true); break; } return pg; }
private static void AddAttachment(Request request, string path, bool filepathOnly, string contentype) { Attachment attachment = null; string id = Guid.NewGuid().ToString(); string index = request.Attachments.Length.ToString(CultureInfo.InvariantCulture); attachment = new Attachment(new FCS.Lite.Interface.File(path, Path.GetFileName(path)), contentype, id, index, false); attachment.Properties = new CustomProperty[0]; attachment.Content = null; CustomProperty fileContentSource = new CustomProperty(ContentItemAdaptor.ContentDataSourceKey, path); attachment.Properties = new CustomProperty[] {fileContentSource}; List<Attachment> attachments = new List<Attachment>(request.Attachments); attachments.Add( attachment ); request.Attachments = attachments.ToArray(); }
private void SetPluginsVariables(string strClassName, string strPluginName, List<CPluginVariable> lstVariables) { if (lstVariables != null) { foreach (CPluginVariable cpvVariable in lstVariables) { string strCategoryName = strPluginName; string strVariableName = cpvVariable.Name; string[] a_strVariable = cpvVariable.Name.Split(new char[] { '|' }, 2); if (a_strVariable.Length == 2) { strCategoryName = a_strVariable[0]; strVariableName = a_strVariable[1]; } Enum generatedEnum = null; Match isGeneratedEnum; if ((isGeneratedEnum = Regex.Match(cpvVariable.Type, @"enum.(?<enumname>.*?)\((?<literals>.*)\)")).Success == true) { if ((generatedEnum = this.GenerateEnum(isGeneratedEnum.Groups["enumname"].Value, isGeneratedEnum.Groups["literals"].Value.Split('|'))) != null) { string variableValue = cpvVariable.Value; if (Enum.IsDefined(generatedEnum.GetType(), variableValue) == false) { string[] a_Names = Enum.GetNames(generatedEnum.GetType()); if (a_Names.Length > 0) { variableValue = a_Names[0]; } } if (Enum.IsDefined(generatedEnum.GetType(), variableValue) == true) { if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, Enum.Parse(generatedEnum.GetType(), variableValue), generatedEnum.GetType(), false, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = Enum.Parse(generatedEnum.GetType(), variableValue); } } } } else { switch (cpvVariable.Type) { case "bool": bool blTryBool; if (bool.TryParse(cpvVariable.Value, out blTryBool) == true) { if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, blTryBool, typeof(bool), false, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = blTryBool; } } break; case "onoff": if (Enum.IsDefined(typeof(enumBoolOnOff), cpvVariable.Value) == true) { if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, Enum.Parse(typeof(enumBoolOnOff), cpvVariable.Value), typeof(enumBoolOnOff), false, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = Enum.Parse(typeof(enumBoolOnOff), cpvVariable.Value); } } break; case "yesno": if (Enum.IsDefined(typeof(enumBoolYesNo), cpvVariable.Value) == true) { if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, Enum.Parse(typeof(enumBoolYesNo), cpvVariable.Value), typeof(enumBoolYesNo), false, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = Enum.Parse(typeof(enumBoolYesNo), cpvVariable.Value); } } break; case "int": int iTryInt; if (int.TryParse(cpvVariable.Value, out iTryInt) == true) { if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, iTryInt, typeof(int), false, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = iTryInt; } } break; case "double": double dblTryDouble; if (double.TryParse(cpvVariable.Value, out dblTryDouble) == true) { if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, dblTryDouble, typeof(double), false, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = dblTryDouble; } } break; case "string": if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, CPluginVariable.Decode(cpvVariable.Value), typeof(String), false, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = cpvVariable.Value; } break; case "multiline": if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { CustomProperty cptNewProperty = new CustomProperty(strVariableName, strCategoryName, strClassName, CPluginVariable.Decode(cpvVariable.Value), typeof(String), false, true); cptNewProperty.Attributes = new AttributeCollection( new EditorAttribute(typeof(System.ComponentModel.Design.MultilineStringEditor), typeof(System.Drawing.Design.UITypeEditor)), new TypeConverterAttribute(typeof(System.ComponentModel.Design.MultilineStringEditor)) ); this.m_cscPluginVariables.Add(cptNewProperty); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = cpvVariable.Value; } break; case "stringarray": if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, CPluginVariable.DecodeStringArray(cpvVariable.Value), typeof(string[]), false, true)); //this.m_cscPluginVariables.Add(new CustomProperty(cpvVariable.Name, strPluginName, strClassName, "Alaska", typeof(StatesList), false, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = CPluginVariable.DecodeStringArray(cpvVariable.Value); } break; } // } } } } this.ppgScriptSettings.Refresh(); }
public void FromDTO(OrderDTO dto) { if (dto == null) return; this.AffiliateID = dto.AffiliateID ?? string.Empty; this.BillingAddress.FromDto(dto.BillingAddress); this.bvin = dto.Bvin ?? string.Empty; this.Coupons.Clear(); if (dto.Coupons != null) { foreach (OrderCouponDTO c in dto.Coupons) { OrderCoupon cp = new OrderCoupon(); cp.FromDto(c); this.Coupons.Add(cp); } } this.CustomProperties.Clear(); if (dto.CustomProperties != null) { foreach (CustomPropertyDTO prop in dto.CustomProperties) { CustomProperty p = new CustomProperty(); p.FromDto(prop); this.CustomProperties.Add(p); } } this.FraudScore = dto.FraudScore; this.Id = dto.Id; this.Instructions = dto.Instructions ?? string.Empty; this.IsPlaced = dto.IsPlaced; this.Items.Clear(); if (dto.Items != null) { foreach (LineItemDTO li in dto.Items) { LineItem l = new LineItem(); l.FromDto(li); this.Items.Add(l); } } this.LastUpdatedUtc = dto.LastUpdatedUtc; this.Notes.Clear(); if (dto.Notes != null) { foreach (OrderNoteDTO n in dto.Notes) { OrderNote nn = new OrderNote(); nn.FromDto(n); this.Notes.Add(nn); } } this.OrderDiscountDetails.Clear(); if (dto.OrderDiscountDetails != null) { foreach (DiscountDetailDTO d in dto.OrderDiscountDetails) { Marketing.DiscountDetail m = new Marketing.DiscountDetail(); m.FromDto(d); this.OrderDiscountDetails.Add(m); } } this.OrderNumber = dto.OrderNumber ?? string.Empty; this.Packages.Clear(); if (dto.Packages != null) { foreach (OrderPackageDTO pak in dto.Packages) { OrderPackage pak2 = new OrderPackage(); pak2.FromDto(pak); this.Packages.Add(pak2); } } this.PaymentStatus = (OrderPaymentStatus)((int)dto.PaymentStatus); this.ShippingAddress.FromDto(dto.ShippingAddress); this.ShippingDiscountDetails.Clear(); if (dto.ShippingDiscountDetails != null) { foreach (DiscountDetailDTO sd in dto.ShippingDiscountDetails) { Marketing.DiscountDetail sdd = new Marketing.DiscountDetail(); sdd.FromDto(sd); this.ShippingDiscountDetails.Add(sdd); } } this.ShippingMethodDisplayName = dto.ShippingMethodDisplayName ?? string.Empty; this.ShippingMethodId = dto.ShippingMethodId ?? string.Empty; this.ShippingProviderId = dto.ShippingProviderId ?? string.Empty; this.ShippingProviderServiceCode = dto.ShippingProviderServiceCode ?? string.Empty; this.ShippingStatus = (OrderShippingStatus)((int)dto.ShippingStatus); this.StatusCode = dto.StatusCode ?? string.Empty; this.StatusName = dto.StatusName ?? string.Empty; this.StoreId = dto.StoreId; this.ThirdPartyOrderId = dto.ThirdPartyOrderId ?? string.Empty; this.TimeOfOrderUtc = dto.TimeOfOrderUtc; this.TotalHandling = dto.TotalHandling; this.TotalShippingBeforeDiscounts = dto.TotalShippingBeforeDiscounts; this.TotalTax = dto.TotalTax; this.TotalTax2 = dto.TotalTax2; this.UserEmail = dto.UserEmail ?? string.Empty; this.UserID = dto.UserID ?? string.Empty; }
private void btnAddCake_Click(object sender, EventArgs e) { if (Editor.Instance.CustomPropertyGroups.ContainsKey(cbbGroup.Text)) { CustomPropertyGroup group = Editor.Instance.CustomPropertyGroups[cbbGroup.Text]; foreach(CustomProperty prop in group.customproperties.Values) { CustomProperty cp = new CustomProperty(); cp.name = (String)prop.name.Clone(); cp.description = (String)prop.description.Clone(); cp.type = prop.type; if (prop.type == typeof(Vector2)) { Regex r = new Regex(@"^\d+(\.)?\d*$"); float x = ((Vector2)(prop.value)).X; float y = ((Vector2)(prop.value)).Y; cp.value = new Vector2(x, y); } else if (prop.type == typeof(Color)) { byte R = ((Color)(prop.value)).R; byte G = ((Color)(prop.value)).G; byte B = ((Color)(prop.value)).B; cp.value = new Color(R, G, B); } else { cp.value = prop.value; } if (cbxToAllSelected.Checked)//add to all selected items { foreach (Item item in Editor.Instance.SelectedItems) { if (cbxAddMode.Checked) { item.CustomProperties[cp.name] = cp.clone(); } else { if (item.CustomProperties.ContainsKey(cp.name) == false) { item.CustomProperties[cp.name] = cp.clone(); } } } } else//add to selected { if (customproperties.ContainsKey(cp.name) && cbxAddMode.Checked == false) { continue; } customproperties[cp.name] = cp.clone(); } } updateControls(); MainForm.Instance.propertyGrid1.Refresh(); } else { MessageBox.Show("A Custom Property Group with name \"" + cbbGroup.Text + "\" doesn't exists."); } }
private static void setExportFile(Level level, string filename) { string path = filename; if (level.CustomProperties.ContainsKey(EXPORTPATH_KEY)) { level.CustomProperties[EXPORTPATH_KEY].value = path; } else { CustomProperty exportPath = new CustomProperty(); exportPath.type = typeof(string); exportPath.name = "exportPath"; exportPath.value = path; level.CustomProperties.Add(EXPORTPATH_KEY, exportPath); } }
private void AddCustomProperties() { int i = 0; CustomProperty cp = new CustomProperty(); CustomPropertyObject cpo = new CustomPropertyObject(); string[] selectedIds = null; string[] selectedValues = null; if (Request.Form[hdnSelectedIDS.UniqueID] != "") { selectedIds = Request.Form[hdnSelectedIDS.UniqueID].Remove(System.Convert.ToInt32(Request.Form[hdnSelectedIDS.UniqueID].Length - 1), 1).Split(";".ToCharArray()); } if (Request.Form[hdnSelectValue.UniqueID] != "") { selectedValues = Request.Form[hdnSelectValue.UniqueID].Remove(System.Convert.ToInt32(Request.Form[hdnSelectValue.UniqueID].Length - 1), 1).Split(";".ToCharArray()); } if ((selectedIds != null)&& (selectedValues != null)) { if (selectedIds.Length == selectedValues.Length) { for (i = 0; i <= selectedIds.Length - 1; i++) { CustomPropertyData customPropertyData = cp.GetItem(Convert.ToInt64 (selectedIds[i]), m_refApi.ContentLanguage); CustomPropertyObjectData data = new CustomPropertyObjectData(TaxonomyId, m_refApi.ContentLanguage,Convert.ToInt64 ( selectedIds[i]), EkEnumeration.CustomPropertyObjectType.TaxonomyNode); if ((customPropertyData != null) && (data != null)) { string inputValue = HttpUtility.UrlDecode((string) (selectedValues[i].ToString())); switch (customPropertyData.PropertyDataType) { case EkEnumeration.CustomPropertyItemDataType.Boolean: bool booleanValue; if (bool.TryParse(inputValue, out booleanValue)) { data.AddItem(booleanValue); } break; case EkEnumeration.CustomPropertyItemDataType.DateTime: DateTime dateTimeValue; if (DateTime.TryParse(inputValue, out dateTimeValue)) { data.AddItem(dateTimeValue); } break; default: data.AddItem(inputValue); break; } cpo.Add(data); } } } } }
public override string ToString() { return($"\"TextElementType\":\"{TextElementType}\",\"CustomProperty\":{CustomProperty.ToString()}"); }
internal static async Task <CustomProperty> CreateAndGetCustomProperty(IApprendaTestSession session) { // Assemble var client = await session.GetClient(ApiPortals.SOC); var suffix = new Random().Next(10000); var customProperty = new CustomProperty { Name = $"test{suffix}", DisplayName = $"Testing {suffix}", Applicability = new CustomPropertyApplicabilityOptionCollection { Applications = new CustomPropertyApplicationOptions { AllowMultipleValues = true, IsApplied = true, IsComponentLevel = false, ApplicationComponentLevelOptions = new CustomPropertyApplicationComponentOptions { Databases = true, JavaWebApplications = true, LinuxServices = true, UserInterfaces = true, WindowsServices = true } }, ComputeServers = new CustomPropertyApplicabilityOption { IsApplied = true, AllowMultipleValues = true, }, DatabaseServers = new CustomPropertyApplicabilityOption { IsApplied = true, AllowMultipleValues = true, }, ResourcePolicies = new CustomPropertyApplicabilityOption { IsApplied = true, AllowMultipleValues = true }, StorageQuotas = new CustomPropertyApplicabilityOption { IsApplied = true, AllowMultipleValues = true } }, DeveloperOptions = new CustomPropertyDeveloperOptions { IsVisible = true, VisibilityOptions = new VisibilityOptions { IsEditableByDeveloper = true, IsRequiredForDeployment = true } }, ValueOptions = new CustomPropertyValueOptions { AllowCustomValues = true, PossibleValues = new List <string> { "one", "two", "three" }, DefaultValues = new List <string> { "two", "three" } } }; // Act var responseProperty = await client.CreateCustomProperty(customProperty); // Assert Assert.Equal(customProperty.Name, responseProperty.Name); Assert.NotEqual(0, responseProperty.Id); return(responseProperty); }
public static IHasCustomProperties SetCustomProperty(this IHasCustomProperties obj, CustomProperty customProperty) { var existing = obj.CustomProperties.SingleOrDefault(x => x.Definition.Value == customProperty.Definition.Value); if (existing != null) { existing.Value = customProperty.Value; } else { obj.CustomProperties.Add(customProperty); } return(obj); }
private void Properties_PropertyValueChanged(System.Object s, System.Windows.Forms.PropertyValueChangedEventArgs e) { string message; StatusLabel.Image = SystemIcons.Information.ToBitmap(); switch (e.ChangedItem.PropertyDescriptor.GetType().Name) { case "CustomPropertyDescriptor": CustomProperty.CustomPropertyDescriptor cpd = e.ChangedItem.PropertyDescriptor as CustomProperty.CustomPropertyDescriptor; if (cpd != null) { CustomProperty cp = (PropertyGridEx.CustomProperty)cpd.CustomProperty; if (cp == null) { return; } if (cp.Value != null) { message = " Value: " + cp.Value.ToString(); if (e.OldValue != null) { message = message + "; Previous: " + e.OldValue.ToString(); } if (cp.SelectedItem != null) { message = message + "; SelectedItem: " + cp.SelectedItem.ToString(); } if (cp.SelectedValue != null) { message = message + "; SelectedValue: " + cp.SelectedValue.ToString(); } StatusLabel.Text = message; } } break; case "MergePropertyDescriptor": message = " {MultiProperty [" + e.ChangedItem.Label + "]} " + e.ChangedItem.Value.ToString(); if (e.OldValue == null) { message = message + "; Nothing"; } else { message = message + "; " + e.OldValue.ToString(); } StatusLabel.Text = message; break; case "ReflectPropertyDescriptor": message = " {NestedProperty [" + e.ChangedItem.Label + "]} " + e.ChangedItem.Value.ToString(); if (e.OldValue == null) { message = message + "; Nothing"; } else { message = message + "; " + e.OldValue.ToString(); } StatusLabel.Text = message; break; default: StatusLabel.Image = SystemIcons.Error.ToBitmap(); StatusLabel.Text = " {Unknown PropertyDescriptor}"; break; } }
private void Add(CustomProperty Value) { _propertyCollection.Add(Value); }
public void AddCustomProperty(ITreeItem treeItem, CustomProperty newCustomProperty) { treeItem.ItemProperties.CustomProperties.Add(newCustomProperty.Name, newCustomProperty); tryFire(() => ItemChanged, treeItem); }
public CustomPropertyDescriptor(ref CustomProperty myProperty, Attribute[] attrs) : base(myProperty.Name, attrs) { m_Property = myProperty; }
public IEnumerable <CustomPropertyTab> GetCustomProps(string type = "", string docTypeAlias = "") { var outProps = new List <CustomPropertyTab>(); // we need either param if (string.IsNullOrEmpty(docTypeAlias) && string.IsNullOrEmpty(type)) { return(outProps); } // get doc type from pipeline config if (string.IsNullOrEmpty(docTypeAlias) && !string.IsNullOrEmpty(type)) { var pipelineConfig = PipelineConfig.GetConfig().AppSettings; switch (type) { case "contact": docTypeAlias = pipelineConfig.ContactDocTypes; break; case "organisation": docTypeAlias = pipelineConfig.OrganisationDocTypes; break; case "segment": docTypeAlias = pipelineConfig.SegmentDocTypes; break; default: docTypeAlias = pipelineConfig.OpportunityDocTypes; break; } if (string.IsNullOrEmpty(docTypeAlias) || Services.ContentTypeService.GetContentType(docTypeAlias) == null) { return(outProps); } } // check there is such a doc type if (Services.ContentTypeService.GetContentType(docTypeAlias) == null) { return(outProps); } // construct shadow doc type definition var tabs = Services.ContentTypeService.GetContentType(docTypeAlias).PropertyGroups.OrderBy(x => x.SortOrder); foreach (var tab in tabs) { var tabProps = new CustomPropertyTab() { name = tab.Name.Contains('.') ? tab.Name.Split('.')[1] : tab.Name, items = new List <CustomProperty>() }; var props = tab.PropertyTypes.OrderBy(x => x.SortOrder); if (props.Any()) { foreach (var prop in props) { dynamic config = new ExpandoObject(); var prevalues = Services.DataTypeService.GetPreValuesCollectionByDataTypeId(prop.DataTypeDefinitionId).PreValuesAsDictionary; if (prevalues.Any()) { var items = new List <CustomPropertyPreValue>(); foreach (var preval in prevalues) { items.Add(new CustomPropertyPreValue() { id = preval.Value.Id, alias = preval.Key, value = preval.Value.Value }); } config.items = items; // marks as multiPicker if it has min/max number if (items.Any(x => x.alias == "minNumber" || x.alias == "maxNumber")) { config.multiPicker = "1"; } } var newProp = new CustomProperty() { id = prop.Id, alias = prop.Alias, label = prop.Name, description = prop.Description, view = PropertyEditorResolver.Current.GetByAlias(prop.PropertyEditorAlias).ValueEditor.View, config = config }; tabProps.items.Add(newProp); } outProps.Add(tabProps); } } return(outProps); }
/// <summary> /// Конструктор класса /// </summary> /// <param name="doc">Свойство документа</param> public PropertyItem(CustomProperty prop) { Prop = prop; }
void buttonOkClick(object sender, EventArgs e) { //todo: move to an action if (uiFirstItemCustomPropertyNameTextBox.Text == "") { MessageBox.Show( @"Please specify a name for the Custom Property that is to be added to the first Item!", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (uiLinkSecondItemToFirstCheckbox.Checked && uiSecondItemCustomPropertyNameTextBox.Text == string.Empty) { MessageBox.Show( @"Please specify a name for the Custom Property that is to be added to the second Item!", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var model = ObjectFactory.GetInstance <IModel>(); IEnumerable <ITreeItem> selectedEditors = model.Level.SelectedEditors.ToList( ); ITreeItem firstSelectedItem = selectedEditors.First(); CustomProperties customPropertiesForFirstItem = firstSelectedItem.ItemProperties.CustomProperties; if (customPropertiesForFirstItem.ContainsKey(uiFirstItemCustomPropertyNameTextBox.Text)) { MessageBox.Show( "The first Item ({0}) already has a Custom Property named \"{1}\". Please use another name.".FormatWith(firstSelectedItem.ItemProperties.Name, uiFirstItemCustomPropertyNameTextBox.Text), @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var customProperty = new CustomProperty { Name = uiFirstItemCustomPropertyNameTextBox.Text, Type = typeof(ItemEditor) }; ITreeItem secondSelectItem = selectedEditors.ElementAt(1); customProperty.Value = secondSelectItem; customPropertiesForFirstItem.Add(customProperty.Name, customProperty); if (uiLinkSecondItemToFirstCheckbox.Checked) { CustomProperties customPropertiesForSecondItem = secondSelectItem.ItemProperties.CustomProperties; if (customPropertiesForSecondItem.ContainsKey(uiSecondItemCustomPropertyNameTextBox.Text)) { MessageBox.Show( "The second Item ({0}) already has a Custom Property named \"{1}\". Please use another name!".FormatWith(secondSelectItem.ItemProperties.Name, uiSecondItemCustomPropertyNameTextBox.Text), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); customPropertiesForFirstItem.Remove(customProperty.Name); return; } customProperty = new CustomProperty { Name = uiSecondItemCustomPropertyNameTextBox.Text, Type = typeof(ItemEditor), Value = firstSelectedItem }; customPropertiesForSecondItem.Add(customProperty.Name, customProperty); } Hide(); }
private void buttonOK_Click(object sender, EventArgs e) { if (cbbName.Text.Length==0) { MessageBox.Show("Please enter a Property Name."); return; } CustomProperty cp = new CustomProperty(); cp.name = cbbName.Text; cp.description = textBox2.Text; if (rdbFreeText.Checked) { cp.type = typeof(string); cp.value = txbFreetext.Text; } if (rdbBoolean.Checked) { cp.type = typeof(bool); cp.value = cbbBoolean.SelectedItem.ToString().Equals("true"); } if (rdbVector2.Checked) { cp.type = typeof(Vector2); Regex r=new Regex(@"^\d+(\.)?\d*$"); if(r.IsMatch(txbX.Text)&&r.IsMatch(txbY.Text)) { float x=float.Parse(txbX.Text); float y=float.Parse(txbY.Text); cp.value = new Vector2(x,y); } else { MessageBox.Show("Please enter valid numeric value."); return; } } if (rdbColor.Checked) { cp.type = typeof(Color); byte R = byte.Parse(numUDR.Value.ToString()); byte G = byte.Parse(numUDG.Value.ToString()); byte B = byte.Parse(numUDB.Value.ToString()); cp.value =new Color(R,G,B); } if (rdbItem.Checked) { cp.type = typeof(Item); cp.value = null; } if (cbxToAllSelected.Checked)//add to all selected items { foreach (Item item in Editor.Instance.SelectedItems) { if (cbxAddMode.Checked) { item.CustomProperties[cp.name] = cp.clone(); } else { if (item.CustomProperties.ContainsKey(cp.name)==false) { item.CustomProperties[cp.name] = cp.clone(); } } } } else//add to selected { if (customproperties.ContainsKey(cbbName.Text)) { MessageBox.Show("A Custom Property with that name already exists."); return; } customproperties[cp.name] = cp; } updateControls(); MainForm.Instance.propertyGrid1.Refresh(); }
private void mnuEditNamespace_Click(object sender, EventArgs e) { switch (SelectedType) { case SelectedTypes.Namespace: CustomNamespace ns = EntitySet.CustomNamespaces.First(n => n.Value == SelectedNamespace); Input.Text = ns.Value; Input.AutoAddToEntities = ns.AutoAddToEntities; if (Input.ShowDialog(this) == DialogResult.OK) { if (SelectedNamespace != Input.Text) { ns.Value = Input.Text; ns.AutoAddToEntities = Input.AutoAddToEntities; PopulateEntitiesGrid(); } } break; case SelectedTypes.Implement: CustomImplement ci = EntitySet.CustomImplements.First(n => n.Value == SelectedImplement); Input.Text = ci.Value; Input.AutoAddToEntities = ci.AutoAddToEntities; if (Input.ShowDialog(this) == DialogResult.OK) { if (SelectedImplement != Input.Text) { ci.Value = Input.Text; ci.AutoAddToEntities = Input.AutoAddToEntities; PopulateEntitiesGrid(); } } break; case SelectedTypes.Attribute: CustomAttribute ca = EntitySet.CustomAttributes.First(n => n.RawName == SelectedAttribute); FormAttributeEditor form = new FormAttributeEditor(ca.RawName, ca.RawArgumentString, ca.AutoAddToEntities); if (form.ShowDialog(this) == DialogResult.OK) { if (ca.RawName != form.RawName || ca.RawArgumentString != form.RawArgumentString || ca.AutoAddToEntities != form.AutoAddToEntities) { ca.RawName = form.RawName; ca.RawArgumentString = form.RawArgumentString; ca.AutoAddToEntities = form.AutoAddToEntities; PopulateEntitiesGrid(); } } break; case SelectedTypes.Property: CustomProperty cp = EntitySet.CustomProperties.First(n => n.Name == SelectedProperty); FormCodeInput.FillData(cp); if (FormCodeInput.ShowDialog(this) == DialogResult.OK) { PopulateEntitiesGrid(); } break; case SelectedTypes.Function: CustomFunction cm = EntitySet.CustomFunctions.First(n => n.Name == SelectedFunction); FormCodeInput.FillData(cm); if (FormCodeInput.ShowDialog(this) == DialogResult.OK) { PopulateEntitiesGrid(); } break; default: throw new NotImplementedException("Type not handled yet: " + SelectedType.ToString()); } }
public Task <CustomProperty> CreateCustomProperty(CustomProperty customProperty) { return(PostAsync <CustomProperty>("customproperties", customProperty, SOC)); }
private AppProject AddNewApp(TencentAppStoreModel.AppListItem app, AppProject appProject, AppInfo appInfo) { try { #region Set up Applist appProject = new AppProject(); var appProjectId = RedisService.Add <AppProject>(appProject); App ap = new App(); var appId = RedisService.Add <App>(ap); AppSettingsForAppList appSetting = new AppSettingsForAppList() { Id = appId, CreateDateTime = DateTime.Now }; CustomProperty prop = new CustomProperty() { Id = AppConfigKey.OS_ATTR_ID, Value = AppConfigKey.OS_ATTR_VALUE }; RedisService.AddCustomPropertyFor <App, CustomProperty>(ap.Id, prop); var lcdDetails = AppStoreUIService.GetElementDetailList(AppConfigKey.LCD_ATTR_ID); foreach (var lcd in lcdDetails) { SetLCD(ap.Id, lcd.Value.ToString()); } AppStoreUIService.SetAppForAppList <AppProject>(appProjectId, appSetting); #endregion #region Set up app project var originalAppProject = CloneHelper.DeepClone <AppProject>(appProject); appProject.AppNo = "tencent_" + app.appid; appProject.Creator = app.cpname; appProject.LogoFile = GetFileNameFromUri(appInfo.logo); appProject.Name = appInfo.name; appProject.PackageName = appInfo.packageName; appProject.Rate = appInfo.star.ToFloat(); RedisService.UpdateWithRebuildIndex <AppProject>(originalAppProject, appProject); #endregion #region Set up App var originalApp = CloneHelper.DeepClone <App>(ap); var originalApp2 = RedisService.Get <App>(ap.Id); ap.AppNo = appProject.AppNo; ap.AppProjectId = appProject.Id; ap.UseGreaterVersion = true; ClientImageInfo lg = new ClientImageInfo { BelongsToAppId = ap.Id, FileUrl = Path.Combine(LogoDirRoot, GetFileNameFromUri(appInfo.logo)), TypeId = "1" }; RedisService.Add <ClientImageInfo>(lg); ap.ClientLogos = new List <ClientImageInfo> { lg }; ImageInfo lg2 = new ImageInfo { BelongsToAppId = ap.Id, FileUrl = Path.Combine(LogoDirRoot, GetFileNameFromUri(appInfo.logo)) }; RedisService.Add <ImageInfo>(lg2); ap.Logo = lg2; ap.Name = appInfo.name; ap.OrderNumber = appInfo.downnum; ap.DownloadTimes = appInfo.downnum; ap.Status = 1; foreach (var s in appInfo.images) { ImageInfo ss = new ImageInfo { BelongsToAppId = ap.Id, FileUrl = Path.Combine(ScreenshotDirRoot, GetFileNameFromUri(s)) }; RedisService.Add <ImageInfo>(ss); ap.ScreenShot.Add(ss); } ap.PlatformType = AppConfigKey.PLATFORM_TYPE_ID.ConfigValue().ToInt32(); ap.Summary = appInfo.detail.Replace("<br/>", string.Empty).Replace("<br>", string.Empty); RedisService.UpdateWithRebuildIndex <App>(originalApp2, ap); #endregion #region Set up App Version if (!string.IsNullOrEmpty(appInfo.apkurl)) { FileInfo fi = new FileInfo(Path.Combine(APK_Folder_Base, GetFileNameFromUri(appInfo.apkurl))); if (fi != null && fi.Exists) { AppVersion ver = new AppVersion { FileSize = (int)fi.Length, FileUrl = GetFileNameFromUri(appInfo.apkurl), PublishDateTime = appInfo.updatetime, Status = 1, VersionName = appInfo.apkver, Id = appInfo.versionCode.ToString() }; RedisService.SetSubModel <App, AppVersion>(ap.Id, ver); AppStoreUIService.SetAppCurrentTestVersion(appId, ver.Id); AppStoreUIService.PublishAppVersion(appId); AndroidPackageView apkInfo = FileService.GetAndroidPackageInfomation(fi.FullName); apkInfo.Id = ver.Id; RedisService.SetSubModel <App, AndroidPackageView>(ap.Id, apkInfo); } } #endregion #region Set up tags if (appInfo.type.StartsWith("soft", StringComparison.OrdinalIgnoreCase)) { AppStoreUIService.AddTagForAppProject(AppConfigKey.TAG_SOFTWARE, appProject.Id); AppStoreUIService.AddTagForAppProject(AppConfigKey.TAG_TOT_10_SOFTWARE, appProject.Id); } else { AppStoreUIService.AddTagForAppProject(AppConfigKey.TAG_GAME, appProject.Id); AppStoreUIService.AddTagForAppProject(AppConfigKey.TAG_TOT_10_GAMES, appProject.Id); } AppStoreUIService.AddTagForAppProject(AppConfigKey.TAG_LATEST, appProject.Id); AppStoreUIService.AddTagForAppProject(appInfo.category, appProject.Id); AddMarketTag(appInfo.category, ap.Id); AppStoreUIService.AddTagForApp("Live", ap.Id); AppStoreUIService.AddTagForApp("Valid", ap.Id); AppStoreUIService.AddTagForAppProject("From_tencent", appProject.Id); #endregion } catch (Exception ex) { LogHelper.WriteError(ex.Message + ex.StackTrace); LogHelper.WriteInfo(string.Format("This AppProject {0} will delete, appProjectId is {1}", appProject.Name, appProject.Id)); AppProjectDelete(appProject.Id); } return(appProject); }
/// <summary> /// This is implemented to handle properties as they are parsed from the data stream /// </summary> /// <param name="propertyName">The name of the property.</param> /// <param name="parameters">A string collection containing the parameters and their values. If empty, /// there are no parameters.</param> /// <param name="propertyValue">The value of the property.</param> /// <remarks><para>There may be a mixture of name/value pairs or values alone in the parameters string /// collection. It is up to the derived class to process the parameter list based on the specification /// to which it conforms. For entries that are parameter names, the entry immediately following it in /// the collection is its associated parameter value. The property name, parameter names, and their /// values may be in upper, lower, or mixed case.</para> /// /// <para>The value may be an encoded string. The properties are responsible for any decoding that may /// need to occur (i.e. base 64 encoded image data).</para></remarks> /// <exception cref="PDIParserException">This is thrown if an error is encountered while parsing the data /// stream. Refer to the and inner exceptions for information on the cause of the problem.</exception> protected override void PropertyParser(string propertyName, StringCollection parameters, string propertyValue) { string temp; int idx; // The last entry is always CustomProperty so scan for length minus one for (idx = 0; idx < ntv.Length - 1; idx++) { if (ntv[idx].IsMatch(propertyName)) { break; } } // An opening BEGIN:VNOTE property must have been seen if (currentNote == null && ntv[idx].EnumValue != PropertyType.Begin) { throw new PDIParserException(this.LineNumber, LR.GetString("ExParseNoBeginProp", "BEGIN:VNOTE", propertyName)); } // Handle or create the property switch (ntv[idx].EnumValue) { case PropertyType.Begin: // The value must be VNOTE if (String.Compare(propertyValue.Trim(), "VNOTE", StringComparison.OrdinalIgnoreCase) != 0) { throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedTagValue", ntv[idx].Name, propertyValue)); } // NOTE: If serializing into an existing instance, this may not be null. If so, it is // ignored. if (currentNote == null) { currentNote = new VNote(); vNotes.Add(currentNote); } break; case PropertyType.End: // The value must be VNOTE if (String.Compare(propertyValue.Trim(), "VNOTE", StringComparison.OrdinalIgnoreCase) != 0) { throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedTagValue", ntv[idx].Name, propertyValue)); } // When done, we'll propagate the version number to all objects to make it consistent currentNote.PropagateVersion(); // The vNote is added to the collection when created so we don't have to rely on an END:VNOTE // to add it. currentNote = null; break; case PropertyType.Version: // Version must be 1.1 temp = propertyValue.Trim(); if (temp != "1.1") { throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedVersion", "vNote", temp)); } currentNote.Version = SpecificationVersions.IrMC11; break; case PropertyType.UniqueId: currentNote.UniqueId.EncodedValue = propertyValue; break; case PropertyType.Summary: currentNote.Summary.DeserializeParameters(parameters); currentNote.Summary.EncodedValue = propertyValue; break; case PropertyType.Body: currentNote.Body.DeserializeParameters(parameters); currentNote.Body.EncodedValue = propertyValue; break; case PropertyType.Class: currentNote.Classification.EncodedValue = propertyValue; break; case PropertyType.Categories: currentNote.Categories.DeserializeParameters(parameters); currentNote.Categories.EncodedValue = propertyValue; break; case PropertyType.DateCreated: currentNote.DateCreated.DeserializeParameters(parameters); currentNote.DateCreated.EncodedValue = propertyValue; break; case PropertyType.LastModified: currentNote.LastModified.DeserializeParameters(parameters); currentNote.LastModified.EncodedValue = propertyValue; break; default: // Anything else is a custom property CustomProperty c = new CustomProperty(propertyName); c.DeserializeParameters(parameters); c.EncodedValue = propertyValue; currentNote.CustomProperties.Add(c); break; } }
// Create an invoice template. private static DocX CreateInvoiceTemplate() { // Create a new document. DocX document = DocX.Create(@"docs\InvoiceTemplate.docx"); // Create a table for layout purposes (This table will be invisible). Table layout_table = document.InsertTable(2, 2); layout_table.Design = TableDesign.TableNormal; layout_table.AutoFit = AutoFit.Window; // Dark formatting Formatting dark_formatting = new Formatting(); dark_formatting.Bold = true; dark_formatting.Size = 12; dark_formatting.FontColor = Color.FromArgb(31, 73, 125); // Light formatting Formatting light_formatting = new Formatting(); light_formatting.Italic = true; light_formatting.Size = 11; light_formatting.FontColor = Color.FromArgb(79, 129, 189); #region Company Name // Get the upper left Paragraph in the layout_table. Paragraph upper_left_paragraph = layout_table.Rows[0].Cells[0].Paragraphs[0]; // Create a custom property called company_name CustomProperty company_name = new CustomProperty("company_name", "Company Name"); // Insert a field of type doc property (This will display the custom property 'company_name') layout_table.Rows[0].Cells[0].Paragraphs[0].InsertDocProperty(company_name, f: dark_formatting); // Force the next text insert to be on a new line. upper_left_paragraph.InsertText("\n", false); #endregion #region Company Slogan // Create a custom property called company_slogan CustomProperty company_slogan = new CustomProperty("company_slogan", "Company slogan goes here."); // Insert a field of type doc property (This will display the custom property 'company_slogan') upper_left_paragraph.InsertDocProperty(company_slogan, f: light_formatting); #endregion #region Company Logo // Get the upper right Paragraph in the layout_table. Paragraph upper_right_paragraph = layout_table.Rows[0].Cells[1].Paragraphs[0]; // Add a template logo image to this document. Novacode.Image logo = document.AddImage(@"images\logo_template.png"); // Insert this template logo into the upper right Paragraph. upper_right_paragraph.InsertPicture(logo.CreatePicture()); upper_right_paragraph.Alignment = Alignment.right; #endregion // Custom properties cannot contain newlines, so the company address must be split into 3 custom properties. #region Hired Company Address // Create a custom property called company_address_line_one CustomProperty hired_company_address_line_one = new CustomProperty("hired_company_address_line_one", "Street Address,"); // Get the lower left Paragraph in the layout_table. Paragraph lower_left_paragraph = layout_table.Rows[1].Cells[0].Paragraphs[0]; lower_left_paragraph.InsertText("TO:\n", false, dark_formatting); // Insert a field of type doc property (This will display the custom property 'hired_company_address_line_one') lower_left_paragraph.InsertDocProperty(hired_company_address_line_one, f: light_formatting); // Force the next text insert to be on a new line. lower_left_paragraph.InsertText("\n", false); // Create a custom property called company_address_line_two CustomProperty hired_company_address_line_two = new CustomProperty("hired_company_address_line_two", "City,"); // Insert a field of type doc property (This will display the custom property 'hired_company_address_line_two') lower_left_paragraph.InsertDocProperty(hired_company_address_line_two, f: light_formatting); // Force the next text insert to be on a new line. lower_left_paragraph.InsertText("\n", false); // Create a custom property called company_address_line_two CustomProperty hired_company_address_line_three = new CustomProperty("hired_company_address_line_three", "Zip Code"); // Insert a field of type doc property (This will display the custom property 'hired_company_address_line_three') lower_left_paragraph.InsertDocProperty(hired_company_address_line_three, f: light_formatting); #endregion #region Date & Invoice number // Get the lower right Paragraph from the layout table. Paragraph lower_right_paragraph = layout_table.Rows[1].Cells[1].Paragraphs[0]; CustomProperty invoice_date = new CustomProperty("invoice_date", DateTime.Today.Date.ToString("d")); lower_right_paragraph.InsertText("Date: ", false, dark_formatting); lower_right_paragraph.InsertDocProperty(invoice_date, f: light_formatting); CustomProperty invoice_number = new CustomProperty("invoice_number", 1); lower_right_paragraph.InsertText("\nInvoice: ", false, dark_formatting); lower_right_paragraph.InsertText("#", false, light_formatting); lower_right_paragraph.InsertDocProperty(invoice_number, f: light_formatting); lower_right_paragraph.Alignment = Alignment.right; #endregion // Insert an empty Paragraph between two Tables, so that they do not touch. document.InsertParagraph(string.Empty, false); // This table will hold all of the invoice data. Table invoice_table = document.InsertTable(4, 4); invoice_table.Design = TableDesign.LightShadingAccent1; invoice_table.Alignment = Alignment.center; // A nice thank you Paragraph. Paragraph thankyou = document.InsertParagraph("\nThank you for your business, we hope to work with you again soon.", false, dark_formatting); thankyou.Alignment = Alignment.center; #region Hired company details CustomProperty hired_company_details_line_one = new CustomProperty("hired_company_details_line_one", "Street Address, City, ZIP Code"); CustomProperty hired_company_details_line_two = new CustomProperty("hired_company_details_line_two", "Phone: 000-000-0000, Fax: 000-000-0000, e-mail: [email protected]"); Paragraph companyDetails = document.InsertParagraph(string.Empty, false); companyDetails.InsertDocProperty(hired_company_details_line_one, f: light_formatting); companyDetails.InsertText("\n", false); companyDetails.InsertDocProperty(hired_company_details_line_two, f: light_formatting); companyDetails.Alignment = Alignment.center; #endregion // Return the document now that it has been created. return(document); }
internal CustomPropertyDescriptor(object owner, CustomProperty property) : base(property.Name, null) { o = owner; p = property; }
/// <summary> /// Allows you to populate the current line item object using a LineItemDTO instance /// </summary> /// <param name="dto">An instance of the line item from the REST API</param> public void FromDto(LineItemDTO dto) { if (dto == null) { return; } Id = dto.Id; StoreId = dto.StoreId; LastUpdatedUtc = dto.LastUpdatedUtc; BasePricePerItem = dto.BasePricePerItem; LineTotal = dto.LineTotal; AdjustedPricePerItem = dto.AdjustedPricePerItem; IsUserSuppliedPrice = dto.IsUserSuppliedPrice; IsBundle = dto.IsBundle; IsGiftCard = dto.IsGiftCard; PromotionIds = dto.PromotionIds; FreeQuantity = dto.FreeQuantity; DiscountDetails.Clear(); if (dto.DiscountDetails != null) { foreach (var detail in dto.DiscountDetails) { var d = new DiscountDetail(); d.FromDto(detail); DiscountDetails.Add(d); } } OrderBvin = dto.OrderBvin ?? string.Empty; ProductId = dto.ProductId ?? string.Empty; VariantId = dto.VariantId ?? string.Empty; ProductName = dto.ProductName ?? string.Empty; ProductSku = dto.ProductSku ?? string.Empty; ProductShortDescription = dto.ProductShortDescription ?? string.Empty; Quantity = dto.Quantity; QuantityReturned = dto.QuantityReturned; QuantityShipped = dto.QuantityShipped; ShippingPortion = dto.ShippingPortion; TaxRate = dto.TaxRate; TaxPortion = dto.TaxPortion; StatusCode = dto.StatusCode ?? string.Empty; StatusName = dto.StatusName ?? string.Empty; SelectionData.Clear(); if (dto.SelectionData != null) { foreach (var op in dto.SelectionData) { var o = new OptionSelection(); o.FromDto(op); SelectionData.OptionSelectionList.Add(o); } } IsNonShipping = dto.IsNonShipping; TaxSchedule = dto.TaxSchedule; ProductShippingHeight = dto.ProductShippingHeight; ProductShippingLength = dto.ProductShippingLength; ProductShippingWeight = dto.ProductShippingWeight; ProductShippingWidth = dto.ProductShippingWidth; CustomProperties.Clear(); if (dto.CustomProperties != null) { foreach (var cpd in dto.CustomProperties) { var prop = new CustomProperty(); prop.FromDto(cpd); CustomProperties.Add(prop); } } ShipFromAddress.FromDto(dto.ShipFromAddress); ShipFromMode = (ShippingMode)(int)dto.ShipFromMode; ShipFromNotificationId = dto.ShipFromNotificationId ?? string.Empty; ShipSeparately = dto.ShipSeparately; ExtraShipCharge = dto.ExtraShipCharge; ShippingCharge = (ShippingChargeType)(int)dto.ShippingCharge; }
private static void SetCustomProperty(IList<CustomProperty> properties, string propertyName, string value) { CustomProperty prop = properties .FirstOrDefault((item) => item.Name == propertyName); if (prop == null) { prop = new CustomProperty(); prop.Name = propertyName; properties.Add(prop); } prop.Value = value; }
/// <summary> /// This is implemented to handle properties as they are parsed from the data stream /// </summary> /// <param name="propertyName">The name of the property.</param> /// <param name="parameters">A string collection containing the parameters and their values. If empty, /// there are no parameters.</param> /// <param name="propertyValue">The value of the property.</param> /// <remarks><para>There may be a mixture of name/value pairs or values alone in the parameters string /// collection. It is up to the derived class to process the parameter list based on the specification /// to which it conforms. For entries that are parameter names, the entry immediately following it in /// the collection is its associated parameter value. The property name, parameter names, and their /// values may be in upper, lower, or mixed case.</para> /// /// <para>The value may be an encoded string. The properties are responsible for any decoding that may /// need to occur (i.e. base 64 encoded image data).</para></remarks> /// <exception cref="PDIParserException">This is thrown if an error is encountered while parsing the data /// stream. Refer to the and inner exceptions for information on the cause of the problem.</exception> protected override void PropertyParser(string propertyName, StringCollection parameters, string propertyValue) { SpecificationVersions version = SpecificationVersions.None; string temp, group = null; int idx; // Parse out the group name if there is one idx = propertyName.IndexOf('.'); if (idx != -1) { group = propertyName.Substring(0, idx).Trim(); propertyName = propertyName.Substring(idx + 1).Trim(); } // The last entry is always CustomProperty so scan for length minus one for (idx = 0; idx < ntv.Length - 1; idx++) { if (ntv[idx].IsMatch(propertyName)) { break; } } // An opening BEGIN:VCARD property must have been seen if (currentCard == null && ntv[idx].EnumValue != PropertyType.Begin) { throw new PDIParserException(this.LineNumber, LR.GetString("ExParseNoBeginProp", "BEGIN:VCARD", propertyName)); } // Handle or create the property switch (ntv[idx].EnumValue) { case PropertyType.Begin: // The value must be VCARD if (String.Compare(propertyValue.Trim(), "VCARD", StringComparison.OrdinalIgnoreCase) != 0) { throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedTagValue", ntv[idx].Name, propertyValue)); } // NOTE: If serializing into an existing instance, this may not be null. If so, it is // ignored. if (currentCard == null) { currentCard = new VCard(); vCards.Add(currentCard); } currentCard.Group = group; break; case PropertyType.End: // The value must be VCARD if (String.Compare(propertyValue.Trim(), "VCARD", StringComparison.OrdinalIgnoreCase) != 0) { throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedTagValue", ntv[idx].Name, propertyValue)); } // The group must match too if (currentCard.Group != group) { throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnexpectedGroupTag", currentCard.Group, group)); } // When done, we'll propagate the version number to all objects to make it consistent currentCard.PropagateVersion(); // The vCard is added to the collection when created so we don't have to rely on an END:VCARD // to add it. currentCard = null; break; case PropertyType.Profile: // The value must be VCARD if (String.Compare(propertyValue.Trim(), "VCARD", StringComparison.OrdinalIgnoreCase) != 0) { throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedTagValue", ntv[idx].Name, propertyValue)); } currentCard.AddProfile = true; break; case PropertyType.Version: // Version must be 2.1 or 3.0 temp = propertyValue.Trim(); if (temp == "2.1") { version = SpecificationVersions.vCard21; } else if (temp == "3.0") { version = SpecificationVersions.vCard30; } else { throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedVersion", "vCard", temp)); } currentCard.Version = version; break; case PropertyType.MimeName: currentCard.MimeName.EncodedValue = propertyValue; break; case PropertyType.MimeSource: currentCard.MimeSource.DeserializeParameters(parameters); currentCard.MimeSource.EncodedValue = propertyValue; break; case PropertyType.ProductId: currentCard.ProductId.EncodedValue = propertyValue; break; case PropertyType.Nickname: currentCard.Nickname.DeserializeParameters(parameters); currentCard.Nickname.EncodedValue = propertyValue; currentCard.Nickname.Group = group; break; case PropertyType.SortString: currentCard.SortString.DeserializeParameters(parameters); currentCard.SortString.EncodedValue = propertyValue; currentCard.SortString.Group = group; break; case PropertyType.Class: currentCard.Classification.EncodedValue = propertyValue; currentCard.Classification.Group = group; break; case PropertyType.Categories: currentCard.Categories.DeserializeParameters(parameters); currentCard.Categories.EncodedValue = propertyValue; currentCard.Categories.Group = group; break; case PropertyType.FormattedName: currentCard.FormattedName.DeserializeParameters(parameters); currentCard.FormattedName.EncodedValue = propertyValue; currentCard.FormattedName.Group = group; break; case PropertyType.Name: currentCard.Name.DeserializeParameters(parameters); currentCard.Name.EncodedValue = propertyValue; currentCard.Name.Group = group; break; case PropertyType.Title: currentCard.Title.DeserializeParameters(parameters); currentCard.Title.EncodedValue = propertyValue; currentCard.Title.Group = group; break; case PropertyType.Role: currentCard.Role.DeserializeParameters(parameters); currentCard.Role.EncodedValue = propertyValue; currentCard.Role.Group = group; break; case PropertyType.Mailer: currentCard.Mailer.DeserializeParameters(parameters); currentCard.Mailer.EncodedValue = propertyValue; currentCard.Mailer.Group = group; break; case PropertyType.Url: currentCard.Url.DeserializeParameters(parameters); currentCard.Url.EncodedValue = propertyValue; currentCard.Url.Group = group; break; case PropertyType.Organization: currentCard.Organization.DeserializeParameters(parameters); currentCard.Organization.EncodedValue = propertyValue; currentCard.Organization.Group = group; break; case PropertyType.UniqueId: currentCard.UniqueId.EncodedValue = propertyValue; currentCard.UniqueId.Group = group; break; case PropertyType.BirthDate: currentCard.BirthDate.DeserializeParameters(parameters); currentCard.BirthDate.EncodedValue = propertyValue; currentCard.BirthDate.Group = group; break; case PropertyType.Revision: currentCard.LastRevision.DeserializeParameters(parameters); currentCard.LastRevision.EncodedValue = propertyValue; currentCard.LastRevision.Group = group; break; case PropertyType.TimeZone: currentCard.TimeZone.DeserializeParameters(parameters); currentCard.TimeZone.EncodedValue = propertyValue; currentCard.TimeZone.Group = group; break; case PropertyType.GeographicPosition: currentCard.GeographicPosition.EncodedValue = propertyValue; currentCard.GeographicPosition.Group = group; break; case PropertyType.PublicKey: currentCard.PublicKey.DeserializeParameters(parameters); currentCard.PublicKey.EncodedValue = propertyValue; currentCard.PublicKey.Group = group; break; case PropertyType.Photo: currentCard.Photo.DeserializeParameters(parameters); currentCard.Photo.EncodedValue = propertyValue; currentCard.Photo.Group = group; break; case PropertyType.Logo: currentCard.Logo.DeserializeParameters(parameters); currentCard.Logo.EncodedValue = propertyValue; currentCard.Logo.Group = group; break; case PropertyType.Sound: currentCard.Sound.DeserializeParameters(parameters); currentCard.Sound.EncodedValue = propertyValue; currentCard.Sound.Group = group; break; case PropertyType.Note: NoteProperty n = new NoteProperty(); n.DeserializeParameters(parameters); n.EncodedValue = propertyValue; n.Group = group; currentCard.Notes.Add(n); break; case PropertyType.Address: AddressProperty a = new AddressProperty(); a.DeserializeParameters(parameters); a.EncodedValue = propertyValue; a.Group = group; currentCard.Addresses.Add(a); break; case PropertyType.Label: LabelProperty l = new LabelProperty(); l.DeserializeParameters(parameters); l.EncodedValue = propertyValue; l.Group = group; currentCard.Labels.Add(l); break; case PropertyType.Telephone: TelephoneProperty t = new TelephoneProperty(); t.DeserializeParameters(parameters); t.EncodedValue = propertyValue; t.Group = group; currentCard.Telephones.Add(t); break; case PropertyType.EMail: EMailProperty e = new EMailProperty(); e.DeserializeParameters(parameters); e.EncodedValue = propertyValue; e.Group = group; currentCard.EMailAddresses.Add(e); break; case PropertyType.Agent: AgentProperty ag = new AgentProperty(); ag.DeserializeParameters(parameters); ag.EncodedValue = propertyValue; ag.Group = group; currentCard.Agents.Add(ag); break; default: // Anything else is a custom property CustomProperty c = new CustomProperty(propertyName); c.DeserializeParameters(parameters); c.EncodedValue = propertyValue; c.Group = group; currentCard.CustomProperties.Add(c); break; } }
public void FromDto(OrderPackageDTO dto) { if (dto == null) return; if (dto.CustomProperties != null) { this.CustomProperties.Clear(); foreach (CustomPropertyDTO prop in dto.CustomProperties) { CustomProperty p = new CustomProperty(); p.FromDto(prop); this.CustomProperties.Add(p); } } this.Description = dto.Description ?? string.Empty; this.EstimatedShippingCost = dto.EstimatedShippingCost; this.HasShipped = dto.HasShipped; this.Height = dto.Height; this.Id = dto.Id; if (dto.Items != null) { this.Items.Clear(); foreach (OrderPackageItemDTO item in dto.Items) { OrderPackageItem pak = new OrderPackageItem(); pak.FromDto(item); this.Items.Add(pak); } } this.LastUpdatedUtc = dto.LastUpdatedUtc; this.Length = dto.Length; this.OrderId = dto.OrderId ?? string.Empty; this.ShipDateUtc = dto.ShipDateUtc; this.ShippingMethodId = dto.ShippingMethodId ?? string.Empty; this.ShippingProviderId = dto.ShippingProviderId ?? string.Empty; this.ShippingProviderServiceCode = dto.ShippingProviderServiceCode ?? string.Empty; this.SizeUnits = (MerchantTribe.Shipping.LengthType)((int)dto.SizeUnits); this.StoreId = dto.StoreId; this.TrackingNumber = dto.TrackingNumber ?? string.Empty; this.Weight = dto.Weight; this.WeightUnits = (MerchantTribe.Shipping.WeightType)((int)dto.WeightUnits); this.Width = dto.Width; }
public void InstallOrUpdate() { _persistenceInstaller.InstallOrUpdate(); Database database = _databaseFactory.Get(); int currentVersion = database.ExecuteScalar <int>("SELECT SpecialActionsVersion FROM TeaCommerce_Version"); int newVersion = 5; while (currentVersion < newVersion) { try { #region 2.1.0 if (currentVersion + 1 == 1) { #region Auto set current cart and order number for all stores foreach (Store store in _storeService.GetAll()) { store.CurrentCartNumber = database.ExecuteScalar <long>("SELECT COUNT(Id) FROM TeaCommerce_Order WHERE StoreId=@0", store.Id); store.CurrentOrderNumber = database.ExecuteScalar <long>("SELECT COUNT(Id) FROM TeaCommerce_Order WHERE StoreId=@0 AND DateFinalized IS NOT NULL", store.Id); store.Save(); } #endregion } #endregion #region 2.1.1 if (currentVersion + 1 == 2) { #region Correct wrong order properties for sage pay orders foreach (Store store in _storeService.GetAll()) { List <long> sagePayPaymentMethodIds = _paymentMethodService.GetAll(store.Id).Where(p => p.PaymentProviderAlias == "SagePay").Select(p => p.Id).ToList(); if (sagePayPaymentMethodIds.Any()) { IEnumerable <Order> orders = _orderService.Get(store.Id, database.Fetch <Guid>("SELECT Id FROM TeaCommerce_Order WHERE StoreId=@0 AND PaymentMethodId IN (" + string.Join(",", sagePayPaymentMethodIds) + ")", store.Id)); foreach (Order order in orders) { CustomProperty vendorTxCode = order.Properties.Get("VendorTxCode"); CustomProperty txAuthNo = order.Properties.Get("TxAuthNo"); if (vendorTxCode == null && txAuthNo == null) { continue; } if (vendorTxCode != null) { vendorTxCode.Alias = "vendorTxCode"; } if (txAuthNo != null) { txAuthNo.Alias = "txAuthNo"; } order.Save(); } } } #endregion } #endregion #region 2.2 if (currentVersion + 1 == 3) { //Had to remove the deletion of TeaCommerce.PaymentProviders.dll and TeaCommerce.PaymentProviders.XmlSerializers.dll } #endregion #region 2.3.2 if (currentVersion + 1 == 3) { #region Remove order xml cache because properties was wrongly serialized string teaCommerceAppDataPath = HostingEnvironment.MapPath("~/App_Data/tea-commerce"); if (teaCommerceAppDataPath != null) { DirectoryInfo teaCommerceAppDataFolder = new DirectoryInfo(teaCommerceAppDataPath); if (teaCommerceAppDataFolder.Exists) { foreach (FileInfo orderXmlCache in teaCommerceAppDataFolder.GetFiles("finalized-orders-xml-cache*")) { orderXmlCache.Delete(); } } } #endregion } #endregion #region 3.0.0 if (currentVersion + 1 == 4) { #region Remove old javascript API file string javaScriptApiFile = HostingEnvironment.MapPath("~/scripts/tea-commerce.min.js"); if (javaScriptApiFile != null && File.Exists(javaScriptApiFile)) { File.Delete(javaScriptApiFile); } #endregion #region Remove old Tea Commerce folder in Umbraco plugins string oldTeaCommercePluginPath = HostingEnvironment.MapPath("~/umbraco/plugins/tea-commerce"); if (oldTeaCommercePluginPath != null && Directory.Exists(oldTeaCommercePluginPath)) { Directory.Delete(oldTeaCommercePluginPath, true); } oldTeaCommercePluginPath = HostingEnvironment.MapPath("~/App_Plugins/tea-commerce"); if (oldTeaCommercePluginPath != null && Directory.Exists(oldTeaCommercePluginPath)) { Directory.Delete(oldTeaCommercePluginPath, true); } #endregion #region Create default gift card settings foreach (Store store in _storeService.GetAll()) { store.GiftCardSettings.Length = 10; store.GiftCardSettings.DaysValid = 1095; store.Save(); } #endregion } #endregion currentVersion++; database.Execute("UPDATE TeaCommerce_Version SET SpecialActionsVersion=@0", currentVersion); } catch (Exception exp) { LoggingService.Instance.Log(exp); break; } } }
public void FromDto(LineItemDTO dto) { if (dto == null) { return; } this.Id = dto.Id; this.StoreId = dto.StoreId; this.LastUpdatedUtc = dto.LastUpdatedUtc; this.BasePricePerItem = dto.BasePricePerItem; this.DiscountDetails.Clear(); if (dto.DiscountDetails != null) { foreach (DiscountDetailDTO detail in dto.DiscountDetails) { DiscountDetail d = new DiscountDetail(); d.FromDto(detail); this.DiscountDetails.Add(d); } } this.OrderBvin = dto.OrderBvin ?? string.Empty; this.ProductId = dto.ProductId ?? string.Empty; this.VariantId = dto.VariantId ?? string.Empty; this.ProductName = dto.ProductName ?? string.Empty; this.ProductSku = dto.ProductSku ?? string.Empty; this.ProductShortDescription = dto.ProductShortDescription ?? string.Empty; this.Quantity = dto.Quantity; this.QuantityReturned = dto.QuantityReturned; this.QuantityShipped = dto.QuantityShipped; this.ShippingPortion = dto.ShippingPortion; this.StatusCode = dto.StatusCode ?? string.Empty; this.StatusName = dto.StatusName ?? string.Empty; this.TaxPortion = dto.TaxPortion; this.SelectionData.Clear(); if (dto.SelectionData != null) { foreach (OptionSelectionDTO op in dto.SelectionData) { Catalog.OptionSelection o = new Catalog.OptionSelection(); o.FromDto(op); this.SelectionData.Add(o); } } this.ShippingSchedule = dto.ShippingSchedule; this.TaxSchedule = dto.TaxSchedule; this.ProductShippingHeight = dto.ProductShippingHeight; this.ProductShippingLength = dto.ProductShippingLength; this.ProductShippingWeight = dto.ProductShippingWeight; this.ProductShippingWidth = dto.ProductShippingWidth; this.CustomProperties.Clear(); if (dto.CustomProperties != null) { foreach (CustomPropertyDTO cpd in dto.CustomProperties) { CustomProperty prop = new CustomProperty(); prop.FromDto(cpd); this.CustomProperties.Add(prop); } } this.ShipFromAddress.FromDto(dto.ShipFromAddress); this.ShipFromMode = (Shipping.ShippingMode)((int)dto.ShipFromMode); this.ShipFromNotificationId = dto.ShipFromNotificationId ?? string.Empty; this.ShipSeparately = dto.ShipSeparately; this.ExtraShipCharge = dto.ExtraShipCharge; }
private void SetPluginsVariables(string strClassName, string strPluginName, List <CPluginVariable> lstVariables) { if (lstVariables != null) { foreach (CPluginVariable cpvVariable in lstVariables) { string strCategoryName = strPluginName; string strVariableName = cpvVariable.Name; string[] a_strVariable = cpvVariable.Name.Split(new char[] { '|' }, 2); if (a_strVariable.Length == 2) { strCategoryName = a_strVariable[0]; strVariableName = a_strVariable[1]; } Enum generatedEnum = null; Match isGeneratedEnum; if ((isGeneratedEnum = Regex.Match(cpvVariable.Type, @"enum.(?<enumname>.*?)\((?<literals>.*)\)")).Success == true) { if ((generatedEnum = this.GenerateEnum(isGeneratedEnum.Groups["enumname"].Value, isGeneratedEnum.Groups["literals"].Value.Split('|'))) != null) { string variableValue = cpvVariable.Value; if (Enum.IsDefined(generatedEnum.GetType(), variableValue) == false) { string[] a_Names = Enum.GetNames(generatedEnum.GetType()); if (a_Names.Length > 0) { variableValue = a_Names[0]; } } if (Enum.IsDefined(generatedEnum.GetType(), variableValue) == true) { if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, Enum.Parse(generatedEnum.GetType(), variableValue), generatedEnum.GetType(), false, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = Enum.Parse(generatedEnum.GetType(), variableValue); } } } } else { switch (cpvVariable.Type) { case "bool": bool blTryBool; if (bool.TryParse(cpvVariable.Value, out blTryBool) == true) { if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, blTryBool, typeof(bool), false, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = blTryBool; } } break; case "onoff": if (Enum.IsDefined(typeof(enumBoolOnOff), cpvVariable.Value) == true) { if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, Enum.Parse(typeof(enumBoolOnOff), cpvVariable.Value), typeof(enumBoolOnOff), false, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = Enum.Parse(typeof(enumBoolOnOff), cpvVariable.Value); } } break; case "yesno": if (Enum.IsDefined(typeof(enumBoolYesNo), cpvVariable.Value) == true) { if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, Enum.Parse(typeof(enumBoolYesNo), cpvVariable.Value), typeof(enumBoolYesNo), false, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = Enum.Parse(typeof(enumBoolYesNo), cpvVariable.Value); } } break; case "int": int iTryInt; if (int.TryParse(cpvVariable.Value, out iTryInt) == true) { if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, iTryInt, typeof(int), false, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = iTryInt; } } break; case "double": double dblTryDouble; if (double.TryParse(cpvVariable.Value, out dblTryDouble) == true) { if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, dblTryDouble, typeof(double), false, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = dblTryDouble; } } break; case "string": if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, CPluginVariable.Decode(cpvVariable.Value), typeof(String), false, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = cpvVariable.Value; } break; case "multiline": if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { CustomProperty cptNewProperty = new CustomProperty(strVariableName, strCategoryName, strClassName, CPluginVariable.Decode(cpvVariable.Value), typeof(String), false, true); cptNewProperty.Attributes = new AttributeCollection(new EditorAttribute(typeof(System.ComponentModel.Design.MultilineStringEditor), typeof(System.Drawing.Design.UITypeEditor)), new TypeConverterAttribute(typeof(System.ComponentModel.Design.MultilineStringEditor))); this.m_cscPluginVariables.Add(cptNewProperty); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = cpvVariable.Value; } break; case "stringarray": if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, CPluginVariable.DecodeStringArray(cpvVariable.Value), typeof(string[]), false, true)); //this.m_cscPluginVariables.Add(new CustomProperty(cpvVariable.Name, strPluginName, strClassName, "Alaska", typeof(StatesList), false, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = CPluginVariable.DecodeStringArray(cpvVariable.Value); } break; } // } } } } this.ppgScriptSettings.Refresh(); }
/// <summary> /// Add CustomProperty to Collectionbase List /// </summary> /// <param name="Value"></param> public void Add(CustomProperty Value) { base.List.Add(Value); }