public BomScan(SwApiWrapper swApi, SwModelWrapper swModel, PropertyScaffold scaffold) { InitializeComponent(); this.swMod = swModel; this.swApi = swApi; this.scaffold = scaffold; }
private void GetOdooImage() { if (this.oProd.HasProduct && !this.oProd.Table.Rows[0].IsNull("OdooImage")) { byte[] bytes = Convert.FromBase64String((string)this.oProd.Table.Rows[0]["OdooImage"]); pbOdooImage.Image = PropertyScaffold.ByteArrayToImage(bytes); cmdUpload.Text = "Replace"; } }
public OdooProduct(OdooRpcCs.OdooClient oClient, string productCode, PropertyScaffold scaffold) { this.scaffold = scaffold; this.oClient = oClient; this.productCode = productCode; (this.engCode, _, this.engRev) = ParseProductCode(productCode); foreach (DataRow dr in scaffold.FieldDefs.Select("odoo_model='product.product'")) { prodFields.Add(dr["odoo_field"].ToString()); } foreach (DataRow dr in scaffold.FieldDefs.Select("odoo_model='product.template'")) { tmplFields.Add(dr["odoo_field"].ToString()); } Refresh(); }
private void CmdUpload_Click(object sender, EventArgs e) { if (this.oProd == null) { MessageBox.Show("No Odoo product has been loaded"); return; } byte[] byteArray = PropertyScaffold.ImageToByteArray((Bitmap)pbModelImage.Image); string base64String = Convert.ToBase64String(byteArray); Dictionary <string, Object> values = new Dictionary <string, Object>() { { "image", base64String }, }; oProd.RawWrite(values); GetOdooImage(); }
public DataRow GetCustomProp(string configName, bool withImage = false, bool merge = false) { DataRow dr = propScaffold.MainRow; // Return an empty DataRow if the config name doesn't exist in this model if (configName != "" && !configNames.Contains(configName)) { return(dr); } // Get property manager for this config CustomPropertyManager swCustPropMgr = (CustomPropertyManager)swModelDocExt.get_CustomPropertyManager(configName); CustomPropertyManager swAltCustPropMgr = (CustomPropertyManager)swModelDocExt.get_CustomPropertyManager(""); string[] nameArray = swCustPropMgr.GetNames(); List <string> propNames = new List <string>(); if (nameArray != null) { propNames.AddRange(swCustPropMgr.GetNames()); } dr["filename"] = pathName; dr["configname"] = configName; dr["PlaceHoldFlag"] = false; dr["ShowChildren"] = swMainConfig.ShowChildComponentsInBOM; // Get custom properties from specific configuration // Get the file level properties when the config name is an empty string (i.e. "") string strVal; string strResolved; foreach (DataRow drField in propScaffold.FieldDefs.Select("sw_prop is not null")) { string propName = drField["sw_prop"].ToString(); string fieldName = drField["field"].ToString(); string typeName = drField["dt_type"].ToString(); swCustPropMgr.Get4(propName, false, out strVal, out strResolved); strResolved = strResolved.Trim(); dr[fieldName] = GetPropDefaultValue(strResolved, typeName); // If merging config specific properties with the file level properties if (merge && configName != "" && !propNames.Contains(propName)) { swAltCustPropMgr.Get4(propName, false, out strVal, out strResolved); strResolved = strResolved.Trim(); dr[fieldName] = GetPropDefaultValue(strResolved, typeName); } } // Get model image // The default is swIsometricView = 7 // Only get an image if the part is measured in discreet (non-continuous) units propScaffold.UomMapping.TryGetValue(dr["Uom"].ToString(), out string matchedUom); if (withImage && matchedUom == "EA") { byte[] bytes = PropertyScaffold.ImageToByteArray(GetIsometricImage()); string imageString = Convert.ToBase64String(bytes); dr["Image"] = imageString; } // Get sheet metal properties if (swMainModel.GetType() == (int)swDocumentTypes_e.swDocPART && IsSheetMetal()) { Feature cutList = GetUpdatedCutList(); if (cutList != null) { // Get sheet metal properties //Feature cutList = swMainModel.SelectionManager.GetSelectedObject6(1, 0); CustomPropertyManager cutPropMgr = cutList.CustomPropertyManager; List <string> names = new List <string>(cutPropMgr.GetNames()); string valOut; string resolvedValOut; decimal decimalValOut; int intValOut; bool wasResolved; cutPropMgr.Get5("Sheet Metal Thickness", false, out valOut, out resolvedValOut, out wasResolved); Decimal.TryParse(resolvedValOut, out decimal sheetThickness); if (names.Contains("Sheet Metal Thickness") && sheetThickness != 0.0M) { cutPropMgr.Get5("Cutting Length-Outer", false, out valOut, out resolvedValOut, out wasResolved); Decimal.TryParse(resolvedValOut, out decimalValOut); dr["CuttingLengthOuter"] = Decimal.Round(decimalValOut, 2); cutPropMgr.Get5("Cutting Length-Inner", false, out valOut, out resolvedValOut, out wasResolved); Decimal.TryParse(resolvedValOut, out decimalValOut); dr["CuttingLengthInner"] = Decimal.Round(decimalValOut, 2); cutPropMgr.Get5("Cut Outs", false, out valOut, out resolvedValOut, out wasResolved); int.TryParse(resolvedValOut, out intValOut); dr["CutOutCount"] = intValOut; cutPropMgr.Get5("Bends", false, out valOut, out resolvedValOut, out wasResolved); int.TryParse(resolvedValOut, out intValOut); dr["BendCount"] = intValOut; Decimal mult = AZI_SWCustomProperties.Properties.AppSettings.Default.AreaFactor; cutPropMgr.Get5("Bounding Box Length", false, out valOut, out resolvedValOut, out wasResolved); Decimal.TryParse(resolvedValOut, out decimal boxLength); cutPropMgr.Get5("Bounding Box Width", false, out valOut, out resolvedValOut, out wasResolved); Decimal.TryParse(resolvedValOut, out decimal boxWidth); Decimal qty = Math.Ceiling((boxLength + mult * sheetThickness) * (boxWidth + mult * sheetThickness)); dr["ChildQty"] = Decimal.Round(qty, 2); } } } return(dr); }