public override void ProcessRow(IList <object> row) { FieldModel newField = new FieldModel() { Field = (string)row[FieldNameIndex], Farm = (string)row[FarmNameIndex], Id = Convert.ToInt32(row[IdIndex]), Acreage = 0.0M }; bool validDecimal = decimal.TryParse((string)row[AcreageIndex], out decimal acreage); if (validDecimal && acreage > 0) { newField.Acreage = acreage; } foreach (var rotationColumn in RotationColumns) { int columnIndex = rotationColumn.Value; RotationModel newRotation = new RotationModel() { FieldId = newField.Id, RotationYear = rotationColumn.Key }; string plannedCrop = (string)row[columnIndex]; if (plannedCrop.Length > 0) { // convert names to lowercase so just the text is being compared ProductModel matchedCrop = Crops.Where(crop => crop.ItemName.ToLower() == plannedCrop.ToLower()) .ToList().First(); if (matchedCrop == null) { throw new Exception($"Crop matching error. Current crop count is: {plannedCrop}"); } else { newRotation.ProductId = matchedCrop.Id; newField.Rotations.Add(newRotation); } } } GlobalConfig.Connection.CreateField(newField); Fields.Add(newField); IList <object> updateRow = new string[] { newField.Farm, newField.Field, newField.Id.ToString() }; UpdateValues.Add(updateRow); }
static int set_target(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); RotationModel obj = (RotationModel)o; UnityEngine.Transform arg0 = (UnityEngine.Transform)ToLua.CheckUnityObject(L, 2, typeof(UnityEngine.Transform)); obj.target = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index target on a nil value" : e.Message)); } }
static int get_speed(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); RotationModel obj = (RotationModel)o; float ret = obj.speed; LuaDLL.lua_pushnumber(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index speed on a nil value" : e.Message)); } }
static int get_target(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); RotationModel obj = (RotationModel)o; UnityEngine.Transform ret = obj.target; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index target on a nil value" : e.Message)); } }
static int set_speed(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); RotationModel obj = (RotationModel)o; float arg0 = (float)LuaDLL.luaL_checknumber(L, 2); obj.speed = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index speed on a nil value" : e.Message)); } }