Wednesday, June 10, 2020

LWC - navigation in lightning community

Hello
I recently started working on the LWC framework, which is the next version of aura framework.
today i came across a situation where I have to navigate to different pages or list views from the home page and I started using the different options and found below one working.



 Html

Tuesday, October 25, 2016

Journey to Salesforce

Hello Guys,

Thanks for following me. till now you have seen all .NET related post on my blog.

going forward you will also see salesforce related post in my blog. I have recently started learning the salesforce. I'll keep posting tips / tricks and useful notes through this channel.

so stay tune and follow me on this new journey. Thank you ..


Saturday, June 7, 2014

Jquery shake effect - part 2

Hurrey 100th post , and again on Jquery :)


Jquery shake effect is very popular & more searchable topic now a days.

Long back i had written a post on jquery shake effect. this is my part 2 post where here I'm going to explain what all method and what option you may find in
JRumble plugin
 
You must have seen that vibrant, rotate, shake and many other elements of effects. using css and other scripting language you can create more eye catch able effects.

JRumble is new plugin which has more elements on effects. it also a good plugin with hover and direction effect.

Below are few objects


  $('imgName').jrumble();
  // you may stop the elements like this way
  $('imgName').trigger('stopRumble');


You many even customize this options with below attributes:


Rotation : set the range , default is 1


Speed : set  frequency or speed between the two movements


X : set horizontal pixels


Y : set vertical pixels


and there are many other elements. 


The below code shows the example along with basic functionality.




$(document).ready(function() {
    $('ImageName').jrumble({
        y:4,
        x:3,
        rotation: 10,
    speed:500,
    opacity:100
    });

    $('ImageName').hover(function() {
        $(this).trigger('startRumble');
    }, function() {
        $(this).trigger('stopRumble');
    });
});​



See the below example :


Sunday, January 26, 2014

which binding we used for WCF REST protocol

In my previous post i explained, Interview question and few details on WCF. and Transaction in WCF  Now in this article i will explain which binding used during the WCF REST protocol. 


most of the time this question may asked during the interview , Yes its simple. 

For WCF REST used WebHttpBinding. You may enabled WebHttpBinding by as shown in the below code snippet.

    <endpointBehaviors>
            <behavior name="NewBehavior0">       
            <webHttp />
            </behavior>
    </endpointBehaviors>
 You can find more details here.


Saturday, December 28, 2013

Transactions in WCF

In my previous post i explained, Interview question and few details on WCF. Now in this article i will explain how WCF Transaction protocol.

Transaction is an important factor in any business application which contain CRUD operations. Here in WCF we have TransactionScope class which basically manages the transaction and also detech the transaction scope.


for ex. If your calling multiple methods and if any of method fails, then entire transaction will be rolled back unless its outside boundary of Scope.
WCF supports transaction on below bindings.
 
1.  WSHttpBinding
2.  WSFederationHttpBinding
3.  NetNamedPipeBinding
4.  NetTcpBinding
5.  WSDualHttpBinding



You need to specify the TransactionFlow attribute on all the contracts where it required transaction to be handled. where we have to specified that transaction are allowed for this specific method by assigning enum as 'TransactionFlowOption.Allowed'  

[ServiceContract]

public interface IUserDetails

{

    [OperationContract]

    [TransactionFlow(TransactionFlowOption.Allowed)]

    public void DeleteUserData();   
    [OperationContract]

    [TransactionFlow(TransactionFlowOption.Allowed)]

    public void UpdateUserData();   

}

there are following option present in TransactionFlow attribute.
TransactionFlowOption.Allowed :Transaction can be flowed.
TransactionFlowOption.NotAllowed: Transaction should not be flowed. This is default.
TransactionFlowOption.Mandatory: Transaction must be flowed.
 


Now implementing 'TransactionScopeRequired' attribute on specific method.

[OperationBehavior(TransactionScopeRequired = true)]
public void UpdateUserData()
{
  // database call goes here.
}

Once the scope assing, the last process will be enabling the transaction flow in config file.
 

Now consume the service by calling the UpdateUserData method and assign the scope block which check if the transaction method fails, if so then it will automatically rollback it.


using (TransactionScope Transcope = new TransactionScope())
{
  try
  {
   Services.UserDetailsService.UserDetailsServiceClient()
   clientVal = new Services.UserDetailsService.UserDetailsServiceClient();


   // code goes here to call method and assing the value.
   scope.Complete();
 }
catch (Exception ex)
{
scope.Dispose();

}

I know this will helps to understand the concepts of transaction in WCF , if you have any query or suggestion please put your comments to know more.
 

Saturday, December 21, 2013

Change schema name of tables, store procedure, views and functions

Today i come across one situation where i need to changes my current SQL schema to some other name. due to client requirement.so i searched few article and decided to write one article on same

Below query will returns list of all tables along with the schema name from your database.



SELECT TABLE_SCHEMA, TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES


If you want to add new schema you need to add that into sys.schemas table then only it will be accessible else it will give an error message as 


 Cannot alter the schema 'xxx', because it does not exist or you do not have permission.
 

IF (NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'Excprod'))
BEGIN
    EXEC ('CREATE SCHEMA [Excprod] AUTHORIZATION [dbo]')
END

You can also view list of schema from below query and you will find new schema "Excprod" get added.

SELECT * FROM sys.schemas

Now, below query used to alter the scheme tables

ALTER SCHEMA Excprod TRANSFER dbo.Temp1
ALTER SCHEMA Excprod TRANSFER dbo.Temp2
ALTER SCHEMA Excprod TRANSFER dbo.temp3


You may also alter the schema for store procedure as well. to find the list of all store procedures from your
database just use.



select * from information_schema.routines
where routine_type = 'PROCEDURE'


below query will generate the select statement for all list of sp



select 'ALTER SCHEMA Excprod TRANSFER ' + SPECIFIC_SCHEMA + '.' + ROUTINE_NAME
from INFORMATION_SCHEMA.ROUTINES where ROUTINE_TYPE='procedure'
Result will be :


ALTER SCHEMA Excprod TRANSFER synprod.Usp_Response
ALTER SCHEMA Excprod TRANSFER synprod.Usp_Request


To view list of view from database use this


SELECT * FROM information_schema.VIEWS


Please comment if you want more details on this.

Wednesday, December 11, 2013

Interview questions on WCF


Today i would like to share something about WCF, This is my first post on Windows Communication Foundation (WCF). since last 1 year i worked on WCF, so i would like to share my experience/points with you.
First will see what exactly mean by WCF . It's Microsoft programming model which helps for building service-oriented application. where we can send/ received the data asynchronously. service endpoint is the main channel where client can request data.

It has very good features :

1. Extensibility
2. Interoperability
3. Data Contracts
4. Security
5. Transactions
6. AJAX and REST Support
You may refer more about wcf here
 
 
Below interview question helps you to know more about WCF.
 
1.How session management worked in WCF?
answer - WCF manage the session by instanciating the service class. It basically used the Instance Context class to manage the server side at server side. you can refer more about Session management in WCF.


 
2. Is overloading possible in WCF? and How?
Yes method overloading is possbile in WCF. But yes it will raise the error as contract mismatch during method overload.
By providing the unique operationcontract name you can resolved that issue. It has Name property which expose the wcf method to schemas.
Look at the below example.
 
[ServiceContract]

public interface ICalculate
{

    [OperationContract(Name="ADD")]
    string methodName(int x,int y);
    

    [OperationContract(Name = "DISPLAY")]
    string methodName(string val1, string val2);
}
 
all the method get called by their attribute name and parameter value. 
for ex
ClientApp client = new ClientApp();
           
string method1 = client.methodName(1, 1);

string method2 = client.methodName("sample1", "sample2");

3.how to track no of visit to your service.
WCF has very good feature which enable us to manage the service call. with the help of this you can easily track the count. extension point is used.


4. list types of binding and have you worked on netMsmqBinding or netNamedPipeBinding ?
 
 
If you know more unique questions, please do share it.

Saturday, November 23, 2013

creating word documents using open xml with asp.net

Now in this article i will explain how to use the Office Open XML C# (alternate solution to the Interop object. 

The Open XML provides you set of .NET API. It helps helps you manipulate and creating the documents in the Open XML Formats
in both the environments (i.e client and server both) and that is without help of MS office applications.

Before using Open XML Format, you have to add the below namespaces in your C# class. Add references to the Packaging and Spreadsheet API components with the following code.
 
 
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
 
Here is the CreateOpenXmlDocument function where you need to pass the filepath and it will created that doc file on specified positionl
 
public void CreateOpenXmlDocument(string filepath)
{
    
 using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(filepath, WordprocessingDocumentType.Document))
  {
    // Add a main document part.
    MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();

    mainPart.Document = new Document();
    Body body = mainPart.Document.AppendChild(new Body());
    Paragraph para = body.AppendChild(new Paragraph());
    Run run = para.AppendChild(new Run());
    run.AppendChild(new Text("Create text sample text, coding stuffs daily..."));
  }
}



Here now i am integrating that function into my page_load event.


protected void Page_Load(object sender, EventArgs e)
{

      string FilePath =  @"C:\\Temp";
      CreateWordprocessingDocument(FilePath);

      FileInfo myDoc = new FileInfo(FilePath);
      Response.Clear();
      Response.ContentType = "Application/msword";
      Response.AddHeader("content-disposition", "attachment;filename=" + myDoc.Name);
      Response.AddHeader("Content-Length", myDoc.Length.ToString());
      Response.ContentType = "application/octet-stream";
      Response.WriteFile(myDoc.FullName);
      Response.End();

}
 
 
This is just an sample doc creation , you may even format the document with adding images, graphs, style to para and may more. Just refer this Microsoft article on how to do this. 

feel free to raise your suggestion/comments on this. Thanks you and happy coding....


 
 
 

Tuesday, November 12, 2013

Microsoft.Office.Interop.Word how to prevent word file opening

In my previous post i explained, how to Convert the dataset to xml string using  C# and asp.net
Now in this article i will explain how to prevent the word file opening, i have bunch of word document and i want to read/search text value out of it.  i tried that using Microsoft.office.Interop.Word object. 

Here is the sample code which prevent the word to opening the main window.
private void PreventOpenWord(string Filepath)
{
 Application word = new Application();
 FileInfo fileInfo = (FileInfo)file;


object save = false;
object confirmConversion = false;
object visible = false;
object skipEncodingDialog = true;
object readOnly = true;
object filename = fileInfo.FullName;

word.Visible = false;

Document srcDoc = word.Documents.Open(ref Filepath, ref confirmConversion, ref readOnly, ref missing,
    ref missing, ref missing, ref missing, ref missing,
    ref missing, ref missing, ref missing, ref visible,
    ref missing, ref missing, ref skipEncodingDialog, ref missing);




foreach (Microsoft.Office.Interop.Word.Range docRange in doc.Words)
{
if (docRange.Text.Trim().Equals(textToFind,
StringComparison.CurrentCultureIgnoreCase))
{
  
IsWordFound = true;
break;
}
}
}
catch (Exception ex)
{
 Response.Write("Error while reading file : " + ex.Message);
}
}


Hope this will helps you.. Happy  coding.. 

Sunday, October 27, 2013

Convert Dataset to xml string using C#


In my previous post i explained, Save images to database using SQL. Count string occurrence and much more articles realted with asp.net, SQL. Now in this article i will going to explain how to Convert the dataset to xml string using  C# and asp.net 

below is the short and sweet way to convert the dataset into xml.


DataSet dsUser = new DataSet();

SqlCommand cmdSelect = new SqlCommand("select name,age,location,ph,cell,status from userDetails ", conn);

SqlDataAdapter sda = new SqlDataAdapter(cmdSelect);

da.Fill(dsUser);

string strUserDetails = dsUser.GetXml();

Its very simple and easy method. Please post your comments for any suggestion.

Saturday, October 19, 2013

Access content of iframe using jquery



It's very simple and straightforward.

Lets say, your using iframe and hello.aspx page like




1. < iframe id="frametemp" height="20px" width="90px"> </iframe>

which contain some control likes



2. <div id="divDisplayBox" > Say, Hello world! </div>

you can use .contents() method to find the specific id and like

3. $('#frametemp').contents().find('#divDisplayBox').html();

Hope this will helps you, Put your comments/suggestion if any.



 

Saturday, September 28, 2013

Save images to database using SQL


Most of the time we want to save store/save images to database. In order to store image on sql server we need to store that in binary format. the most easiest way to do so in execute the SQL OPENROWSET command with SINGLE BLOB & BULK options.


Let's create one sample table and insert the sample result in it.


create table imageSave
(
   [img_name] varchar(250),
   [Img_binary] varbinary(max)
)

will insert some sample result into the imageSave table.

Insert into imageSave

SELECT 'SAMPLE Image', *

FROM OPENROWSET(BULK N'F:\Images\sample-test.jpg', SINGLE_BLOB) image;

Admin(sa) & developer has rights to work with OPENROWSET command.



Tuesday, September 24, 2013

Find Header & Footer template from Repeater control in .Net



This article will explain you how to find the Repeater Header and Footer template details.

I had created one user control which contain the Repeater. It generate the product showcase. i used that control in multiple pages but some where i need to update few details like header title , footer text at run time and that i have achieved it through find control.
Below example can helps you to understand the clear idea.


<asp:Repeater ID="ProductsDetails" runat="server">  
<HeaderTemplate> 
     <asp:Label ID="lblProductDetails" runat="server" Fore-Color= "Red"  Font-Bold = "true" />
 <br />  
</HeaderTemplate>  
<ItemTemplate>      
 Product Name : <%#Eval("Name") %> <br />  
</ItemTemplate>  
<FooterTemplate>      
 <asp:Label ID="lblPriceDetails" runat="server" Fore-Color= "Green" Font-Bold = "true" />  
</FooterTemplate>
</asp:Repeater>


Here i have define repeater control along with header & footer details , now i want to change the text of label called "lblProductDetails" at run-time. below snippets will helps you to get the Repeater details and base on that you can easily find the footer  & header controls  and change the text.


//Find HeaderTemplate
   Control TempHeaderDet = ProductsDetails.Controls[0].Controls[0];      
   Label lblHeaderDet = TempHeaderDet.FindControl("lblProductDetails") as Label;      
   lblHeaderDet.Text = "Product Description :";

//Find FooterTemplate

   Control FooterTemplateDet = ProductsDetails.Controls[ProductsDetails.Controls.Count - 1].Controls[0];            
   Label lblFooterDet = FooterTemplateDet.FindControl("lblPriceDetails") as Label;      
   lblFooter.Text = "Product Price:";



Yeap, i know its not very big deal... but yes some time this trick will helps you and save time as well. 

put your comments/ question in case of any concerns.

 

Friday, September 6, 2013

Andriod KitKat

Yes, once again andriod version has been named base on dessert.

after the cupcake, donut, Gingerbread, ice-cream sandwish and jelly beans. new decided name of next version of andriod as favourite chocolate "Kit Kat".

Android 4.4 KitKat

As andriod says people can easily remember such name because they can't leave without chocoates. :)

Here are the some versions of Android in Pictures













    Looks good, isn't it?   Post your comments and queries to know more about KitKat

Saturday, January 19, 2013

C# zip unzip using window shell

If you want to zip / unzip files using C# code .yes its easy and you can do that without using any third party tools. using simple dll (Windows Shell32) you can do that quickly.

Just find below steps.

1.Create new project in Visual Basic 2010.
2.From the main menu, select Project -> Add Reference.
3.Select the COM tab and search for Microsoft Shell Controls and Automation.  



 Try using below code and zip/unzip your code.

Public Class Form1
 
    Sub Zip()
        '1) Lets create an empty Zip File .
        'The following data represents an empty zip file .

        Dim startBuffer() As Byte = {80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, _
                                     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} 
        ' Data for an empty zip file .
        FileIO.FileSystem.WriteAllBytes("d:\empty.zip", startBuffer, False)
 
        'We have successfully made the empty zip file .

        '2) Use the Shell32 to zip your files .
        ' Declare new shell class
        Dim sc As New Shell32.Shell()
        'Declare the folder which contains the files you want to zip .
        Dim input As Shell32.Folder = sc.NameSpace("D:\neededFiles")
        'Declare  your created empty zip file as folder  .
        Dim output As Shell32.Folder = sc.NameSpace("D:\empty.zip")
        'Copy the files into the empty zip file using the CopyHere command .
        output.CopyHere(input.Items, 4)
 
    End Sub
 
    Sub UnZip()
        Dim sc As New Shell32.Shell()
        ''UPDATE !!
        'Create directory in which you will unzip your files .
        IO.Directory.CreateDirectory("D:\extractedFiles") 
        'Declare the folder where the files will be extracted
        Dim output As Shell32.Folder = sc.NameSpace("D:\extractedFiles")
        'Declare your input zip file as folder  .
        Dim input As Shell32.Folder = sc.NameSpace("d:\myzip.zip")
        'Extract the files from the zip file using the CopyHere command .
        output.CopyHere(input.Items, 4)
 
    End Sub
 
End Class
 

Sunday, May 6, 2012

delete existing store procedure and tables

Delete all existing database use this scripts.
    
DECLARE @Sql NVARCHAR(500) DECLARE @Cursor CURSOR
SET @Cursor = CURSOR FAST_FORWARD FOR
SELECT DISTINCT sql = 'ALTER TABLE [' + tc2.TABLE_NAME + '] DROP [' + rc1.CONSTRAINT_NAME + ']'
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc1
LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc2 ON tc2.CONSTRAINT_NAME =rc1.CONSTRAINT_NAME
OPEN @Cursor FETCH NEXT FROM @Cursor INTO @Sql
WHILE (@@FETCH_STATUS = 0)
BEGIN
Exec SP_EXECUTESQL @Sql
FETCH NEXT FROM @Cursor INTO @Sql
END
CLOSE @Cursor DEALLOCATE @Cursor
GO
EXEC sp_MSForEachTable 'DROP TABLE ?
GO



if you want to delete all existing store procedure use this scripts.



DECLARE @procedureName varchar(500)
DECLARE cur CURSOR
      FOR SELECT [name] FROM sys.objects WHERE type = 'p'
      OPEN cur

      FETCH NEXT FROM cur INTO @procedureName
      WHILE @@fetch_status = 0
      BEGIN
            EXEC('DROP PROCEDURE ' + @procedureName)
            FETCH NEXT FROM cur INTO @procedureName
      END
      CLOSE cur
      DEALLOCATE cur
 
Hope it will help you :)


Monday, March 28, 2011

Export Gridview to PDF

we have seen how to export the data from gridview to Excel file, today this post will helps you to export the gridview data to PDF, if you want protect you data being edit/ cut/ delete then Export to PDF will be a better option for you.there is a open source project for iTextShart. you can download the dll from them and you can use it.

only you need to add this content on your page

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment; filename= SampleExport.pdf");
Response.End();


Even you can format the text also,if you want to set the page with A4 or any other even you can also do the same.you can also specify the font size, style color all the basic things you can do with it.

you can download the code from the below link. you can try that it will helps you.

download Source

Sunday, July 18, 2010

how to add related posts on Blogger

we have seen on most of the blogger site , "Related post" section is there after every post now you want to add this Related post / Similar post on your blog ? follow the below easy steps and configure you blogger accordingly.

  • Open blogger.com site

  • Go to Design section under that you will get Edit Html Tab just click on it.

  • now before making any changes on your xml file just take abackup for safty

  • just click on "Expand widget templates "

  • Add the below code above the </head > section or better way is search the keyword </head>

    <script src='https://www.opendrive.com/files/6673148_cnSMd/RelatedPosts_Blogger.js' type='text/javascript'/>


  • now search for code <data:post.body/>

  • After this paste the below code line



  • <b:if cond='data:blog.pageType == "item"'>
    <div id='related-posts'>
    <font face='Arial' size='3'><b>Related Posts: </b></font><font color='#000000'><b:loop values='data:post.labels' var='label'><data:label.name/><b:if cond='data:label.isLast != "true"'>,</b:if><b:if cond='data:blog.pageType == "item"'>
    <script expr:src='"/feeds/posts/default/-/" + data:label.name + "?alt=json-in-script&callback=related_results_labels&max-results=5"' type='text/javascript'/></b:if></b:loop> </font>
    <script type='text/javascript'> removeRelatedDuplicates(); printRelatedLabels();
    </script></div></b:if>



  • now on the above code you will see the red section line "max-results=xx" here you can enter no of post you want to see on your page
    accordingly you can mention it.

  • now save you template and see the magic on your post

  • you will see the number of post after each article , before that you need to add label on your post. hope you like it


  • if you face any problem while doing this plz leave a comment.

Friday, June 11, 2010

How strong name assemblies keep you out of DLL Hell

while using Microsoft .NET framework for creating any application we are previously facing same problem with the DLL Hell. it arises a problem while updating a components so it breaks the other application which are depend on it. to overcome such a issues developer needs to implement the concept of Strong name .In this article you can through with how and why to use strong name .

Strong Name :
what is strong name? A Strong name is of information used to identify the assembly which may consist of Text-name , four part of version number , culture information , public key and the digital signature which may stored in a assembly manifest that get embedded on the file of the assembly.

By using the Strong name the CLR can assured that two assembly can be there with the same name. by the way strong name is basically provided the unique identification of the assembly. there are two scenarios in which the strong name can included in the assembly
1.Shared Assemblies
2. Serviced Components.

on the first case the shared assemblies can be used in the multiple application which may running on the same machine on GAC. and you may get the benefit ares:
1. Single Development
2. Bypass verification
3. Centralized update

yes as your getting such a good benefits then surely there is also a some issues on it that is
1.calling a private assemblies : if the shared assemblies can load with the type of private assembly then CRL will throw an Error because it reference only shared assemblies.
2. Trusting assemblies :
3. Installation issues :

How to create "Strong Name".
To create strong name for assembly you need a (al.exe) tool which is a assembly generation tool .now to create a key pair in the file you can use Strong name utility (Sn.exe) like this way.
Sn.exe -k filename.dat

The key file could be used on Al.exe to generate the strong name.
Al.exe /out:Input.dll /Keyfile:output.dat

Like this way you can design your strong name with the key. hope you get something from this
if you have any query on it plz post the reply.

Sunday, April 25, 2010

my oracle interview experience

hi friends,

last week i was attended "ORACLE financial services" interview for the .NET Developer post. Here i am sharing my experience on interview hope so it will help you while going for an Oracle Interview. i was disqualify from 3rd Round (Final Technical Round).

Interview Process:
There was 4 Round 1 st Online Test ( 47 Question 1 hrs ) but be careful there is also a negative marking as well as there is also a cutoff (if u select more than 1 answer and answer is wrong ) then again some deduction on your marks . Quite tough mostly Question on Assembly , Framework , C# , then hardly question on Datalist,Datagrid, Gridview and all basic. we totally 3 people get selected in first round out of 10.

Second Round is Technical Round. it was ok only basic question get ask during the interview , but in most of them are in-depth question just like on DataGrid DataBind() wht happen exactly , which function get executed at first onRowDataBound() or DataBind(). how .net life cycle will work on this process and all . i also got selected on this round .

now There was a Final Round on again Technical . There was 2 panelist in front of me and asking question on most of the SDLC (Software Development Life Cycle) and Question on backed on Pl-sql / SQL2005 . i thing around 15+ question get ask during the interview process i have answer most of them . but interview was cool .

at last there was an only final Round Remaining which is HR Round. but sorry to say friends i was disqualified from this process (2nd Technical Round). hope my this experience will help you to get it in ORACLE or any other software farm .because most of the time same process is there every where .

hope i will get good company out of this. better luck next time .but one thing is sure i am getting very good experience from this.