Cannot edit a feature layer when I start a session editing - gis

I am developing a standalone app based on ArcGIS Engine, and when I starting a session editing with the code block below:
//Declare the Engine editor at the class level.
private IEngineEditor m_engineEditor = new EngineEditorClass();
private void StartEditing(IMapControl2 m_mapControl)
{
IMap map = m_mapControl.Map;
//If an edit session has already been started, exit.
if (m_engineEditor.EditState != esriEngineEditState.esriEngineStateNotEditing)
return ;
//Start editing the workspace of the first feature layer found.
for (int layerCounter = 0; layerCounter <= map.LayerCount - 1; layerCounter++)
{
ILayer currentLayer = map.get_Layer(layerCounter);
if (currentLayer is IFeatureLayer)
{
IFeatureLayer featureLayer = currentLayer as IFeatureLayer;
IDataset dataset = featureLayer.FeatureClass as IDataset;
IWorkspace workspace = dataset.Workspace;
m_engineEditor.StartEditing(workspace, map);
((IEngineEditLayers)m_engineEditor).SetTargetLayer(featureLayer);
break;
}
}
}
An exception occurred with error code: HRESULT: 0x80004005 (E_FAIL)). Please help me

After asking Google and reading ArcGIS Engine documents. I found my SDE GeoDatabase does not allow editing data, because I turn off version manager of ArcGIS GeoDatabase. Turn on it and add some code to check feature layer is editable.
IEngineEditLayers m_engineLayersEditor = m_engineEditor as IEngineEditLayers;
if (!m_engineLayersEditor.IsEditable(featureLayer))
{
MessageBox.Show("Can not start editing. Because feature layer is not allow editing", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}

Related

Geolocator.RequestAccessAsync throws "method called at unexpected time" exception

I have a chunk of code I use to get device location. This is done in a monogame windows uwp project. The following code worked before (I was on VS2015 Community). I recent did a fresh OS and install VS2017 Community. I finally got my project to build and run. The only thing not working is the Geolocator.RequestAccessAsync is throwing a "method called at unexpected time" exception. Any ideas?
public async Task<Vector2> GetDeviceGps()
{
var accessStatus = await Geolocator.RequestAccessAsync();
switch (accessStatus)
{
case GeolocationAccessStatus.Allowed:
// If DesiredAccuracy or DesiredAccuracyInMeters are not set (or value is 0), DesiredAccuracy.Default is used.
Geolocator geolocator = new Geolocator { DesiredAccuracyInMeters = 10 };
// Subscribe to the StatusChanged event to get updates of location status changes.
//geolocator.StatusChanged += OnStatusChanged;
// Carry out the operation.
Geoposition pos = await geolocator.GetGeopositionAsync();
return new Vector2((float)pos.Coordinate.Point.Position.Longitude, (float)pos.Coordinate.Point.Position.Latitude);
case GeolocationAccessStatus.Denied:
//Do something!
break;
case GeolocationAccessStatus.Unspecified:
//Murp
break;
}
return Vector2.Zero;
}
This is invoked and handled like so (called from update method of game):
mapper.GetDeviceGps().ContinueWith(pos =>
{
Vector2 bob = pos.Result;
});
When you run the RequestAccessAsync for the first time in your app, the user will be asked to grant your app the location permission. Therefore the method needs to be executed in the UI thread.

Embarcadero C++ : How to notify user if new update is available?

I am beginner in Embarcadero C++, If my application is developed in Embarcadero C++ and installed in client machine then how my application notify user if new update is available? If user clicked on yes button then it will first download the application then install it.
Please let me know if anybody have any Idea.
Here is how I check if new version of program is available on the server, using
Indy Client component TIdHTTP.
Let's say you have uploaded a new version of your application. Besides installation or zip file containing you application, upload a one line text file (applicationBuildData.txt) which contains build value (integer), delimiter (;) and optionally some other data (version number, program name, etc...). For example:
20170215; ProgamName rel. 1.2.
This is the only line in applicationBuildData.txt file. Here is the code sample (I've modified my original code a bit):
void __fastcall TfrmDialog::Button1Click(TObject *Sender)
{
TIdHTTP *IdHTTP1 = new TIdHTTP(this);
// let's say this is current app build (on user's side)
int currAppBuild = 20170101;
int prodBuildNew = 0;
UnicodeString prodVersionNew;
UnicodeString version_str;
try {
// get content of applicationBuildData.txt into string
version_str = IdHTTP1->Get("http://www.your-site.com/applicationBuildData.txt");
prodBuildNew = StrToInt(version_str.SubString(1, version_str.Pos(";") - 1).Trim());
prodVersionNew = version_str.SubString(version_str.Pos(";") + 1, 100).Trim();
}
catch (...)
{
prodBuildNew = 0;
prodVersionNew = "???";
}
if (prodBuildNew == 0) {
// ...faild to get data from server...
// display message
}
else if (prodBuildNew > currAppBuild) {
// new version is available
// display message
}
else {
// application version is up to date
// display message
}
delete IdHTTP1;
}
In this example, current build number is smaller then uploaded build number and it will indicate user that new version is available.
Note: currAppBuild is usually some global constant, or global variable that presents build version. After new version on the server is detected, you can either download installation/zip or simply display message and let the user go to your site and download new version manually.
Edit: How to download the file to your local disk using TIdHTTP component, check the following video:
https://www.youtube.com/watch?v=fcN8K3R4iZE

API to 'Disable downloading, printing, and copying of any Google Drive file'

Google released this feature couple of months ago. The link below mentions that it is accessible via API. Tried using drive api patch call to toggle the "disable downloading .." flag which I assume is the "copyable" flag, but to no avail.
https://connect.googleforwork.com/docs/DOC-11088
Appreciate any help, thanks.
You're looking for the "labels.restricted" Property.
Here's what you would do it in C#.
Google.Apis.Drive.v2.Data.File body = new Google.Apis.Drive.v2.Data.File();
body.Title = Path.GetFileName(filename);
body.Labels = new Google.Apis.Drive.v2.Data.File.LabelsData();
body.Labels.Restricted = true;
byte[] byteArray = System.IO.File.ReadAllBytes(filename);
MemoryStream stream = new MemoryStream(byteArray);
try
{
FilesResource.InsertMediaUpload request =
service.Files.Insert(body, stream, mimeType);
request.Upload();
}
catch(Exception ex){
ExceptionLogger.log(ex);
}
Check out the link below for samples.
https://developers.google.com/drive/v2/reference/files/copy.
labels.restricted is deprecated.
You should to set the copyRequiresWriterPermission metadata property instead.
Source: Google Drive API Files Reference

Xamarin.Forms Maps crashing app

I'm having a hard time trying to show a map on my Xamarin Forms app. This is the error I get everytime I open the page with the map:
0x29 in System.Diagnostics.Debugger.Mono_UnhandledException_internal C#
0x1 in System.Diagnostics.Debugger.Mono_UnhandledException C#
0x6 in Android.Runtime.UncaughtExceptionHandler.UncaughtException at /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d23da369/source/monodroid/src/Mono.Android/src/Runtime/UncaughtExceptionHandler.cs:35,4 C#
0x1C in Java.Lang.Thread.IUncaughtExceptionHandlerInvoker.n_UncaughtException_Ljava_lang_Thread_Ljava_lang_Throwable_ at /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d23da369/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Java.Lang.Thread.cs:221,5 C#
0x1D in object.28d67210-c8ee-4f17-9d83-36104107982d C#
This is the code for creating the page:
var topLayout = new StackLayout
{
Children =
{
new Map(MapSpan.FromCenterAndRadius(new Position(37,-122), Distance.FromMiles(0.3)))
{
IsShowingUser = true,
HeightRequest = 100,
VerticalOptions = LayoutOptions.FillAndExpand
}
}
};
var bottomLayout = new StackLayout { Children = { ... } }; //shortened for readability
Content = new StackLayout
{
Children = { topLayout, bottomLayout }
};
I'm saying the problem is the map, because if I change the "new Map" line for a Label, for instance, it works.
I'm instantiating the Maps FW as said here: http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/maps/
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
Xamarin.FormsMaps.Init(this, bundle);
LoadApplication(new FullHelp.App());
}
I tried your solution for Android, and yes it did throw an Exception.
In the Debug --> Exceptions dialog box, if you click the Thrown checkbox for Common Language Runtime Exceptions you will get a more meaningful description of the exception to be resolved.
The exception detail thrown is:
'Java.Lang.RuntimeException: API key not found. Check that <meta-data android:name="com.google.android.geo.API_KEY" android:valu…'
Looking at your AndroidManifest.xml you have no keys defined / capabilities.
Refer to this link that will discuss how to configure your Xamarin.Forms application to handle Maps integration as you appear to be missing some things.
There is more detail on my other StackOverflow answer here that details how to create the API key for Andorid.
Hold short keys Ctrl+Alt+E to open Exceptions in Visual Studio.

Windows Phone 8 HRESULT: 0X80042706

I'm developing a Windows Phone 8 Application that uses the map control. I have followed the tutorial, but I keep geeting the messagebox error: HRESULT: 0X80042706. Here is the code from the tutorial
protected override void OnNavigatedTo(NavigationEventArgs e)
{
map.ColorMode = MapColorMode.Light; map.CartographicMode = MapCartographicMode.Road; map.LandmarksEnabled = true; map.PedestrianFeaturesEnabled = true; map.ZoomLevel = 17;
routeQuery.TravelMode = TravelMode.Walking; routeQuery.QueryCompleted += rq_QueryCompleted;
base.OnNavigatedTo(e);
}
...
void rq_QueryCompleted(object sender, QueryCompletedEventArgs<Route> e) {
if (null == e.Error) {
//Recommended way to display route on map
Route MyRoute = e.Result;
MapRoute MyMapRoute = new MapRoute(MyRoute);
map.AddRoute(MyMapRoute);
}
else
MessageBox.Show("Error occured:\n" + e.Error.Message);
}
I tried to search what kind of error HRESULT: 0X80042706 was from here, but I have no idea what that meant.
I even tried to switch the if condition to e.Error == null, but still no good. Can anyone help me?
The error is because your device does not support CHAP authentication while connecting to Virtual Disk Service (i.e. Maps)
This is because you don't have an authentication id from Microsoft.
Follow the details here ( for wp8 maps another authentication is required)
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207033(v=vs.105).aspx
I received the same error from the same tutorial, and found it was due to no internet access to my PC (and hence no map data). Restored Internet access and the error resolved itself.
Please once check your Manifestfile and select Capability option click in ID_CAP_MAP.