private IHouseType GetHouseType(TempCase tc) { IHouseType houseType = new HouseType(); try { conn.Open(); SqlCommand command = new SqlCommand("CH_SP_SelectHouseType", conn); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@CaseNumber", tc.Case.CaseNumber)); command.Parameters.Add(new SqlParameter("@CaseYear", tc.Case.DateOfCreation.Year)); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { reader.Read(); string name; if (reader.IsDBNull(0)) { name = null; } else { name = reader.GetString(0); } string description; if (reader.IsDBNull(1)) { description = null; } else { description = reader.GetString(1); } int?area; if (reader.IsDBNull(2)) { area = null; } else { area = reader.GetInt32(2); } decimal?price; if (reader.IsDBNull(3)) { price = null; } else { price = reader.GetDecimal(3); } houseType.Name = name; houseType.Description = description; houseType.Area = area; houseType.TotalPrice = price; } reader.Close(); reader.Dispose(); } catch (SqlException) { } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } } return(houseType); }
//Load JsonFile (Bridges and teleporters) void LoadData() { /* Load Switches And Bridges */ SetSpawnPoint(); try { foreach (string DataBridge in loadedData.ListBridges) { bool SwitchToLoadNormal = true; bool BridgeOpen = false; List <GameObject> CaseBridgeTemp = new List <GameObject>(); int indexXSwitch; int indexZSwitch; if (DataBridge[0].ToString() == "S") { SwitchToLoadNormal = false; } else if (DataBridge[0].ToString() == "N") { SwitchToLoadNormal = true; } if (DataBridge[1].ToString() == "0") { BridgeOpen = false; } else if (DataBridge[1].ToString() == "1") { BridgeOpen = true; } string[] SplitsData = DataBridge.Split('-'); string Coord = SplitsData[0]; int indexTemp = Coord.IndexOf("(") + 1; string RawCoord = Coord.Substring(indexTemp, Coord.Length - indexTemp - 1); string[] SplitsCoord = RawCoord.Split(','); indexXSwitch = Int32.Parse(SplitsCoord[0]); indexZSwitch = Int32.Parse(SplitsCoord[1]); string ListCaseBridge = SplitsData[1]; ListCaseBridge = ListCaseBridge.Substring(1, ListCaseBridge.Length - 2); string[] SplitsCoordData = ListCaseBridge.Split(';'); int indexXCase; int indexZCase; foreach (string dataCoord in SplitsCoordData) { int indexTemp2 = dataCoord.IndexOf("(") + 1; string RawCaseCoord = dataCoord.Substring(indexTemp2, dataCoord.Length - indexTemp2 - 1); string[] SplitCoordCase = RawCaseCoord.Split(','); indexXCase = Int32.Parse(SplitCoordCase[0]); indexZCase = Int32.Parse(SplitCoordCase[1]); float ScaleY = WoodCasePrefab.transform.localScale[1]; float IndexY = -(ScaleY / 2); float postionX = (indexXCase * WoodCasePrefab.transform.localScale[0]) - (WoodCasePrefab.transform.localScale[0] / 2); float postionZ = (indexZCase * WoodCasePrefab.transform.localScale[2]) - (WoodCasePrefab.transform.localScale[2] / 2); GameObject TempCase; if (BoardList[indexZCase - 1][indexXCase - 1].ToString() == "3") { TempCase = Instantiate(BrickCasePrefab, new Vector3(postionX, IndexY, postionZ), transform.rotation); CaseBridgeTemp.Add(TempCase); if (!BridgeOpen) { TempCase.SetActive(false); } else { string CoordinateTemp = "(" + indexXCase.ToString() + "," + indexZCase.ToString() + ")"; CurrentlyActivatedCasesBridge.Add(CoordinateTemp); } } else if (BoardList[indexZCase - 1][indexXCase - 1].ToString() == "4") { TempCase = Instantiate(WoodCasePrefab, new Vector3(postionX, IndexY, postionZ), transform.rotation); CaseBridgeTemp.Add(TempCase); if (!BridgeOpen) { TempCase.SetActive(false); } else { string CoordinateTemp = "(" + indexXCase.ToString() + "," + indexZCase.ToString() + ")"; CurrentlyActivatedCasesBridge.Add(CoordinateTemp); } } } string CoordSwitchForList = indexXSwitch.ToString() + "," + indexZSwitch.ToString(); try { if (SwitchToLoadNormal) { NormalSwitches.Add(CoordSwitchForList, CaseBridgeTemp); } else { StrongSwitches.Add(CoordSwitchForList, CaseBridgeTemp); } } catch { } } } catch { } /* Load Teleporter */ arrivalTeleport = loadedData.arrivalTeleport; }
public List <ICase> GetAllCases() { List <ICase> listOfCases = new List <ICase>(); List <TempCase> tempCases = new List <TempCase>(); try { conn.Open(); SqlCommand command = new SqlCommand("CH_SP_GetAllCases", conn); command.CommandType = CommandType.StoredProcedure; SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { int caseNumber = reader.GetInt32(0); DateTime?constructionStartDate; if (reader.IsDBNull(1)) { constructionStartDate = null; } else { constructionStartDate = reader.GetDateTime(1); } DateTime?moveInDate; if (reader.IsDBNull(2)) { moveInDate = null; } else { moveInDate = reader.GetDateTime(2); } string description; if (reader.IsDBNull(3)) { description = null; } else { description = reader.GetString(3); } int amountOfRevisions = reader.GetInt32(4); DateTime dateOfCreation = reader.GetDateTime(5); DateTime dateOfLastRevision = reader.GetDateTime(6); bool sold = reader.GetBoolean(7); string customerEmail = reader.GetString(8); int?moneyInstituteId; if (reader.IsDBNull(9)) { moneyInstituteId = null; } else { moneyInstituteId = reader.GetInt32(9); } string employeeEmail = reader.GetString(10); int?plotId; if (reader.IsDBNull(11)) { plotId = null; } else { plotId = reader.GetInt32(11); } int?imageId; if (reader.IsDBNull(12)) { imageId = null; } else { imageId = reader.GetInt32(12); } Case caseObj = (Case)ObjectFactory.Instance.CreateNewCase(); caseObj.CaseNumber = caseNumber; caseObj.ConstructionStartDate = constructionStartDate; caseObj.MoveInDate = moveInDate; caseObj.Description = description; caseObj.AmountOfRevisions = amountOfRevisions; caseObj.DateOfCreation = dateOfCreation; caseObj.DateOfLastRevision = dateOfLastRevision; caseObj.Sold = sold; TempCase tempCase = new TempCase(caseObj, customerEmail, moneyInstituteId, employeeEmail, plotId, imageId); tempCases.Add(tempCase); listOfCases.Add(caseObj); } } reader.Close(); reader.Dispose(); command.Dispose(); } catch (SqlException) { } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } } GetCaseDependencies(tempCases); return(listOfCases); }
internal void AddCase(TempCase con) { Cases.Add(con); }