Is there anyway I can get linux server time from windows service given linux server IP ? I tried to use Cliwrap (https://github.com/Tyrrrz/CliWrap) and wrote the following function but it is not working as well:
public string GetLinuxServerTime()
{
using (var cli = new Cli("bash.exe"))
{
// Execute
var output = cli.Execute("ssh user#10.104.12.114 date");
return "abc";
}
}
Kindly suggest some another way.
Related
I want to deploy a server (on Azure) using SignalR.
And the console client, so that it accepts commands from the server.
The server code was taken from here: https://learn.microsoft.com/ru-ru/aspnet/signalr/overview/getting-started/tutorial-getting-started-with-signalr
Example of a console client from here:https://www.codeproject.com/Articles/804770/Implementing-SignalR-in-Desktop-Applications
using Microsoft.AspNet.SignalR.Client;
using System;
namespace SignalRClient
{
class Program
{
static void Main(string[] args)
{
IHubProxy _hub;
string url = #"https://signalrchatmsdn20210410135946.azurewebsites.net/";
//string url = #"http://localhost:62545";
var connection = new HubConnection(url);
_hub = connection.CreateHubProxy("BetHub");
connection.Start().Wait();
_hub.On("ReceiveLength", x => Console.WriteLine(x));
string line = null;
while ((line = System.Console.ReadLine()) != null)
{
_hub.Invoke("DetermineLength", line).Wait();
}
Console.Read();
}
}
}
If I run the server locally, everything works (string url = #"http://localhost:62545";)
If I run the server on Azure, it works through the browser. But the console client throws an exception.
System.Net.WebException
jdweng absolutely right.
In my case, it was enough to change the deployment setting.
TLS\SSL settings => HTTPS Only: Off
I am trying pull metrics such as 'MediaType' from MSFT_PhysicalDisk. I'm successful on a Windows 10 machine, but not on a Windows 7 machine.
On what type of machines is MSFT_PhysicalDisk available?
The reference for Storage Management API Classes:
https://learn.microsoft.com/en-us/previous-versions/windows/desktop/stormgmt/storage-management-api-classes
See code below for an example of what I'm trying to do:
bool isSsd;
try
{
var physDiskQuery =
$"SELECT MediaType FROM MSFT_PhysicalDisk WHERE DeviceID='{driveNumber.Value}'";
var wmiScope = #"\\.\root\microsoft\windows\storage";
using (var physicalDiskSearcher = new ManagementObjectSearcher(wmiScope, physDiskQuery))
{
var objectCollection = physicalDiskSearcher.Get();
var physicalDisk = objectCollection.Cast<ManagementBaseObject>().SingleOrDefault();
if (physicalDisk == null)
return null;
isSsd = (ushort)physicalDisk["MediaType"] == 4;
}
}
catch (Exception exception)
{
Debug.WriteLine($"Error while checking for SSD drive. Details: {exception.GetBaseException()}");
return null;
}
return isSsd;
MSDN documentation lists requirements way at the bottom of the page. For the MSFT_PhysicalDisk class it says...
Minimum supported client: Windows 8 [desktop apps only]
Minimum supported server: Windows Server 2012 [desktop apps only]
In other words, you need at least Windows version 6.2.
I am trying to learn MongoDB for my next project. I have installed MongoDB on my Windows 7 machine. I am able to create collection and retrieve data using mongo.exe. I am trying to use official C# driver to manipulate collection but my test console application goes in "abyss" while trying to connect to server (I guess).
I have written following code:
static void Main(string[] args)
{
try
{
// Create server settings to pass connection string, timeout, etc.
var settings = new MongoServerSettings();
settings.Server = new MongoServerAddress("localhost", 27017);
// Create server object to communicate with our server
var server = new MongoServer(settings);
server.Connect(TimeSpan.FromMilliseconds(1000));
// Get our database instance to reach collections and data
var message = string.Empty;
server.IsDatabaseNameValid("test", out message);
Console.WriteLine(message);
var database = server.GetDatabase("test");
var users = database.GetCollection("users").FindAll();
foreach (var user in users)
{
Console.WriteLine("User found");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.InnerException);
Console.WriteLine(ex.StackTrace);
}
Console.ReadLine();
}
Console application stops working on line server.Connect(). I have put this line just to find problem, I know it is not necessary to connect to server explicitly. If I remove that line then Console application stops working on line foreach (var user in users)
I also tried to get server using following code with no success:
var mongoClient = new MongoClient("mongodb://<host>:27017");
var server = mongoClient.GetServer();
Code is perfect! It was idiosyncrasy of MongoDB that when you try to connect to MongoDB through C# driver, you will have to accept connection for first time. Next time onwards MongoDB will remember your last acceptance and move on.
There has to be setting to remove this condition but I haven't found it yet. I will update as soon as possible.
Happy MangoDB Learning.
use your last example like this:
var mongoClient = new MongoClient("mongodb://localhost");
var server = mongoClient.GetServer();
Unless it's not running on the same machine or not on the standard port
I was trying to create send ports using C# .NET through following code :
using Microsoft.BizTalk.ExplorerOM;
private void CreateSendPort()
{
// connect to the local BizTalk Management database
BtsCatalogExplorer catalog = new BtsCatalogExplorer();
catalog.ConnectionString = "Server=.;Initial Catalog=BizTalkMgmtDb;Integrated Security=SSPI;";
try
{
// create a new static one-way SendPort
SendPort myStaticOnewaySendPort = catalog.AddNewSendPort(false, false);
myStaticOnewaySendPort.Name = "myStaticOnewaySendPort1";
myStaticOnewaySendPort.PrimaryTransport.TransportType = catalog.ProtocolTypes[0];
myStaticOnewaySendPort.PrimaryTransport.Address = "http://sample1";
myStaticOnewaySendPort.SendPipeline = catalog.Pipelines["Microsoft.BizTalk.DefaultPipelines.XMLTransmit"];
// create a new dynamic two-way sendPort
SendPort myDynamicTwowaySendPort = catalog.AddNewSendPort(true, true);
myDynamicTwowaySendPort.Name = "myDynamicTwowaySendPort1";
myDynamicTwowaySendPort.SendPipeline = catalog.Pipelines["Microsoft.BizTalk.DefaultPipelines.XMLTransmit"];
myDynamicTwowaySendPort.ReceivePipeline = catalog.Pipelines["Microsoft.BizTalk.DefaultPipelines.XMLReceive"];
// persist changes to BizTalk Management database
catalog.SaveChanges();
}
catch(Exception e)
{
catalog.DiscardChanges();
throw e;
}
}
Source
But I'm getting following issue
Explorer OM is not supported in a 64bit process.
when this line is executed :
BtsCatalogExplorer catalog = new BtsCatalogExplorer();
I'm well aware of the fact i.e. : "Warning
Microsoft.BizTalk.ExplorerOM.dll is only supported if used from 32 bit processes. If you are building a solution for a 64 bit system you should not use this library."
But in this case how can I create send ports on 64bit machine, Can anybody please help me with this?
Force it to run in a 32 bit process.
http://lostechies.com/gabrielschenker/2009/10/21/force-net-application-to-run-in-32bit-process-on-64bit-os/
As of BizTalk 2010, this restriction was lifted and ExplorerOM can be used in 64-bit and 32-bit processes.
I have one console application.The application calls WCF on server.
The application runs perfectly in Visual Studio 2008.
error:
I used an installer project in Visual Studio.
I make an installer give primary output to the Application.
It cannot connect to WCF on server.
What steps are necessary to make an installer which has an console (Application)exe,
which in turn uses WCF.
My Scope Initialization starts from initScopeInfo.
private void initScopeInfo()
{
DBSyncProxy.SqlSyncProviderProxy client = null;
ScopeConfigHandler scopeHandler = null;
try
{
//Providing the Config file name('db_config_new.xml') stored in static variable.
DBSyncXMLUtil.setXPathDocument(DBSyncConstants.DB_SYNC_CONFIG_FILE_NAME);
//DBSyncXMLUtil.setXPathDocument(filepath);
string endpoint = DBSyncXMLUtil.getSystemParameter(DBSyncXMLUtil.getDocumnetRoot(), "ServiceURL");
In setXpathDocument
public static void setXPathDocument(string uri)
{
public static XPathDocument doc = null;
doc = new XPathDocument(uri);
}
public static string getSystemParameter(XPathNavigator docroot, string key)
{
string value = null;
try
{
string xpath = DBSyncConstants.XPATH_SYSTEM_PARAMETER;
xpath += "[#key='" + key + "']";
Console.WriteLine("DBSyncXMLUtil :: getParameter() :: XPATH =="+xpath);
Probably Error on below mentioned line
XPathNavigator node = getDocumnetRoot(doc).SelectSingleNode(xpath);
if (node != null)
value = node.Value;
else
Console.WriteLine("Invalid XPATH");
}
catch (Exception ex)
{
Console.WriteLine("DBSyncXMLUtil :: getSystemParameter() :: Exception ==" + ex.ToString());
}
return value;
}
Actually you cannot directly create an installer project by adding primary output from a WCF service. You should host the WCF service inside a windows service and add the primary output of the windows service to the installer project.
create a WCF.
create a windows service and host the WCF inside it (call the WCF from windows service).
Create a setup project (installer project).
Add the primary output of the windows service to the installer project.
see this link to see the hosting details...
http://msdn.microsoft.com/en-us/library/ms733069.aspx
See this blog. It will help you with the implementation of windows service...
http://joefreeman.co.uk/blog/2010/03/creating-a-setup-project-for-a-windows-wcf-service-with-visual-studio/