object oriented progring in javascript

October 16, 2014

object oriented progring in javascript :

if there is no reusability then there is no need to keep the function name in memory .so go for anonymous or lamba functions

self invoking in javascript.

variables cannot be forward referenced
funcations can be forward referenced

too many arguments will be ifnoted
too less will be undefined

can be called in four ways:
1.as a function
2.as a method of another function
3.call and apply
4.as a constructor
5. inner function
6. inner function can acces the variables of outside functions

call method
Apply methods in javascript

in javsript scope is defnined by function and not by block

javascript closure.

undefined vs null
null : compiler is telling able to identify u but u have not given any value
undefined means : compiler is telling not able to identify u

———

to achieve inheritance, and obj oriented features in javscript “prototype based progring” was introduced.

namespace: grouping of all classes

in javscript namespace will be treated as another object

“this” keyword

extension methods using prototype keyword

there is no class,namespace concepts in javascript but only functions r ther

how to achieve inheritance in javscript
Object.Create

there is no interface concept to achieve inheritance like in c#

———————-

object oriented progring in javascript :

Prototype based programing.
Namespace –it is nothing but another object
contructor– a function itself constructor here.
properties-variables of function
methods
extension methods using prototype keyword
private variables
inheritence
abstruct
object method calling
function method calling
apply, call keywords
scope of variables in function
closure **
-> javascript garbage collector eg: if you declared and called a function named “fun” inside of “circus” function that “fun function ” wo’t went off from memory untill “circus ” function memory sruf off by garbage collector
->anomysys function
-> javascript arrays are not type specific
-> calling a function as constructor

——————————————————

if there is no reusability then there is no need to keep the function name in memory .so go for anonymous or lamba functions

self invoking in javascript.

variables cannot be forward referenced
funcations can be forward referenced

too many arguments will be ifnoted
too less will be undefined

can be called in four ways:
1.as a function
2.as a method of another function
3.call and apply
4.as a constructor
5. inner function
6. inner function can acces the variables of outside functions

call method
Apply methods in javascript

in javsript scope is defnined by function and not by block

javascript closure.

undefined vs null
null : compiler is telling able to identify u but u have not given any value
undefined means : compiler is telling not able to identify u

Data Access throw entity framework and Fluent API:-

? Micorsoft ORM Tool-entity Framework
? What is agile
? Data annotations / comments
? DTO(Data transfer Object) –it means pulling entire layer and objects and using it
? Is it database version dependent? Ans) same conditions need to take as per general DB migration
? Isolation from other layers entity framework
? Development approache:- DB First,Model First,Code First
? Architectural Concers:-
1) Persistence Ignorence(POCO)
2) Application patterns(Repository & unit work)
3) N-tire application
? Default mapper class will crated by frame work.
? What id Doamin Driven design ?
? Bulid with patterns of entity entity framework
? POCO?
? Sql Helper?
? 1)Entity Object(DTO),2)mapper class for DTO, data context & add mappings
? Lazy loading
? Attributes & annotations
? Indexing & performance in production deployment need to do as in separate concern
? What is n-Hybernate.

Building APP:
? Two kind of apps:-
1) Native( it’s like windows application in mobile)
2) Hybrid ( its like web application in mobile)

? Requirements :- 1) simulator
2) Phone gap not know what it is
3) IDE eg: eclipse
4) Plugins eg: ADT plugin
5) Java
? PhoneGAP.com go to this link for more info

———
JavaScript OOD :-

to achieve inheritance, and obj oriented features in javscript “prototype based progring” was introduced.

namespace: grouping of all classes

in javscript namespace will be treated as another object

“this” keyword

extension methods using prototype keyword

there is no class,namespace concepts in javascript but only functions r ther

how to achieve inheritance in javscript
Object.Create

there is no interface concept to achieve inheritance like in c#
———————————


Sqlserver : Saving changes is not permitted. The changes that you have made require the following tables to be dropped and re-created.

October 8, 2014

Saving changes is not permitted. The changes that you have made require the following tables to be dropped and re-created.

http://www.sql-server-performance.com/2009/saving-changes-not-permitted/

ERROR:

“Saving changes is not permitted. The changes that you have made require the following tables to be dropped and re-created. You have either made changes to a table that can’t be re-created or enabled the option Prevent saving changes that require the table to be re-created.”

This error happens because “Saving Changes is not permitted” when using SQL Server 2008 Management Studio to modify the structure of a table especially when SQL Server needs to drop and recreate a table to save the structural changes. It is always advised to make a structural change for a table using TSQL. However, it is a convenient option for database developers to use SQL Server Management Studio make such changes as the Prevent Saving Changes That Require Table Re-creation option is enabled by default in SQL Server 2008 Management Studio.

Disable “Prevent saving changes that require the table re-creation”

1. Open SQL Server 2008 Management Studio (SSMS). Click Tools menu and then click on Options… as shown in the snippet below.

2. In the navigation pane of the Options window, expand Designers node and select Table and Database Designers option as shown in the below snippet. Under Table Options you need to uncheck “Prevent saving changes that require the table re-creation” option and click OK to save changes.

This option when enabled prevents users from making structural changes to table using SQL Server Management Studio especially when SQL Server needs to recreate the table to save changes. By default, this option is checked and you need to uncheck this option to allow users to make any structural change through SSMS that require table recreation.


Calling Sharepoint 2013 methods as services using WCF

September 12, 2014

http://sanjivblog.wordpress.com/2010/10/04/get-all-the-item-of-specific-folder-of-document-library-or-list-in-sharepoint-using-c/

http://pankajspoint.blogspot.in/2011/02/iterating-through-sharepoint-document.html

webservice can transfer dataset but not generic lists
where as wcf can transfer both dataset and lists

sp object model cant be accessed in normal appln.sp context will come only if appln is hosted in sp like gmc ,ecg applns.

for accessing sp object model in asp.net web appln u have to expose those sp methods as webservices in sp machine and consume them in the web appln.

host webservice in sharepoint and consuming (2007 sharepoint.using disco command)
—–

http://msdn.microsoft.com/en-us/library/office/ms464040%28v=office.14%29.aspx

http://msmvps.com/blogs/windsor/archive/2011/11/04/walkthrough-creating-a-custom-asp-net-asmx-web-service-in-sharepoint-2010.aspx

sharepoint service network credentials authentication

http://man.ddvip.com/web/bsaspnetapp/LiB0087.html

how to add a new item to sharepoint list programmatically

http://www.mindfiresolutions.com/Add-Update-and-Delete-List-Items-Programmatically-in-Sharepoint-372.php

addding files to doc library

http://www.sharepointblog.in/2013/06/programmatically-addupload-file-to.html

document library

http://blah.winsmarts.com/2009-12-sharepoint_productivity_tip_of_the_day.aspx

http://www.c-sharpcorner.com/UploadFile/anavijai/how-to-create-and-host-wcf-service-inside-sharepoint-2010/

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS

host wcf service in sharepoint and consuming : (select sharpoint 2010 empty project sharepoint template.add service reference and not web reference)
———————————————-

http://mstecharchitect.blogspot.in/2010/03/hosting-wcf-service-inside-sharepoint.html

http://mstecharchitect.blogspot.in/2010/03/calling-wcf-service-hosted-in.html

http://www.c-sharpcorner.com/UploadFile/anavijai/how-to-create-and-host-wcf-service-inside-sharepoint-2010/

authentication : anonymous enabled
error :The HTTP request is unauthorized with client authentication scheme ‘Negotiate’. The authentication header received from the server was ‘NTLM’.

http://jktarun.blogspot.in/2013/03/the-http-request-is-unauthorized-with.html

http://morrisbahrami.blogspot.com.au/2011/02/http-request-is-unauthorized-with.html

http://forums.asp.net/t/1302832.aspx?The+authentication+header+received+from+the+server+was+Negotiate+NTLM+

wcf specified column is added

http://stackoverflow.com/questions/2046206/how-to-prevent-specified-properties-being-generated-in-wcf-clients

————–
Failed to convert key to token – The public key for assembly ‘(null)’ was invalid when running the sn command to know the publickeytoken of an asembly

ERROR: When trying to know the Public key token fo the strong assembly using sn command you may receive an error as below:
Failed to convert key to token — The public key for assembly ‘(null)’ was inval id.

SOLUTION: This error comes because the command options are case sensitive. The option Tp is case sensitive.
C:\Program Files\Microsoft Visual Studio 9.0\VC>sn -Tp \PendingTaskReport.dll

Error : Service Reference Error: Failed to generate code for the service reference
soln: Have to uncheck the Reuse types in all referenced assemblies from Configure service reference option

An unhandled exception of type ‘System.TimeoutException’ occurred in mscorlib.dll

Additional information: The request channel timed out while waiting for a reply after 00:00:59.8750656. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.

—-

http://blog.myitechnology.com/2009/06/right-way-to-spwebensureuser.html

if u have people as column in document library or list then u have to insert value there like below (use elevateprivileges)

http://www.c-sharpcorner.com/uploadfile/dhananjaycoder/multiple-user-insertion-in-sharepoint-list/

How to Insert?

Let us suppose, you need to add more than one user at single time in SharePoint List. Users’ values may come from an Active Directory or metadata. All the users are in a string as comma or semicolon separated value. Let us suppose users are in below format.

string usercontrolvalue = “dhananjay,arun,anoj,patra,mub”;

We need to inert these multiple users in a column of type People or Group in SharePoint list.

Step 1

First we need to split name of all the users from the string. Since in our case users are comma separated so below code will make a string array with users as value at different index.

string[] userarray = usercontrolvalue.Split(‘,’);

Step 2

Now we need to convert users as string to SPFieldUserValue. Below function is taking user name as string and converting that into SPFieldUserValue.

_Web variable is denoting current web where List is part of.

public SPFieldUserValue ConvertLoginName(string userid)
{
SPUser requireduser = _web.EnsureUser(userid);
SPFieldUserValue uservalue = new SPFieldUserValue(_web, requireduser.ID, requireduser.LoginName);
return uservalue;
}

Step 3

We need to make instance of SPFieldUserValueCollection

SPFieldUserValueCollection usercollection = new SPFieldUserValueCollection();

Step 4

For all the user; we need to convert that as SPFieldUserValue then add that them to SPFieldUserValueCollection instance

for (int i = 0; i < userarray.Length; i++)
{
SPFieldUserValue usertoadd = ConvertLoginName(userarray[i]);
usercollection.Add(usertoadd);
}

Only we need to perform above said task. For your reference entire code as below,

Entire code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
namespace TestingMultipleUsre
{
public partial class _Default : System.Web.UI.Page
{
SPWeb _web;
SPSite _site;
SPList myList
protected void Page_Load(object sender, EventArgs e)
{
string usercontrolvalue = "dhananjay,arun,anoj,patra,mub";
_site = new SPSite("http://adfsaccount:2222/&quot;);
_web = _site.OpenWeb();
myList = _web.Lists["TestingUser"];
_web.AllowUnsafeUpdates = true ;
myList = _web.Lists["TestingUser"];
SPListItem item = myList.Items.Add();
SPFieldUserValueCollection usercollection = new SPFieldUserValueCollection();
string[] userarray = usercontrolvalue.Split(',');
for (int i = 0; i cd c:\windows\syswow64\inetsrv

c:\Windows\SysWOW64\inetsrv>appcmd.exe list config -section:system.webServer/ser
verRuntime

c:\Windows\SysWOW64\inetsrv>appcmd.exe set config -section:system.webServer/serv
erRuntime /uploadReadAheadSize:”204800″
Applied configuration changes to section “system.webServer/serverRuntime” for “M
ACHINE/WEBROOT/APPHOST” at configuration commit path “MACHINE/WEBROOT/APPHOST”

———–
in vs command prompt :
at the solution/bin/debug folder type : sn -T “dllname” (for getting strong name) …u will get publickeytoken of that assembly
at the solution/bin/debug foder type : gacutil -i “dllname”(for keeping into gac)
at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI type disco http://skeltadtptest:1111/_vti_bin/final/service.asmx.

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI
c:\Windows\assembly\GAC_msil
c:\windows\assembly


SqlServer Notes : How to RESET identity columns in SQL Server

August 27, 2014

DBCC CHECKIDENT(‘[table_name]‘, RESEED, [new_reseed_value])
— for example
DBCC CHECKIDENT(‘product’, RESEED, 0)

Here product is the table name


SQL Server – Finding TCP Port Number SQL Instance is Listening on

August 13, 2014

http://sqlandme.com/2013/05/01/sql-server-finding-tcp-port-number-sql-instance-is-listening-on/

By default SQL Server listens on TCP port number 1433, and for named instances TCP port is dynamically configured. There are several options available to get the listening port for SQL Server Instance.

Here are a few methods which we can use to get this information.

Method 1: SQL Server Configuration Manager

Method 2: Windows Event Viewer

Method 3: SQL Server Error Logs

Method 4: sys.dm_exec_connections DMV

Method 5: Reading registry using xp_instance_regread

Let’s see how you can use each of these methods in detail:

Method 1: SQL Server Configuration Manager:

Step 1. Click Start > All Programs > Microsoft SQL Server 2012 > Configuration Tools > SQL Server Configuration Manager

Step 2. Go to SQL Server Configuration Manager > SQL Server Network Configuration > Protocols for

Step 3. Right Click on TCP/IP and select Properties

image

Step 4. In TCP/IP Properties dialog box, go to IP Addresses tab and scroll down to IPAll group.

image

If SQL Server if configured to run on a static port it will be available in TCP Port textbox, and if it is configured on dynamic port then current port will be available in TCP Dynamic Ports textbox. Here my instance is listening on port number 61499.

Method 2: Windows Event Viewer:

When SQL Server is started it logs an event message as ‘Server is listening on [ ‘any’ ‘ in windows event logs. Here will be actual port number on which SQL Server is listening.

To view this using Event Viewer:

Step 1. Click Start > Administrative Tools > Event Viewer.

Note: If Administrative Tools are not available on Start menu, go to Start > Control Panel > System and Maintenance > Administrative Tools > View event logs

Step 2. Navigate to Event Viewer > Windows Logs > Application

Step 3. Since huge amount of event are logged, you need to use filtering to locate the required logs. Right click on Application and select Filter Current Log…

image

Step 4. You can filter the events by Event ID and Event source. The event we are interested in has Event ID of 26022, and it’s source is SQL Server Instance. You need to filter by both Event ID and SQL Server Instance if you have multiple instances installed, for a single instance you can filter by Event ID only. Click on OK to apply the filter.

image

Step 5. Once the filter is applied, Locate message ‘Server is listening on [ ‘any’ …’. As we can see from below screenshot that SQL Server Instance is running on TCP Port 61499.

image

Method 3: SQL Server Error Logs:

When SQL Server is started it also logs an message to SQL Server Error Logs. You can search for port number in SQL Server Error Logs by opening SQL Server Error Log in notepad or via T-SQL using extended stored procedure xp_ReadErrorLog as below:

EXEC xp_ReadErrorLog 0, 1, N’Server is listening on’, N’any’, NULL, NULL, ‘DESC’
GO

Result Set:

LogDate ProcessInfo Text
2013-03-21 13:34:40.610 spid18s Server is listening on [ 'any' 61499].
2013-03-21 13:34:40.610 spid18s Server is listening on [ 'any' 61499].

(2 row(s) affected)

As we can see from the output that SQL Server Instance is listening on 61499.

Note: This method does not work if SQL Server Error Logs have been cycled. See sp_Cycle_ErrorLog for more information.

Method 4: sys.dm_exec_connections DMV:

DMVs return server state that can be used to monitor SQL Server Instance. We can use sys.dm_exec_connections DMV to identify the port number SQL Server Instance is listening on using below T-SQL code:

SELECT local_tcp_port
FROM sys.dm_exec_connections
WHERE session_id = @@SPID
GO

Result Set:

local_tcp_port
61499

(1 row(s) affected)

As we can see from the output… same as above Smile

Method 5: Reading registry using xp_instance_regread:

Port number can also be retrieved from Windows Registry database.

We can use extended stored procedure xp_instance_regread to get port number information using below T-SQL code:

DECLARE @portNumber NVARCHAR(10)

EXEC xp_instance_regread
@rootkey = ‘HKEY_LOCAL_MACHINE’,
@key =
‘Software\Microsoft\Microsoft SQL Server\MSSQLServer\SuperSocketNetLib\Tcp\IpAll’,
@value_name = ‘TcpDynamicPorts’,
@value = @portNumber OUTPUT

SELECT [Port Number] = @portNumber
GO

Result Set:

Port Number
61499

(1 row(s) affected)

As we can see … same as above Smile Smile

Note: The above code will only work if SQL Server is configured to use dynamic port number. If SQL Server is configured on a static port, we need to use @value_name = ‘TcpPort’ as opposed to @value_name = ‘TcpDynamicPorts’.


Asp.net – try catch finally notes

March 27, 2014

The code inside a finally block will get executed regardless of whether or not there is an exception.

http://www.codeproject.com/Articles/154121/Using-Try-Catch-Finally

Exception handling in C#. In the below code

Try
{

//Throwing Error
}
Catch
{
//Getting Caught
}
Finally
{
int x =3;
}

int x = 5 ;

In Try after throwing an Error which is caught in Catch ,After that Finall Block Executes with Assignment of x=3. and after that next line x=5 is also executed.Program not getting terminated..What might be the reason ?


SqlServer notes : Inbuilt reports provided by Sqlserver itself

March 13, 2014

In Object Explorer

 

right click on server name and select Reports->Standard Reports->

Performance -Top Queries by Average CPU Time


Follow

Get every new post delivered to your Inbox.