Run MongoDump / MongoRestore in C# - c#

Is there an easy way to run these commands using the C# driver? The only documentation I found involves running the EXE as a process etc, which seems a bit heavy.
The only related question I found was unanswered... am I missing something fundamental here?
http://grokbase.com/t/gg/mongodb-user/127zntq9pr/mongodump-in-c

mongodump and mongorestore are applications, not MongoDB commands which is why you would have to run the executable.

unfortunately nope. I think that easier way to do regular backup of your mongodb is to write backup script and to create task in scheduler. nice answer how to do this you can find here: MongoDB script to backup replication set locally to a Windows Server
if there are simpler solutions I'll be happy to know about them -- this problem is actual for me too. :)

Related

Share data between C++ and C# or VB (2 running program)

is there a way (other than network(i hate io-streams)) to communicate between 2 process? one in c++ and other one in C# or VB.
my problem is, im writing a AVR program using c++, but for debugging purpose i need a GUI to test different inputs. since i donno anything about GUI in c++ ( and i have no plan to learn it), i want to write the GUI using .net and somehow connect it to my c++ code.
since i have 2 running process i cant use p/invoke and other similar methods. If i could share my variables between 2 process or call a function in c# from c++ (from running process to running process), that would solve my problem.
anything other than sockets?
Since you mentioned .NET you probably on MS Windows. You may use DDE (Dynamic Data Exchange):
https://msdn.microsoft.com/en-us/library/windows/desktop/ms648774(v=vs.85).aspx
You can find .NET tutorial for it here:
http://blogs.artinsoft.net/Mrojas/archive/2009/06/10/DDE-in-NET.aspx
If you want fast dummy solution that will work for you just for debugging not as real solution. You may share your data by writing them to the hard disk and reading it from it again. It is not hard neither complicated.
What about databases? if you are using MS you can try MSSQL.
Its absolutely free for small databases i think :)

Run my own application on hadoop without coding mapreduce?

Maybe I did not fully understand how complex hadoop really is, if there is something incorrect please help me out. So what I got is this:
Hadoop is a great thing to handle a big amount of data. Mostly for data analysis and mining. I can write my own mapreduce functions or using pig or hive. I can even use existing functions, wordcount and stuff like that - I dont even have to write code.
Ok, but what if I would like to use the great power of hadoop for non-analysis/mining things? As example I have a .NET application written in C# that is able to read files and generating pdfs with some barcodes. This application is running on one server, but because the one server cannot handle the big amount of files I need more power. Why not adding some hadoop nodes/clusters to handle this job?
Question: can I take my .NET application and tell hadoop "do this, on every on your nodes/cluster"? -> Running these jobs without coding, is it possible?
If not, do I have to throw away the .NET application and rewrite everything in pig/hive/java-mapreduce? Or how do people solve these issues in my situation?
PS: The important thing here is not the pdf generator and maybe also not .NET/C# - the question is: there is an application in language whatever - can I give it to hadoop just like that? Or do we have to rewrite everything in mapreduce functions?
#Mongo : I'm not sure if I understood correct but I'd try sharing what I know. First of all hadoop is a framework - not an extension or a plugin.
If you want to process the files or perform a task in hadoop, you need to make sure that your requirements are properly put forward so that hadoop understand what to do with your data. To put it simple, let us consider the same word count example. If you want to perform the word count on a file, you can do it using any language. Lets say we have done it in Java, and we want to scale it to larger files- dumping the same code in to a hadoop cluster would not be helpful. Though the java logic remains the same, you will have to write a Map reduce code in java which would be understood by the hadoop framework.
Here's an example of a C# map reduce program for Hadoop processing
Here's another example of MapReduce Without Hadoop Using the ASP.NET Pipeline
Hope this is helpful. I'm assuming that my post adds some value to your question. I'm sure you would be getting better thoughts/suggestions/answers from the wonderful people here...
P.S: You could mostly do anything and everything thats related to file processing/ data analysis in Hadoop. It all depends up on how you do it :)
Cheers !
Any application that can run in Linux can be done in Hadoop, using Hadoop-streaming. And a C# application can run in Linux using Mono.
So you can run your C# application using both Hadoop-streaming and Mono. But still, you need to adapt your logic to the map-reduce paradigm.
However, it should not be a big deal in your case. For instance, you could:
create a Hadoop-streaming job with mappers only (no reducers)
process exactly 1 file per mapper
each mapper would run "mono yourApp.exe", reading the input file in stdin, and writing the output in stdout
Also, Mono must be available on the Hadoop cluster. If not, some admin privileges will be required to install and deploy Mono yourself.

Build script with C#

For insight into the below, read: http://martinfowler.com/articles/rake.html
I've been using Rake (with Albacore) recently, and like it alot. Mostly the strength of having the Ruby language right at hand when I need it.
I must admit I am alot more at home with C# - and that lead me to thinking if there was an equivalent to Rake in the .NET world.
What I am looking for is a way to write build scripts in C#, or maybe a DSL, having the same dependency programming model, where I can also use C#.
Maybe I'm way off base asking this question. But if it's possible to do with Ruby (and an internal DSL), then I can't right off the bat say why the same wouldn't be possible for C#. And I certainly don't understand why it hasn't already been done :-)
Anyone have some perspectives on the issue?
What we already know:
C# needs to be compiled to run, so we would need to create a seperate build-script, that is parsed, and compiled at run-time by an executable.
Thanks in advance!
Solution
Use "Cake" http://cakebuild.net/ -- with Roslyn compiler what I wanted (years ago) is now possible. Thanks Microsoft. And thanks to the people who wrote Cake.
An alternative is to use Powershell. The library is called Psake (saké)
Maybe Cake is what you're looking for: https://github.com/cake-build/cake
A lot of people do use Rake for build scripts. There are even Rake tasks just for .NET. http://albacorebuild.net/
But there is a c# based make utility I know about. http://shake.codeplex.com/ And I thought I saw one on github. But I think they require a compile and that didn't seem as cool.
I ended up on https://github.com/psake/psake mainly because I wanted to learn Powershell and everyone already had it installed.
Hmm Bounce too https://github.com/refractalize/bounce
You can script your build/deployment tasks with msbuild and then script your tasks and execute them from bat files.

Extension SNMP Agent C#

I am a complete newbie to SNMP. Recently, I am trying to write a simple program that is supposed to monitor and modify a data file in a remote machine. The file itself could just be a plain-text file or whatsoever. I was introduced to the SNMP, and tried to figure out a way to make SNMP do the job in Windows OS. The prefered language is C# or any .net. I have been googling for a few days, however, did not find a good how-to instruction to do so.
Really need help on this to get my job done.
Thank you very much,
Terry
Here's one SnmpSharpNet. More can be found here.
I use SharpSnmpLib. It works very well for SNMPv2 and is pretty easy to understand

What's a good way to write batch scripts in C#?

I would like to write simple scripts in C#. Stuff I would normally use .bat or 4NT .btm files for. Copying files, parsing text, asking user input, and so on. Fairly simple but doing this stuff right in a batch file is really hard (no exceptions for example).
I'm familiar with command line "scripting" wrappers like AxScript so that gets me part of the way there. What I'm missing is the easy file-manipulation framework. I want to be able to do cd(".."), copy(srcFile, destFile) type functionality.
Tools I have tried:
NANT, which we use in our build process. Not a good scripting tool. Insanely verbose XML syntax and to add a simple function you must write an extension assembly. Can't do it inline.
PowerShell. Looks great, but I just haven't been able to switch over to this as my primary shell. Too many differences from 4NT. Whatever I do needs to run from an ordinary command prompt and not require a special shell to run it through. Can PowerShell be used as a script executor?
Perl/Python/Ruby. Really hate learning an entirely new language and framework just to do batch file operations. Haven't been able to dedicate the time I need to do this. Plus, we're a 99% .NET shop for our toolchain and I really want to leverage our existing experience and codebase.
Are there frameworks out there that are trying to solve this problem of "make a batch file in C#" that you have used?
I want the power of C#/.NET with the immediate-mode type functionality of a typical cmd.exe shell language. Am I alone in wanting something like this?
I would try to get over the PowerShell anxiety because it is the shell of the future. All of the software coming out of Microsoft is using it as their management interface and especially version 2.0 is ridiculously useful.
I'm a C# developer most of the time but PowerShell has solved that whole "WindowsApplication42" problem of temp projects just piling up. PowerShell gives you full access to the .NET framework in a command line shell so even if you don't know how to do something in PowerShell, you most likely know how to do it in .NET.
IronPython and IronRuby do let you leverage all of your .NET "experience and codebase" (they don't answer your objection to learning new languages, however).
If you have any bash nerds, you can always try cygwin.
Also remember that Python was originally intended as a "glue" langauge. If you used the aforementioned IronPython, it's pretty easy to tie together pre-written C# classes.
If you are bind to MS, PowerShell is surely the way to go. But I don't like it much.
I personally use MSBuild script more, and would like to see Mono C# Shell one day comes to Windows.
I think CS-Script might be the ideal solution for you.

Categories

Resources