Exemplo n.º 1
0
        public static GravityBin MapBinToGravityType(this Feature inFeature, IBinstance bin)
        {
            GravityBin gbin = new GravityBin(bin);

            double d;
            string s;

            try
            {
                s = inFeature.Attributes["chute_length"].ToString();
                gbin.ChuteLength = double.TryParse(s, out d) ? d : 0.0;
            }
            catch (Exception)
            {
                gbin.ChuteLength = 0;
            }

            try
            {
                s = inFeature.Attributes["hopper_height"].ToString();
                gbin.HopperHeight = double.TryParse(s, out d) ? d : 0;
            }
            catch (Exception)
            {
                gbin.HopperHeight = 0;
            }

            try
            {
                s = inFeature.Attributes["rectangle_height"].ToString();
                gbin.RectangleHeight = double.TryParse(s, out d) ? d : 0.0;
            }
            catch (Exception)
            {
                gbin.RectangleHeight = 0;
            }

            try
            {
                s = inFeature.Attributes["rectangle_length"].ToString();
                gbin.RectangleLength = double.TryParse(s, out d) ? d : 0;
            }
            catch (Exception)
            {
                gbin.RectangleLength = 0;
            }

            try
            {
                s = inFeature.Attributes["rectangle_width"].ToString();
                gbin.RectangleWidth = double.TryParse(s, out d) ? d : 0.0;
            }
            catch (Exception)
            {
                gbin.RectangleWidth = 0;
            }


            return(gbin);
        }
Exemplo n.º 2
0
        public static FlatBin MapBinToFlatType(this BinViewModel inViewModel, IBinstance bin)
        {
            FlatBin fbin = new FlatBin(bin);
            double  d;

            try
            {
                fbin.CribLength = double.TryParse(inViewModel.CribLength, out d) ? d : 0.0;
            }
            catch (Exception)
            {
                fbin.CribLength = 0;
            }

            try
            {
                fbin.CribWidth = double.TryParse(inViewModel.CribWidth, out d) ? d : 0;
            }
            catch (Exception)
            {
                fbin.CribLength = 0;
            }

            return(fbin);
        }
Exemplo n.º 3
0
        //handle bin type specific mapping below

        public static FlatBin MapBinToFlatType(this Feature inFeature, IBinstance bin)
        {
            FlatBin fbin = new FlatBin(bin);

            double d;

            try
            {
                string s = inFeature.Attributes["crib_height"].ToString();
                fbin.CribLength = double.TryParse(s, out d) ? d : 0.0;
            }
            catch (Exception)
            {
                fbin.CribLength = 0;
            }

            try
            {
                string s = inFeature.Attributes["crib_width"].ToString();
                fbin.CribWidth = double.TryParse(s, out d) ? d : 0;
            }
            catch (Exception)
            {
                fbin.CribLength = 0;
            }

            return(fbin);
        }
Exemplo n.º 4
0
        public static GravityBin MapBinToGravityType(this BinViewModel inViewModel, IBinstance bin)
        {
            GravityBin gbin = new GravityBin(bin);
            double     d;

            try
            {
                gbin.ChuteLength = double.TryParse(inViewModel.ChuteLength, out d) ? d : 0.0;
            }
            catch (Exception)
            {
                gbin.ChuteLength = 0;
            }

            try
            {
                gbin.HopperHeight = double.TryParse(inViewModel.HopperHeight, out d) ? d : 0;
            }
            catch (Exception)
            {
                gbin.HopperHeight = 0;
            }

            try
            {
                gbin.RectangleHeight = double.TryParse(inViewModel.RectangleHeight, out d) ? d : 0.0;
            }
            catch (Exception)
            {
                gbin.RectangleHeight = 0;
            }

            try
            {
                gbin.RectangleLength = double.TryParse(inViewModel.RectangleLength, out d) ? d : 0;
            }
            catch (Exception)
            {
                gbin.RectangleLength = 0;
            }

            try
            {
                gbin.RectangleWidth = double.TryParse(inViewModel.RectangleWidth, out d) ? d : 0.0;
            }
            catch (Exception)
            {
                gbin.RectangleWidth = 0;
            }


            return(gbin);
        }
Exemplo n.º 5
0
 public GravityBin(IBinstance bin)
 {
     base.BinType                 = bin.BinType;
     base.BinVolume               = bin.BinVolume;
     base.CreatedBy               = bin.CreatedBy;
     base.HasDryingDevice         = bin.HasDryingDevice;
     base.HasGrainHeightIndicator = bin.HasGrainHeightIndicator;
     base.Identifier              = bin.Identifier;
     base.Image         = bin.Image;
     base.IsLeased      = bin.IsLeased;
     base.LadderType    = bin.LadderType;
     base.ModifiedBy    = bin.ModifiedBy;
     base.Notes         = bin.Notes;
     base.YearCollected = bin.YearCollected;
     base.YTYDatas      = bin.YTYDatas;
 }
Exemplo n.º 6
0
        public static PolygonBin MapBinToPolyType(this Feature inFeature, IBinstance bin)
        {
            PolygonBin pbin = new PolygonBin(bin);

            double d;
            string s;

            try
            {
                s = inFeature.Attributes["side_height"].ToString();
                pbin.SideHeight = double.TryParse(s, out d) ? d : 0.0;
            }
            catch (Exception)
            {
                pbin.SideHeight = 0;
            }

            try
            {
                s = inFeature.Attributes["side_width"].ToString();
                pbin.SideWidth = double.TryParse(s, out d) ? d : 0;
            }
            catch (Exception)
            {
                pbin.SideWidth = 0;
            }

            try
            {
                int i;
                s = inFeature.Attributes["number_of_sides"].ToString();
                pbin.NumberOfSides = int.TryParse(s, out i) ? i : 0;
            }
            catch (Exception)
            {
                pbin.NumberOfSides = 0;
            }


            return(pbin);
        }
Exemplo n.º 7
0
        public RoundBin(IBinstance bin)
        {
            base.BinType                 = bin.BinType;
            base.BinVolume               = bin.BinVolume;
            base.CreatedBy               = bin.CreatedBy;
            base.HasDryingDevice         = bin.HasDryingDevice;
            base.HasGrainHeightIndicator = bin.HasGrainHeightIndicator;
            base.Identifier              = bin.Identifier;
            base.Image         = bin.Image;
            base.IsLeased      = bin.IsLeased;
            base.LadderType    = bin.LadderType;
            base.ModifiedBy    = bin.ModifiedBy;
            base.Notes         = bin.Notes;
            base.YearCollected = bin.YearCollected;
            base.YTYDatas      = bin.YTYDatas;
            //Type t = bin.GetType();
            //if (t.Equals(typeof(RoundBin)))
            //{

            //}
        }
Exemplo n.º 8
0
        public static PolygonBin MapBinToPolyType(this BinViewModel inViewModel, IBinstance bin)
        {
            PolygonBin pbin = new PolygonBin(bin);

            double d;

            try
            {
                pbin.SideHeight = double.TryParse(inViewModel.SideHeight, out d) ? d : 0.0;
            }
            catch (Exception)
            {
                pbin.SideHeight = 0;
            }

            try
            {
                pbin.SideWidth = double.TryParse(inViewModel.SideWidth, out d) ? d : 0;
            }
            catch (Exception)
            {
                pbin.SideWidth = 0;
            }

            try
            {
                int i;
                pbin.NumberOfSides = int.TryParse(inViewModel.NumberOfSides, out i) ? i : 0;
            }
            catch (Exception)
            {
                pbin.NumberOfSides = 0;
            }

            return(pbin);
        }
Exemplo n.º 9
0
        public static void MapBinstanceToViewModel(this BinViewModel inViewModel)
        {
            IBinstance oldBin = inViewModel.Binstance;

            inViewModel.Identifier = oldBin.Identifier;

            switch (oldBin.BinType)
            {
            case Enums.BinTypeEnum.FlatStructure:
                inViewModel.BinType = 0;
                inViewModel.FlatBinstanceToViewModel();
                break;

            case Enums.BinTypeEnum.GravityWagon:
                inViewModel.BinType = 1;
                inViewModel.GravityBinstanceToViewModel();
                break;

            case Enums.BinTypeEnum.PolygonStructure:
                inViewModel.BinType = 2;
                inViewModel.PolyBinstanceToViewModel();
                break;

            case Enums.BinTypeEnum.RoundStorage:
                inViewModel.BinType = 3;
                inViewModel.RoundBinstanceToViewModel();
                break;

            case Enums.BinTypeEnum.NotFound:
                inViewModel.BinType = -1;
                break;
            }

            switch (oldBin.IsLeased)
            {
            case true:
                inViewModel.Owned = 0;
                break;

            case false:
                inViewModel.Owned = 1;
                break;

            case null:
                inViewModel.Owned = -1;
                break;
            }

            switch (oldBin.HasDryingDevice)
            {
            case true:
                inViewModel.HasDryingDevice = 0;
                break;

            case false:
                inViewModel.HasDryingDevice = 1;
                break;

            case null:
                inViewModel.HasDryingDevice = -1;
                break;
            }

            switch (oldBin.HasGrainHeightIndicator)
            {
            case true:
                inViewModel.HasGrainHeightIndicator = 0;
                break;

            case false:
                inViewModel.HasGrainHeightIndicator = 1;
                break;

            case null:
                inViewModel.HasGrainHeightIndicator = -1;
                break;
            }

            switch (oldBin.LadderType)
            {
            case Enums.Ladder.None:
                inViewModel.LadderType = 0;
                break;

            case Enums.Ladder.Stairs:
                inViewModel.LadderType = 1;
                break;

            case Enums.Ladder.Ladder:
                inViewModel.LadderType = 2;
                break;

            default:
                inViewModel.LadderType = -1;
                break;
            }

            inViewModel.Notes = oldBin.Notes;
        }
Exemplo n.º 10
0
        public static RoundBin MapBinToRoundType(this BinViewModel inViewModel, IBinstance bin)
        {
            RoundBin rbin = new RoundBin(bin);

            try
            {
                switch (inViewModel.HasHopper)
                {
                case 0:
                    rbin.HasHopper = true;
                    break;

                case 1:
                    rbin.HasHopper = false;
                    break;

                default:
                    rbin.HasHopper = null;
                    break;
                }
            }
            catch (Exception)
            {
                rbin.HasHopper = null;
            }

            double d;

            try
            {
                rbin.Radius = double.TryParse(inViewModel.Radius, out d) ? d : 0.0;

                rbin.Circumference = rbin.Radius * 2 * Math.PI;
            }
            catch (Exception)
            {
                rbin.Radius        = 0;
                rbin.Circumference = 0;
            }

            try
            {
                rbin.WallHeight = double.TryParse(inViewModel.WallHeight, out d) ? d : 0;
            }
            catch (Exception)
            {
                rbin.WallHeight = 0;
            }

            try
            {
                rbin.RoofHeight = double.TryParse(inViewModel.RoofHeight, out d) ? d : 0;
            }
            catch (Exception)
            {
                rbin.RoofHeight = 0;
            }

            try
            {
                rbin.HopperHeight = double.TryParse(inViewModel.HopperHeight, out d) ? d : 0;
            }
            catch (Exception)
            {
                rbin.HopperHeight = 0;
            }

            return(rbin);
        }
Exemplo n.º 11
0
        public static async Task <ArcCrudEnum> EditBin(BinViewModel binViewModel)
        {
            IBinstance    bin           = binViewModel.Binstance;
            ArcGISFeature featureToEdit = binViewModel.ArcGISFeature;

            try
            {
                await featureToEdit.LoadAsync();

                featureToEdit.Attributes["identifier"]  = bin.Identifier;
                featureToEdit.Attributes["modified_by"] = binViewModel.EmpoyeeNumber;

                switch (bin.BinType)
                {
                case BinTypeEnum.RoundStorage:
                    featureToEdit.Attributes["bin_type"] = "round_storage";
                    break;

                case BinTypeEnum.GravityWagon:
                    featureToEdit.Attributes["bin_type"] = "gravity_wagon";
                    break;

                case BinTypeEnum.PolygonStructure:
                    featureToEdit.Attributes["bin_type"] = "polygon_structure";
                    break;

                case BinTypeEnum.FlatStructure:
                    featureToEdit.Attributes["bin_type"] = "flat_structure";
                    break;
                }

                featureToEdit.Attributes["year_collected"] = bin.YearCollected;


                if (bin.IsLeased.HasValue)
                {
                    featureToEdit.Attributes["owned_or_leased"] = bin.IsLeased.Value ? "leased" : "owned";
                }

                if (bin.HasDryingDevice.HasValue)
                {
                    featureToEdit.Attributes["drying_device"] = bin.HasDryingDevice.Value ? "true" : "false";
                }

                if (bin.HasGrainHeightIndicator.HasValue)
                {
                    featureToEdit.Attributes["bin_level_indicator_device"] = bin.HasGrainHeightIndicator.Value ? "true" : "false";
                }

                switch (bin.LadderType)
                {
                case Ladder.None:
                    featureToEdit.Attributes["ladder_type"] = "none";
                    break;

                case Ladder.Ladder:
                    featureToEdit.Attributes["ladder_type"] = "ladder";
                    break;

                case Ladder.Stairs:
                    featureToEdit.Attributes["ladder_type"] = "stairs";
                    break;
                }

                featureToEdit.Attributes["notes"] = bin.Notes;

                double dr;
                //double.TryParse(bin.BinVolume, out dr);
                //featureToEdit.Attributes["bin_volume"] = dr;

                //bin type specific logic below
                Type t = bin.GetType();
                if (bin.BinType == BinTypeEnum.FlatStructure)
                {
                    if (t.Equals(typeof(FlatBin)))
                    {
                        FlatBin flat = (FlatBin)bin;
                        featureToEdit.Attributes["crib_height"] = flat.CribLength;
                        featureToEdit.Attributes["crib_width"]  = flat.CribWidth;
                    }
                }
                else if (bin.BinType == BinTypeEnum.GravityWagon)
                {
                    if (t.Equals(typeof(GravityBin)))
                    {
                        GravityBin gravityBin = (GravityBin)bin;
                        featureToEdit.Attributes["chute_length"]     = gravityBin.ChuteLength;
                        featureToEdit.Attributes["hopper_height"]    = gravityBin.HopperHeight;
                        featureToEdit.Attributes["rectangle_height"] = gravityBin.RectangleHeight;
                        featureToEdit.Attributes["rectangle_length"] = gravityBin.RectangleLength;
                        featureToEdit.Attributes["rectangle_width"]  = gravityBin.RectangleWidth;
                    }
                }
                else if (bin.BinType == BinTypeEnum.PolygonStructure)
                {
                    if (t.Equals(typeof(PolygonBin)))
                    {
                        PolygonBin polygonBin = (PolygonBin)bin;
                        featureToEdit.Attributes["side_height"]     = polygonBin.SideHeight;
                        featureToEdit.Attributes["side_width"]      = polygonBin.SideWidth;
                        featureToEdit.Attributes["number_of_sides"] = polygonBin.NumberOfSides;
                    }
                }
                else if (bin.BinType == BinTypeEnum.RoundStorage)
                {
                    if (t.Equals(typeof(PolygonBin)))
                    {
                        RoundBin round = (RoundBin)bin;
                        if (round.HasHopper.HasValue)
                        {
                            featureToEdit.Attributes["has_hopper"] = round.HasHopper.Value ? "true" : "false";
                        }

                        featureToEdit.Attributes["radius"]        = round.Radius;
                        featureToEdit.Attributes["wall_height"]   = round.WallHeight;
                        featureToEdit.Attributes["roof_height"]   = round.RoofHeight;
                        featureToEdit.Attributes["hopper_height"] = round.HopperHeight;
                    }
                }


                // can't be null
                if (binViewModel.Binstance.YTYDatas == null)
                {
                    binViewModel.Binstance.YTYDatas = new List <YTYData>();
                }
                //use data in _binViewModel

                System.Diagnostics.Debug.Print("Feature can edit attachments" + (featureToEdit.CanEditAttachments ? "Yes" : "No"));
                //-------- Formatting --------
                //create json
                string jsonString = JsonConvert.SerializeObject(binViewModel.Binstance.YTYDatas);

                //System.Diagnostics.Debug.Print(jsonString);
                //System.Diagnostics.Debug.Print(((Binstance)(binViewModel.Binstance)).YTYDatasString());
                // convert json to byte array
                byte[] byteArray = Encoding.UTF8.GetBytes(jsonString);


                //-------- ARC Connection --------
                //remove old YTYData
                List <Attachment>          attachmentsToRemove = new List <Attachment>();
                IReadOnlyList <Attachment> attachments         = await featureToEdit.GetAttachmentsAsync();

                foreach (Attachment attachment in attachments)
                {
                    System.Diagnostics.Debug.Print(attachment.Name);
                    if (attachment.Name.Equals(YTY_FILE_NAME))
                    {
                        System.Diagnostics.Debug.Print("Found YTY attachment");
                        attachmentsToRemove.Add(attachment);
                    }
                }
                System.Diagnostics.Debug.Print("Attachments to remove:");
                foreach (Attachment attachment in attachments)
                {
                    System.Diagnostics.Debug.Print(attachment.Name);
                }

                if (attachmentsToRemove.Any())
                {
                    //update the json file
                    await featureToEdit.UpdateAttachmentAsync(attachmentsToRemove.First(), YTY_FILE_NAME, "application/json", byteArray);
                }

                _featureTable = (ServiceFeatureTable)featureToEdit.FeatureTable;

                // update feature after attachment added
                await _featureTable.UpdateFeatureAsync(featureToEdit); //agsFeature

                System.Diagnostics.Debug.Print("Feature table updated");

                // push to ArcGIS Online feature service
                IReadOnlyList <EditResult> editResults = await _featureTable.ApplyEditsAsync();

                System.Diagnostics.Debug.Print("Arc updated");

                foreach (var er in editResults)
                {
                    if (er.CompletedWithErrors)
                    {
                        // handle error (er.Error.Message)
                        return(ArcCrudEnum.Failure);
                    }
                }

                return(ArcCrudEnum.Success);
            }
            catch (ArcGISWebException)
            {
                return(ArcCrudEnum.Exception);
            }
        }
Exemplo n.º 12
0
        public static async Task <ArcCrudEnum> AddBin(BinViewModel binViewModel)
        {
            IBinstance            bin = binViewModel.Binstance;
            IEnumerable <YTYData> yTY = bin.YTYDatas;

            try
            {
                await _featureTable.LoadAsync();

                var attributes = new Dictionary <string, object>();
                attributes.Add("identifier", bin.Identifier);
                attributes.Add("created_by", bin.CreatedBy);
                attributes.Add("modified_by", bin.ModifiedBy);

                switch (bin.BinType)
                {
                case BinTypeEnum.RoundStorage:
                    attributes.Add("bin_type", "round_storage");
                    break;

                case BinTypeEnum.GravityWagon:
                    attributes.Add("bin_type", "gravity_wagon");
                    break;

                case BinTypeEnum.PolygonStructure:
                    attributes.Add("bin_type", "polygon_structure");
                    break;

                case BinTypeEnum.FlatStructure:
                    attributes.Add("bin_type", "flat_structure");
                    break;
                }

                attributes.Add("year_collected", bin.YearCollected);

                if (bin.IsLeased.HasValue)
                {
                    attributes.Add("owned_or_leased", bin.IsLeased.Value ? "leased" : "owned");
                }

                if (bin.HasDryingDevice.HasValue)
                {
                    attributes.Add("drying_device", bin.HasDryingDevice.Value ? "true" : "false");
                }

                if (bin.HasGrainHeightIndicator.HasValue)
                {
                    attributes.Add("bin_level_indicator_device", bin.HasGrainHeightIndicator.Value ? "true" : "false");
                }

                switch (bin.LadderType)
                {
                case Ladder.None:
                    attributes.Add("ladder_type", "none");
                    break;

                case Ladder.Ladder:
                    attributes.Add("ladder_type", "ladder");
                    break;

                case Ladder.Stairs:
                    attributes.Add("ladder_type", "stairs");
                    break;
                }

                attributes.Add("notes", bin.Notes);

                //bin type specific logic below
                Type t = bin.GetType();
                if (bin.BinType == BinTypeEnum.FlatStructure)
                {
                    if (t.Equals(typeof(FlatBin)))
                    {
                        FlatBin flat = (FlatBin)bin;
                        attributes.Add("crib_height", flat.CribLength);
                        attributes.Add("crib_width", flat.CribWidth);
                    }
                }
                else if (bin.BinType == BinTypeEnum.GravityWagon)
                {
                    if (t.Equals(typeof(GravityBin)))
                    {
                        GravityBin gravityBin = (GravityBin)bin;
                        attributes.Add("chute_length", gravityBin.ChuteLength);
                        attributes.Add("hopper_height", gravityBin.HopperHeight);
                        attributes.Add("rectangle_height", gravityBin.RectangleHeight);
                        attributes.Add("rectangle_length", gravityBin.RectangleLength);
                        attributes.Add("rectangle_width", gravityBin.RectangleWidth);
                    }
                }
                else if (bin.BinType == BinTypeEnum.PolygonStructure)
                {
                    if (t.Equals(typeof(PolygonBin)))
                    {
                        PolygonBin polygonBin = (PolygonBin)bin;
                        attributes.Add("side_height", polygonBin.SideHeight);
                        attributes.Add("side_width", polygonBin.SideWidth);
                        attributes.Add("number_of_sides", polygonBin.NumberOfSides);
                    }
                }
                else if (bin.BinType == BinTypeEnum.RoundStorage)
                {
                    if (t.Equals(typeof(RoundBin)))
                    {
                        RoundBin round = (RoundBin)bin;
                        if (round.HasHopper.HasValue)
                        {
                            attributes.Add("has_hopper", round.HasHopper.Value ? "true" : "false");
                        }
                        attributes.Add("radius", round.Radius);
                        attributes.Add("wall_height", round.WallHeight);
                        attributes.Add("roof_height", round.RoofHeight);
                        attributes.Add("hopper_height", round.HopperHeight);
                    }
                }

                MapPoint mp;
                double   lat = 0;
                double   lon = 0;

                try
                {
                    var locator = CrossGeolocator.Current;
                    locator.DesiredAccuracy = 1000;
                    var position = await locator.GetPositionAsync();

                    if (position == null)
                    {
                        Console.WriteLine("Location Service error");
                    }
                    lat = position.Latitude;
                    lon = position.Longitude;
                }
                catch { }

                string   lonS      = lon.ToString();
                string[] split     = lonS.Split('.');
                var      charArray = split[1].ToCharArray();
                //seperate good location, make third if necassary
                string first     = charArray[0].ToString();
                string second    = charArray[1].ToString();
                string third     = charArray[2].ToString();
                Random random    = new Random();
                int    addition  = random.Next(25, 75);
                string additionS = addition.ToString();
                string newLong   = split[0] + '.' + first + second + third + additionS;
                //latitude
                string   latS       = lat.ToString();
                string[] splitL     = latS.Split('.');
                var      charArrayL = splitL[1].ToCharArray();
                //seperate good location, make third if necassary
                string firstL             = charArrayL[0].ToString();
                string secondL            = charArrayL[1].ToString();
                string thirdL             = charArrayL[2].ToString();
                int    additionL          = random.Next(25, 75);
                string additionSL         = additionL.ToString();
                string newLat             = splitL[0] + '.' + firstL + secondL + thirdL + additionSL;
                double clusteredLongitude = double.Parse(newLong);
                double clusteredLatitude  = double.Parse(newLat);

                mp = new MapPoint(clusteredLongitude, clusteredLatitude);

                binViewModel.ArcGISFeature = (ArcGISFeature)_featureTable.CreateFeature(attributes, mp);

                await _featureTable.AddFeatureAsync(binViewModel.ArcGISFeature);

                await binViewModel.ArcGISFeature.LoadAsync();

                if (DeviceInfo.DeviceType == DeviceType.Physical)
                {
                    using (var memoryStream = new MemoryStream())
                    {
                        bin.Image.GetStream().CopyTo(memoryStream);
                        // add an attachment - pass the name, mime type, and attachment data (bytes, etc.)
                        await binViewModel.ArcGISFeature.AddAttachmentAsync("Photo.jpg", "image/jpg", memoryStream.ToArray()); //agsFeature
                    }
                }

                if (yTY == null)
                {
                    yTY = new List <YTYData>();
                }

                //create json
                string jsonString = JsonConvert.SerializeObject(yTY);
                byte[] byteArray  = Encoding.UTF8.GetBytes(jsonString);

                List <Attachment>          attachmentsToRemove = new List <Attachment>();
                IReadOnlyList <Attachment> attachments         = await binViewModel.ArcGISFeature.GetAttachmentsAsync();

                foreach (Attachment attachment in attachments)
                {
                    if (attachment.Name.Equals(YTY_FILE_NAME))
                    {
                        attachmentsToRemove.Add(attachment);
                    }
                }

                await binViewModel.ArcGISFeature.DeleteAttachmentsAsync(attachmentsToRemove);

                await binViewModel.ArcGISFeature.AddAttachmentAsync(YTY_FILE_NAME, "application/json", byteArray); //agsFeature

                await _featureTable.UpdateFeatureAsync(binViewModel.ArcGISFeature);                                //agsFeature

                // push to ArcGIS Online feature service
                IReadOnlyList <EditResult> editResults = await _featureTable.ApplyEditsAsync();

                // check results for errors
                foreach (var er in editResults)
                {
                    if (er.CompletedWithErrors)
                    {
                        return(ArcCrudEnum.Failure);
                    }
                }

                return(ArcCrudEnum.Success);
            }
            catch (ArcGISWebException)
            {
                return(ArcCrudEnum.Exception);
            }
        }
Exemplo n.º 13
0
        public static RoundBin MapBinToRoundType(this Feature inFeature, IBinstance bin)
        {
            RoundBin rbin = new RoundBin(bin);

            try
            {
                string hasHopper = (string)inFeature.Attributes["has_hopper"];
                hasHopper.ToLowerInvariant();
                if (hasHopper.Equals("true"))
                {
                    rbin.HasHopper = true;
                }
                else if (hasHopper.Equals("false"))
                {
                    rbin.HasHopper = false;
                }
                else
                {
                    rbin.HasHopper = null;
                }
            }
            catch (Exception)
            {
                rbin.HasHopper = null;
            }

            double d;
            string s;

            try
            {
                s           = inFeature.Attributes["radius"].ToString();
                rbin.Radius = double.TryParse(s, out d) ? d : 0.0;

                rbin.Circumference = rbin.Radius * 2 * Math.PI;
            }
            catch (Exception)
            {
                rbin.Radius        = 0;
                rbin.Circumference = 0;
            }

            try
            {
                s = inFeature.Attributes["wall_height"].ToString();
                rbin.WallHeight = double.TryParse(s, out d) ? d : 0;
            }
            catch (Exception)
            {
                rbin.WallHeight = 0;
            }

            try
            {
                s = inFeature.Attributes["roof_height"].ToString();
                rbin.RoofHeight = double.TryParse(s, out d) ? d : 0;
            }
            catch (Exception)
            {
                rbin.RoofHeight = 0;
            }

            try
            {
                s = inFeature.Attributes["hopper_height"].ToString();
                rbin.HopperHeight = double.TryParse(s, out d) ? d : 0;
            }
            catch (Exception)
            {
                rbin.HopperHeight = 0;
            }


            return(rbin);
        }