Cross Platform Socket Programming (Mac-Windows)

Overview: Sockets vs Streams Socket represents a unique communication endpoint on the network. When your app needs to exchange data with another app, it creates a socket and uses it to connect to the other app’s socket. You can both send and receive data through the same socket. Each socket has an IP address and …

Recursive in C#

public partial class _Default : System.Web.UI.Page { List lst = new List(); int mainnode = 0; protected void Page_Load(object sender, EventArgs e) { if(!Page.IsPostBack) RadTreeView1.Nodes.Insert(0, new RadTreeNode(“Table of Content”)); } protected void Button1_Click(object sender, EventArgs e) { updatemainnode(); lst.Add(“end”); gv1.DataSource = lst; gv1.DataBind(); } public void updatemainnode() { for (int i = 0; i 0) …

System tray menu in MAC OS x application

1. Open interface builder create NSMenu from Tools->Library. And create NSMenuItem “Active” and “Quit”. 2. “Active” select “Sent Action” -> “Window Server” and select “deminiature” action. 3. “Quit” select “Sent Action” -> “Application” and select “terminate” action. 4. “Menu” select “Outlet” ->ServerControll (applcation name control) 5. In “ServerController.h” file IBOutlet NSMenu *menu; NSStatusItem *statusItem; NSImage …

ESC handle by AppleScript

tell application “System Events” tell application “TextEdit” to activate tell application “TextEdit” to run keystroke “s” using {command down} key code 53 end tell ——————- tell application “System Events” tell application “TextEdit” to activate tell application “TextEdit” to run keystroke “s” using {command down} key code 53 –esc –key code 36 — enter –key code …

AppleScript in Cocoa Class

//message= TextEdit:f NSString *string = message; // split the text by the : to get an array containing { “AAA”, “BBB” } NSArray *splitText = [string componentsSeparatedByString:@”:”]; // form a new string of the form “BBB AAA” by using the individual entries in the array NSString *cellText = [NSString stringWithFormat:@”%@ %@”, [splitText objectAtIndex:1], [splitText objectAtIndex:0]]; …

Implement Logger in asp.net

First of create LoggingConstant.cs File in that Declare all Pages name as variable without extension. For ex. public enum ModuleToLog { default, login } public enum LogType { DEBUG, EXCEPTION, INFO } After that create Logger.cs File.. public class Logger { public static void Write(LogType eLogType, ModuleToLog eModule, string strMethodName, string LogMessage, string strUserId) { …

Windows Users List in Asp.Net c#

using System.Management; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { SelectQuery query = new SelectQuery(“Win32_UserAccount”); ManagementObjectSearcher searcher = new ManagementObjectSearcher(query); foreach (ManagementObject envVar in searcher.Get()) { Console.WriteLine(“Username : {0}”, envVar[“Name”]); } Console.ReadLine(); } } }

create xml file dynamically

try { if (System.Web.HttpContext.Current.Session[“UserId”] != null && System.Web.HttpContext.Current.Session[“EventId”] != null && System.Web.HttpContext.Current.Session[“EventConfiguration”] != null) { Logger.Write(LogType.INFO, ModuleToLog.EventInformation, “WriteEventHistory”, “EventHistory”, HttpContext.Current.Session[“UserName”].ToString()); string pageName = System.IO.Path.GetFileName(System.Web.HttpContext.Current.Request.ServerVariables[“SCRIPT_NAME”]); UserService.UserClient proxyFind = new ePlannerPro2Client.UserService.UserClient(); epp2ClientPL.UsersProperties result = proxyFind.LoadById(new Guid(Convert.ToString(System.Web.HttpContext.Current.Session[“UserId”])), new Guid(Convert.ToString(System.Web.HttpContext.Current.Session[“EventId”]))); if (result == null) { return; } //epp2ClientPL.UsersProperties result = proxyFind.LoadUsersByEventId(new Guid(Convert.ToString(Convert.ToString(System.Web.HttpContext.Current.Session[“EventId”])))).Where(u => u.UserId.Equals(new Guid(Convert.ToString(System.Web.HttpContext.Current.Session[“UserId”])))).SingleOrDefault(); epp2ClientPL.EventConfigurationProperties files = (epp2ClientPL.EventConfigurationProperties)System.Web.HttpContext.Current.Session[“EventConfiguration”]; …