GMap .net offline - c#

I'm developing an application using Gmap in c# (great API, btw), not to confuse with google-map API, and I did some really cool and useful stuff ever since.
My problem is that some of my clients won't have an internet connection, and that is why I need to be able to display the background (the map) offline. I used to use the property GMap.NET.AccessMode.ServerAndCache; to get my data from the server, and now I would like to be able to use GMap.NET.AccessMode.CacheOnly with a full cache.
Letting them load the cache with a connection to prepare for an offline use is not an option, the PCs will never be connected to the internet. After some research, I learned OpenStreetMap is the only open source map that would allow me to use their map for free (and that is good because they have very good maps). I downloaded a 20GB map of Europe, but I have no idea how to specify it as the cache (I know how to locate the cache folder).
Most of the time, my Google searches showed me people trying to create a virtual sqlite server with all the map's tiles in a DB accessed via localhost, but honestly I think this is very complex and I would like to know if anybody has an idea to allow me to use those maps offline or a link for the doc of this api, impossible to find on the net (I found the sources, but almost no comment and no explanation).
Thanks in advance, and sorry for my bad English.
réponses en français bienvenues.

you can create a separate program to prefetch tiles for offline use. Or use the GMap NET demo program (https://github.com/radioman/greatmaps/tree/master/Demo.WindowsPresentation)
The code below is for a button press after you've selected an area using ALT + mouse first button.
RectLatLng area = mapView.SelectedArea;
if (!area.IsEmpty)
{
for (int i = (int)mapView.Zoom; i <= mapView.MaxZoom; i++)
{
TilePrefetcher obj = new TilePrefetcher();
obj.Title = "Prefetching Tiles";
obj.Icon = this.Icon;
obj.Owner = this;
obj.ShowCompleteMessage = false;
obj.Start(area, i, mapView.MapProvider, 100);
}
DialogResult = true;
Close();
}
else
{
MessageBox.Show("No Area Chosen", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
(mostly copied from Gmap NET Demo source)
https://github.com/radioman/greatmaps/tree/master/Demo.WindowsPresentation
The Files are stored in C:\Users\[your user name]\AppData\Local\GMap.NET\TileDBv5\en
Once you've successfully prefetched the tiles you can copy the files to the same location in the offline pc and it should use it (or just copy the whole GMap.NET folder to the offline pc via usb or whatever)

use gmap.CacheLocation = #"C:\Users\xxx\Desktop\"; to specify the cache location.
Just copy the cache to different machine under the same directory will work.
To cache the map data, check my github https://github.com/williamwdu/GMap.NETChacher
The cache directory will look like this TileDBv5\en\Data.gmdb

Pay attention that the Provider of the MAP that you have downloaded be the same provider that you have used in your code.
eq: GMap.NET.MapProviders.GMapProviders.OpenStreetMap

Related

UCMA recording app

I've installed a MSPL script to redirect INVITE audio messages to the UCMA sip address
I'm currently writing a UCMA app for Skype for Business to:
receive incoming calls
accept the call
create a conference call
add a trusted participant to the conference
create a recording instance on the trusted participant audio flow to record the conversation
The last thing I need to do is add the To caller URI to the conference call.
I've tried to invite the new participant into the conference using the code examples from this article, but I get an exception saying there are no AvailableMediaTypes in the conversation.
public static async void InviteToConference(string destinationUri)
{
//Create a new conversation for the application endpoint.
_toConversation = new Conversation(_server.ApplicationEndPoint);
var conferenceInviteSettings = new ConferenceInvitationSettings();
conferenceInviteSettings.ConferenceUri = _conferenceUri;
ConferenceInvitation invitation = new ConferenceInvitation(_toConversation, conferenceInviteSettings);
try
{
await invitation.DeliverAsync(destinationUri);
}
catch (InvalidOperationException)
{
// Conversation was terminated while trying to add participant.
}
}
Can someone please show me what I need to do to add / invite a participant into a conference call?
It would be even better if someone could show me how to record a Skype for Business call without the need to create a conference, as a conference can't be forwarded.
Your code looks like the old way (UCMA 3) of doing it. Have you tried this.
e.g.
McuDialOutOptions mcuDialOutOptions = new McuDialOutOptions();
mcuDialOutOptions.ParticipantUri = "sip:alice#contoso.com";
mcuDialOutOptions.ParticipantDisplayName = "Alice";
mcuDialOutOptions.PreferredLanguage = CultureInfo.GetCultureInfo("en-us");
conversation.ConferenceSession.AudioVideoMcuSession.BeginDialOut("tel:+14255551234", mcuDialOutOptions, dialOutCallback, state);
Using this sort of method to record very specific and low traffic should be fine but when you start to scale it up then you are going to hit all sorts of problems.
As for how to do it without a conference:
There is no way to do it fully with the supplied Microsoft API's.
What you have to do is implement, buy or use open source libraries for the following pieces:
sniff network packets
decode RTP/SRTP streams
decode the audio and/or video codecs used between the callers
encode streams into your desired format and save somewhere
To get access to the SRTP streams encryption setup and to figure out what the dynamic payload types for the audio/video codecs used, you also need to know the SDP offered and answered between the calling parties. You also need access to the SIP traffic to determine the calling parties to know who called who. This can be a lot more trouble than what it seems...
To get the SIP/SDP information there are two options that I know of:
Skype/Lync Server SDK (MSPL / Server Application) to see most of the SIP traffic. This is what I've used to implement a recording solution.
Skype/Lync SDN SDK - I haven't used this API but it seems to give access to the SDP so it should work.
If you get all these peices into place then the next problem is you can only "record" (basically "sniff") what you can see. If you can't see the RTP/SRTP traffic you can't record the calls.
So you need to have the sniffer part of the recording software on areas of the network that see the traffic you want to record. For example if you wish to record all PSTN calls, you can have a network spanning port off the Skype mediation servers.
If you wish to record ALL calls, then that gets a lot harder. You most likely need to either:
Force all media trafic to go through a known place (like the Edge server) and put sniffers on the that network.
Have lots of sniffers in strategic areas of the network to capture most RTP/SRTP traffic.
The problems with the above solutions are:
Forcing all the traffic through one point can cause performance issues (like you will see with your conference setup) once load starts to increase. Also forcing external (edge server users) and/or federated calls through this one point can cause a problems. Think edger server user calls to edge server users where the media traffic may not even go into your network at all but live only on the internet. Forcing the trafficing into your network can cause performance issues.
When not forcing all the traffic through one point, you may never be see all skype user to skype user calls depending on your network setup. Calls between Edge server skype users are even more of a problem as the media traffic may not even enter your network at all.
On top of all that there are the general problems of storage management (recording after a while will start taking up a large amount of disk space) and call recording management (e.g. searching for a specific call) and user security around these recordings to deal with. I'm sure I'm missing a lot but those are the basics.
If recording in not going to be a core component, you could just buy a 3rd party call recording solution that supports Lync/Skype.

Performance considerations when getting license information for WP app

Introduction
I have a Windows Phone 8.1 Silverlight (WP8.1 SL) based app in the store. Some users complain about performance issues when they have a bad network connection. I searched a bit and came up with the idea that it might be related to new LicenseInformation() that gives me the information of whether the app is running in Trial mode or not. The question is, whether this requires network information or not, and whether CurrentApp.LicenseInformation is a suitable replacement for a WP8.1 SL app.
Background and What I did so far
In general, the app does not need a network connection (no data to load, no advertisements, ...). To confirm that I used Fiddler to watch over the network sent by my phone. The result was that no network traffic is generated. However, the problem still persists.
After a lot of research and playing around I got the feeling that this issue might be related to the code part that checks on whether the app is in trial mode or not. I use the following code to check that.
var li = new LicenseInformation();
if (li.IsTrial()) {
...
}
I do this a couple of times during startup. So in case IsTrial() requires a network connection this could be the actual issue when there is only a bad connection available. But again, I couldn't find anything using Fiddler. The documentation (see here) for LicenseInformation does not mention whether a network connection is required or not.
Searching around I found that there is an updated interface available for both WP 8.1 SL and also W10M UWP.
var li = CurrentApp.LicenseInformation;
if (li.IsTrial) {
...
}
Its documentation clearly states that there is no network connection required for that (see here).
Even though the docs say that CurrentApp.LicenseInformation is also available on WP8 I also found some references that say that you only get a reliable answer for the IsTrial-question when using new LicenseInformation() (e.g. here).
Actual Questions
Is new LicenseInformation() required on WP8.1 SL, or can I use CurrentApp.LicenseInformation as well?
Does new LicenseInformation() require a network connection compared to CurrentApp.LicenseInformation?

How can I upload a static HTML site to a Windows Azure Website programmatically?

I am currently building a local static site generator in C#. It compiles a bunch of templates together into a hierarchy of plain old HTML files. I want to upload the resulting files to my Windows Azure Website and have the changes reflected live, and I want to be able to do this programmatically via my script.
As it stands, I'm having to upload the generated files manually using WebMatrix, as I haven't been able to find an API or SDK that lets me directly upload HTML to a Windows Azure Website.
Surely there must be a way to do this from code, other than just using an sFTP library (which, because it doesn't use the WebMatrix/IIS protocol, which I think sends zipped diffs, would be slow and would mean out-of-sync data during the upload while some files have been updated and others haven't.) I'd also rather not have to commit my generated site to source control if I can avoid it. It seems conceptually wrong to me to be putting something into source control merely as an implementation detail of deployment.
Update: WebMatrix internally uses Web Deploy (MSDeploy). Theoretically you should be able to build the deployment package yourself using the API, but 99% of the examples I can find are using the command-line tool or the GUI tools in Visual Studio. I need to build the package and deploy it programmatically from within C#. Any ideas or guidance on how to go about this? The docs on MSDN don't really show any examples for this kind of scenario.
OK, so I worked out what to do with help from a couple of friendly folks at Microsoft. (See David's Ebbo's response to my forum question, and this very helpful info from Sayed Hashimi showing how to do exactly what I wanted to do from the msdeploy.exe console app).
Just grab your PublishSettings file from the Azure web portal. Open it in a text editor to get the values to paste into the below code.
var destinationOptions = new DeploymentBaseOptions()
{
// userName from Azure Websites PublishSettings file
UserName = "$msdeploytest",
// pw from PublishSettings file
Password = "ThisIsNotMyPassword",
// publishUrl from PublishSettings file using https: protocol prefix rather than 443 port
// and adding "/msdeploy.axd?site={msdeploySite-variable-from-PublishSettings}"
ComputerName = "https://waws-prod-blu-003.publish.azurewebsites.windows.net/msdeploy.axd?site=msdeploytest",
AuthenticationType = "Basic"
};
// This option says we're giving it a directory to deploy
using (var deploymentObject = DeploymentManager.CreateObject(DeploymentWellKnownProvider.ContentPath,
// path to root directory of source files
#"C:\Users\ryan_000\Downloads\dummysite"))
{
var syncOptions = new DeploymentSyncOptions();
syncOptions.WhatIf = false;
// "msdeploySite" variable from PublishSettings file
var changes = deploymentObject.SyncTo(DeploymentWellKnownProvider.ContentPath, "msdeploytest", destinationOptions, syncOptions);
Console.WriteLine("BytesCopied: " + changes.BytesCopied.ToString());
Console.WriteLine("Added: " + changes.ObjectsAdded.ToString());
Console.WriteLine("Updated: " + changes.ObjectsUpdated.ToString());
Console.WriteLine("Deleted: " + changes.ObjectsDeleted.ToString());
Console.WriteLine("Errors: " + changes.Errors.ToString());
Console.WriteLine("Warnings: " + changes.Warnings.ToString());
Console.WriteLine("ParametersChanged: " + changes.ParameterChanges.ToString());
Console.WriteLine("TotalChanges: " + changes.TotalChanges.ToString());
}
You might also be able to stumble your way through the obscure documentation on MSDN. There is a lot of passing around of oddly-named options classes, but with a bit of squinting of one's eyes and flailing about in the docs it's possible to see how the command-line options (of which it is much easier to find examples online) map to API calls.
The easiest way is probably to set up Git publishing for your website and programmatically do a git commit followed by a git push. You can think of it as a deployment mechanism instead of source control, given that Azure websites natively support a backing Git repository that doesn't have to have anything to do with your chosen SCM solution.
WebMatrix uses WebDeploy to upload the files to Windows Azure Web Sites.
An alternative is to use the VFS REST API (https://github.com/projectkudu/kudu/wiki/REST-API#wiki-vfs). The diagnostic console uses this to work with the file system today.

C# Service Will not write files, no errors

EDIT:
Ok, as of now and looking through countless posts I this i've arrived to a solution, I cannot do what I need to do from a service, I wanted it to be a service so that it would always be on for the computer, but apparently with the way services are written I may not be able to run the commands I want to run because "The service does not run in the same space as the users desktop" so it wont be able to capture the desktop, at least, thats what im gathering so far.
As for now, I'll leave this here and maybe find a way to start a program under the users name when they logon, to capture the desktop, rather than try and do it from the service directly.
I've been banging my head on the wall for a couple hours now trying to figure this out, I've never made a service before, just forms applications, well my next project (Client Server Model Client Monitoring utility) needs to be installed as a service on the client machines and send data back to the main server.
Having never written a service before I looked up how to write one and how to install it and whatnot. I got it all working fine, the current working version spits an event log out every 30 seconds to show its working.
I started by running it in LocalSystem because I assumed it had the permissions to write to the file, but after that failed I tried LocalService, that didn't work either.
Im specifying the Directory as C:\WatcherData\Test.jpg
and tested it in a regular forms application (which works)
OutputImage.Save("c:\watcherdata\test.jpg", ImageFormat.Jpeg);
No exceptions, no events, it just doesn't happen, but the EventLog message is put in immediately before it,so it should be reaching that point, right?
Any assistance would be appreciated, If you need to know anything else I would be happy to oblige
EDIT:
Here goes a little code:
private void ServiceWorkerThread(object state)
{
while (!this.stopping)
{
this.eventLog1.WriteEntry("This is a test2");
CallMe();
Thread.Sleep(30000);
}
this.stoppedEvent.Set();
}
private void CallMe()
{
try
{
int screenWidth = Screen.GetBounds(new Point(0, 0)).Width;
int screenHeight = Screen.GetBounds(new Point(0, 0)).Height;
Bitmap OutputImage = new Bitmap(screenWidth, screenHeight);
Graphics gfx = Graphics.FromImage((Image) OutputImage);
gfx.CopyFromScreen(0, 0, 0, 0, new Size(screenWidth, screenHeight));
OutputImage.Save("c:\\watcherdata\\test.jpg", ImageFormat.Jpeg);
}
catch (Exception e)
{
this.eventLog1.WriteEntry(e.Message + "\r\n" + e.StackTrace, EventLogEntryType.Error);
}
}
most of it was taken from a Microsoft sample document, as I said, I'm new to services
currently still trying to figure it out, will let you guys know if i get anywhere
EDIT 2
After playing around some more I managed to get it to write to the file, After realizing that most of the problem was with my lack of knowledge on how to build services and installers, apparently i wasnt rebuilding the installers when i built my service.
Now it just writes all black, a large, black picture. but at least its writing!
How about some source code?
I might add some tracing to make sure the file write code is executed.
Most cases, this type of failure is a permissions issue and/or folks are trying to write to a Windows system directory. You question suggests you are ensuring that you are NOT writing to a Windows Directory. Please make sure c:\watcherdata folder exists.

Secure My ASP .NET Code For Presentation?

I have a web application , for presentation to my client they ask me to install it on their local server so they can test it , here is my question !?
Is there any way so i can publish uniquely for that server , i did put some limitation but many features in my app are open , so they can make a disk image from server and use it anywhere else ,
Is there any method to use so my web application check if this server is same server ( by hardware id or anything i don't have any idea ) then start to work !
I saw many codes but they are win forms for generating unique hid , but how can i connect done it with asp .net
EDIT
Could u take a look at this also ,
i am using system.management class
is this reliable i mean are they unique ?
private string GetUniqueID()
{
string cpuInfo = string.Empty;
ManagementClass mc = new ManagementClass("win32_processor");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if (cpuInfo == "")
{
//Get only the first CPU's ID
cpuInfo = mo.Properties["processorID"].Value.ToString();
break;
}
}
ManagementObject dsk = new ManagementObject(#"win32_logicaldisk.deviceid=""" + "C" + #":""");
dsk.Get();
string volumeSerial = dsk["VolumeSerialNumber"].ToString();
string HardWareUniqueID = volumeSerial + cpuInfo;
return HardWareUniqueID;
}
Appreciate your answers,
Thanks in advance
If you want to avoid having it "phone home" an alternative is to generate some kind of certificate and place it on the machine. Use a private key that only you know to encrypt the machine name and/or IP. Then have your app use your public key to decrypt it to verify that it is allowed to run on this server. Nobody who doesn't know your private key will be able to create valid certificates.
You hae a few choices...
Lock your web site to the single IP address you install it on. To make your life easier, check for that IP in a common page base class. (Note, you could also write HTTP handlers, but the base-class approach is easier.)
Put a 'phone home' call in the app that checks with your server every time it's started up. That way you can check if they have moved it or if multiple instances are running.
Use the built-in licensing features of .NET (the same one third-party developers use for controls, etc.)
The easiest... just put in a time-bomb that lets them test it for a few weeks, then automatically blocks access. Be smart though... persist the last-checked time so you can tell if they've rolled back their clock trying to get more usage.
Just make sure to distribute a web application, not a web project so you can distribute your code as a compiled bumary rather than having to ship the code-behind files. That will keep prying eyes out, but does make deployment more a pain since you always have to recompile with every change (as opposed to on-demand compiling.)
I would put in a time bomb. It's trivial to implement. Also, your client's won't think that you don't trust them. A fixed evaluation period in the application is extremely common.
Provide them a VMware image without any user-access just allow them to open the website externally via HTTP in their web browser.

Categories

Resources