コード例 #1
0
        //Upload a symbolicLocation in the background (update or create)
        //Form: AsyncTask<[Input Parameter Type], [Progress Report Type], [Result Type]>
        private void AddEdgeTask()
        {
            isUploading = true;
            mContext = LocationService.radiomapContext;
            
            /*
            Uri radiomapUri = new Uri("http://smartcampusaau.cs.aau.dk/RadioMapService3/RadioMapService.svc/");
            mContext = new radiomapEntities(radiomapUri);
            Building b = (mContext.Buildings.Where(b1 => b1.ID == LocationService.CurrentBuilding.ID)).First();
            Vertex v0 = (mContext.Vertices.Where(v => v.ID == mCurrentEdge.Vertices[0].ID)).First();
            Vertex v1 = (mContext.Vertices.Where(v => v.ID == mCurrentEdge.Vertices[1].ID)).Single();
            mContext.AddToEdges(mCurrentEdge);
            mContext.AddLink(b, "Edges", mCurrentEdge);
            mContext.AddLink(v0, "Edges", mCurrentEdge);
            mContext.AddLink(v1, "Edges", mCurrentEdge);
            */

            //Link to/from the building and endpoints
            mContext.AddToEdges(mCurrentEdge);
            Building b = LocationService.CurrentBuilding;
            b.Edges.Add(mCurrentEdge);
            /*
            foreach (Vertex v in mCurrentEdge.Vertices)
            {
                if (!v.Edges.Contains(mCurrentEdge))
                    v.Edges.Add(mCurrentEdge);
            }
            */
            try
            {
                mContext.BeginSaveChanges(OnChangesSaved, mContext);

                uploadProgressIndicator.IsVisible = isUploading;

            }
            catch (Exception ex)
            {
                isUploading = false;
                uploadProgressIndicator.IsVisible = isUploading;

                MessageBox.Show(string.Format("The changes could not be saved.\n"
                    + "The following error occurred: {0}", ex.Message));
            }
        }
コード例 #2
0
        private void RemoveEdgeTask()
        {
            if (CurrentEdge == null)
                throw new InvalidOperationException("No link to remove");

            isUploading = true;
            mContext = LocationService.radiomapContext;

            //Add the edge
            mContext.DeleteObject(CurrentEdge);
            
            try
            {
                mContext.BeginSaveChanges(OnChangesSaved, mContext);

                uploadProgressIndicator.IsVisible = isUploading;
            }
            catch (Exception ex)
            {
                isUploading = false;
                uploadProgressIndicator.IsVisible = isUploading;

                // Display the error from the response.
                string errorMsg = ex.InnerException != null ?
                    ex.InnerException.Message :
                    ex.Message;
                MessageBox.Show(string.Format("The following error occured: {0}", errorMsg));
            }
        }
コード例 #3
0
 private static void UploadTrackingDataAndFlushBuffer()
 {
     if (bufferedTrackedPositions == null)
         return;
     if (bufferedTrackedPositions.Count == 0)
         return;
                 
     //copy tracking data and clear buffer
     TrackedPosition[] tmp;
     lock (bufferedTrackedPositionsLock)
     {
         int numPositions = bufferedTrackedPositions.Count;
         tmp = new TrackedPosition[numPositions];
         bufferedTrackedPositions.CopyTo(tmp);
         bufferedTrackedPositions.Clear();
     }
     
     radiomapEntities context = new radiomapEntities(radiomapUri);
     foreach (TrackedPosition pos in tmp)
     {
         context.AddToTrackedPositions(pos);
     }
     context.BeginSaveChanges(SaveChangesOptions.Batch, OnPositionEstimatesSaved, context);
     
 }
コード例 #4
0
        //Upload a symbolicLocation in the background (update or create)
	    //Form: AsyncTask<[Input Parameter Type], [Progress Report Type], [Result Type]>
	    private void UploadSymbolicLocationTask(SymbolicLocation tmpSymLoc)
        {
            isUploading = true;
            mContext = LocationService.radiomapContext;

		    Vertex currentVertex = Map2DOffline.SelectedOfflineVertex;
			SymbolicLocation currentSymLoc = currentVertex.SymbolicLocations.FirstOrDefault();
			//1) upload NEW symbolic location 
			if (currentSymLoc == null)
            {
                mContext.AddRelatedObject(currentVertex, "SymbolicLocations", tmpSymLoc);
                currentVertex.SymbolicLocations.Add(tmpSymLoc);
			}
			//2) or UPDATE existing
			else
			{
                //copy updated values 
                currentSymLoc.title = tmpSymLoc.title;
                currentSymLoc.description = tmpSymLoc.description;
                currentSymLoc.url = tmpSymLoc.url;
                currentSymLoc.is_entrance = tmpSymLoc.is_entrance;    
                
                mContext.UpdateObject(currentSymLoc);				
			}
            try
            {
                mContext.BeginSaveChanges(OnChangesSaved, mContext);
                
                //uploadProgressBar.Visibility = System.Windows.Visibility.Visible;
                uploadProgressIndicator.IsVisible = isUploading;             
                
            }
            catch (Exception ex)
            {
                isUploading = false;
                uploadProgressIndicator.IsVisible = isUploading;
                                
                MessageBox.Show(string.Format("The changes could not be saved.\n"
                    + "The following error occurred: {0}", ex.Message));
            }
		}