RavenDB access embedded database - ravendb

I am looking to see if I can access an embedded RavenDB database as part of a Datazen install.
So far I have a prototype console app that has some simple code as follows
private static void Connect()
{
string location = #"C:\Program Files\Datazen Enterprise Server\service\Raven";
int port = 82;
NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(port);
var docStore = new EmbeddableDocumentStore()
{
//RunInMemory = true,
DataDirectory = location,
UseEmbeddedHttpServer = true,
};
docStore.Configuration.Storage.Voron.AllowOn32Bits = true;
docStore.Configuration.HostName = "localhost";
docStore.Configuration.Port = port;
docStore.Initialize();
Console.WriteLine("Running...");
Console.ReadLine();
}
I am able to access the Raven studio now via the URL localhost:82 but this just displays the following message
No databases and no filesystems are available. Go ahead and create a
database or distributed file system or manage your server
Am I looking in the wrong file location for the embedded database? The folder I am pointing to contains the following directories:
CompiledIndexCache
IndexDefinitions
Indexes
logs
system
temp
and files
- Data
- raven-data.ico
Edit
From reading the following from the RavenDB docs
I have now pointed to the following path C:\Program Files\Datazen Enterprise Server\service\data
this now returns the following when I attempt to access the Raven studio at localhost:82
Could not write to location: C:\Program Files\Datazen Enterprise Server\service\data. Make sure you have read/write permissions for this path.
I have tried setting the folder (which is set as read only) to not be. But it remains as showing read only in windows explorer (even if I try to make the entire Datazen Enterprise Server folder read/write and cascade to all child items.

Related

Access Database Connection String

I have built an application that connects to an access database on one of my servers at work. I can easily use this on my computer but when I install on another I obviously have an issue specifying the connection to the database location on the server. How do I allow the user to specify the database connection location for use on multiple work stations? Any help is greatly appreciated!
Do not hard-code the filename of the DB in your code, rather store it in a configuration file. E.g. an INI-file or an XML-file. See How to store and retrieve custom information from an application configuration file by using Visual Basic .NET or Visual Basic 2005.
You can save the setting in the App.Config File like this.
Const connectionKey As String = "connection"
Dim config As System.Configuration.Configuration
config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
config.AppSettings(connectionKey) = openFileDialog.FileName
config.Save(ConfigurationSaveMode.Modified)
And you can read it again with
Dim value As String = ConfigurationManager.AppSettings(connectionKey)
(Not tested. Got it from here: Read/Write App.Config File with .NET 2.0.)

asp.net MVC 4 FilePathResult error: "The directory property cannot be found in the cache"

In my asp.net MVC 4 application, I have an action that returns FilePathResult.
In my local machine and QA server this action worked with no error.
In the production server it is throwing exception: "The directory property cannot be found in the cache"
This is the code I have:
public FileResult Export(string type,string tableName)
{
var outputFileName = IOHelper.BuildOutputFileNameAndPath("output.csv", tableName)
tableAPI.ExportTables(type, outputFileName);
return File(outputFileName, "text/csv", type + ".csv");
}
The difference between the QA server and production server is that the application files in the production server is on a NETWORK DRIVE and not local drive.
The value of the outputFileName variable is File Path is: \\[the root directory of the app]\App_Data\AdminTablesBackup\output.csv
I can see that the file is created but it fails when trying to return the file to the client.
Any suggestions ?
Make sure that the account you are running your Application Pool under has sufficient read permissions to this shared folder. If you are running under the default ApplicationPoolIdentity chances are that this account will not have permissions to access network shares.

Event viewer log creation error with MVC 4

Action Method
public ActionResult Index()
{
ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
LogError("lok", "lok2", "lok3");
return View();
}
LogError Method
private void LogError(string transactionId, string sAmountPaid, string deviceId)
{
// Creating the source, which will generate error
if (!EventLog.SourceExists("MyApplication"))
{
//Creating log, where error will be logged
EventLog.CreateEventSource("MyApplication", "MyLog");
}
// Creating object of EventLog to log error
var myAppLog = new EventLog { Source = "MyApplication" };
//Writing error to log
myAppLog.WriteEntry(transactionId + sAmountPaid + deviceId);
}
When I run Home page it always shows "Error. An error occurred while processing your request.".I suspect this is due to unable to create log on "Event Viewer".When I run above code on local host it's working fine.But when I publish it into IIS server on Windows Server 2012 it's giving above error.
My Question: Should I enable any kind of permission for create log on Event viewer.If so how to do that ? My IIS is working on Windows Server 2012.
This has been asked before. The following link is to that discussion.
Writing to an event log in ASP.NET on Windows Server 2008 IIS7
You will need to give the application the privileges to write to the Windows Event Log.
However, it is not recommended because of several reasons.
Does not scale.
Introduces an attack vector to the server itself, that can be exploited if your application is not secured properly.
Application cannot be hosted in a 'shared hosting' host solution and you would have to have access to OS itself to grant these (or a system that allows this like cPanel)
Alternatives to logging into windows event log:
Log into a Database or to Files
In a distributed architecture, or enterprise level system, send the event log entries into a queue system that passes the data to an aggregation system.
You need admin privilege to create an event source, becuase the name has to be unique, and to check whether it is all the registry items need to be checked including security. I doubt you want to giv your IIS account local admin though.
Way we do this is (for desktop apps), is our installer creates the event source (as admin), and then our apps just read write from it.

Is it possible to connect to an embedded DB with Raven Management Studio

I'm playing with Raven DB and am wondering if it's possible to connect to an embedded DB with Raven Management Studio. Has anyone ever done this?
If I understood you correct and you mean the Web UI, you simply have to enable the embedded web server.
var documentStore = new EmbeddableDocumentStore
{
DataDirectory = "Data",
UseEmbeddedHttpServer = true
};
See http://ravendb.net/docs/server/deployment/embedded
Also make sure to include Raven.Studio.xap in the root of your web application

FileUpload SaveAs UnauthorizedAccessException error (Dotnetnuke)

I am trying to save an image file in a custom module I am building for a DNN site.
However when I run the code I get an UnauthorizedAccessException.
if(upLoadAddImg.HasFile)
{
String imageLocation = ConfigurationManager.AppSettings["ImageFolderPath"];
//Upload file
upLoadAddImg.SaveAs(Server.MapPath(imageLocation));
}
I am running on localhost using the internal visual studio server. Tthe folderpath is all right and I have made sure Network Service has full permissions.
Am I missing something obvious or does DNN have some special permission setting I am missing?
If you are using the dev server in VS its identity is not Network Service by default. Most likely the directory you are saving to loccally is not allowed for the aspnet user - if you run this on a web site it should work at least code wise -------
To test it you can do one of two things make the portal directory open to everyone or set up a local site not run on the dev server ----