示例#1
0
        public void SetMapWithId(int id, int submap)
        {
            Console.WriteLine($"MapViewForm: SetMapWithId({id}, 0{submap.ToString()});");

            Models.Territory territory = Globals.exdreader.GetTerritory(id);
            territoryId = id;

            actors.Clear();

            if (territory != null)
            {
                Image mapImage;
                try
                {
                    string path = $"map/ui/map/{territory.Identifier}/0{submap.ToString()}/{territory.Identifier}0{submap.ToString()}_m.tex.png";
                    mapImage = Image.FromFile(path);

                    mapPictureBox.Image = mapImage;
                    mapPictureBox.Size  = new Size(mapImage.Width / 3, mapImage.Height / 3);

                    this.Width  = mapPictureBox.Size.Width + 16;
                    this.Height = mapPictureBox.Size.Height + 38;

                    infoLabel.Text = $"TerritoryID: {id}\nTerritoryName: {Globals.exdreader.GetTerritoryName(id)}\n{path}";

                    this.Text = $"FFXIVActorCapture | {Globals.exdreader.GetTerritoryName(id)}({id}, 0{submap.ToString()})";
                }
                catch (System.IO.FileNotFoundException exc)
                {
                    if (submap < 4)
                    {
                        SetMapWithId(id, submap + 1);
                    }
                    else
                    {
                        infoLabel.Text = $"TerritoryID: {id}\nTerritoryName: {Globals.exdreader.GetTerritoryName(id)}\nCould not load map file!\n{exc}";

                        mapPictureBox.Image = Properties.Resources.error;
                        mapPictureBox.Size  = new Size(Properties.Resources.error.Width / 4, Properties.Resources.error.Height / 4);

                        this.Width  = mapPictureBox.Size.Width + 16;
                        this.Height = mapPictureBox.Size.Height + 38;

                        this.Text = $"FFXIVActorCapture | {Globals.exdreader.GetTerritoryName(id)}({id})";
                        return;
                    }
                }
            }
            else
            {
                infoLabel.Text = $"TerritoryID: {id}\nTerritoryName:\nTerritoryID not in EXH!";
                this.Text      = $"FFXIVActorCapture | {Globals.exdreader.GetTerritoryName(id)}({id}, 0{submap.ToString()})";

                mapPictureBox.Image = Properties.Resources.error;
                mapPictureBox.Size  = new Size(Properties.Resources.error.Width / 4, Properties.Resources.error.Height / 4);

                this.Width  = mapPictureBox.Size.Width + 16;
                this.Height = mapPictureBox.Size.Height + 38;
            }
        }
示例#2
0
        public async Task <IActionResult> Details(int id)
        {
            Models.Territory territory = await _unitOfWork.Territory.GetFirstOrDefaultAsync(t => t.Id == id);

            PublisherTerritory publisherTerritoryObj = new PublisherTerritory()
            {
                Territory   = territory,
                TerritoryId = territory.Id
            };

            return(View(publisherTerritoryObj));
        }
        public async Task <ActionResult <Models.Territory> > GetTerritory(int territoryId)
        {
            System.Text.StringBuilder sqlStatement;
            DateTime processingDateTime;

            NpgsqlConnection sqlConnection;
            NpgsqlCommand    sqlCommandGetTerritory;
            NpgsqlDataReader sqlDataReaderGetTerritory;

            try
            {
                Models.Territory returnValue = new Models.Territory();

                processingDateTime = System.DateTime.Now;

                using (sqlConnection = new NpgsqlConnection(configuration["ConnectionStrings:PolitiScout"]))
                {
                    await sqlConnection.OpenAsync();

                    sqlStatement = new System.Text.StringBuilder();
                    sqlStatement.Append("SELECT t.territory_level_id, t.full_name, t.short_name_abbreviation ");
                    sqlStatement.Append("  FROM territory t ");
                    sqlStatement.Append("  WHERE t.territory_id = @territory_id ");

                    sqlCommandGetTerritory                = sqlConnection.CreateCommand();
                    sqlCommandGetTerritory.CommandText    = sqlStatement.ToString();
                    sqlCommandGetTerritory.CommandTimeout = 600;
                    sqlCommandGetTerritory.Parameters.Add(new NpgsqlParameter("@territory_id", NpgsqlTypes.NpgsqlDbType.Integer));

                    sqlCommandGetTerritory.Parameters["@territory_id"].Value = 0;
                    await sqlCommandGetTerritory.PrepareAsync();

                    sqlCommandGetTerritory.Parameters["@territory_id"].Value = territoryId;
                    using (sqlDataReaderGetTerritory = await sqlCommandGetTerritory.ExecuteReaderAsync(System.Data.CommandBehavior.CloseConnection))
                    {
                        if (await sqlDataReaderGetTerritory.ReadAsync())
                        {
                            returnValue.territoryId      = territoryId;
                            returnValue.territoryLevelId = sqlDataReaderGetTerritory.GetInt32(ApplicationValues.TERRITORY_QUERY_RESULT_COLUMN_OFFSET_TERRITORY_LEVEL_ID);
                            returnValue.fullName         = sqlDataReaderGetTerritory.GetString(ApplicationValues.TERRITORY_QUERY_RESULT_COLUMN_OFFSET_FULL_NAME);
                            returnValue.shortName        = sqlDataReaderGetTerritory.GetString(ApplicationValues.TERRITORY_QUERY_RESULT_COLUMN_OFFSET_SHORT_NAME);
                        }
                        ;

                        await sqlDataReaderGetTerritory.CloseAsync();
                    };

                    await sqlConnection.CloseAsync();
                }       // using (sqlConnection = new NpgsqlConnection(configuration["ConnectionStrings:PolitiScout"]))

                return(Ok(returnValue));
            }
            catch (Exception ex1)
            {
                logger.LogError(string.Format("Unhandled exception occurred in TerritoryWSController::GetTerritory().  Message is {0}", ex1.Message));

                if (ex1.InnerException != null)
                {
                    logger.LogError(string.Format("  -- Inner exception message is {0}", ex1.InnerException.Message));

                    if (ex1.InnerException.InnerException != null)
                    {
                        logger.LogError(string.Format("  -- --  Inner exception message is {0}", ex1.InnerException.InnerException.Message));
                    }
                }

                logger.LogError(string.Format("{0}", ex1.StackTrace));

                return(StatusCode(StatusCodes.Status500InternalServerError, ex1.Message));
            }
        }       // GetTerritory()
示例#4
0
 public IActionResult Update([FromBody] Models.Territory territory)
 {
     _unitOfWork.TerritoryRepository.Update(territory);
     _unitOfWork.Complete();
     return(new JsonResult(territory));
 }