Xamarin.Forms Portable + Mono.Data.Sqlite.Portable - sqlite

Good day to everyone,
I'm building an application in Xamarin.Forms Portable for iOS,Android,Windows Universal(10) .
I'm trying to use the Mono.Data.Sqlite.Portable, but I'm not able to create or connect to a local database, I've tried many solutions to fix the problem, but until now I dint find the solution..
The error is trow at "connection.open();"
The Code is :
var config = DependencyService.Get<DB.IConfig>();
var cnn = config.DirectoryDB;
using (var connection = new SqliteConnection("" +
new SqliteConnectionStringBuilder
{
DataSource = "URI=file::memory:",
Version=3,
}))
{
//connection.ChangeDatabase("hello.db");
connection.Open();
using (var transaction = connection.BeginTransaction())
{
var insertCommand = connection.CreateCommand();
insertCommand.Transaction = transaction;
insertCommand.CommandText = "CREATE TABLE TESTE(teste as varchar(10))";
insertCommand.ExecuteNonQuery();
transaction.Commit();
}
}
on the "DataSource" I've a local path, and other paths.
(Ex:. C:\Users\MyMachineName\AppData\Local\Packages\f736c883-f105-4d30-a719-4bf328872f5e_nh7s0b45jarrj\LocalState\hello.db)
The error is :
An exception of type 'System.NotImplementedException' occurred in Mono.Data.Sqlite.dll but was not handled in user code
Additional information: The method or operation is not implemented.
ImageError
Connection Extra Information
The last picture, it may give more information....
Thank you all in advance :)

I've found the solution,I hope it helps the people that may be looking for the same as I.
Just go to Nuget - And download the Portable.Data.Sqlite that relies on SQLitePCL (Latest version) .
This package (Portable.Data.Sqlite) it will use the connection and will create SqliteDataReader and other property's that we are used to use .
This will work on Visual Studio 2015 and the project must be in framework 4.51 +=
----Error Tips----
if you encounter this error : Cant use Temporary Database or Path, just download Sqlite.dll and place on the project BIN folder and System32/ SysWoW64 .

Related

Assigning content store using JAVA API

I had posting in alfresco hub , couldnt get solution yet.
I was trying to convert javascript API code to java API which move files to different content store(' storeB'). We have storeB defined in - 'content-store-selector-context.xml'. We are using Enterrprises version of Alfresco 5.2.
java script code as follows , - Works perfectly fine . its working code.
for each (var n in node.children) {
if (n.isDocument) {
//Apply script for moving files to DMS Store 01
n.removeAspect("cm:versionable");
n.addAspect("cm:storeSelector");
n.properties['cm:storeName'] = "storeB";
n.save();
}
}
Below is Java API Code - But this code is not moving files to 'storeB'. Is there anything i am missing ?
Is there any similiar method available in java APIs.
List<ChildAssociationRef> children = nodeService.getChildAssocs(dayFolderRef);
Map<QName, Serializable> aspectsProps = new HashMap<QName, Serializable>(1);
aspectsProps.put(ContentModel.PROP_STORE_NAME, "storeB");
LOG.info("Folder::" + dayFolderRef.getId());
LOG.info("Number of Subfolder to be moved is ::" + children.size());
for (ChildAssociationRef childAssoc : children) {
NodeRef childNodeRef = childAssoc.getChildRef();
if (ContentModel.TYPE_CONTENT.equals(nodeService.getType(childNodeRef))) {
LOG.info("Moving the file to secondary storae "+childNodeRef.getId());
nodeService.removeAspect(childNodeRef, ContentModel.ASPECT_VERSIONABLE);
nodeService.addAspect(childNodeRef, ContentModel.ASPECT_STORE_SELECTOR, aspectsProps);
}
}
I can see a save method is java script API. based on response recieved Alfresco forum , there is no save method in javascript API. Java API run in transactions , so will commit eventually . But i can see from DB using the below SQL -
SELECT count(*)
FROM alf_content_url
WHERE orphan_time IS NOT NULL;
the above SQL returns same count after executing the code , so no DB updates happening. Anything wrong ?
Any help , appreciated
Regards
Brijesh
I don't see why that would not work, are you positive you're even entering that method? Try adding the content store selector aspect with no properties map, then add the content store name property with setProperty method separately.

Auto Fill Web Forms in .net-Core

I am new to .net core.
How can I auto fill forms and submit in dotnet core ?
Please find following sample URLs I want to try
https://mparivahan.in/uyt/?pur_cd=102
Value - 1 = "MH1R"
Value - 2 = "5656"
https://www.filegstrstnow.com/searchGSTTaxpayer
sample Value = "24AADCS0852Q1Z2"
With Regards
I guess you want to automate operations in browser. For this purpose you need a browser automation framework which can be used in you .NET Core 2.0 code. Something like Selenium WebDriver. In this case you code will look like this:
[Test]
public void TestWithFirefoxDriver()
{
using (var driver = new FirefoxDriver())
{
driver.Navigate().GoToUrl(#"https://parivahan.gov.in/rcdlstatus/?pur_cd=102");
driver.FindElement(By.Id("form_rcdl:tf_reg_no1")).Send("GJ01RR");
driver.FindElement(By.Id("form_rcdl:tf_reg_no2")).Send("5656");
driver.FindElement(By.Id("form_rcdl:j_idt36")).Click();
var wait = new WebDriverWait(driver, TimeSpan.FromMinutes(1));
// Find element with the result to retrieve value, and so on..
}
}
Note: I didn't check the code above in runtime, it is just for demonstration purposes.
To run Selenium automation code without opening the browser you could use PhantomJS driver instead of drivers for real browsers like FirefoxDriver. Change this line:
using (var driver = new FirefoxDriver())
to:
using (var driver = new PhantomJSDriver())

Sqlite crashes on open

I try to run some basic code to test Sqlite in y project and the project always stops/exits on the call to Open().
Then in the debug window, I see that "Activation of the Windows Store app 'f398a499-0092-462e-9b50-aab3651b4b69_kxamnsbhqvv2e!App' failed with error 'Windows was unable to communicate with the target application. This usually indicates that the target application's process aborted. More information may be available in the Debug pane of the Output window (Debug->Windows->Output)'."
Version of Microsoft.Data.Sqlite is 1.0.0
Version of Microsoft.NETCore.UniversalWindowsPlatform is 6.0.6
Here is my code :
SqliteEngine.UseWinSqlite3(); //Configuring library to use SDK version of SQLite
using (SqliteConnection db = new SqliteConnection("Filename=sqliteSample.db"))
{
db.Open();
var tableCommand = "CREATE TABLE IF NOT EXISTS MyTable (Primary_Key INTEGER PRIMARY KEY AUTOINCREMENT, Text_Entry NVARCHAR(2048) NULL)";
var createTable = new SqliteCommand(tableCommand, db);
try
{
createTable.ExecuteReader();
}
catch (SqliteException e)
{
//Do nothing
}
}
Thanks
Changed the version of Sqlite to 1.1.1 and now it works.

asp.net app calling service says its not initialized?

So this code runs in an asp.net app on Linux. The code calls one of my services. (WCF doesn't work on mono currently, that is why I'm using asmx). This code works AS INTENDED when running from Windows (while debugging). As soon as I deploy to Linux, it stops working. I'm definitely baffled. I've tested the service thoroughly and the service is fine.
Here is the code producing an error: (NewVisitor is a void function taking 3 strings in)
//This does not work.
try
{
var client = new Service1SoapClient();
var results = client.NewVisitor(Request.UserHostAddress, Request.UrlReferrer == null ? String.Empty : Request.UrlReferrer.ToString(), Request.UserAgent);
Logger.Debug("Result of client: " + results);
}
Here is the error generated: Object reference not set to an instance of an object
Here is the code that works perfectly:
//This works (from the service)
[WebMethod(CacheDuration = _cacheTime, Description = "Returns a List of Dates", MessageName = "GetDates")]
public List<MySqlDateTime> GetDates()
{
return db.GetDates();
}
//Here is the code for the method above
var client = new Service1Soap12Client();
var dbDates = client.GetDates();
I'd love to figure out why it is saying that the object is not set.
Methods tried:
new soap client.
new soap client with binding and endpoint address specified
Used channel factory to create and open the channel.
If more info is needed I can give more. I'm out of ideas.
It looks like a bug in mono. You should file a bug with a reproducible test case so it can be fixed (and possibly find a workaround you can use).
Unfortunately, I don't have Linux to test it but I'd suggest you put the client variable in an using() statement:
using(var client = new Service1SoapClient())
{
var results = client.NewVisitor(Request.UserHostAddress, Request.UrlReferrer == null ?
String.Empty : Request.UrlReferrer.ToString(), Request.UserAgent);
Logger.Debug("Result of client: " + results);
}
I hope it helps.
RC.

"Unable to open database file" using SQLite on Windows Phone 7

I am using SQLite for Windows Phone 7 (http://sqlitewindowsphone.codeplex.com/) and I have done every steps from this tutorial (http://dotnetslackers.com/articles/silverlight/Windows-Phone-7-Native-Database-Programming-via-Sqlite-Client-for-Windows-Phone.aspx)
Then I try to make some simple application with basic features like select and delete. App is working properly till I want to make one of this operations. After I click select or delete, compiler shows me errors that he is unable to open database file...
I have no idea why?
I used the same Sqlite client, and had the same problem. This problem occurs because the sqlite try to create file in IsolatedFileStorage "DatabaseName.sqlite-journal" and it does not have enough permissions for that. I solved the problem, so that created "DatabaseName.sqlite-journal" before copying database to IsolatedFileStorage. Here's my method that did it:
private void CopyFromContentToStorage(String assemblyName, String dbName)
{
IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication();
string uri = dbName + "-journal";
store.CreateFile(uri);
using (Stream input = Application.GetResourceStream(new Uri("/" + assemblyName + ";component/" + dbName,UriKind.Relative)).Stream)
{
IsolatedStorageFileStream dest = new IsolatedStorageFileStream(dbName, FileMode.OpenOrCreate, FileAccess.Write, store);
input.Position = 0;
CopyStream(input, dest);
dest.Flush();
dest.Close();
dest.Dispose();
}
}
it helped me, and worked well.
hope this will help you
Are you sure the file exists?
You can check like that:
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
exists = store.FileExists(DbfileName);
}

Resources