void Awake() { Debug.Log("RUNNING AWAKE FUNCTION OF GLOBALOBJECT.CS"); if (GlobalObject.instance == null) { GlobalObject.instance = this; DontDestroyOnLoad(this.gameObject); //Register for OnSceneLoaded event SceneManager.sceneLoaded += this.OnSceneLoaded; } else if (instance != this) { Debug.LogError("DUPLICATE GLOBAL OBJECT FOUND! DELETING THIS ONE"); Destroy(this.gameObject); } //Build list of commander scripts from prefabs foreach (GameObject commanderPrefab in this.commanderList) { Commander commander = commanderPrefab.GetComponent <Commander>(); this.loadedCommanders.Add(commander); } //Build list of all cards for use with card selection manager or wherever else it is needed this.CreateCardEntryList(); //Do something based on loaded scene if (SceneManager.GetActiveScene().name != "BossSelect" && SceneManager.GetActiveScene().name != "Game" && SceneManager.GetActiveScene().name != "GameCommanders" && SceneManager.GetActiveScene().name != "CommanderSelect" && SceneManager.GetActiveScene().name != "Map" && SceneManager.GetActiveScene().buildIndex != GameConstants.SCENE_INDEX_POST_BATTLE_CARD_SELECT) { Debug.LogWarning("WARNING! Scene Manger is Loading a non specified scene which it assumes is the card select!!!"); } //Build the strings dictionary ReadWriteCSV.CsvFileReader fileReader = new ReadWriteCSV.CsvFileReader("Assets/Resources/Localization/localization-en.csv"); List <string> stringList = fileReader.BuildStringsList(); for (int i = 0; i < stringList.Count; i++) { if (i % 2 == 0) { stringDictionary.Add(stringList[i], stringList[i + 1]); } } }
public ActionResult Upload(HttpPostedFileBase file) { var beacon = new Entities.Beacon(); JsonResponse response = new JsonResponse(); if (file == null) { ViewBag.AlertMessage = "Please select a .csv File"; } else { //TO:DO var fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/Content/Upload"), fileName); file.SaveAs(path); ModelState.Clear(); ViewBag.Message = "File uploaded successfully"; using (LiveKart.Business.CSV.ReadWriteCSV.CsvFileReader reader = new ReadWriteCSV.CsvFileReader(path)) { LiveKart.Business.CSV.ReadWriteCSV.CsvRow row = new LiveKart.Business.CSV.ReadWriteCSV.CsvRow(); long count = 0; long dcount = 0; long ccount = 0; while (reader.ReadRow(row)) { beacon.BeaconID = row[0].ToString(); beacon.BeaconName = row[1].ToString(); beacon.Description = row[2].ToString(); beacon.Active = true; beacon.CreatedBy = CurrentUser; beacon.CreatedDate = DateTime.UtcNow; beacon.CompanyID = CurrentCompany.CompanyId; var existingBeacon = _unitOfWorkAsync.Repository <Entities.Beacon>().GetByBeaconNum(beacon.BeaconID); if (existingBeacon == null) { _unitOfWorkAsync.Repository <Entities.Beacon>().Insert(beacon); var success = _unitOfWorkAsync.SaveChanges() > 0; if (success) { count = count + 1; } else { dcount = dcount + 1; } } else { ccount = ccount + 1; } } if (dcount == 0 && count > 0 && ccount == 0) { ViewBag.AlertMessage = " Beacons created sucessfully."; } else if (count > 0 && dcount > 0 && ccount == 0) { ViewBag.AlertMessage = count + " Beacons created sucessfully and " + dcount + " Beacons not created."; } else if (count > 0 && dcount > 0 && ccount > 0) { ViewBag.AlertMessage = count + " Beacons created sucessfully , " + dcount + " Beacons not created. and " + ccount + " beacons already exists."; } else if (count > 0 && dcount == 0 && ccount > 0) { ViewBag.AlertMessage = count + " Beacons created sucessfully and " + ccount + " beacons already exists."; } else if (count == 0 && dcount == 0 && ccount > 0) { ViewBag.AlertMessage = "Beacons already Exists"; } } } return(View()); }