|
I got the answer I needed, which isn't the one I was hoping for. The project will be for an application that creates a single assembly (client requirement). We have been looking at different structures to see how easily the typical C# developers could pick up the project and run with it, based on different file/folder structures.
There are a few instances where pairs or trios of file only work when all are in place. Similar to .ascx, .ascx.desinger, and .ascx.cs.
Its a good idea to test the waters before making these kinds of decision.
In general it appears C# devs are culturally inured to grouping files by technical purpose rather than business purpose, even if there is little reuse of object and the debugging worklfow would be much faster by having files grouped by business purpose.
Your answer was clear and its was VERY helpful! Thanks!
|
|
|
|
|
OMVB wrote: Why are project files/classes organized by class type (Models folder, Repositories folder, Interfaces Folder), instead of business purpose (Account Objects, Employee Objects)? Because programmers work with projects and types, and not with the abstractions called "Account Object". A code-solution is not an exact model of the business, and there's usually more types in a library than business objects.
OMVB wrote: Organizing projects by class type seems like story left shoes in one room and right shoes in another room. ..Yes, in the same way that a car has wheels in the front as well as in the back, but in the storage-room you'll find them on the same heap.
They're also not organized by "class", but by "target" or "goal"; there's no models-folder in my private projects, but models go together so that it's easy to find if I need a specific one. No, we don't have all resources in the same folder, but the resources that are considered a single package are.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
i everyone,i have a problem.i wan to scan my local network to get information about all the devices inside like OS name,Ip adresse netmask and mac adresse to realise a topologie of my network.thanks
|
|
|
|
|
|
|
Amusingly, that article would been called a code dump under the current criteria and probably relegated to a tip, how things change.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello,
I work at my school, I have a client-server application in C # with Visual Studio 2010 and I have my first client 1 that connects to server. but now I have a problem to connect a server to another client 2 in a VM (Virtual Machine: Virtual Box Windows 7).
Client 2:
* It should be the server connects to the client 2?
* The server sends a message to the client that son located in a virtual machine?
* After sent, the server received a confirmation message from client 2?
So it remains to create of client 2 code that receives a message from the server and client 2 sends a confirmation response to server and client 1?
so when I do the execution console server on my physical machine displays the following address: @ IP: 193.51.91.5:10000 & @ IP: 127.0.0.1:10000
and when I do the execution of the console server in the virtual machine (virtual box with windows 7) displays the following address: @ IP address: 192.168.56.1:10000 & @ IP: 127.0.0.1:10000
Please find attached client / server code.
Very thank you in advance and regards.
thank you
client :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using DPSBase;
using NetworkCommsDotNet;
namespace SocketProject.Client
{
class Program
{
#region [ Fields ]
private static ConnectionInfo connectionInfo = null;
private static Stopwatch _stopWatch = null;
#endregion
static void Main(string[] args)
{
string serverIP = string.Empty;
int serverPort = 0;
int loopCounter = 1;
TCPConnection serverConnection = null;
string result = string.Empty;
Console.WriteLine("SVP, saisissez l’adresse IP et le port du serveur (127.0.0.1:10000) : ");
Console.WriteLine();
string serverInfo = Console.ReadLine();
serverIP = serverInfo.Split(‘:’).First();
serverPort = int.Parse(serverInfo.Split(‘:’).Last());
while (true)
{
NetworkComms.RemoveGlobalIncomingPacketHandler();
connectionInfo = new ConnectionInfo(serverIP, serverPort);
serverConnection = TCPConnection.GetConnection(connectionInfo);
NetworkComms.AppendGlobalIncomingPacketHandler<string>("SendMessageToOthersClt", HandleIncomingCltMessage);
NetworkComms.AppendGlobalIncomingPacketHandler<string>("CustomObjectReply", HandleIncomingSrvMessage);
Console.Write(string.Format("Entrez votre {0}{1} message : \n ", loopCounter, (loopCounter == 0) ? "er" : "eme"));
string messageToSend = Console.ReadLine();
_stopWatch = new Stopwatch();
if (messageToSend.StartsWith("SendMsg"))
{
int firstSpace = messageToSend.IndexOf(‘ ‘);
serverConnection.SendObject("SendMessageToOthersClt", messageToSend.Substring(firstSpace));
}
else
serverConnection.SendObject("RequestCustomObject", messageToSend);
Console.WriteLine();
if (Console.ReadKey(true).Key == ConsoleKey.Q) break;
loopCounter++;
}
NetworkComms.Shutdown();
}
private static void HandleIncomingSrvMessage(PacketHeader header, Connection connection, string incomingMessage)
{
string messageToShow = string.Empty;
string execTime = string.Empty;
messageToShow = "——————————————————————————-\n";
string[] res = incomingMessage.Trim().Split(‘-’);
if (res.Length > 1)
execTime = ((_stopWatch.Elapsed.Milliseconds * 1000) + int.Parse(res[0])).ToString();
else
execTime = (_stopWatch.Elapsed.Milliseconds * 1000).ToString();
switch (res[1])
{
case "LaunchVM":
messageToShow += "Virtual Box Lancée après " + execTime + "(ns)\n";
break;
case "LaunchVagrant":
messageToShow += "Vagrant Lancée après " + execTime + "(ns)\n";
break;
case "SendMsg":
messageToShow += "Le message envoyée aprés " + execTime + "(ns)\n";
break;
default:
messageToShow += "Le message ‘" + res[1] + "‘ a été reçu par le serveur après " + execTime + "(ns)\n";
break;
}
messageToShow += "——————————————————————————-\n";
Console.Write(messageToShow);
}
private static void HandleIncomingCltMessage(PacketHeader header, Connection connection, string incomingMessage)
{
TimeSpan ts = _stopWatch.Elapsed;
Console.Write(string.Format("Message reçu de la part d’un autre client : {0} \n ", incomingMessage));
}
}
}
server:
using System;
using NetworkCommsDotNet;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DPSBase;
using System.Threading;
namespace SocketProject.Server
{
class Program
{
static void Main(string[] args)
{
NetworkComms.AppendGlobalIncomingPacketHandler<string>("RequestCustomObject", (packetHeader, connection, message) =>
{
Stopwatch stopWatchLaunchVagrant = new Stopwatch();
stopWatchLaunchVagrant.Start();
string msgConsole = string.Empty;
string elapsedTime = "";
string process = "";
string workingDirectory = "";
string arg = "";
msgConsole += "—————————————————————————–\n";
msgConsole += string.Format("Message reçu de la part Client {0}, le contenu est : {1} \n", "[" + connection.ConnectionInfo.NetworkIdentifier.Value + " " + connection.ConnectionInfo.LocalEndPoint.Address.ToString() + ":" + connection.ConnectionInfo.LocalEndPoint.Port.ToString() + "]", message);
if (message == "LaunchVM")
{
process = @"VirtualBox.exe";
workingDirectory = @"C:\Program Files\Oracle\VirtualBox\";
}
else if (message == "LaunchVagrant")
{
process = "cmd.exe";
workingDirectory = @"C:\Vagrant\";
arg = "vagrant up";
}
else if (message == "LaunchVagrantDistant")
{
process = "cmd.exe";
workingDirectory = @"\\dauphine-PC\Vagrant\";
arg = "vagrant up";
}
else if (message == "test")
{
process = "devenv.exe";
workingDirectory = @"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\";
}
ProcessStartInfo psi = new ProcessStartInfo(process)
{
UseShellExecute = true,
RedirectStandardOutput = false,
RedirectStandardInput = false,
RedirectStandardError = false,
CreateNoWindow = true,
WorkingDirectory = workingDirectory
};
if (!(string.IsNullOrEmpty(arg)))
psi.Arguments = "/C " + arg;
System.Diagnostics.Process p = System.Diagnostics.Process.Start(psi);
stopWatchLaunchVagrant.Stop();
elapsedTime = (p.TotalProcessorTime.TotalMilliseconds * 1000 + stopWatchLaunchVagrant.ElapsedMilliseconds * 1000).ToString();
msgConsole += "Temps d’exécution est : " + elapsedTime + "\n";
msgConsole += "—————————————————————————–\n";
Console.Write(msgConsole);
connection.SendObject("CustomObjectReply", elapsedTime + "-" + message);
});
NetworkComms.AppendGlobalIncomingPacketHandler<string>("SendMessageToOthersClt", (packetHeader, connection, message) =>
{
string msgConsole = string.Empty;
msgConsole += "—————————————————————————–\n";
msgConsole += string.Format("Le Client {0} a envoyé ce message : \" {1} \" aux autres clients \n", "[" + connection.ConnectionInfo.NetworkIdentifier.Value + " " + connection.ConnectionInfo.LocalEndPoint.Address.ToString() + ":" + connection.ConnectionInfo.LocalEndPoint.Port.ToString() + "]", message);
var allRelayConnections = (from current in NetworkComms.GetExistingConnection() where current != connection select current).ToArray();
foreach (var relayConnection in allRelayConnections)
{
try
{
relayConnection.SendObject("SendMessageToOthersClt", message);
}
catch (CommsException) { }
}
msgConsole += "—————————————————————————–\n";
Console.Write(msgConsole);
});
NetworkComms.AppendGlobalConnectionEstablishHandler((connection) => { Console.Write(string.Format(" Nouveau client connecté : [IP : {0}, PORT : {1}] \n", connection.ConnectionInfo.LocalEndPoint.Address.ToString(), connection.ConnectionInfo.LocalEndPoint.Port.ToString())); });
TCPConnection.StartListening(true);
foreach (System.Net.IPEndPoint localEndPoint in TCPConnection.ExistingLocalListenEndPoints())
Console.WriteLine("Serveur demarré – Infos : {0}:{1}", localEndPoint.Address, localEndPoint.Port);
Console.WriteLine("\n Cliquez sur une touche pour fermer le serveur.");
Console.ReadKey(true);
NetworkComms.Shutdown();
}
public static string elapsedTime { get; set; }
}
}
|
|
|
|
|
That's the wrong way round, the server should never initiate the connection, it should merely listen for incoming calls.
Use the best guess
|
|
|
|
|
heloo,
it
should Client 2:
* It should be the server connects to the client 2?
* The server sends a message to the client that son located in a virtual machine?
* After sent, the server received a confirmation message from client 2?
So it remains to create of client 2 code that receives a message from the server and client 2 sends a confirmation response to server and client 1?
|
|
|
|
|
The server accepts a connection from client 2. It does not connect to client 2.
It doesn't really matter where the client is located - it will open a channel of communication to the server, which will generally be at a fixed location and port.
The server will be able to send and receive messages - and so will the client.
Have a look at any sample using TCP to get some ideas (or, take a look at using Windows Communication Foundation).
|
|
|
|
|
Heloo,
for the subject of my project is : Scalable MapReduce.
must connect the server to the client 2 located in a Virtual Machine (Virtual Box on Windows 7) and IP @: @ IP address: 192.168.56.1:10000
Thank you for attention.
|
|
|
|
|
And? This doesn't change my answer. Good luck writing this.
|
|
|
|
|
As Pete has said, get the client to connect to the server.
But then get the server to send the information out to the client once connected.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Hello ,
me my project this contrast,
must connecter server to client 2
After meet client2 server response confirmation
finally the client 2 also meet the client 1.
thank you for attention
|
|
|
|
|
Cool, it almost looks like you did not read the answers given. Why? Was it too complex in formulation? What's your native language?
What kind of school? Is there an IT-department there that we could abuse to help with this topic?
hajajj 2 wrote: must connecter server to client 2 "Server sockets" do not initiate connections, they accept them. It's "client sockets" that initiate connections. Hence, if your server-app needs to connect to something else, then your server-application must use a client-socket.
hajajj 2 wrote: After meet client2 server response confirmation
finally the client 2 also meet the client 1. Ah, so the exercise is to get a list of connected clients from the server?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
How to use bizTalk To Receive Emails From Email (such as gmail) .. Then Save these data in Database (sql) ? using Visual Studio and Console Administration
Can anyone provide me detailed steps of how to achieve this or any existing link for the same. 
|
|
|
|
|
|
Hi,
I want to create a websocket server in c# and HTML5 browser is my client. I want to send string text and a XML file from server to client via websocket.
I got some code from internet but that code is not much useful for me. I got stuck into this so can anybody help me to resolve this as early as possible.
Configurations :
1. Visual Studio 2010
2. Dot Net framework 4.0
3. Windows 7 and 32bit o.s
Thank you in advance.
|
|
|
|
|
Plenty of good samples all around - this might[^] help you get started.
|
|
|
|
|
Hi there,
This is kind of hard to explain. I have 4 columns in a radgrid:
A | B | C | D
A user will use this grid to insert information for each of the four columns. When they click Add, the form inserts their inputted values into each of the four columns.
I need to be able to concatenate the A and B columns into one column. So for instance, the grid will now look like:
A | B | C | D
-----------
1 | 2 | 3 | 4
5 | 6 | 7 | 8
9 | A | B | C
I can hide Column A and column B and make column A-B read-only. The reason for this is when they click add, they will be inserting column A and B values separately...so column A and column B must exist but be hidden. So now there will now be 5 columns, Column A, B, C, D, and A-B.
The tricky part is that these columns have to be searchable... so for instance if these were fields in the columns:
A-B | C | D
-----------
1-2 | 3 | 4
5-6 | 7 | 8
9-A | B | C
If the user puts "1" in the search box for the A-B column, the number 1-2 will show up. If they put "6" in the search box, the number 5-6 will show up.
How on earth can I get this to work? I'm lost How do I tell the grid that I want to show and search a concatenated field? Is this even possible?
I have been looking into getters and setters but I don't know how they work.
|
|
|
|
|
Change you underlying collection to reflect the data, not the UI control
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Is there a special name for objects created in a loop which all have the same identifier?
for (int i = 0; i < 10; i++)
{
MyClass a = new MyClass();
}
|
|
|
|
|
In your example, yes: "Fallen out of scope". Those objects get created and are orphaned pretty much immediately. Since there are no references being held to those objects, the GC will get around to disposing and cleaning them up.
Once execution gets to the end of the loop iteration, a is no longer in scope (in your example any way), and the object is subject to being freed and collected.
|
|
|
|
|
So what is the point, you will never be able to access the class, and as soon as it falls out of scope, it will be available for garbage collection. Anything created in a loop like that is only available within the loop, so effectively the object is destroyed before the next object is created
|
|
|
|
|