Monday, July 23, 2018

Command to get windows services and windows features

Following are the PowerShell script and Command to get the Windows Servers and Windows Roles and features list

Get Services using PowerShell

Import-Module Servermanager
Get-Service | Export-Csv -path "H:\SharePoint\Services_Features\MYUATSQL_services.csv"
Get-WindowsFeature | Export-Clixml "H:\SharePoint\Services_Features Report\MYUATSQL_features.xml"

Get Service logons details using command prompt.

wmic service get name,startname> "H:\SharePoint\Services_Features\MYUATSQL_serviceLogons.csv"

Wednesday, April 18, 2018

Android close app when back button is pressed using Xamarin c#

Requirement: Close the app when back button is pressed using C# in Xamarin.

Scenario: We may need to close the app when we press back button from app's home page

Code:
Use the following line of code in OnBackPressed event.

public class MainActivity : Activity
{
....
....
...
...

   public override void OnBackPressed()
   {
                base.OnBackPressed();
                var intent = new Intent(this, typeof(MainActivity)); 
                base.Finish();
                System.Environment.Exit(0);
    }
}


Thursday, January 11, 2018

Render JSON data in HTML using ReactJS

Following code is to render JSON data in HTML using ReactJS

HTML Code

<div id="root"></div>

JS Code
Load latest react scripts files.
Following script files were used in this example.
Add following code in to your script.
//Your JSON Data
var empdata = {
 content: {
     employee: [
       {
         name: "Joe",
         Age: 30,
         id : 1007
       },
       {
         name: "Bill",
         Age: 35,
         id : 1008
       }
     ]
  }
};
//Create Class
var Employees = React.createClass({
render: function() {
  //To retrieve keys from data.content
  var keys = Object.keys(empdata.content);
  //iterate through the keys to get the underlying values
  var allEmps = keys.map((t) => empdata.content[t].map((e) => ({e.id}-{e.name}-{e.Age})));
return ({allEmps})
}
});

//Render data to HTML
ReactDOM.render(, document.getElementById("root"));