Wednesday, July 30, 2014

The thread '<No Name>' (0x12f8) has exited with code 0 (0x0). on await

Issue on Await: The thread '<No Name>' (0x12f8) has exited with code 0 (0x0). on await

This is thread deadlock issue. To avoid this issue, you should use ConfigureAwait(false) to make the runtime continue in a different thread.

await Task.WhenAll(aAsync, bAsync).ConfigureAwait(false);


The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Today I was working on Asp.net 4.5 website and I got following error:

The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

I have solved this issue by adding one line in web.config file:

    <compilation debug="true" targetFramework="4.5">
      <assemblies> 
        <add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 
      </assemblies>
    </compilation>


I got three of them, I have added all those assemblies into web.config like above and it works perfect.

How to convert JSON string to Javascript object?

You can convert JSON String to JavaScript Object Using JSON.parse method of JavaScript.

<script>
   //Json string
   var customer = '{"Name":"John","City":"NJ"}';
   var customers = '[{"Name":"John","City":"NJ"},{"Name":"Miller","City":"PA"}]';

   //Converting Json to Javascript Object
   var Customer = JSON.parse(customer);
   var Customers = JSON.parse(customers);

   //Result
   alert(Customer.Name);
   alert(Customers[1].Name);

</script>


Tuesday, July 29, 2014

How to connect Salesforce from Asp.net? Salesforce Integration in Asp.net

Today I will show you how to use new salesforce toolkit for .NET Application. Follows the steps:

Step 1. Create a project with C# ASP.NET 4.5 empty web application.

Step 2. Right click on this project and click on “Manage NuGet Packages”. Now search for “salesforce” and install “DeveloperForce.Force” NuGet package like this: see screen.



Step 3. After installing this package, add new webform in the project. Name it “Default.aspx”

Step 4. Before I show you complete code, you need five things from salesforce: “ConsumerKey, ConsumerSecret, username, password and security token”.

Note:A security token is an automatically generated key that you must add to the end of your password in order to log into Salesforce from an untrusted network. For example, if your password is mypassword, and your security token is XXXXXXXXXX, then you must enter mypasswordXXXXXXXXXX to log in.

Step 5. Paste following code in your “Default.aspx.cs” page.

    public partial class Default : System.Web.UI.Page
    {
        List<contact> Contacts;
        protected void Page_Load(object sender, EventArgs e)
        {
            Do().Wait();

            foreach (var item in Contacts)
            {
                Response.Write(item.LastName + ",");
            }
        }
        async Task Do()
        {
            //get credential values
            string consumerkey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
            string consumersecret = "XXXXXXXXXXXXXXXXX";
            string username = "XXXXXXXXXXX";
            string password = "mypasswordXXXXXXXXXX";

            //create auth client to retrieve token
            var auth = new AuthenticationClient();

            //get back URL and token
            await auth.UsernamePasswordAsync(consumerkey, 
                       consumersecret, username, password);

            var instanceUrl = auth.InstanceUrl;
            var accessToken = auth.AccessToken;
            var apiVersion = auth.ApiVersion;
            var client = new ForceClient(instanceUrl, accessToken, apiVersion);

            var contacts = await 
                client.QueryAsync<contact>("SELECT Id, LastName From Contact");

            Contacts = contacts.records;

        }
        public class Contact
        {
            public string Id { get; set; }
            public string LastName { get; set; }
        }

    }


Now, run your application and it works perfect :)

I hope this article will help you in connecting Salesforce from Asp.Net

Monday, July 28, 2014

What is the difference between IEnumerable and IEnumerator? ASP.Net

IEnumerable is an interface for all non-generic collections that can be enumerated. IEnumerable contains a single method, GetEnumerator, which returns an IEnumerator.

Syntax:
public interface IEnumerable
{
IEnumerator GetEnumerator();
}


IEnumerator provides the ability to iterate through the collection by exposing a Current property and MoveNext and Reset methods. Enumerators can be used to read the data in the collection, but they cannot be used to modify the underlying collection.

Syntax:
public interface IEnumerator
{
object Current { get; }
bool MoveNext();
void Reset();
}


Friday, July 25, 2014

Partitions in Multidimensional Models (SSAS, SQL Server 2014)

In Analysis Services, a partition provides the physical storage of fact data loaded into a measure group. A single partition is created for each measure group automatically, but it is common to create additional partitions that further segment the data, resulting in more efficient processing and faster query performance.

Processing is more efficient because partitions can be processed independently and in parallel, on one or more servers. Queries run faster because each partition can be configured to have storage modes and aggregation optimizations that result in shorter response times. For example, choosing MOLAP storage for partitions containing newer data is typically faster than ROLAP. Likewise, if you partition by date, partitions containing newer data can have more optimizations than partitions containing older data that is accessed less frequently. Note that varying storage and aggregation design by partition will have a negative impact on future merge operations. Be sure to consider whether merging is an essential component of your partition management strategy before optimizing individual partitions.

Dimensions in Multidimensional Models (SSAS, SQL Server 2014)

A database dimension is a collection of related objects, called attributes, which can be used to provide information about fact data in one or more cubes. For example, typical attributes in a product dimension might be product name, product category, product line, product size, and product price. These objects are bound to one or more columns in one or more tables in a data source view. By default, these attributes are visible as attribute hierarchies and can be used to understand the fact data in a cube. Attributes can be organized into user-defined hierarchies that provide navigational paths to assist users when browsing the data in a cube.

Cubes contain all the dimensions on which users base their analyses of fact data. An instance of a database dimension in a cube is called a cube dimension and relates to one or more measure groups in the cube. A database dimension can be used multiple times in a cube. For example, a fact table can have multiple time-related facts, and a separate cube dimension can be defined to assist in analyzing each time-related fact. However, only one time-related database dimension needs to exist, which also means that only one time-related relational database table needs to exist to support multiple cube dimensions based on time.

Cubes in Multidimensional Models (SSAS, Sql Server 2014)

A cube is a multidimensional structure that contains information for analytical purposes; the main constituents of a cube are dimensions and measures. Dimensions define the structure of the cube that you use to slice and dice over, and measures provide aggregated numerical values of interest to the end user. As a logical structure, a cube allows a client application to retrieve values, of measures, as if they were contained in cells in the cube; cells are defined for every possible summarized value. A cell, in the cube, is defined by the intersection of dimension members and contains the aggregated values of the measures at that specific intersection.

Data Source Views in Multidimensional Models (DSV in SSAS) Sql Server 2014

A data source view (DSV) is an abstraction of a relational data source that becomes the basis of the cubes and dimensions you create in a multidimensional project. The purpose of a DSV is to give you control over the data structures used in your project, and to work independently of the underlying data sources (for example, the ability to rename or concatenate columns without directly modifying the original data source).

You can build multiple data source views in an Analysis Services project or database on one or more data sources, and construct each one to satisfy the requirements for a different solution.

Thursday, July 24, 2014

Merge Transformation vs Union All Transformation in SSIS

The main difference is: Merge Transformation takes two inputs and gives one output whereas Union All Transformation takes multiple inputs and gives one output

Merge Transformation:

The Merge transformation combines two sorted datasets into a single dataset. The rows from each dataset are inserted into the output based on values in their key columns.

By including the Merge transformation in a data flow, you can perform the following tasks:

• Merge data from two data sources, such as tables and files.
• Create complex datasets by nesting Merge transformations.
• Remerge rows after correcting errors in the data.

Union All Transformation:

The Union All transformation combines multiple inputs into one output. For example, the outputs from five different Flat File sources can be inputs to the Union All transformation and combined into one output.

The Merge transformation is similar to the Union All transformations. Use the Union All transformation instead of the Merge transformation in the following situations:

• The transformation inputs are not sorted.
• The combined output does not need to be sorted.
• The transformation has more than two inputs.


Wednesday, July 23, 2014

How can i convert LookupSet result, which is in array, into comma separated? SSRS

You can convert array to comma separated string by using Join() function.

=JOIN(LookupSet(Fields!ID.Value, Fields!ID.Value, Fields!Name.Value, "Sections"),",")


Syntax:
LookupSet(source_expression, destination_expression, result_expression, dataset)



React-select is very slow on larger list - Found solution - using react-window

 I had more than 4000 items in searchable dropdownlist. I have used react-select but it was very slow. finally I found complete solution to ...