private UnitsType[] GenerateNetSuiteNewlst(List <UnitsOfMeasure> ColLst) { #region variables com.netsuite.webservices.UnitsType[] UnitsTypeArr = new com.netsuite.webservices.UnitsType[ColLst.Count]; com.netsuite.webservices.UnitsType unitsTypeobj; UnitsTypeUomList UnitsTypeUomLst; UnitsTypeUom UnitsTypeUomobj; Foodics.NetSuite.Shared.Model.UnitsOfMeasure Obj_info; Foodics.NetSuite.Shared.Model.UnitsOfMeasureIngredient Obj_ingredient; #endregion for (int i = 0; i < ColLst.Count; i++) { try { Obj_info = ColLst[i]; UnitsTypeUomLst = new UnitsTypeUomList(); UnitsTypeUomobj = new UnitsTypeUom(); unitsTypeobj = new UnitsType(); UnitsTypeUomobj.baseUnit = Obj_info.baseUnit; UnitsTypeUomobj.baseUnitSpecified = true; UnitsTypeUomobj.conversionRate = 1; UnitsTypeUomobj.conversionRateSpecified = true; UnitsTypeUomobj.abbreviation = Obj_info.abbreviation; UnitsTypeUomobj.pluralAbbreviation = Obj_info.pluralAbbreviation; UnitsTypeUomobj.pluralName = Obj_info.pluralName; UnitsTypeUomobj.unitName = Obj_info.unitName; List <UnitsOfMeasureIngredient> Ingredientlst = new GenericeDAO <UnitsOfMeasureIngredient>().GetWhere(" UnitsOfMeasure_Id =" + Obj_info.Id); UnitsTypeUom[] UnitsTypeUomarr = new UnitsTypeUom[Ingredientlst.Count + 1]; UnitsTypeUomarr[0] = UnitsTypeUomobj; for (int x = 0; x < Ingredientlst.Count; x++) { Obj_ingredient = Ingredientlst[x]; UnitsTypeUom UnitsTypeUom_Item = new UnitsTypeUom(); UnitsTypeUom_Item.conversionRate = string.IsNullOrEmpty(Obj_ingredient.Storage_To_Ingredient_Value) ? 1 : Utility.ConvertToDouble(Obj_ingredient.Storage_To_Ingredient_Value); UnitsTypeUom_Item.conversionRateSpecified = true; UnitsTypeUom_Item.abbreviation = Obj_ingredient.unitName; UnitsTypeUom_Item.pluralAbbreviation = Obj_ingredient.unitName; UnitsTypeUom_Item.pluralName = Obj_ingredient.unitName; UnitsTypeUom_Item.unitName = Obj_ingredient.unitName; UnitsTypeUomarr[x + 1] = UnitsTypeUom_Item; } UnitsTypeUomLst.uom = UnitsTypeUomarr; unitsTypeobj.uomList = UnitsTypeUomLst; unitsTypeobj.name = Obj_info.Name; UnitsTypeArr[i] = unitsTypeobj; } catch (Exception ex) { ColLst.RemoveAt(i); LogDAO.Integration_Exception(LogIntegrationType.Error, this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Error " + ex.Message); } } return(UnitsTypeArr); }
public override void Get() { UnitsTypeSearch custSearch = new UnitsTypeSearch(); UnitsTypeSearchBasic custSearchBasic = new UnitsTypeSearchBasic(); custSearch.basic = custSearchBasic; Preferences prefs = new Preferences(); Service(true).preferences = prefs; prefs.warningAsErrorSpecified = true; prefs.warningAsError = false; SearchPreferences _srch_pref = new SearchPreferences(); Service().searchPreferences = _srch_pref; Service().searchPreferences.bodyFieldsOnly = false; bool bodyonly = Service().searchPreferences.bodyFieldsOnly; SearchResult response = Service().search(custSearch); if (response.totalRecords > 0) { List <UnitsOfMeasure> list = new List <UnitsOfMeasure>(); for (int i = 0; i < response.totalRecords; i++) { UnitsType cr = (UnitsType)response.recordList[i]; try { UnitsTypeUomList uomList = cr.uomList; for (int j = 0; j < uomList.uom.Length; j++) { UnitsOfMeasure entity = new UnitsOfMeasure(); entity.unit_id = Convert.ToInt32(cr.internalId); entity.details_id = Convert.ToInt32(uomList.uom[j].internalId); entity.Netsuite_Id = Convert.ToInt32(cr.internalId + uomList.uom[j].internalId); entity.InActive = cr.isInactive; entity.Name = cr.name; entity.baseUnit = uomList.uom[j].baseUnit; entity.unitName = uomList.uom[j].unitName; entity.pluralName = uomList.uom[j].pluralName; entity.abbreviation = uomList.uom[j].abbreviation; entity.pluralAbbreviation = uomList.uom[j].pluralAbbreviation; entity.conversionRate = (float)uomList.uom[j].conversionRate; list.Add(entity); } } catch (Exception ex) { throw ex; } } if (list.Count > 0) { new GenericeDAO <UnitsOfMeasure>().UnitmeasureNetSuiteIntegration(list); } } }