private void Cancel() { _selectionDisplayControl.ClearSelection(_areaBuilder.GetTiles()); _areaBuilder = null; _modeControl.ChangeSelectionMode(SelectionMode.Area); gameObject.SetActive(false); }
public SubGeographicalRegion(string thisName) { name = thisName; subStations = new Dictionary<string, EquipmentContainer>(); positions = new Dictionary<string, PositionPoint>(); locations = new Dictionary<string, Location>(); builder = new AreaBuilder(this); builder.BuildModel(); }
public Area Create(AreaBuilder builder, Config configuration) { builder.CreateArea(); builder.SetColor(); builder.SetTops(configuration); builder.SetVolume(configuration); builder.SetShiftingVector(configuration); return(builder.Area); }
public override void Import(string selectedNids) { DataTable Table = null; int ProgressCounter = 0; AreaBuilder AreaBuilderObj = null; AreaInfo AreaInfoObj = null; Dictionary <string, DataRow> FileWithNids = new Dictionary <string, DataRow>(); DIConnection SourceDBConnection = null; DIQueries SourceDBQueries = null; // Initialize progress bar this.RaiseProgressBarInitialize(selectedNids.Split(',').GetUpperBound(0) + 1); //////-- Step 1: Get TempTable with Sorted SourceFileName ////Table = this._TargetDBConnection.ExecuteDataTable(this.ImportQueries.GetImportAreas(this._CurrentTemplateFileNameWPath,selectedNids)); //-- Step 2:Initialise Indicator Builder with Target DBConnection AreaBuilderObj = new AreaBuilder(this.TargetDBConnection, this.TargetDBQueries); ////-- Step 3: Import Nids for each SourceFile //foreach (DataRow Row in Table.Copy().Rows) //{ try { SourceDBConnection = new DIConnection(DIServerType.MsAccess, String.Empty, String.Empty, this._CurrentTemplateFileNameWPath, String.Empty, MergetTemplateConstants.DBPassword); SourceDBQueries = DataExchange.GetDBQueries(SourceDBConnection); // AreaInfoObj = this.GetIndicatorInfo(Row); //AreaBuilderObj.ImportArea(selectedNids, 1, SourceDBConnection, SourceDBQueries); //AreaBuilderObj.ImportAreaMaps(selectedNids, 1, SourceDBConnection, SourceDBQueries); AreaBuilderObj.ImportArea(selectedNids, DICommon.SplitString(selectedNids, ",").Length, SourceDBConnection, SourceDBQueries, true); ProgressCounter += 1; this.RaiseProgressBarIncrement(ProgressCounter); } catch (Exception ex) { ExceptionFacade.ThrowException(ex); } finally { if (SourceDBConnection != null) { SourceDBConnection.Dispose(); } if (SourceDBQueries != null) { SourceDBQueries.Dispose(); } } //} this._UnmatchedTable = this.GetUnmatchedTable(); this._AvailableTable = this.GetAvailableTable(); // Close ProgressBar this.RaiseProgressBarClose(); }
/// <summary> /// Imports records from source database to target database/template /// </summary> /// <param name="selectedNids"></param> /// <param name="allSelected">Set true to import all records</param> public override void ImportValues(List <string> SelectedNids, bool allSelected) { AreaBuilder AreaBuilderObj = new AreaBuilder(this._TargetDBConnection, this._TargetDBQueries); DI7MetadataCategoryBuilder AreaMetadataCategoryBuilder = null; int SelectedCount = SelectedNids.Count; try { // 1. import all area metadata categories if (this.IncludeMap) { AreaMetadataCategoryBuilder = new DI7MetadataCategoryBuilder(this._TargetDBConnection, this._TargetDBQueries); AreaMetadataCategoryBuilder.ImportAllMetadataCategories(this.SourceDBConnection, this.SourceDBQueries, MetadataElementType.Area); } // 2. add event handlers AreaBuilderObj.ProcessInfo += new ProcessInfoDelegate(AreaBuilderObj_ProcessInfo); AreaBuilderObj.BeforeProcess += new ProcessInfoDelegate(AreaBuilderObj_BeforeProcess); // 3. updated selected count variable if (allSelected) { SelectedCount = -1; } // 4. import selected areas if (this.IncludeArea & this.IncludeMap) { // import area and maps AreaBuilderObj.ImportArea(string.Join(",", SelectedNids.ToArray()), SelectedCount, this.SourceDBConnection, this.SourceDBQueries, this.SelectedAreaLevel, true); } else if (this.IncludeArea) { // import area AreaBuilderObj.ImportArea(string.Join(",", SelectedNids.ToArray()), SelectedCount, this.SourceDBConnection, this.SourceDBQueries, this.SelectedAreaLevel); } else if (this.IncludeMap) { // import area maps AreaBuilderObj.ImportAreaMaps(string.Join(",", SelectedNids.ToArray()), SelectedCount, this.SourceDBConnection, this.SourceDBQueries, this.SelectedAreaLevel); } } catch (Exception ex) { throw new ApplicationException(ex.ToString()); } }
private void Save() { if (!_areaBuilder.IsValid()) { return; } var newArea = Instantiate(worldAreaPrefab, _world.transform); var worldArea = newArea.GetComponent <WorldArea>(); _areaBuilder.Build(worldArea); _modeControl.ChangeSelectionMode(SelectionMode.Area); _areaBuilder = null; _selectionDisplayControl.UpdateSelection(worldArea.tiles[0]); gameObject.SetActive(false); }
// Builds the extra UI content for debugging public static void Build() { // Build the Debug Handler GameObject info = TargetingUI.Instance.infoText.gameObject; GameObject debug = Instantiate(info, info.transform.parent); debug.name = "Debug"; debug.AddComponent <DebugHandler>(); DebugText = debug.GetComponent <TMP_Text>(); DebugText.richText = true; DebugText.text = string.Empty; // Build all required debug things AreaBuilder.Build(); // Setup things Setup(); }
private void OnEnable() { _areaBuilder = new AreaBuilder(); }
void Start() { BuildBufferCamera(); AreaBuilder.BuildArea("demoArea"); }
/// <summary> /// Imports mapped values into database and returns unmatched elements info /// </summary> /// <param name="mappedValues"></param> /// <param name="dataValue"></param> /// <param name="denominator"></param> /// <returns></returns> public UnMatchedElementInfo ImportMappedValuesIntoDB(DIConnection dbConnection, DIQueries dbQueries, string dataValue, string denominator) { UnMatchedElementInfo RetVal = new UnMatchedElementInfo(); int IndicatorNId = -1; int UnitNId = -1; int SGNId = -1; int IUSNId = -1; int AreaNId = -1; int SourceNId = -1; int TimeperiodNId = -1; int DataNId = -1; Dictionary <string, int> IUSNIds = new Dictionary <string, int>(); Dictionary <string, int> AreaNIds = new Dictionary <string, int>(); Dictionary <string, int> SourceNIds = new Dictionary <string, int>(); Dictionary <string, int> TimeperiodNIds = new Dictionary <string, int>(); IndicatorBuilder IndicatorBuilderObj; UnitBuilder UnitBuilderObj; DI6SubgroupValBuilder SGValBuilderObj; IUSBuilder IUSBuilderObj; AreaBuilder AreaBuilderObj; SourceBuilder SourceBuilderObj; TimeperiodBuilder TimeperiodBuilderObj; DIDatabase TargetDatabase; try { IndicatorBuilderObj = new IndicatorBuilder(dbConnection, dbQueries); UnitBuilderObj = new UnitBuilder(dbConnection, dbQueries); SGValBuilderObj = new DI6SubgroupValBuilder(dbConnection, dbQueries); IUSBuilderObj = new IUSBuilder(dbConnection, dbQueries); AreaBuilderObj = new AreaBuilder(dbConnection, dbQueries); SourceBuilderObj = new SourceBuilder(dbConnection, dbQueries); TimeperiodBuilderObj = new TimeperiodBuilder(dbConnection, dbQueries); TargetDatabase = new DIDatabase(dbConnection, dbQueries); // import value if (this.IsVaildMappedValues()) { // check IUSNId in IUSNIDs list if (IUSNIds.ContainsKey(this._IndicatorGID + this._UnitGID + this._SubgroupValGID)) { IUSNId = IUSNIds[this._IndicatorGID + this._UnitGID + this._SubgroupValGID]; } else { // indicator Nid IndicatorNId = IndicatorBuilderObj.GetIndicatorNid(this._IndicatorGID, this._IndicatorName); // UnitNId UnitNId = UnitBuilderObj.GetUnitNid(this._UnitGID, this._UnitName); // SG Val NID SGNId = SGValBuilderObj.GetSubgroupValNid(this._SubgroupValGID, this._SubgroupVal); //IUSNID IUSNId = IUSBuilderObj.GetIUSNid(IndicatorNId, UnitNId, SGNId); // if IUSNID <=0 then create the given IUS combinator into database if (IUSNId <= 0) { IUSNId = IUSBuilderObj.InsertIUSIntoDB(this._IndicatorGID, this._UnitGID, this._SubgroupValGID); } IUSNIds.Add((this._IndicatorGID + this._UnitGID + this._SubgroupValGID), IUSNId); } if (IUSNId > 0) { // get AREANID if (AreaNIds.ContainsKey(this._AreaID)) { AreaNId = AreaNIds[this._AreaID]; } else { AreaNId = AreaBuilderObj.GetAreaNidByAreaID(this._AreaID); AreaNIds.Add(this._AreaID, AreaNId); } // get sourcenid if (SourceNIds.ContainsKey(this._Source)) { SourceNId = SourceNIds[this._Source]; } else { SourceNId = SourceBuilderObj.CheckNCreateSource(this._Source); SourceNIds.Add(this._Source, SourceNId); } // get timeperiodNId if (TimeperiodNIds.ContainsKey(this._Timeperiod)) { TimeperiodNId = TimeperiodNIds[this._Timeperiod]; } else { TimeperiodNId = TimeperiodBuilderObj.CheckNCreateTimeperiod(this._Timeperiod); TimeperiodNIds.Add(this._Timeperiod, TimeperiodNId); } if (AreaNId > 0 && IUSNId > 0 && SourceNId > 0 && TimeperiodNId > 0 && !string.IsNullOrEmpty(dataValue)) { DataNId = TargetDatabase.CheckNCreateData(AreaNId, IUSNId, SourceNId, TimeperiodNId, dataValue); } // denominator value if (!string.IsNullOrEmpty(denominator) && DataNId > 0) { try { TargetDatabase.UpdateDenominatorValue(DataNId, Convert.ToInt32(Convert.ToDecimal(denominator))); } catch (Exception ex) { throw new ApplicationException(ex.ToString()); } } } } // for log file if (!string.IsNullOrEmpty(dataValue)) { if (AreaNId <= 0 || IUSNId <= 0 || SourceNId <= 0 || TimeperiodNId <= 0) { // for log file if (AreaNId <= 0) { RetVal.Areas.Add(this._AreaID, this._Area); } if (IndicatorNId <= 0) { RetVal.Indicators.Add(this._IndicatorGID, this._IndicatorName); } if (UnitNId <= 0) { RetVal.Units.Add(this._UnitGID, this._UnitName); } if (SGNId <= 0) { RetVal.Subgroups.Add(this._SubgroupValGID, this._SubgroupVal); } } } } catch (Exception ex) { throw new ApplicationException(ex.ToString()); } return(RetVal); }
/// <summary> /// Generate SDMX Files from DES /// </summary> /// <param name="DESFileNameWithPath"></param> /// <param name="DSDFileNameWPath"></param> /// <param name="outputFolder"></param> /// <returns></returns> public static bool Generate_SDMXML_Data(string DESFileNameWithPath, string DSDFileNameWPath, string outputFolder) { bool RetVal = false; DIConnection DBConnection = null; DIQueries DBQueries = null; int count = 0; // Utility.TemporaryFileNamePath DataTable Table = DevInfo.Lib.DI_LibBAL.Import.DAImport.DES.DataEntrySpreadsheets.GetDataTableForAllDESSheets(DESFileNameWithPath); string TempDatabaseName = string.Empty; string TempDatabaseNameCompact = string.Empty; TempDatabaseName = Path.Combine(Path.GetDirectoryName(DESFileNameWithPath), DICommon.GetValidFileName(DateTime.Now.Ticks.ToString() + DICommon.FileExtension.Template)); Dictionary <string, int> IndicatorList = new Dictionary <string, int>(); Dictionary <string, int> UnitList = new Dictionary <string, int>(); Dictionary <string, int> AreaList = new Dictionary <string, int>(); Dictionary <string, int> SgValList = new Dictionary <string, int>(); Dictionary <string, int> TimepeirodList = new Dictionary <string, int>(); Dictionary <string, int> SourceList = new Dictionary <string, int>(); try { DevInfo.Lib.DI_LibDAL.Resources.Resource.GetBlankDevInfoDBFile(TempDatabaseName); DBConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, TempDatabaseName, string.Empty, string.Empty); DBQueries = new DIQueries(DBConnection.DIDataSetDefault(), DBConnection.DILanguageCodeDefault(DBConnection.DIDataSetDefault())); DIDataValueHelper.MergeTextualandNumericDataValueColumn(DBConnection, DBQueries); IndicatorBuilder IndBuilder = new IndicatorBuilder(DBConnection, DBQueries); UnitBuilder UBuilder = new UnitBuilder(DBConnection, DBQueries); DI6SubgroupValBuilder SGBuilder = new DI6SubgroupValBuilder(DBConnection, DBQueries); AreaBuilder AreaBuilderObj = new AreaBuilder(DBConnection, DBQueries); IndicatorClassificationBuilder ICBuilder = new IndicatorClassificationBuilder(DBConnection, DBQueries); TimeperiodBuilder TBuilder = new TimeperiodBuilder(DBConnection, DBQueries); SourceBuilder SrcBuilder = new SourceBuilder(DBConnection, DBQueries); DIDatabase DatabaseObj = new DIDatabase(DBConnection, DBQueries); IUSBuilder IUSBuilderObj = new IUSBuilder(DBConnection, DBQueries); foreach (DataRow Row in Table.Rows) { int IndicatorNId = 0; int UnitNId = 0; int SGValNId = 0; int AreaNId = 0; int TimeperiodNId = 0; int SourceNid = 0; int IUSNID = 0; //-- Import Indicator if (IndicatorList.ContainsKey(Convert.ToString(Row[Indicator.IndicatorGId]))) { IndicatorNId = IndicatorList[Convert.ToString(Row[Indicator.IndicatorGId])]; } else { IndicatorNId = IndBuilder.ImportIndicator(Convert.ToString(Row[Indicator.IndicatorName]), Convert.ToString(Row[Indicator.IndicatorGId]), false); IndicatorList.Add(Convert.ToString(Row[Indicator.IndicatorGId]), IndicatorNId); } //-- Import Unit if (UnitList.ContainsKey(Convert.ToString(Row[Unit.UnitGId]))) { UnitNId = UnitList[Convert.ToString(Row[Unit.UnitGId])]; } else { UnitNId = UBuilder.ImportUnit(Convert.ToString(Row[Unit.UnitGId]), Convert.ToString(Row[Unit.UnitName]).Trim(), false); UnitList.Add(Convert.ToString(Row[Unit.UnitGId]), UnitNId); } //-- Import SubgroupVal if (!string.IsNullOrEmpty(Convert.ToString(Row[SubgroupVals.SubgroupVal]))) { if (SgValList.ContainsKey(Convert.ToString(Row[SubgroupVals.SubgroupValGId]))) { SGValNId = SgValList[Convert.ToString(Row[SubgroupVals.SubgroupValGId])]; } else { SGValNId = SGBuilder.ImportSubgroupVal(Convert.ToString(Row[SubgroupVals.SubgroupVal]), Convert.ToString(Row[SubgroupVals.SubgroupValGId]), false); SgValList.Add(Convert.ToString(Row[SubgroupVals.SubgroupValGId]), SGValNId); } } //-- Import Area if (AreaList.ContainsKey(Convert.ToString(Row[Area.AreaID]))) { AreaNId = AreaList[Convert.ToString(Row[Area.AreaID])]; } else { AreaNId = AreaBuilderObj.ImportArea(Convert.ToString(Row[Area.AreaName]), Convert.ToString(Row[Area.AreaID]), String.Empty, false); AreaList.Add(Convert.ToString(Row[Area.AreaID]), AreaNId); } //-- Import Timeperiod if (TimepeirodList.ContainsKey(Convert.ToString(Row[Timeperiods.TimePeriod]))) { TimeperiodNId = TimepeirodList[Convert.ToString(Row[Timeperiods.TimePeriod])]; } else { TimeperiodNId = TBuilder.CheckNCreateTimeperiod(Convert.ToString(Row[Timeperiods.TimePeriod])); TimepeirodList.Add(Convert.ToString(Row[Timeperiods.TimePeriod]), TimeperiodNId); } //-- Import Source if (SourceList.ContainsKey(Convert.ToString(Row[IndicatorClassifications.ICName]))) { SourceNid = SourceList[Convert.ToString(Row[IndicatorClassifications.ICName])]; } else { SourceNid = SrcBuilder.CheckNCreateSource(Convert.ToString(Row[IndicatorClassifications.ICName])); SourceList.Add(Convert.ToString(Row[IndicatorClassifications.ICName]), SourceNid); } IUSNID = IUSBuilderObj.ImportIUS(IndicatorNId, UnitNId, SGValNId, 0, 0, DBQueries, DBConnection); if (IUSNID > 0 && AreaNId > 0 && TimeperiodNId > 0 && !string.IsNullOrEmpty(Convert.ToString(Row[Data.DataValue]))) { DatabaseObj.CheckNCreateData(AreaNId, IUSNID, SourceNid, TimeperiodNId, Convert.ToString(Row[Data.DataValue])); } } DatabaseObj.UpdateIndicatorUnitSubgroupNIDsInData(); //-- Compact Database into TempFile TempDatabaseNameCompact = Path.Combine(Path.GetDirectoryName(DESFileNameWithPath), DICommon.GetValidFileName(DateTime.Now.Ticks.ToString() + DICommon.FileExtension.Template)); DIDatabase.CompactDataBase(ref DBConnection, DBQueries, TempDatabaseNameCompact, true); DBConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, TempDatabaseNameCompact, string.Empty, string.Empty); DBQueries = new DIQueries(DBConnection.DIDataSetDefault(), DBConnection.DILanguageCodeDefault(DBConnection.DIDataSetDefault())); if (!Directory.Exists(Path.Combine(outputFolder, DBQueries.LanguageCode.Trim('_')))) { Directory.CreateDirectory(Path.Combine(outputFolder, DBQueries.LanguageCode.Trim('_'))); } System.Xml.XmlDocument XmlDoc = SDMXUtility.Get_Query(SDMXSchemaType.Two_One, null, QueryFormats.StructureSpecificTS, DataReturnDetailTypes.Full, Guid.NewGuid().ToString().Replace("-", "").Replace("_", ""), DBConnection, DBQueries); RetVal = SDMXUtility.Generate_Data(SDMXSchemaType.Two_One, XmlDoc, DevInfo.Lib.DI_LibSDMX.DataFormats.StructureSpecificTS, DBConnection, DBQueries, outputFolder); } catch (Exception ex) { ExceptionFacade.ThrowException(ex); } return(RetVal); }
public void StartElement(string uri, string localName, string qName, IEnumerable <XAttribute> attributes) { try { if ("rendertheme".Equals(qName)) { CheckState(qName, Element.RenderTheme); this.renderTheme = new RenderThemeBuilder(qName, attributes).build(); } else if (ElementNameRule.Equals(qName)) { CheckState(qName, Element.Rule); Rule rule = new RuleBuilder(qName, attributes, this.ruleStack).build(); if (this.ruleStack.Count != 0) { this.currentRule.AddSubRule(rule); } this.currentRule = rule; this.ruleStack.Push(this.currentRule); } else if ("area".Equals(qName)) { CheckState(qName, Element.RenderingInstruction); Area area = new AreaBuilder(qName, attributes, this.level++, this.relativePathPrefix).build(); this.currentRule.AddRenderingInstruction(area); } else if ("caption".Equals(qName)) { CheckState(qName, Element.RenderingInstruction); Caption caption = new CaptionBuilder(qName, attributes).build(); this.currentRule.AddRenderingInstruction(caption); } else if ("circle".Equals(qName)) { CheckState(qName, Element.RenderingInstruction); Circle circle = new CircleBuilder(qName, attributes, this.level++).build(); this.currentRule.AddRenderingInstruction(circle); } else if ("line".Equals(qName)) { CheckState(qName, Element.RenderingInstruction); Line line = new LineBuilder(qName, attributes, this.level++, this.relativePathPrefix).build(); this.currentRule.AddRenderingInstruction(line); } else if ("lineSymbol".Equals(qName)) { CheckState(qName, Element.RenderingInstruction); LineSymbol lineSymbol = new LineSymbolBuilder(qName, attributes, this.relativePathPrefix).build(); this.currentRule.AddRenderingInstruction(lineSymbol); } else if ("pathText".Equals(qName)) { CheckState(qName, Element.RenderingInstruction); PathText pathText = new PathTextBuilder(qName, attributes).build(); this.currentRule.AddRenderingInstruction(pathText); } else if ("symbol".Equals(qName)) { CheckState(qName, Element.RenderingInstruction); Symbol symbol = new SymbolBuilder(qName, attributes, this.relativePathPrefix).build(); this.currentRule.AddRenderingInstruction(symbol); } else { throw new XmlException("unknown element: " + qName); } } catch (IOException e) { throw new XmlException(null, e); } }