public void CardClickFlavorText(OperationCard thisCard) { int cardClickedIdx = operationCardsList.FindIndex(x => x == thisCard); int flavorRandIdx = 0; // Positive Feedback (Successful Click) if (thisCard == currentCard) { flavorRandIdx = Random.Range(0, currentBuildingClicked.buildingInformation.buildingCard[cardClickedIdx].cardPosMesg.Count); flavorText.shakingText.text = currentBuildingClicked.buildingInformation.buildingCard[cardClickedIdx].cardPosMesg[flavorRandIdx]; } // Negative Feedback else { flavorRandIdx = Random.Range(0, currentBuildingClicked.buildingInformation.buildingCard[cardClickedIdx].cardNegMesg.Count); flavorText.shakingText.text = currentBuildingClicked.buildingInformation.buildingCard[cardClickedIdx].cardNegMesg[flavorRandIdx]; } }
public void SetAsCurrentCard(OperationCard thisCard) { if (thisCard != currentCard) { currentCard = thisCard; informationActionHandler.SwitchSubPanel(false); // BACKGROUND ENLARGED VERSION OF THE IMAGE BUT NOT VISIBLE if (!focusedCardIcon.gameObject.activeInHierarchy) { focusedCardIcon.gameObject.SetActive(true); } focusedCardIcon.sprite = currentCard.cardIcon.sprite; // --------------------------- IF FOUND USELESS [RECOMMENDED TO REMOVE] CardClickFlavorText(currentCard); } // SETTING VISUAL FOR ACTION CARDS for (int i = 0; i < operationCardsList.Count; i++) { if (operationCardsList[i] != thisCard) { operationCardsList[i].SetAsUnselected(); } else { operationCardsList[i].SetAsSelected(); informationActionHandler.selectedCardIdx = i; selectedCardIdx = i; cardNameText.text = currentBuildingClicked.buildingInformation.buildingCard[selectedCardIdx].cardName; } } // OPEN CARD INFORMATION [AFTER BUILDING] informationActionHandler.SetupActionList(currentBuildingClicked.buildingInformation.buildingCard[selectedCardIdx].actionTypes); informationActionHandler.OpenPanel(currentBuildingClicked.buildingType); }
public async Task <string> ExecuteAsync(OperationCardModel operationCardModel) { if (operationCardModel == null) { throw new ArgumentNullException(nameof(operationCardModel)); } try { using (var dbSession = dbFacade.Transaction()) { OperationCard operationCard = await dbSession.Set <OperationCard>() .FirstOrDefaultAsync(u => u.HeatNumber == operationCardModel.HeatNumber); if (operationCard == null) { // Check if a Production Order corresponding to that HeatNumber exists if (!await dbSession.Set <ProductionOrder>().AnyAsync(u => u.HeatNumber == operationCardModel.HeatNumber)) { return("No ProductionOrder for the inserted HeatNumber"); } // (Create) int productionOrderID = dbSession.Set <ProductionOrder>().FirstOrDefault(u => u.HeatNumber == operationCardModel.HeatNumber).ID; int instructionID = dbSession.Set <Instruction>().FirstOrDefault(u => u.ProductionOrderID == productionOrderID).ID; operationCard = new OperationCard { HeatNumber = operationCardModel.HeatNumber, SlagNumber = operationCardModel.SlagNumber, BlockSurfaceID = operationCardModel.BlockSurface?.ID, ErrorCode = operationCardModel.ErrorCode, Glow = operationCardModel.Glow, Photo = operationCardModel.Photo, UserID = operationCardModel.UserID, ProductionOrderID = productionOrderID, InstructionID = instructionID }; dbSession.Set <OperationCard>().Add(operationCard); // Persist to DB and fetch created PK (OperationCardID) await dbSession.SaveChangesAsync(); } else { // (Update) operationCard.SlagNumber = operationCardModel.SlagNumber; operationCard.BlockSurfaceID = operationCardModel.BlockSurface?.ID; operationCard.ErrorCode = operationCardModel.ErrorCode; operationCard.Glow = operationCardModel.Glow; operationCard.Photo = operationCardModel.Photo; operationCard.UserID = operationCardModel.UserID; } await SaveSignatures(operationCardModel, dbSession, operationCard.ID); await SaveSubstances(operationCardModel, dbFacade, dbSession, operationCard); // Persist Changes in the DataBase await dbSession.SaveChangesAsync(); return(null); } } catch (Exception e) { throw Oops.Rewrap(e); } }
private async Task SaveSubstances(OperationCardModel operationCardModel, IDbFacade dbFacade, IDbSession dbSession, OperationCard operationCard) { if (operationCardModel.Substances.Operator == null && operationCardModel.Substances.SubstanceList == null) { return; } if (operationCardModel.Substances.SubstanceList.Count == 0) { return; } var operationCardLogSubst = new OperationCardLogs() { ID = operationCardModel.Substances.LogPKID, OperationCardID = operationCard.ID, Type = "Substances", Content = null, LoggedError = null, Date = operationCardModel.Substances != null ? operationCardModel.Substances.Date : new DateTime(), OperatorID = operationCardModel.Substances != null ? operationCardModel.Substances.Operator.ID : -1 }; // Substance TimeStamp if (operationCardLogSubst.OperatorID != -1) { if (!await dbSession.Set <OperationCardLogs>().AnyAsync(u => u.ID == operationCardLogSubst.ID)) { dbSession.Set <OperationCardLogs>().Add(operationCardLogSubst); } else { var logEntry = await dbSession.Set <OperationCardLogs>().FirstOrDefaultAsync(u => u.ID == operationCardLogSubst.ID); logEntry.Date = operationCardModel.Substances.Date; logEntry.OperatorID = operationCardModel.Substances.Operator.ID; } } // Substances if (operationCardModel.Substances?.SubstanceList != null) { // Get Instruction Recipe Materials var instructionRecipeMaterials = new GetAllSubstances(dbFacade).Execute(operationCardModel.HeatNumber); // Get Instruction var instruction = dbSession.Set <Instruction>() .Include(x => x.Materials) .Where(x => x.ID == operationCard.InstructionID) .FirstOrDefault(); foreach (var item in operationCardModel.Substances?.SubstanceList.Where(x => x.Weight > 0)) { // Add or Update to the newest Amounts if (instruction.Materials.Any(y => y.MaterialID == item.Subst.ID)) { instruction.Materials.FirstOrDefault(y => y.MaterialID == item.Subst.ID).Amount = item.Weight; } else { instruction.Materials.Add(new InstructionMaterial() { InstructionID = instruction.ID, MaterialID = item.Subst.ID, Amount = item.Weight }); } } } }