Esempio n. 1
0
        public async Task <KMLDoc> CreateKML(Guid Id, Guid tablemapId, string options, IDataService _dataService)
        {
            ge_data_table dt = await _dataService.GetFileAsClass <ge_data_table>(Id);

            ge_table_map map = await _dataService.GetFileAsClass <ge_table_map>(tablemapId);

            if (dt != null && map != null)
            {
                KMLDoc kml_file = CreateKML(dt, map, options);
                return(kml_file);
            }

            return(null);
        }
Esempio n. 2
0
        public async Task <ge_data> CreateData(Guid projectId, string UserId, KMLDoc doc, string filename, string description, string format)
        {
            ge_MimeTypes mtypes = new ge_MimeTypes();

            string fileext = ".kml";

            string s1 = doc.SerializeToXmlString <KMLDoc>();

            if (format == "kml")
            {
                fileext = ".kml";
            }
            if (format == "json")
            {
                fileext = ".json";
            }

            string filetype = mtypes[fileext];

            var _data = new ge_data {
                Id              = Guid.NewGuid(),
                projectId       = projectId,
                createdId       = UserId,
                createdDT       = DateTime.Now,
                editedDT        = DateTime.Now,
                editedId        = UserId,
                filename        = filename,
                filesize        = s1.Length,
                fileext         = fileext,
                filetype        = filetype,
                filedate        = DateTime.Now,
                encoding        = "utf-8",
                datumProjection = datumProjection.NONE,
                pstatus         = PublishStatus.Uncontrolled,
                cstatus         = ConfidentialityStatus.RequiresClientApproval,
                version         = "P01.1",
                vstatus         = VersionStatus.Intermediate,
                qstatus         = QualitativeStatus.AECOMFactual,
                description     = description,
                operations      = "Read;Download;Update;Delete",
                file            = new ge_data_file {
                    data_xml = s1
                }
            };

            return(await CreateData(_data));
        }
        public async Task <IActionResult> CreateKML(Guid Id,
                                                    Guid tablemapId,
                                                    string options,
                                                    string format = "view",
                                                    Boolean save  = false)
        {
            if (Id == Guid.Empty || tablemapId == Guid.Empty)
            {
                return(NotFound());
            }

            var _data = await _dataTableFileService.GetDataByIdWithAll(Id);

            var _tablemapId = await _dataTableFileService.GetDataByIdWithAll(tablemapId);

            var _user = await GetUserAsync();

            if (_data == null || _tablemapId == null)
            {
                return(NotFound());
            }

            ITableFileKMLService _tableFileKMLService = new TableFileKMLService();

            KMLDoc _kml = await _tableFileKMLService.CreateKML(Id, tablemapId, options, _dataTableFileService);

            if (save == true)
            {
                await _dataKMLService.CreateData(_data.projectId,
                                                 _user.Id,
                                                 _kml,
                                                 _data.FileNameNoExtention() + ".kml",
                                                 $"KML Conversion from data table {_data.filename} using table map {_tablemapId.filename}",
                                                 "kml");
            }

            if (format == "view")
            {
                return(View(_kml));
            }

            return(Ok(_kml));
        }
Esempio n. 4
0
        public KMLDoc CreateKML(ge_data_table dt_file, ge_table_map map, string options)
        {
            KMLDoc       kml          = new KMLDoc();
            ILocaService _locaService = new LocaService();

            foreach (table_map tm in map.table_maps.Where(m => m.destination == "kml"))
            {
                List <ge_data> list = ConvertDataTable <ge_data>(dt_file.dt, tm);
                foreach (ge_data d in list)
                {
                    string msg;
                    if (d.folder == null)
                    {
                        d.folder = dt_file.dt.TableName;
                    }
                    if (d.datumProjection == datumProjection.NONE)
                    {
                        d.datumProjection = datumProjection.OSGB36NG;
                    }
                    if (d.locName == "P2BH20")
                    {
                        Console.WriteLine("P2BH20");
                    }
                    _locaService.UpdateProjectionLoc(d, out msg, "");
                    d.phistory = msg;
                }
                string[] folders = list.Select(m => m.folder).Distinct().ToArray();
                foreach (string folder in folders)
                {
                    Folder f = new Folder();
                    f.name       = folder;
                    f.Placemarks = GetPlacemarks(list);
                    kml.Document.Folders.Add(f);
                }
            }

            return(kml);
        }
        public async Task <IActionResult> ProcessFileToKML(Guid Id,
                                                           Guid?templateId,
                                                           string table,
                                                           string sheet,
                                                           Guid?tablemapId,
                                                           string options = "",
                                                           string format  = "view",
                                                           Boolean save   = false)
        {
            Boolean save_file = true;
            Boolean save_kml  = save;

            if (options == null)
            {
                options = "";
            }

            if (options.Contains("background"))
            {
                if (save == true && !options.Contains("save_kml"))
                {
                    options += ",save_kml";
                }

                //  return await ProcessFileBackground (Id,
                //                                      templateId,
                //                                      table,
                //                                     sheet,
                //                                      tablemapId,
                //                                      agstables,
                //                                      options);
            }

            if (options.Contains("read_file_only"))
            {
                save_file = false;
            }

            var calc_resp = await ReadFile(Id, templateId.Value, table, sheet, "", save_file);

            var okResult = calc_resp as OkObjectResult;

            if (okResult == null)
            {
                var vwResult = calc_resp as ViewResult;

                if (vwResult == null)
                {
                    return(Json(calc_resp));
                }

                return(calc_resp);
                // return View ("OperationRequest",calc_resp);
            }

            ge_data_table _dt_file = okResult.Value as ge_data_table;

            if (options.Contains("view_file"))
            {
                if (format == "view")
                {
                    return(View("ReadData", _dt_file));
                }

                if (format == "json")
                {
                    return(Json(_dt_file));
                }

                return(Ok(_dt_file));
            }

            if (save_file == false)
            {
                ITableFileKMLService _tableFileKMLService = new TableFileKMLService();
                ge_table_map         _tm = await _dataTableFileService.GetFileAsClass <ge_table_map>(tablemapId.Value);

                if (_tm == null)
                {
                    return(Json($"table map for field not found for id={tablemapId.Value}"));
                }

                KMLDoc _kml = _tableFileKMLService.CreateKML(_dt_file, _tm, options);

                if (save_kml == true)
                {
                    var _data = await _dataTableFileService.GetDataByIdWithAll(Id);

                    var _tablemap = await _dataTableFileService.GetDataByIdWithAll(tablemapId.Value);

                    var _user = await GetUserAsync();

                    await _dataKMLService.CreateData(_data.projectId,
                                                     _user.Id,
                                                     _kml,
                                                     _data.FileNameNoExtention() + ".kml",
                                                     $"KML Conversion from data table {_data.filename} using table map {_tablemap.filename}",
                                                     "ags");
                }

                if (format == "view")
                {
                    return(View(_kml));
                }

                if (format == "json")
                {
                    return(Json(_kml));
                }

                return(Ok(_kml));
                // return await View  (mond, format);
            }

            return(await CreateKML(Id, tablemapId.Value, options, format, save_kml));
        }