Wednesday, 31 May 2017

Remove HTML all css Microsoft word (MS WORD) format

public static string StripHtml(string source)
    {
        source = Regex.Replace(source, "(<style.+?</style>)|(<script.+?</script>)", "", RegexOptions.IgnoreCase | RegexOptions.Singleline);
        source = Regex.Replace(source, "(<img.+?>)", "", RegexOptions.IgnoreCase | RegexOptions.Singleline);
        source = Regex.Replace(source, "(<o:.+?</o:.+?>)", "", RegexOptions.IgnoreCase | RegexOptions.Singleline);
        source = Regex.Replace(source, "<!--.+?-->", "", RegexOptions.IgnoreCase | RegexOptions.Singleline);
        source = Regex.Replace(source, "class=.+?>", ">", RegexOptions.IgnoreCase | RegexOptions.Singleline);

        return source = Regex.Replace(source.Replace(System.Environment.NewLine, "<br/>"), "<[^(a|img|b|i|u|ul|ol|li)][^>]*>", " ");

    }

SQL query maximum time execution check

SELECT TOP 20
    qs.total_elapsed_time / qs.execution_count / 1000000.0 AS average_seconds,
    qs.total_elapsed_time / 1000000.0 AS total_seconds,
    qs.execution_count,
    SUBSTRING (qt.text,qs.statement_start_offset/2,
         (CASE WHEN qs.statement_end_offset = -1
            THEN LEN(CONVERT(NVARCHAR(MAX), qt.text)) * 2
          ELSE qs.statement_end_offset END - qs.statement_start_offset)/2) AS individual_query,
    o.name AS object_name,
    DB_NAME(qt.dbid) AS database_name
FROM sys.dm_exec_query_stats qs
    CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) as qt
    LEFT OUTER JOIN sys.objects o ON qt.objectid = o.object_id
WHERE qt.dbid = DB_ID()
ORDER BY average_seconds DESC;

Monday, 15 May 2017

SQL Query Indian all bank and loop example

CREATE TABLE dbo.M_Bank
(
ID           INT IDENTITY NOT NULL,
MB_NAME      NVARCHAR (50),
MB_SNAME     NVARCHAR (20),
MB_ADDUSER   INT,
MB_ADDDate   DATETIME CONSTRAINT DF_M_Bank_MB_ADDDate DEFAULT (getdate()),
MB_MODUSER   INT,
MB_MODDate   DATETIME,
MB_ISActive  BIT CONSTRAINT DF_M_Bank_ISActive DEFAULT ((1)),
MB_ISDeleted BIT CONSTRAINT DF_M_Bank_ISDeleted DEFAULT ((0)),
MB_IP        VARCHAR (30),
CONSTRAINT PK_M_Bank PRIMARY KEY (ID)
)
GO

--Create Function
CREATE FUNCTION [dbo].[nop_splitstring_to_table]
(
    @string NVARCHAR(MAX),
    @delimiter CHAR(1)
)
RETURNS @output TABLE(
    data NVARCHAR(MAX)
)
BEGIN
    DECLARE @start INT, @end INT
    SELECT @start = 1, @end = CHARINDEX(@delimiter, @string)

    WHILE @start < LEN(@string) + 1 BEGIN
        IF @end = 0
            SET @end = LEN(@string) + 1

        INSERT INTO @output (data)
        VALUES(SUBSTRING(@string, @start, @end - @start))
        SET @start = @end + 1
        SET @end = CHARINDEX(@delimiter, @string, @start)
    END
    RETURN
END

GO



DECLARE @BankNameDetails NVARCHAR(4000)=
'Axis Bank,Allahabad Bank,American Express,Andhra Bank,Arab Bangladesh,Bank of Baroda India,Bank Muscat,Bank of America
Bank of India,Bank of Maharashtra,Bank of Punjab,Bank of Rajasthan,Barclays Bank PLC,Bharat Overseas,Canara Bank,Catholic Syrian
,Centurion,Ceylon,Citibank,Corporation,Cosmos Co-operative Bank,DBS,Dena,Deutsche Bank,Development Credit,
Dhanlakshmi,Export-Import Bank Of India,Federal Bank India,Global Trust,HDFC,Hongkong Shanghai Banking,
ICICI Bank,IDBI Bank,Ind Bank Housing,Indian Overseas,IndusInd Bank,Industrial Development,ING Vysya,Jammu and Kashmir
,JP Morgan Chase,Karnataka,Karur vysya,Kotak Mahindra,Lakshmi Vilas,Lord Krishna,Mizuho Corporate,Mudra Bank,
The Nainital Bank Ltd.,North Knara G.S.B. Co-op.,Oriental Bank of Commerce,Punjab and Sind,Punjab National,Ratnakar,
Reserve Bank of India,Royal Bank of Scotland,SBI Commercial,Shamrao Vithal Co-operative,South Indian,
Standard Chartered,State Bank Of Bikaner & Jaipur,State Bank of Hyderabad,State Bank of India,State Bank of Indore,
State Bank of Mysore,State Bank of Patiala,State Bank of Travancore,Syndicate Bank,Tamilnad Mercantile,Union Bank Of India,
UCO Bank,United Bank of India,Vijaya Bank,Yes Bank'

SELECT row_number() OVER(ORDER BY data ASC) AS ROWnno,  data into #temp FROM dbo.nop_splitstring_to_table (@BankNameDetails, ',')

DECLARE @MB_NAME NVARCHAR(50)='Allahabad Bank'


DECLARE @TOTALV BIGINT
DECLARE @InitialValue BIGINT
SET @InitialValue=1
SET @TOTALV=12
SELECT @TOTALV=Count(*) from #temp
WHILE (@InitialValue<=@TOTALV)
BEGIN
SELECT @MB_NAME=data  from #temp WHERE ROWnno=@InitialValue
IF NOT exists(SELECT 1 FROM M_Bank WHERE MB_NAME=@MB_NAME)
BEGIN
INSERT INTO dbo.M_Bank (MB_NAME, MB_SNAME, MB_ISActive, MB_ISDeleted, MB_IP)
VALUES (rtrim(ltrim(@MB_NAME)), '', 1, 0, '127.0.0.1')
SELECT -200
END
print @InitialValue
SET @InitialValue=@InitialValue+1
END
drop table #temp


Thursday, 13 April 2017

Resignation Letter Format

[Director Name]
Director
[Company Address]

Dear Sir


Due to some unavoidable circumstances on personal reasons, I hereby tender my resignation to the post of [Post] with effect from [effect date].
I shall be serving a Notice Period of [notice days] days.
My last working day would be [Last working date].
After serving for almost 1 year, I have gained immensely from the knowledge and experience. I must admit that I take lot of good things from here, which should take me too much higher levels.

It was fantastic working with [company Name]  and I take this opportunity to thank my colleagues. The associations I've made during my employment here will truly be memorable for years to come.

I request the authorities kindly to accept my resignation with effect from [Last working date] Thank you very much for the opportunity to work here.

Sincerely,



Ashish Kumar Srivastava
Sr. Software Engineer

Wednesday, 22 March 2017

Get size of all tables in database


SELECT
    t.NAME AS TableName,
    s.Name AS SchemaName,
    p.rows AS RowCounts,
    SUM(a.total_pages) * 8 AS TotalSpaceKB,
    SUM(a.used_pages) * 8 AS UsedSpaceKB,
 (SUM(a.total_pages) - SUM(a.used_pages)) * 8   AS UnusedSpaceKB,
    (SUM(a.total_pages) - SUM(a.used_pages)) * 8 /1024 AS UnusedSpaceMB
FROM
    sys.tables t
INNER JOIN    
    sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN
    sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN
    sys.allocation_units a ON p.partition_id = a.container_id
LEFT OUTER JOIN
    sys.schemas s ON t.schema_id = s.schema_id
WHERE
    t.NAME NOT LIKE 'dt%'
    AND t.is_ms_shipped = 0
    AND i.OBJECT_ID > 255
GROUP BY
    t.Name, s.Name, p.Rows
ORDER BY
    t.Name

Tuesday, 14 February 2017

Linear Search Program In C For Multiple Occurrences

  1. #include <stdio.h>  
  2. #include <conio.h>   
  3. void main()  
  4. {  
  5.    int array[100], search, i, n, count = 0;  
  6.    
  7.    printf("Enter the number of elements in array\n");  
  8.    scanf("%d", &n);  
  9.    
  10.    printf("Enter %d numbers\n", n);  
  11.    
  12.    for ( i = 0 ; i < n ; i++ )  
  13.     {  
  14.             scanf("%d", &array[i]);  
  15.         }  
  16.   
  17.    printf("Enter the number to search\n");  
  18.    scanf("%d", &search);  
  19.    
  20.    for (i = 0; i < n; i++) {  
  21.       if (array[i] == search) {  
  22.          printf("%d is present at location %d.\n", search, i+1);  
  23.      count++;  
  24.       }  
  25.    }  
  26.    if (count == 0)  
  27.       printf("%d is not present in array.\n", search);  
  28.    else  
  29.       printf("%d is present %d times in array.\n", search, count);  
  30.    
  31.     getch();  
  32. }  

Saturday, 21 January 2017

Color code name and values

Color code name and values

Color NameHEXColorShadesMix
AliceBlue #F0F8FF ShadesMix
AntiqueWhite #FAEBD7 ShadesMix
Aqua #00FFFF ShadesMix
Aquamarine #7FFFD4 ShadesMix
Azure #F0FFFF ShadesMix
Beige #F5F5DC ShadesMix
Bisque #FFE4C4 ShadesMix
Black #000000 ShadesMix
BlanchedAlmond #FFEBCD ShadesMix
Blue #0000FF ShadesMix
BlueViolet #8A2BE2 ShadesMix
Brown #A52A2A ShadesMix
BurlyWood #DEB887 ShadesMix
CadetBlue #5F9EA0 ShadesMix
Chartreuse #7FFF00 ShadesMix
Chocolate #D2691E ShadesMix
Coral #FF7F50 ShadesMix
CornflowerBlue #6495ED ShadesMix
Cornsilk #FFF8DC ShadesMix
Crimson #DC143C ShadesMix
Cyan #00FFFF ShadesMix
DarkBlue #00008B ShadesMix
DarkCyan #008B8B ShadesMix
DarkGoldenRod #B8860B ShadesMix
DarkGray #A9A9A9 ShadesMix
DarkGrey #A9A9A9 ShadesMix
DarkGreen #006400 ShadesMix
DarkKhaki #BDB76B ShadesMix
DarkMagenta #8B008B ShadesMix
DarkOliveGreen #556B2F ShadesMix
Darkorange #FF8C00 ShadesMix
DarkOrchid #9932CC ShadesMix
DarkRed #8B0000 ShadesMix
DarkSalmon #E9967A ShadesMix
DarkSeaGreen #8FBC8F ShadesMix
DarkSlateBlue #483D8B ShadesMix
DarkSlateGray #2F4F4F ShadesMix
DarkSlateGrey #2F4F4F ShadesMix
DarkTurquoise #00CED1 ShadesMix
DarkViolet #9400D3 ShadesMix
DeepPink #FF1493 ShadesMix
DeepSkyBlue #00BFFF ShadesMix
DimGray #696969 ShadesMix
DimGrey #696969 ShadesMix
DodgerBlue #1E90FF ShadesMix
FireBrick #B22222 ShadesMix
FloralWhite #FFFAF0 ShadesMix
ForestGreen #228B22 ShadesMix
Fuchsia #FF00FF ShadesMix
Gainsboro #DCDCDC ShadesMix
GhostWhite #F8F8FF ShadesMix
Gold #FFD700 ShadesMix
GoldenRod #DAA520 ShadesMix
Gray #808080 ShadesMix
Grey #808080 ShadesMix
Green #008000 ShadesMix
GreenYellow #ADFF2F ShadesMix
HoneyDew #F0FFF0 ShadesMix
HotPink #FF69B4 ShadesMix
IndianRed  #CD5C5C ShadesMix
Indigo  #4B0082 ShadesMix
Ivory #FFFFF0 ShadesMix
Khaki #F0E68C ShadesMix
Lavender #E6E6FA ShadesMix
LavenderBlush #FFF0F5 ShadesMix
LawnGreen #7CFC00 ShadesMix
LemonChiffon #FFFACD ShadesMix
LightBlue #ADD8E6 ShadesMix
LightCoral #F08080 ShadesMix
LightCyan #E0FFFF ShadesMix
LightGoldenRodYellow #FAFAD2 ShadesMix
LightGray #D3D3D3 ShadesMix
LightGrey #D3D3D3 ShadesMix
LightGreen #90EE90 ShadesMix
LightPink #FFB6C1 ShadesMix
LightSalmon #FFA07A ShadesMix
LightSeaGreen #20B2AA ShadesMix
LightSkyBlue #87CEFA ShadesMix
LightSlateGray #778899 ShadesMix
LightSlateGrey #778899 ShadesMix
LightSteelBlue #B0C4DE ShadesMix
LightYellow #FFFFE0 ShadesMix
Lime #00FF00 ShadesMix
LimeGreen #32CD32 ShadesMix
Linen #FAF0E6 ShadesMix
Magenta #FF00FF ShadesMix
Maroon #800000 ShadesMix
MediumAquaMarine #66CDAA ShadesMix
MediumBlue #0000CD ShadesMix
MediumOrchid #BA55D3 ShadesMix
MediumPurple #9370D8 ShadesMix
MediumSeaGreen #3CB371 ShadesMix
MediumSlateBlue #7B68EE ShadesMix
MediumSpringGreen #00FA9A ShadesMix
MediumTurquoise #48D1CC ShadesMix
MediumVioletRed #C71585 ShadesMix
MidnightBlue #191970 ShadesMix
MintCream #F5FFFA ShadesMix
MistyRose #FFE4E1 ShadesMix
Moccasin #FFE4B5 ShadesMix
NavajoWhite #FFDEAD ShadesMix
Navy #000080 ShadesMix
OldLace #FDF5E6 ShadesMix
Olive #808000 ShadesMix
OliveDrab #6B8E23 ShadesMix
Orange #FFA500 ShadesMix
OrangeRed #FF4500 ShadesMix
Orchid #DA70D6 ShadesMix
PaleGoldenRod #EEE8AA ShadesMix
PaleGreen #98FB98 ShadesMix
PaleTurquoise #AFEEEE ShadesMix
PaleVioletRed #D87093 ShadesMix
PapayaWhip #FFEFD5 ShadesMix
PeachPuff #FFDAB9 ShadesMix
Peru #CD853F ShadesMix
Pink #FFC0CB ShadesMix
Plum #DDA0DD ShadesMix
PowderBlue #B0E0E6 ShadesMix
Purple #800080 ShadesMix
Red #FF0000 ShadesMix
RosyBrown #BC8F8F ShadesMix
RoyalBlue #4169E1 ShadesMix
SaddleBrown #8B4513 ShadesMix
Salmon #FA8072 ShadesMix
SandyBrown #F4A460 ShadesMix
SeaGreen #2E8B57 ShadesMix
SeaShell #FFF5EE ShadesMix
Sienna #A0522D ShadesMix
Silver #C0C0C0 ShadesMix
SkyBlue #87CEEB ShadesMix
SlateBlue #6A5ACD ShadesMix
SlateGray #708090 ShadesMix
SlateGrey #708090 ShadesMix
Snow #FFFAFA ShadesMix
SpringGreen #00FF7F ShadesMix
SteelBlue #4682B4 ShadesMix
Tan #D2B48C ShadesMix
Teal #008080 ShadesMix
Thistle #D8BFD8 ShadesMix
Tomato #FF6347 ShadesMix
Turquoise #40E0D0 ShadesMix
Violet #EE82EE ShadesMix
Wheat #F5DEB3 ShadesMix
White #FFFFFF ShadesMix
WhiteSmoke #F5F5F5 ShadesMix
Yellow #FFFF00 ShadesMix
YellowGreen #9ACD32 ShadesMix

Upload valid file in C#

    protected bool CheckFileExtandLength(HttpPostedFile HtmlDocFile)     {         try         {             Dictionary<string, byte[]...