As we all know that Log4net is very nice open source for logging and used in almost every software development industries.
I am putting step by step solution in two parts for your refrence.
part1 part2
Happy Coding !!
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]
log4net.config:put the configuration
You are almost done for POC . Just two Steps Remening
DROP TABLE [dbo].[ApplicationLog] CREATE TABLE [dbo].[ApplicationLog] ( [Id] int IDENTITY (1, 1) NOT NULL, [Date] datetime NOT NULL, [Thread] varchar(255) NULL, [Level] varchar(50) NOT NULL, [Logger] varchar(255) NOT NULL, [Host] varchar(50) NOT NULL, [Message] varchar(4000) NOT NULL, [Exception] varchar(2000) NULL, [severity] varchar(255) NULL, [useranme] varchar(255) NULL, [applicationName] varchar(255) NULL )Step:7 In Console application
using System; using Database; namespace LoggingExample { class Program { static void Main(string[] args) { ILogger logger = new Logger(); logger.EnterMethod("Main"); logger.LogInfoMessage("LogInfo"); logger.LogError("ErrorLog"); logger.LeaveMethod("Main"); } } }You are done now !! if you like it please put a comment.
using System; using System.Configuration; using System.Globalization; using log4net; using System.Diagnostics; namespace DatabaseLogger { public class DbLogger : IDbLogger { #region Datamembers private static ILog log = null; private const string Log4netConnectionString = "Log4netConnectionString"; #endregion #region Class Initializer public Logger() { log = LogManager.GetLogger(typeof(DbLogger)); log4net.GlobalContext.Properties["host"] = Environment.MachineName; log4net.GlobalContext.Properties["severity"] = "Low"; log4net.GlobalContext.Properties["userName"] = System.Security.Principal.WindowsIdentity.GetCurrent().Name; log4net.GlobalContext.Properties["applicationName"] = Process.GetCurrentProcess().ProcessName; } #endregion #region IDbLogger Members public void EnterMethod(string methodName) { if (log.IsInfoEnabled) log.Info(string.Format(CultureInfo.InvariantCulture, "Entering Method {0}", methodName)); } public void LeaveMethod(string methodName) { if (log.IsInfoEnabled) log.Info(string.Format(CultureInfo.InvariantCulture, "Leaving Method {0}", methodName)); } public void LogException(Exception exception) { if (log.IsErrorEnabled) log.Error(string.Format(CultureInfo.InvariantCulture, "{0}", exception.Message), exception); } public void LogError(string message) { if (log.IsErrorEnabled) log.Error(string.Format(CultureInfo.InvariantCulture, "{0}", message)); } public void LogWarningMessage(string message) { if (log.IsWarnEnabled) log.Warn(string.Format(CultureInfo.InvariantCulture, "{0}", message)); } public void LogInfoMessage(string message) { if (log.IsInfoEnabled) log.Info(string.Format(CultureInfo.InvariantCulture, "{0}", message)); } #endregion } } using System; namespace DatabaseLogger { public interface IDbLogger { ///Step 4: Now We Need to add One more Class Call SqlServerAppender for Log4Net Connection string/// Writes a log entry when entering the method. /// /// Name of the method. void EnterMethod(string methodName); ////// Writes a log entry when leaving the method. /// /// Name of the method. void LeaveMethod(string methodName); ////// Logs the exception. /// /// The exception. void LogException(Exception exception); ////// Logs the error. /// /// The message. void LogError(string message); ////// Logs the warning message. /// /// The message. void LogWarningMessage(string message); ////// Logs the info message. /// /// The message. void LogInfoMessage(string message); } }
using System; using System.Configuration; using log4net.Appender; namespace Database { public class SqlServerAppender : AdoNetAppender { private const string Log4netConnectionString = "Log4netConnectionString"; public new string ConnectionString { get { return base.ConnectionString; } set { base.ConnectionString = ConfigurationManager.ConnectionStrings[Log4netConnectionString].ConnectionString; } } } }after that Your Dll is ready for Refernceing for your Project where you want to implement it .
using System.Net; using System; using System.Web.Services.Description; using System.CodeDom; using System.IO; using System.CodeDom.Compiler; using System.Reflection; using System.Xml.Serialization; public class DyanamicProxyGeneration { #region Members List_serviceMethods; Uri uri; String Url; WebRequest webRequest; Stream requestStream; ServiceDescription sd; ServiceDescriptionImporter servImport; MethodInfo[] methodInfo; CodeCompileUnit codeCompileUnit; StringWriter stringWriter; CodeNamespace nameSpace; Type service; CSharpCodeProvider prov; Assembly assembly; CompilerResults results; CompilerParameters param; String[] assemblyReferences; #endregion public void DynamicInvocation(string Url) { try { uri = new Uri(Url + "?WSDL"); webRequest = WebRequest.Create(uri); requestStream = webRequest.GetResponse().GetResponseStream(); // Get a WSDL file describing a service sd = ServiceDescription.Read(requestStream); string sdName = sd.Services[0].Name; // Initialize a service description servImport servImport = new ServiceDescriptionImporter(); servImport.AddServiceDescription(sd, String.Empty, String.Empty); servImport.ProtocolName = "Soap"; servImport.CodeGenerationOptions = CodeGenerationOptions.GenerateProperties; nameSpace = new CodeNamespace(); codeCompileUnit = new CodeCompileUnit(); codeCompileUnit.Namespaces.Add(nameSpace); // Set Warnings ServiceDescriptionImportWarnings warnings = servImport.Import(nameSpace, codeCompileUnit); if (warnings == 0) { stringWriter = new StringWriter(System.Globalization.CultureInfo.CurrentCulture); prov = new Microsoft.CSharp.CSharpCodeProvider(); prov.GenerateCodeFromNamespace(nameSpace, stringWriter, new CodeGeneratorOptions()); // Compile the assembly with the appropriate references assemblyReferences = new string[2] { "System.Web.Services.dll", "System.Xml.dll" }; param = new CompilerParameters(assemblyReferences); param.GenerateExecutable = false; param.GenerateInMemory = true; param.TreatWarningsAsErrors = false; param.WarningLevel = 4; results = new CompilerResults(new TempFileCollection()); results = prov.CompileAssemblyFromDom(param, codeCompileUnit); assembly = results.CompiledAssembly; service = assembly.GetType(sdName); methodInfo = service.GetMethods(); foreach (MethodInfo t in methodInfo) { if (t.Name == "Discover") break; _serviceMethods.Add(t.Name); } } } catch (Exception ex) { } } } public object GetResponse(MethodInfo[] methodInfoList) { Object response = null; ParameterInfo [] paramters; foreach (MethodInfo t in methodInfo) { //Invoke Method paramters = new ParameterInfo []{}; paramters = t.GetParameters(); object[] param1 = paramters; Object obj = Activator.CreateInstance(service); response = t.Invoke(obj, param1); break; } if (response != null) { return response; } else return null; }
public class DataAccess { private SqlConnection conn; public DataAccess() { string connectionString = "Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;" // I used for SQLServer2005 .For other Databases check with "http://www.connectionstrings.com" conn = new SQLConnection(connectionString); } // To Get Saved object Id public int Save_Details(string parameter1, string paramter2,....., string parameterN) { int returnObjectId; conn.Open(); SqlCommand cmd = new SqlCommand("SP_Insert", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@parameter1", parameter1); cmd.Parameters.AddWithValue("@parameter2", parameter2); //. //. //. //. cmd.Parameters.AddWithValue("@parameterN", parameterN); cmd.Parameters.Add("@ObjectId", SqlDbType.Int, 0, "Id"); cmd.Parameters["@ObjectId"].Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); returnObjectId = (int)cmd.Parameters["@ObjectId"].Value; conn.Close(); if (returnObjectId > 0) { return returnObjectId;} else {return 0;} } }
--Stored Procedure code SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[SP_Insert] @parameter1 nvarchar(50), @parameter2 nvarchar(50), -- . -- . -- . @parametern nvarchar(50), @Object_Id int OUTPUT AS BEGIN INSERT INTO [dbo].[TableName] ([Parameter1] ,[Parameter2] ,[ParameterN]) VALUES (@parameter1, @parameter2, @parametern) END select @Object_Id =@@Identity
// 1.Create a div or Table where you have to create textboxes // <table> // <tr> // <td id="DynamicTextBox" runat="server" style="width: 165px" align="left"></td> // </tr> // </table> // 2. Create a list or collection //Create Dynamic Textbox int counterTextBox =0; foreach (var item in collection) { //Create Dynamic Textbox System.Web.UI.WebControls.TextBox tb = new System.Web.UI.WebControls.TextBox(); tb.Width = 495; tb.Height = 18; tb.TextMode = TextBoxMode.SingleLine; tb.ID = "TextBox_ID" + ++coutnerTextbox; DynamicTextBox.Controls.Add(tb); DynamicTextBox.Controls.Add(new LiteralControl("<br/>")); }
@echo off set Configuration="debug" set MSBuildPath=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ set dir1="%CD%\(PATH OF PROJECT 1).csproj" set dir2="%CD%\(PATH OF PROJECT 2).csproj" set dir3="%CD%\(PATH OF PROJECT 3).csproj" set dir4="%CD%\(PATH OF PROJECT 4).csproj" set dir5="%CD%\(PATH OF PROJECT 5).csproj" ECHO Building (PUT THE PROJECT/SOLUTION/NAMESPACE FOR REFRENCE(it will show in the screen) ) %MSBuildPath%MSBuild /logger:FileLogger,c:\windows\Microsoft.Net\Framework\v2.0.50727\Microsoft.Build.Engine.Dll;LogFile="BuildLogs\PROJECT_NAME.txt" %dir1% /p:Configuration=%Configuration% %MSBuildPath%MSBuild /logger:FileLogger,c:\windows\Microsoft.Net\Framework\v2.0.50727\Microsoft.Build.Engine.Dll;LogFile="BuildLogs\PROJECT_NAME.txt";Append %dir2% /p:Configuration=%Configuration% %MSBuildPath%MSBuild /logger:FileLogger,c:\windows\Microsoft.Net\Framework\v2.0.50727\Microsoft.Build.Engine.Dll;LogFile="BuildLogs\PROJECT_NAME.txt";Append %dir3% /p:Configuration=%Configuration% %MSBuildPath%MSBuild /logger:FileLogger,c:\windows\Microsoft.Net\Framework\v2.0.50727\Microsoft.Build.Engine.Dll;LogFile="BuildLogs\PROJECT_NAME.txt";Append %dir4% /p:Configuration=%Configuration% %MSBuildPath%MSBuild /logger:FileLogger,c:\windows\Microsoft.Net\Framework\v2.0.50727\Microsoft.Build.Engine.Dll;LogFile="BuildLogs\PROJECT_NAME.txt";Append %dir5% /p:Configuration=%Configuration% ECHO (PUT THE PROJECT/SOLUTION/NAMESPACE FOR REFRENCE(it will show in the screen) ) Completes pause
--Select -------------- select * from Categories select * from Suppliers Select * from Products --InnerJoin (inner join is same as Join ) ------------------------------------------ Select prod.ProductID,prod.ProductName,prod.UnitPrice,sup.CompanyName,sup.City From Products as prod inner join Suppliers as sup on prod.productId = sup.SupplierId --Left Join ------------------------------------------ Select prod.ProductID,prod.ProductName,prod.UnitPrice,sup.CompanyName,sup.City From Products as prod left join Suppliers as sup on prod.productId = sup.SupplierId --Right Join ------------------------------------------ Select prod.ProductID,prod.ProductName,prod.UnitPrice,sup.CompanyName,sup.City From Products as prod Right join Suppliers as sup on prod.productId = sup.SupplierId --Full Join ------------------------------------------ Select prod.ProductID,prod.ProductName,prod.UnitPrice,sup.CompanyName,sup.City From Products as prod Full join Suppliers as sup on prod.productId = sup.SupplierId --Self Join --A self-join is a query in which a table is joined (compared) to itself. ----------------- Select emp.EmployeeId ,emp.FirstName ,emp.ReportsTo from Employees as emp Select emp.EmployeeId ,emp.FirstName ,emp.ReportsTo ,emp1.FirstName as Mgr from Employees as emp Left outer join employees as emp1 on emp1.EmployeeId =emp.ReportsTo --UNION --The SQL UNION Operator --The UNION operator is used to combine the result-set of two or more SELECT statements. --Notice that each SELECT statement within the UNION must have the same number of columns. --The columns must also have similar data types. Also, the columns in each SELECT statement must be in the same order. ------------------------------------------ Select CategoryId,CategoryName from Categories Union Select SupplierId,CompanyName from Suppliers --Select Into -- use to Create Temp data in temp Table -- Temp table is started By '# ' Keyword Like #TableName -------------------------------------------------------- Select * Into Categories in anilTest from Categories drop Table #Categories1 --Select Into -- use to Create Temp data in temp Table -- Temp table is started By '# ' Keyword Like #TableName -------------------------------------------------------- Select * Into Categories in anilTest from Categories drop Table #Categories1 select * Into #Categories From Categories ALTER TABLE Persons DROP CONSTRAINT uc_PersonID select * from #Categories --Constraint -------------------------------------------------------- Alter Table #Categories Add Unique (Categoryid) Alter Table #Categories Drop Constraint Unique Categoryid ALTER TABLE #Categories DROP PRIMARY KEY --Nth Highest salary ------------------------ SELECT distinct emp1.Extension from Employees emp1 Where 3 =(Select Count (Distinct(emp2.Extension))From Employees emp2 Where emp2.Extension<= emp1.Extension) --- Select distinct Top 1 Extension From (Select distinct Top 3 Extension From Employees Order by Extension Desc) Employees Order by Extension Asc --SQL ISNULL(), NVL(), IFNULL() and COALESCE() Functions -------------------------------------------------------- Select * from Suppliers SELECT CompanyName,ContactName*(City+ISNULL(Country,0))FROM Suppliers --DateTime Functions --Function Description --GETDATE() Returns the current date and time --DATEPART() Returns a single part of a date/time --DATEADD() Adds or subtracts a specified time interval from a date --DATEDIFF() Returns the time between two dates --CONVERT() Displays date/time data in different formats --------------------------------------------------------------- --Some other Funtion ----------------------- SELECT FORMAT(column_name,format) FROM table_name
Modern development environments contain sophisticated tools to help you debug your applications. The Transact-SQL Debugger in Visual Studio will help you to identify and fix problems in your code. However, even if your development environment does not support the Transact-SQL Debugger (if you do not have Visual Studio 2005), there are techniques you can employ to achieve the same results.
This section demonstrates the use of the Transact-SQL Debugger from Visual Studio 2005. The major difference between debugging stored procedures and debugging within other programming languages is that you do not need to run the application to debug a single procedure.
The process for starting the debugger is to point to the stored procedure and invoke the Step Into Stored Procedure command:
Open Visual Studio.
Select View | Server Explorer.
In Server Explorer, right-click to open the context-sensitive menu and choose Add Connection.
In the Choose Data Source window, select Microsoft SQL Server and verify that .NET Data Provider for SQL Server is also selected. Click Continue.
In the Add Connection window, specify server name, authentication, and database name (as usual, use AssetS).
Test the connection and if everything is working, click OK to close each window.
Server Explorer now contains a node showing the connection that you have described. It functions like nodes in the Object Browser of Management Studio. Expand the nodes until you find Stored Procedures.
Right-click dbo.ap_InventoryProperties_Get_TempTblOuter to display the context-sensitive menu.
Choose Step Into Stored Procedure (instead of the usual Execute) and the program will initiate the debugging session.
Fill in the input parameters in the Run Stored Procedure window:
The Transact-SQL Debugger opens the source code of the procedure and pauses on the first executable statement. A small yellow arrow on the left border marks the position of the statement to be executed next.
The commands in the Debug menu become enabled, as do several more docked windows displayed as tabbed panes, described here, that enable you to examine the state of the environment.
Locals window Allows you to scroll through the local variables and parameters of the stored procedure and to see its current contents and data type:
As the stored procedure's code is executed, the values of variables change. To help you follow the execution, the Transact-SQL Debugger colors the values of variables that were changed in the previous statement. The Locals window allows you to change values of variables interactively during execution of the code (through the context-sensitive menu for the Value column).
Watch window Has a similar function to the Locals window. You can type, or drag from the code, a Transact-SQL expression to be evaluated in this window. This feature is useful when you want to investigate the values of expressions in If, While, Case, and other similar statements. It is possible to work with up to four Watch windows.
Output window Displays result sets returned by the Select statement and messages sent from the Print statement
Breakpoints window Allows the user to define code locations (lines) and conditions for pausing execution. However, you can also associate it with some additional conditions. For example, you may want to create a breakpoint that pauses execution when a specified location is reached a specified number of times:
These panes have more than four tabs, but only these mean anything for the Transact-SQL Debugger. The other tabs are used to debug client applications.
Breakpoints are markers in code that serve to stop execution when certain conditions are met. In the Transact-SQL Debugger, you can use only a very limited set of conditions. Typically, you can only specify a condition in which the execution has reached the position of the breakpoint or in which a breakpoint has been reached a selected number of times. In other .NET languages such as C# and Visual Basic, the condition can apply when a variable changes value, when a Boolean expression is true, or even when execution starts a specified process or thread.
Breakpoints can be set three ways:
Using the toolbar in the Breakpoints window
Clicking the left edge of the code window
Pressing F9 when the cursor is on the line in which you want to place a breakpoint
Visual Studio marks the breakpoint with a big red dot at the beginning of the line. If the dot contains a plus (+), the breakpoint contains additional criteria.
The toolbar and the Debug menu can contain additional commands for managing breakpoints. You can temporarily enable or disable all breakpoints and permanently remove them. A single breakpoint can be removed by clicking the dot or by pressing F9 when the cursor is on the line containing the breakpoint.
The majority of commands available on the Debug menu target execution control. Most of the time, you will use the Step Into or Step Over command to step through a stored procedure. These commands execute one Transact-SQL statement at a time. The difference between them is in the way they behave when they encounter a nested stored procedure:
Step Into (F11) Opens the code of the nested stored procedure and lets you step through it.
Step Over (F10) The nested stored procedure is treated as any other Transact-SQL statement and is executed in a single step.
Step Out (SHIFT-F11) Enables you to execute the rest of the nested stored procedures without pause and halts only when the stored procedure is completed in the calling stored procedure.
Run To Cursor (CTRL-F10) Enables you to position the cursor somewhere in the code and to execute everything to that point in a single step. In essence, this command lets you set a temporary breakpoint.
Continue (FS) Resumes execution of the code until the (original entry) procedure is completed or until the next breakpoint is reached.
Stop Debugging (SHIFT-FS) Discontinues execution.
Note | Visual Studio menus can be customized to contain different sets of options. If your configuration does not contain options that are mentioned in this section, go to Tools | Customize, open the Commands tab, click the Debug category, and drag commands from the list to the Debug menu. Additionally, you can access these options using keyboard shortcuts even when the commands are not on the menu. |
One of my favorite features in the Visual Studio debugger is the ability to continue execution from the position of the cursor. Unfortunately, due to the architecture of the Transact-SQL Debugger, the Set Next Step command is not available. Another cool feature that was originally available in Visual Basic and then missing in early versions of Visual Studio .NET was the ability to modify code on the fly (during debugging).
Unmanaged executable files are binary images of x86 code loaded into memory. The role of the operating system in this case is to load the application into memory and let it run. Although there are some protections regarding memory management and I/O ports, the operating system does not have any idea what the application is doing.
By contrast, managed code is under full control of the operating system. At any point in time, the operating system can stop running the CPU and investigate the runtime state. It can also insert exception handling, array bounds and indexes, traps, garbage collection hooks, and other things. In this way, it mitigates a whole class of security concerns and typical programming errors. All programming languages that support the .NET Framework produce managed code. There are currently over 30 such languages. Several are provided by Microsoft (C#, Visual Basic .NET, managed C++, J#, JScript .NET), while others are developed by third parties (everything from COBOL to Pascal).
function delRow() { document.getElementById('myTable').deleteRow(0) }
Row1 cell1 | Row1 cell2 |
Row2 cell1 | Row2 cell2 |
function insRow() { document.getElementById('myTable').insertRow(0) }
Row1 cell1 | Row1 cell2 |
Row2 cell1 | Row2 cell2 |
function cell() { var x=document.getElementById('myTable').rows[0].cells; alert(x[0].innerHTML); }
cell 1 | cell 2 |
cell 3 | cell 4 |
public bool CheckVowel(object sender,KeyEventArgs e) { if(e.KeyCode ==Keys.A||e.KeyCode ==Keys.E||e.KeyCode ==Keys.I||e.KeyCode ==Keys.O||e.KeyCode ==Keys.U) { return true; } else return false; }Prog 2: Even Or Odd Solution: ======
public string EvenOrOdd( int Num) { if(num%2 ==0) retrun "evenNumber"; else return "OddNumber" }Prog3:PrimeNumber Soultion: ======
public string PrimeOrNot(int num) { int i = 0; for (i = 3; i < num; i++) { if (num % i == 0) { Console.WriteLine("{0} is not a prime number", num); break; } } if (i == num) { Console.Writeline("{0} is a prime Number", num); } }Prog4:Fibonacci Series Solution: =======
public void FibonacciSeries(int number) { int f_0 = 0; int f_1 = 1; int sum; Console.Write("{0} {1} ", f_0, f_1); for (int i = 2; i < number; i++) { sum = f_0 + f_1; f_0 = f_1; f_1 = sum; int value = f_0 + f_1; Console.Write("{0} ", value); } }Prog5: Factorial Solution: =======
public int Factorial(int number) { int value = 1; for (int i = 1; i <= number; i++) { value = value * i; } return value; }Prog:6 Permutation (nPr) Solution: ====== Refrence Solution 5;
public double Permutation(int n, int r) { double nPr = Factorial(n) / Factorial(n - r); return nPr; }Prog:7 Combination(nCr) Solution: ====== Refrence Solution 5;
public double Combination(int n , int r) { double nCr = Factorial(n)/Factorial(r)*(Factorial(n-r); return nCr; }Prog8 : Add two numbers without using the plus operator Solution: ======
public int Add (int x , int y ) { return x-(-y); }Prog9: Multiply two numbers without usering * operator Solution: =======
public int MulWithOutStarOperator( int x ,int y) { for(int z= 1 ; z<=y ; z++) { int value = value +x; } return value; }Prog:10 String Reverse Solution: =======
public string ReverseString(string str) { int strLenght = str.Lenght; char strArray[] = new char[strLength]; for ( int i = 0 ; iProg:11 Return multiple values from a function Solution: ======== public int Add(int a,int b,out int c) { c=a+1; return a+b; }Description : --------------- when we call the Add method we will get the sum of the a and b and can also use the value of c like int d=0; int e= Add(2,3,d) ; then the value of e will be 5 and the value of d will be 3.
public class EducationProfile { public int Id { get; set; } public string Digree { get; set; } public DateTime PassingYear { get; set; } } //Hope this will give you a little reference of lazy loading public class Candiate { public string Name { get; set; } public int EducationProfileId { get; set; } public List GetAllEducationProfile() { return educationProileList.value; } Lazy> educationProileList; public Candiate(string name, int id) { //Initializing Candiate Object Name = name; EducationProfileId = id; educationProileList = new Lazy
>(() => { return GetEducationProfileList(id); }); //Initialization done } private List GetEducationProfileList(int id) { //Loading EducationProiles List list = new List(); Parallel.For(100, 110, (int i) => { EducationProile educationprofile = new EducationProile(); educationprofile.Id = i; list.Add(educationprofile); }); return list; } }
public static void Main(string[] args) { Candidate candidate = new Candidate("AnyName", 1); foreach(EducationProile eduProfile in candiate.GetAllEducationProfile()) // it will actually load accounts, ie. lazy loading Console.WriteLine("Id:{0}",eduProfile.Id); Console.Read(); }
//Symbol.ResourceCoordination class TerminalInfo terminalIfo = new TerminalInfo(); if (!string.IsNullOrEmpty(terminalIfo.ESN)) { label1.Text = terminalIfo.ESN; } else { label1.Text = "Not able to Get ESN"; }
public class WiFiRadio { WLAN myCommandModeWlan = null; public WiFiRadio() { InitializeWiFi(); } public void InitializeWiFi() { try { myCommandModeWlan = new WLAN(FusionAccessType.COMMAND_MODE); } catch (OperationFailureException ex) { System.Windows.Forms.MessageBox.Show("Command mode is in use", "WiFiMgr"); } } public void ToggleWiFi(bool enableWiFi) { try { if (myCommandModeWlan != null) { if (enableWiFi) { myCommandModeWlan.Adapters[0].PowerState = Adapter.PowerStates.ON; } else { myCommandModeWlan.Adapters[0].PowerState = Adapter.PowerStates.OFF; } } } catch (OperationFailureException ex) { System.Windows.Forms.MessageBox.Show("Command mode is in use", "WiFiMgr"); } } public bool GetCurrentStatus() { if (myCommandModeWlan.Adapters[0].PowerState == Adapter.PowerStates.ON) { return true; } else { return false; } } }
public void GetCurrentBuildVersion() { var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; view.VersionNumber = version.Major + "." + version.Minor + "." + version.Build + "." + version.Revision; }