Console Application crashes remotely but works locally - c#

I have a console application in c#, .Net which I am currently using as a scheduled job.
The idea of this scheduled job is to fetch data and update data.
My solution contains the following:
Web (Mvc)
Contract (models etc)
Datalayer (Database)
Api
Console Application
My issue:
When I am running my Console application I am refering to a dll from 1 Web(mvc). Everything looks good when I am doing this locally,
but when I zip the catalog, drag this to my remote server and try to run it, I get the following exception:
Input string was not in a correct format in double.Parse
Basically these lines of code does not run properly on my remote server:
var weapons = new Weapons();
userWeapon = weapons.Where(x => x.WeaponId== userWeapons.WeaponId).FirstOrDefault();
var parsedValue = Convert.ToDouble(userWeapon.damage);
I mean, how is this possible? Why do I get this error remotely but not locally?
If you have any ideas on why this is occuring, please let me know.
Cheers!

Related

Cannot see my graph on JanusGraph Server with BerkeleyDB storage from .NET client

Can someone help me to understand why I don't see the graph from JanusGraph.Net client?
I'm running the latest Docker image for JanusGraph from Docker Hub. After connecting to the JanusGraph using the built-in console I created a sample Graph of the Gods and was able to query it using the following commands:
graph = JanusGraphFactory.open('conf/janusgraph-berkeleyje-lucene.properties')
GraphOfTheGodsFactory.load(graph)
g = graph.traversal()
g.V().count()
Because the graph remained across container restarts (was able to query it again without GraphOfTheGodsFactory.load(graph) command) and some files were created inside the /opt/janusgraph/db/berkeley/ folder I assume that everything works.
Then I updated the graphs.graph property of the /opt/janusgraph/conf/gremlin-server/gremlin-server.yaml (path taken from docker-entrypoint.sh) to this value:
graphs: {
graph: conf/janusgraph-berkeleyje-lucene.properties
}
and restarted container.
After that I created a simple .NET console application using JanusGraph.Net from with the following code:
static void Main(string[] args)
{
var client = JanusGraphClientBuilder
.BuildClientForServer(new GremlinServer("localhost", 8182))
.Create();
var g = AnonymousTraversalSource
.Traversal()
.WithRemote(new DriverRemoteConnection(client));
var count = g.V().Count().Next();
}
and the count variable is always zero. It looks like that my .NET application connected to some another (probably in-memory) empty graph on this server.
What else should I change or update? Please help to figure this out.
OK, it was not very obvious, but JanusGraph Docker image is pre-configured to use BerkeleyDB by default (BTW according to the documentation it should be Cassandra). I found it taking a look at the Gremlin Server logs. Gremlin Server is configured to use /etc/opt/janusgraph/janusgraph.properties on startup. This file contains a completely different configuration for BerkeleyDB than, for example, conf/janusgraph-berkeleyje.properties - different folders, etc. That is why my .NET application hasn't seen any data - it was connected (through Gremlin Server) to the different BerkeleyDB database.
I also wasn't able to load this file to the Gremlin console via graph = JanusGraphFactory.open('/etc/opt/janusgraph/janusgraph.properties') - got access issues. After I copied this file to the conf directory (and changed the access rights) - I got another error: Could not instantiate implementation: org.janusgraph.diskstorage.berkeleyje.BerkeleyJEStoreManager probably because the BerkeleyDB already exists.
So the only way I've figured out how to connect to the existing database via the Gremlin Console is to use the :remote connect command. I was able to load a sample "Graph of the Gods" database and later access it from my .NET application using the following commands:
:remote connect tinkerpop.server conf/remote.yaml
:> GraphOfTheGodsFactory.load(graph)
:> g.V().count()
==>12

how to set mongo local server using Mongo DB Driver .NET

I want to add an option to save data locally in my application using the mongo databse tools, I want to configure all the server information from within my application.
I have 2 questions.
the following code is working only after manual setup of mongodb localhost database in this way:
but on A computer that didn't configure the database setting, the code will not work.
my code is :
public void createDB()
{
MongoClient client = new MongoClient();
var db = client.GetDatabase("TVDB");
var coll = db.GetCollection<Media>("Movies");
Media video = new Media("", "");
video.Name = "split";
coll.InsertOne(video);
}
this code works only after manual set the database like the picture above.
without it I get in the last line A timeout exception.
how can I configure it from my application to make it work (define Server) ?
Is the user will be must install MongoDB software on his PC, or the API Package is enough in order to use the database?
Many Thanks!
By using that command you're not "configuring the database", you're running it.
If you don't want to manually run it, but want it to be always running, you should install it as a Windows Service as explained in How to run MongoDB as Windows service?.
You need to install and/or run a MongoDB server in order to use it. Using the API alone is not enough, it's not like SQLite.
The Code you are using will search for local mongodb.

Azure WebJob fails on exit code 532462766

I am taking a console app I have that loads new data into a database, and am turning it into a web job that runs at 2am so the stored data is updated daily. The console app works fine locally and is using an Azure SQL database. When running the webjob it fails with this message:
[09/22/2016 20:25:39 > 44575f: SYS ERR ] Job failed due to exit code -532462766
Through some research it looks like the webjob doesn't have my app.config file and thus is missing the correct connection string, but I'm not sure. Does anyone know how to get around this? Do I add a connection string to my .pubxml file, do it in my Azure portal, or could this be something else? Thanks!
web.config is a strange choice but I guess webjob falls back to it. You could also fix the problem by copying the programname.exe.config file along with the exe itself.

PasswordEncoderNotFoundException using Jira SOAP API

I am working on integrating my company's product with Jira so users can log bug reports directly from the application. Everything was wqorking smoothly so i decided to import the data from our live Jira system into my development system so that i had some real world data to play with. Since then when i try to get an authtication token it throws the following exception "com.atlassian.crowd.exception.PasswordEncoderNotFoundException: The PasswordEncoder 'atlassian-security' was not found in the Internal Encoders list by the PasswordEncoderFactory". I have checked and the Atlassian Security Password Encoder is enabled in the Crown Password Encoders plugin.
My code is super simple just an ASP.net based text based issues search with the results wired to a grid view code as below:
JiraSoapServiceService service = new JiraSoapServiceService();
string token = service.login("integration", "test");
if (!string.IsNullOrEmpty(txtSearch.Text))
{
RemoteIssue[] issues = service.getIssuesFromTextSearchWithLimit(token, txtSearch.Text, 0, 100);
gvwIssues.DataSource = issues;
gvwIssues.DataBind();
}
I get the error on the call to service.login, it worked fine before I imported the live data. And yes i did add the integration user again after i had imported the data.
Anyone any ideas on this.
No idea what was causing this but rebooting the PC that the dev Jira was installed on fixed it.
EDIT
I have had this a few times now. It tends to happen when you do something like restart the SQL server, restore the jira database via SQL server, restore jira via the inbuilt XML file import method or similar. You don't have to restart the machine just the jira windows service. No idea if this is a problem with other DBs or server types.

c# console application interacting with PHP page

I have a c# console application that I invoke with a server call in PHP
chdir($filePath);
exec($filePath.$fileName);
This works great, the application is run. The data it is designed to collect is collected and everyone is happy.
Currently I have plans on storing the one time use information on a server or a flat file, but then I noticed that while the console application is running and doing it's magic the page hangs waiting for the application to stop. This intrigued me, and now i'm wondering if there is a way for the application to pass it's data back to the page directly?
Note: I'm running Apache2 on Windows 7
Update:
Ended up using
$runCommand = "D:\\ScanBoyConsole\\ScanBoy_Console.exe COM1 9600 8 1 0 1";
$WshShell = new COM("WScript.Shell");
$output = $WshShell->Exec($runCommand)->StdOut->ReadAll;
json_decode($output);
If you mean by "directly" that you want the application's output sent to the client while it's still running you might be interested in passthru().
If you're also the author of the C# application you could skip the console application and expose the functionality in a way accessible via php's COM and .Net module.
The console app should be able to print (using Console.WriteLine), and PHP can take the results of that...
Back in my PHP days, we called scripts all the time (that are nothing but console apps basically) and had the results spit out to the page.
"shell_exec — Execute command via shell and return the complete output
as a string"
http://php.net/manual/en/function.shell-exec.php
[So, the only difference is that you should use shell_exec instead of a regular exec]

Categories

Resources