Wednesday, November 22, 2017

Microsoft Azure Discovery Day in Melbourne- Indeed a good show

I urge folks out there in Australia to leverage this wonderful opportunity to gather know and how about Azure. Too many things to catch up. Very fast pace of improvement, new services , new products Microsoft Azure is offering on the table so far in terms of PAAS, IAAS and SAAS. Having said that I attended Microsoft Azure Discovery Day in Melbourne on 21st Nov 2017. I liked the presentation , demo and short knowledge transitioned by presenter. I must say there is many thing happening in Azure space.


  • Continuous Delivery as part of App Service
  • Logic App
  • Azure Function
  • Web Apps
  • Automation Run book
  • Security Centre
  • Cloudyn for cost and estimation 
  • OMS
  • App Insight
  • Azure Template

  • [You can now mock api data without being backend ready. You can test api without using developer portal.
    Swagger definition available as part of code editor.]


References:




Thursday, November 9, 2017

Sitecore Dynamic Placeholder

I prefer

  • TDS
  • TDS with glass mapper template[Auto code generation for sitecore template model]
  • Fortis Dynamic Placeholder Nuget
  • Sitecore 8.2.1
  • MVC 5
  • .Net framework 4.5.2

The difficult part of sitecore is setup stage to start your development.

Install MVC Sitecore 8.2.1
Sitecore solution base nuget package can be found in above documentation. Follow step by step instruction.

Install Glass mapper

Install Dynamic Placeholder Nuget




Install TDS

Use wizard to create master content tree sync solution

Sitecore .Net Solution

 

Glass mapper TDS - Template










































Sitecore Rocks

Dynamic Placeholder

Glass Mapper @editable View Rendering


To create this sample. I have created two component in MVC and then corresponding renderings in sitecore.

View  as Component
Placeholder
Sitecore Renderings
1
MainLayoutPage.cshtml

<html>
<body>
      
<div class="container">
        
@Html.Sitecore().DynamicPlaceholder("dynamic-row")
    
</div>
</body>
</html>

dynamic-row

2
OneRowThreeColumn.cshtml

<div class="row">
    
<div class="col-sm-4">
        
<div class="tile--bordered">
            
@Html.Sitecore().DynamicPlaceholder("dynamic-content")
        
</div>
    
</div>
    
<div class="col-sm-4">
        
<div class="tile--bordered">
            
@Html.Sitecore().DynamicPlaceholder("dynamic-content")
        
</div>
    
</div>
    
<div class="col-sm-4">
        
<div class="tile--bordered">
            
@Html.Sitecore().DynamicPlaceholder("dynamic-content")
        
</div>
    
</div>
</div>

dynamic-row
One Row Three Column

3
RichText.cshtml

@inherits Glass.Mapper.Sc.Web.Mvc.GlassViewISingleRichText>

<p class="tile__title">@Editable(Model, y=>y.Title)</p>
<p class="tile__sub-title">
    
@if (Model != null)
    {
        
@Editable(Model, y => y.Detail)
    }
</p>

 

dynamic-content
***Rich Text with Model(Template- Data Template SingleRichText)

Create following items in sitecore:

  1. Layout
  2. Data Template
  3. Renderings
  4. Placeholder setting
  5. Page item in content tree

 

  1. Layout: MainLayout



2.0 Placeholder Settings: dynamic-row



2.1 Placeholder Settings: dynamic-content


 

3.0 Renderings: One Row Three Column



 

3.1 Renderings: Rich Text



 

 

3.2 Data Template





  1. Content Tree


  1.  Presentation: Shared Layout


 

  1.  Experience Editor







 

  1. Presentation: Post Publish- Final Rendering




Wednesday, October 25, 2017

Azure API Management Service New Admin UI and features.

New Azure API Management Service New Admin UI


  • Create Mock request and response without backend being ready
  • Design format with app editor- Front-end request, inbound processing, backend and outbound processing
  • Test
  • Setting
  • Revisions and change logs







Sunday, October 1, 2017

C# Linq ,Generics, Lamda expression and many more.

Introduction
I'll keep this space updating my most used c# stuff in here. This is work in progress to have list of all referenced code that is useful at times of implementation.

Linq Data Parallelism

var quotes =quotesForAllProducts();//e.g Get quotes for all products
Parallel.ForEach(products, item => Process(item,quotes));


private void Process(Product item,List<Quote> quotes)
      {
          
var quote= quotes?.SingleOrDefault
                  (p =>
                      p.Id.Trim().Equals(item.Id ?? 
string.Empty));
          
if (quote != null)
          {
              item.Cost = quote.TotalAmount.GetValueOrDefault();
              item.Code = quote.Code;
          }          
      }

System.Linq.ParallelEnumerable

Set object values for superset.
Packages = poducts.AsParallel().Select(p => new Package
                {
                    tId = p.tId,
                    vId = p.vId
                }).ToList(),

SelectMany

private void SetProductsSubSet(IList<Product> products)
    {
        _products= (
IEnumerable<ProductDetail>) products?.AsParallel().SelectMany(a => a.subLevel.Select(p => new ProductDetail
        {
            Id = a.Id,
            Type = a.Type,
        })) ?? 
new List<ProductDetail>();

    } 


Left Join DefaultIfEmpty()

public List<Product> AddHospitalAndExtrasProduct()
       {
           
return
               (
from A in Main
               
join B in SubB on A.ID equals B?.Id into MainAndSubB
                   
from ResultSetA in MainAndSubB.DefaultIfEmpty()
               
join B in SubC on A.ID equals C?.Id into MainAndSubC
                   
from ResultSetC in MainAndSubC.DefaultIfEmpty()
            select new Product
            {
                Id = Main.Id,
                Name = Main.Name,
                SubBId = ResultSetA != 
null ? ResultSetA .SubBId : string.Empty,
                SubCId = ResultSetC != 
null ? ResultSetC .SubCId : string.Empty,
            }).ToList();          
       }

Monday, September 11, 2017

Use case IEquatable and Object.Equal

Introduction

One can use IEquatable for comparing two object values. This is useful when we have to check any duplicate enteries. Let me know if you have any better solution to implement the same use case scenario. I have address string in Address object.

String Comparisons

  • Handle whitespace between two words , letters.
  • Handle trailing and leading spaces
  • Handle casing of strings

//Private Member
private List<Address> _addresses;

//Method for update Address and duplicate checks
public string UpdateAddress(Address personAddress)
{
           
string requestCorrelationId = _client.GetCorrelationRequest();
           
var userContext = _sessionService.Get<UserContext>(SessionKeys.UserContext);
           
try
           {
               
if (IsDuplicateAddress(personAddress))
               {
return "Duplicate some Message"
}
}
}

//Private Method
private bool IsDuplicateAddress(Address personAddress)
{
    
return _addresses().Any(p => p.Equals(personAddress));
}

//Implement IEquatable
public partial class Address : IEquatable<Address>
  {
  
       
public string AddressLine1 { getset; }

       
public string AddressLine2 { getset; }

       
public string AddressLine3 { getset; }

       
public string Suburb { getset; }

       
public string State { getset; }

       
public string PostCode { getset; }

       
public string CountryCode { getset; }

       
public long? Id { getset; }


      public bool Equals(Address newAddress)
      {     
          
if (newAddress == nullreturn false;
          
return 
string.Equals(Regex.Replace(newAddress.AddressLine1 ?? 
string.Empty, @"\s"string.Empty), 
Regex.Replace(AddressLine1, @"\s"string.Empty), 
StringComparison.OrdinalIgnoreCase)
              && 
string.Equals(Regex.Replace(newAddress.AddressLine2 ?? 
string.Empty, @"\s"string.Empty), 
Regex.Replace(AddressLine2, @"\s"string.Empty), 
StringComparison.OrdinalIgnoreCase)
              && 
string.Equals(Regex.Replace(newAddress.AddressLine3 ?? 
string.Empty, @"\s"string.Empty), 
Regex.Replace(AddressLine3, @"\s"string.Empty), 
StringComparison.OrdinalIgnoreCase)
              && 
string.Equals(newAddress.CountryCode ?? 
string.Empty,CountryCode, 
StringComparison.OrdinalIgnoreCase)
              && 
string.Equals(newAddress.PostCode ?? 
string.Empty,PostCode, 
StringComparison.OrdinalIgnoreCase)
              && 
string.Equals(newAddress.State ?? 
string.Empty, State, 
StringComparison.OrdinalIgnoreCase)
              && 
string.Equals(Regex.Replace(newAddress.Suburb ?? 
string.Empty, @"\s"string.Empty), 
Regex.Replace(Suburb, @"\s"string.Empty), 
StringComparison.OrdinalIgnoreCase);
      }

      
public override bool Equals(object obj)
      {
          
if (ReferenceEquals(null, obj)) return false;
          
if (ReferenceEquals(this, obj)) return true;
          
if (obj.GetType() != GetType()) return false;
          
return Equals(obj as Address);
      }

      
public override int GetHashCode()
      {
          
unchecked
          {
              
var hashCode = AddressLine1?.GetHashCode() ?? 0;
              hashCode = (hashCode
*397) ^ (AddressLine2?.GetHashCode() ?? 0);
              hashCode = (hashCode
*397) ^ (AddressLine3?.GetHashCode() ?? 0);
              hashCode = (hashCode
*397) ^ (Suburb?.GetHashCode() ?? 0);
              hashCode = (hashCode
*397) ^ (State?.GetHashCode() ?? 0);
              hashCode = (hashCode
*397) ^ (PostCode?.GetHashCode() ?? 0);
              hashCode = (hashCode
*397) ^ (CountryCode?.GetHashCode() ?? 0);
              hashCode = (hashCode
*397) ^ Id.GetHashCode();
              
return hashCode;
          }
      }
  }