public List <StageModels> GetStagesForAppandUserID(IConnectToDB _Connect, List <StageModels> Stages, ApplicationModels application, int identity_id) { StagesHelper stageshelper = new StagesHelper(); DataTable ApplicationStages = stageshelper.FindbyColumnID(_Connect, "Applications_ID", application.AppView.applications_id.ToString()); foreach (DataRow StageRows in ApplicationStages.Rows) { StageModels tempStageModel = new StageModels(); tempStageModel.Stage = new StageModel(); tempStageModel.Grips = new List <GripModels>(); tempStageModel.Stage.stages_id = StageRows.Field <long?>("stages_id"); tempStageModel.Stage.stage_name = StageRows.Field <string>("stage_name"); tempStageModel.Stage.stage_type = StageRows.Field <string>("stage_type"); tempStageModel.Stage.dt_created = StageRows.Field <DateTime>("dt_created"); tempStageModel.Stage.dt_available = StageRows.Field <DateTime?>("dt_available"); tempStageModel.Stage.dt_end = StageRows.Field <DateTime?>("dt_end"); tempStageModel.Stage.enabled = StageRows.Field <string>("enabled"); tempStageModel.Grips = GetgripsforStage(_Connect, new List <GripModels>(), tempStageModel, identity_id); Stages.Add(tempStageModel); } return(Stages); }
public bool Update() { pCadenceCounter = pCadenceCounter + 1; // Are we at the last stage of growth? If so, do nothing and exit the update stage if (pCurrentStage == Stages) { return(true); } // If it's time to update the crop to the next stage, do so if (pCadenceCounter >= pStageTime[pCurrentStage - 1]) { if (Form1.Globals.Debug == true) { Form1.m_bot.Say("Updating object " + pObjectID + " for stage " + (pCurrentStage + 1) + " of " + Stages); } // Query the object to make sure we're looking at the right one Form1.m_bot.Attributes.ObjectNumber = 0; Form1.m_bot.Attributes.ObjectId = pObjectID; Form1.m_bot.ObjectQuery(); // Change the model of the object to first stage Form1.m_bot.Attributes.ObjectNumber = 0; Form1.m_bot.Attributes.ObjectId = pObjectID; Form1.m_bot.Attributes.ObjectModel = StageModels.ElementAt(pCurrentStage); Form1.m_bot.Attributes.ObjectX = PosX; Form1.m_bot.Attributes.ObjectY = PosY; Form1.m_bot.Attributes.ObjectZ = PosZ; Form1.m_bot.Attributes.ObjectYaw = PosYaw; Form1.m_bot.Attributes.ObjectTilt = PosTilt; Form1.m_bot.Attributes.ObjectRoll = PosRoll; Form1.m_bot.ObjectChange(); pCurrentStage = pCurrentStage + 1; if (pCurrentStage == Stages) { pHarvestable = true; } } return(true); }
public List <GripModels> GetGrips(IConnectToDB _Connect, StageModels Stage, Boolean _GetObjectSets, Boolean _GetPropertySets, Boolean _GetOptionProperties) { List <GripModels> GripModels = new List <GripModels>(); DataTable _DT = FindbyColumnID(_Connect, "stages_id", Stage.StageView.stages_id.ToString()); foreach (DataRow AppStageRow in _DT.Rows) { GripModels GripModel1 = new GripModels(); GripModel1 = SingleGripView(new ViewGripModel(), AppStageRow); if (_GetObjectSets) { ObjectSetsHelper OSH = new ObjectSetsHelper(); GripModel1.ObjectSets = OSH.GetSets(_Connect, GripModel1, _GetPropertySets, _GetOptionProperties); } GripModels.Add(GripModel1); } return(GripModels); }
public List <GripModels> GetgripsforStage(IConnectToDB _Connect, List <GripModels> Grips, StageModels Stage, int identity_id) { GripsHelper griphelper = new GripsHelper(); DataTable StageGrips = griphelper.FindbyColumnID(_Connect, "Stages_ID", Stage.Stage.stages_id.ToString()); foreach (DataRow GripRows in StageGrips.Rows) { GripModels grip = new GripModels(); grip.gripinfo = new GripModel(); grip.gripinfo.grips_id = GripRows.Field <long?>("grips_id"); grip.gripinfo.grip_name = GripRows.Field <string>("grip_name"); grip.gripinfo.grip_type = GripRows.Field <string>("grip_type"); grip.gripinfo.stages_id = GripRows.Field <long?>("stages_id"); grip.gripinfo.stage_name = GripRows.Field <string>("stage_name"); grip.gripinfo.stage_type = GripRows.Field <string>("stage_type"); grip.gripinfo.identities_id = GripRows.Field <long?>("identities_id"); grip.gripinfo.enabled = GripRows.Field <string>("enabled"); grip.gripinfo.dt_created = GripRows.Field <DateTime>("dt_created"); grip.gripinfo.dt_available = GripRows.Field <DateTime?>("dt_available"); grip.ObjectSets = GetSetsbyGripNID(_Connect, new List <ObjectSetModels>(), grip, identity_id); Grips.Add(grip); } return(Grips); }
public bool Init(int crop, int objid) { // Pull the farm item info out of the CropTable in the database string sql = "select * from CropTable where SimProfile = '" + Form1.Globals.sSimProfile + "' and CropID = '" + crop + "'"; SQLiteCommand sqlcmd = new SQLiteCommand(sql, Form1.Globals.m_db); SQLiteDataReader reader = sqlcmd.ExecuteReader(); // Any items in the reader? If not, return empty handed if (reader.HasRows == false) { Form1.Globals.Error = "FarmItem Error: No such CropID in database."; return(false); } // Set internal object ID pObjectID = objid; // Set the harvestable flag to false pHarvestable = false; //Console.WriteLine("ObjectID: " + pObjectID); // Pull the data for this new farm item from the CropTable query results string tStageModels = "", tStageTime = ""; while (reader.Read()) { CropName = reader["CropName"].ToString(); Stages = Convert.ToInt32(reader["Stages"]); tStageModels = reader["StageModels"].ToString(); tStageTime = reader["StageTime"].ToString(); Fertilizer = reader["Fertilizer"].ToString(); YieldProduct = reader["YieldProduct"].ToString(); YieldProductAmount = reader["YieldProductAmount"].ToString(); YieldSeed = reader["YieldSeed"].ToString(); YieldSeedAmount = reader["YieldSeedAmount"].ToString(); } reader.Close(); StageModels = tStageModels.Split(',').ToList(); StageTime = tStageTime.Split(',').ToList(); // query for and get the x, y, z, yaw, tilt, roll of the object in question Form1.m_bot.Attributes.ObjectNumber = 0; Form1.m_bot.Attributes.ObjectId = pObjectID; var rc = Form1.m_bot.ObjectQuery(); if (rc != Result.Success) { Form1.Globals.Error = "FarmItem Error: Unable to query object."; return(false); } PosX = Form1.m_bot.Attributes.ObjectX; PosY = Form1.m_bot.Attributes.ObjectY; PosZ = Form1.m_bot.Attributes.ObjectZ; PosYaw = Form1.m_bot.Attributes.ObjectYaw; PosTilt = Form1.m_bot.Attributes.ObjectTilt; PosRoll = Form1.m_bot.Attributes.ObjectRoll; Model = Form1.m_bot.Attributes.ObjectModel; // Create a new model at the same location which is the 1st stage of the crop // Don't remove the old one, and keep its model number as well for later comparisons //Form1._instance.Attributes.ObjectNumber = 0; //Form1._instance.Attributes.ObjectId = pObjectID; Form1.m_bot.Attributes.ObjectModel = StageModels.ElementAt(0); Form1.m_bot.Attributes.ObjectDescription = CropName; Form1.m_bot.ObjectAdd(); // Store new objectID //Form1._instance.Attributes.ObjectNumber = 0; //Form1._instance.Attributes.ObjectId = pObjectID; //Form1._instance.Attributes.ObjectModel = StageModels.ElementAt(0); //Form1._instance.ObjectChange(); pObjectID = Form1.m_bot.Attributes.ObjectId; // Set stage and decide the true time values for the stages pCurrentStage = 1; pCadenceCounter = 0; var rnd = new Random(DateTime.Now.Millisecond); foreach (string e in StageTime) { string[] times = e.Split('-'); int tick = rnd.Next(Convert.ToInt32(times[0]), Convert.ToInt32(times[1]) + 1); //Console.WriteLine("Stage time: " + tick); pStageTime.Add(tick); } return(true); }