Sam's Dynamics, Power Platform & AI Blog

Tuesday, 17 January 2017

Important data by G

Latest Technologies for learn-


  1. https://nodejs.org/
  2. http://lesscss.org/#using-less
  3. http://sass-lang.com/
  4. http://bower.io/
  5. http://yeoman.io/generators/
  6. https://www.npmjs.com/
  7. http://gruntjs.com/
  8. http://gulpjs.com/
  9. http://tutorials.jenkov.com/angularjs/index.html
  10. https://scotch.io/

Allow SSL

 ServicePointManager.Expect100Continue = true;

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;

1.link for ASP chart or graphical representation:-




2.query for check no. of open connection in database:-


SELECT
   DB_NAME(dbid) as DBName,
   COUNT(dbid) as NumberOfConnections,
   loginame as LoginName
FROM
   sys.sysprocesses
WHERE
   dbid > 0
GROUP BY
   dbid, loginame


3.Conversion of datatype in C#-
http://msdn.microsoft.com/en-IN/library/bb397679.aspx


4.Open Complete Webform in model Popup(Ajax)




6.Link for login with fb
http://www.codeproject.com/Tips/371917/Get-user-Facebook-details-in-ASP-NET-and-Csharp




7.for ionic App & Angular.js-
https://egghead.io/technologies/angularjs



8.Google map and get geo location-
refrence-


https://maps.googleapis.com/maps/api/geocode/json?address=indore&sensor=false


https://maps.googleapis.com/maps/api/geocode/json?latlng=37.383253,-122.078075&sensor=false;

get longitude and lattitude-


<!DOCTYPE html>
<html>
<body>


<p>Click the button to get your coordinates.</p>


<button onclick="getLocation()">Try It</button>


<p id="demo"></p>


<script>
var x = document.getElementById("demo");


function getLocation() {
   if (navigator.geolocation) {
       navigator.geolocation.getCurrentPosition(showPosition);
   } else {
       x.innerHTML = "Geolocation is not supported by this browser.";
   }
}


function showPosition(position) {
   x.innerHTML = "Latitude: " + position.coords.latitude +
   "<br>Longitude: " + position.coords.longitude;
}
</script>


</body>
</html>
autofill address from google-
<!DOCTYPE html>
<html>
<head>
   <title>Place Autocomplete Address Form</title>
     <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&libraries=places"></script>
   <script>
// This example displays an address form, using the autocomplete feature
// of the Google Places API to help users fill in the information.


var placeSearch, autocomplete;
var componentForm = {
 street_number: 'short_name',
 route: 'long_name',
 locality: 'long_name',
 administrative_area_level_1: 'short_name',
 country: 'long_name',
 postal_code: 'short_name'
};


function initialize() {
 // Create the autocomplete object, restricting the search
 // to geographical location types.
 autocomplete = new google.maps.places.Autocomplete(
     /** @type {HTMLInputElement} */(document.getElementById('autocomplete')),
     { types: ['geocode'] });
 // When the user selects an address from the dropdown,
 // populate the address fields in the form.
 google.maps.event.addListener(autocomplete, 'place_changed', function() {
   fillInAddress();
 });
}


// [START region_fillform]
function fillInAddress() {
 // Get the place details from the autocomplete object.
 var place = autocomplete.getPlace();


 //for (var component in componentForm) {
 //  document.getElementById(component).value = '';
 //  document.getElementById(component).disabled = false;
 //}


 // Get each component of the address from the place details
   // and fill the corresponding field on the form.
 console.log("ok");
 console.log(place.address_components);
 var address = '';
 for (var i = 0; i < place.address_components.length; i++) {
     var addressType = place.address_components[i].types[0];
    
   if (componentForm[addressType]) {
       var val = place.address_components[i][componentForm[addressType]];
       address = address + " " + val;
       //document.getElementById(addressType).value = val;
      }
   //document.getElementById("lable").value = address;
 }
 console.log("address");
 console.log(address);
 document.getElementById('address').value = address;
 
}
// [END region_fillform]


// [START region_geolocation]
// Bias the autocomplete object to the user's geographical location,
// as supplied by the browser's 'navigator.geolocation' object.
function geolocate() {
 if (navigator.geolocation) {
   navigator.geolocation.getCurrentPosition(function(position) {
     var geolocation = new google.maps.LatLng(
         position.coords.latitude, position.coords.longitude);
     var circle = new google.maps.Circle({
       center: geolocation,
       radius: position.coords.accuracy
     });
     autocomplete.setBounds(circle.getBounds());
   });
 }
}
// [END region_geolocation]


   </script>


   
</head>


<body onload="initialize()">
   <div id="locationField">
       <input id="autocomplete" placeholder="Enter your address"
              onfocus="geolocate()" type="text"></input>
   </div>
   <input id="address" disabled="true"></input>
<!--<table id="address">
       <tr>
           <td class="label">Street address</td>
           <td class="slimField">
               <input class="field" id="street_number"
                      disabled="true"></input>
           </td>
           <td class="wideField" colspan="2">
               <input class="field" id="route"
                      disabled="true"></input>
           </td>
       </tr>
       <tr>
           <td class="label">City</td>
           <td class="wideField" colspan="3">
               <input class="field" id="locality"
                      disabled="true"></input>
           </td>
       </tr>
       <tr>
           <td class="label">State</td>
           <td class="slimField">
               <input class="field"
                      id="administrative_area_level_1" disabled="true"></input>
           </td>
           <td class="label">Zip code</td>
           <td class="wideField">
               <input class="field" id="postal_code"
                      disabled="true"></input>
           </td>
       </tr>
       <tr>
           <td class="label">Country</td>
           <td class="wideField" colspan="3">
               <input class="field"
                      id="country" disabled="true"></input>
           </td>
       </tr>
   </table>-->    
</body>
</html>


DELETE ALL TABLES FROM DATABASE-


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


Delete all procedure constraints tables from database


/* Drop all non-system stored procs */
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)


SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 ORDER BY [name])


WHILE @name is not null
BEGIN
   SELECT @SQL = 'DROP PROCEDURE [dbo].[' + RTRIM(@name) +']'
   EXEC (@SQL)
   PRINT 'Dropped Procedure: ' + @name
   SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 AND [name] > @name ORDER BY [name])
END
GO


/* Drop all views */
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)


SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'V' AND category = 0 ORDER BY [name])


WHILE @name IS NOT NULL
BEGIN
   SELECT @SQL = 'DROP VIEW [dbo].[' + RTRIM(@name) +']'
   EXEC (@SQL)
   PRINT 'Dropped View: ' + @name
   SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'V' AND category = 0 AND [name] > @name ORDER BY [name])
END
GO


/* Drop all functions */
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)


SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] IN (N'FN', N'IF', N'TF', N'FS', N'FT') AND category = 0 ORDER BY [name])


WHILE @name IS NOT NULL
BEGIN
   SELECT @SQL = 'DROP FUNCTION [dbo].[' + RTRIM(@name) +']'
   EXEC (@SQL)
   PRINT 'Dropped Function: ' + @name
   SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] IN (N'FN', N'IF', N'TF', N'FS', N'FT') AND category = 0 AND [name] > @name ORDER BY [name])
END
GO


/* Drop all Foreign Key constraints */
DECLARE @name VARCHAR(128)
DECLARE @constraint VARCHAR(254)
DECLARE @SQL VARCHAR(254)


SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' ORDER BY TABLE_NAME)


WHILE @name is not null
BEGIN
   SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME)
   WHILE @constraint IS NOT NULL
   BEGIN
       SELECT @SQL = 'ALTER TABLE [dbo].[' + RTRIM(@name) +'] DROP CONSTRAINT [' + RTRIM(@constraint) +']'
       EXEC (@SQL)
       PRINT 'Dropped FK Constraint: ' + @constraint + ' on ' + @name
       SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' AND CONSTRAINT_NAME <> @constraint AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME)
   END
SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' ORDER BY TABLE_NAME)
END
GO


/* Drop all Primary Key constraints */
DECLARE @name VARCHAR(128)
DECLARE @constraint VARCHAR(254)
DECLARE @SQL VARCHAR(254)


SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' ORDER BY TABLE_NAME)


WHILE @name IS NOT NULL
BEGIN
   SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME)
   WHILE @constraint is not null
   BEGIN
       SELECT @SQL = 'ALTER TABLE [dbo].[' + RTRIM(@name) +'] DROP CONSTRAINT [' + RTRIM(@constraint)+']'
       EXEC (@SQL)
       PRINT 'Dropped PK Constraint: ' + @constraint + ' on ' + @name
       SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' AND CONSTRAINT_NAME <> @constraint AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME)
   END
SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' ORDER BY TABLE_NAME)
END
GO


/* Drop all tables */
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)


SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'U' AND category = 0 ORDER BY [name])


WHILE @name IS NOT NULL
BEGIN
   SELECT @SQL = 'DROP TABLE [dbo].[' + RTRIM(@name) +']'
   EXEC (@SQL)
   PRINT 'Dropped Table: ' + @name
   SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'U' AND category = 0 AND [name] > @name ORDER BY [name])
END
GO



Get views record count with name-
===============================
CREATE PROCEDURE dbo.ViewsRowCount
AS
BEGIN
SET NOCOUNT ON
CREATE TABLE #tempRowCount
(
     Name        VARCHAR(100),
     Row_Count   INT
)
DECLARE     @SQL VARCHAR(MAX)
SET         @SQL = ''
SELECT @SQL = @SQL + 'INSERT INTO #tempRowCount SELECT ''' +
           SCHEMA_NAME(schema_id) + '.' + name + ''', COUNT(*) FROM ' +
           SCHEMA_NAME(schema_id) + '.' + name +
           CHAR(13) FROM sys.objects WHERE type = 'V'
EXEC (@SQL)
SELECT      Name, Row_Count
FROM        #tempRowCount
END
GO
fir execute DECLARE @return_value int


EXEC @return_value = [dbo].[ViewsRowCount]


SELECT 'Return Value' = @return_value


GO

SMTP Email error for sending mail solution

up vote15down vote
When you try to send mail from code and you find the error "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required", than the error might occur due to following cases.
case 1: when the password is wrong
case 2: when you try to login from some App
case 3: when you try to login from the domain other than your time zone/domain/computer (This is the case in most of scenarios when sending mail from code)
There is a solution for each
solution for case 1: Enter the correct password.
solution for case 2: go to security settings at the followig link https://www.google.com/settings/security/lesssecureapps and enable less secure apps . So that you will be able to login from all apps.
solution 1 for case 3: (This might be helpful) you need to review the activity. but reviewing the activity will not be helpful due to latest security standards the link will not be useful. So try the below case.
solution 2 for case 3: If you have hosted your code somewhere on production server and if you have access to the production server, than take remote desktop connection to the production server and try to login once from the browser of the production server. This will add excpetioon for login to google and you will be allowed to login from code.
But what if you don't have access to the production server. try the solution 3
solution 3 for case 3: You have to enable login from other timezone / ip for your google account.
to do this follow the link https://g.co/allowaccess and allow access by clicking the continue button.
And that's it. Here you go. Now you will be able to login from any of the computer and by any means of app to your google account.


Multiple pinpoint on google map-


http://deepak-sharma.net/2013/06/17/adding-markers-to-google-maps-from-database-using-asp-net/


Unique records from any scope
$scope.FilteredCategory = _.map(_.groupBy($scope.warehousefiltereddepartment, function (cat) {
           return cat.Categoryid;
       }), function (grouped) {
           return grouped[0];
       });


Alternative of parseHTML-


$('<div/>').html(found).contents();


Get data from url c# in one line-


var response = new WebClient().DownloadString("http://test.com?id=1");


Use of groupby in c#


context.DbUserSchedules.GroupBy(x => x.UserId).Select(g => new { g.Key, Count = g.OrderByDescending(x => x.StartTime).FirstOrDefault() }).ToList();

JIRA :-


Link for create jira Account


https://www.atlassian.com/ondemand/signup/form?product=jira-software.ondemand,jira-servicedesk.ondemand,confluence.ondemand


Angular Beginner-









for allowed put methoed on godady-


<modules runAllManagedModulesForAllRequests="true">
   <remove name="WebDAVModule"/>
   <!-- add this -->
 </modules>
<handler>
<remove name="WebDAV" />  (In handler tag)
</handler>

for Self Refrencing loop error-


config.Formatters.JsonFormatter
           .SerializerSettings
           .ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;


Add in webapi.config file



for Enable Cors(web.config)-


 <system.webServer>
   <httpProtocol>
     <customHeaders>
       <add name="Access-Control-Allow-Origin" value="*" />
       <add name="Access-Control-Allow-Headers" value="content-type, Encoding, authorization, XMLHttpRequest" />
       <add name="Access-Control-Allow-Methods" value="POST,GET,OPTIONS,PUT,DELETE" />
       <add name="Access-Control-Max-Age" value="1728000" />
     </customHeaders>
   </httpProtocol>
 </system.webServer>

For Trust level issue or if Deployed code is not working on Production Server-
<system.web>
<trust level="Full"/>
 <customErrors mode="Off"/>
</system.web>
//for adx portal deployment
<portals>
<websiteSelector type="Adxstudio.Xrm.Cms.WebsiteSelectors.NameAndWebsitePathWebsiteSelector, Adxstudio.Xrm"/>
</portals>

On IIS 6

<configuration>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true"/>
</system.web>
</configuration>


On IIS 7

<configuration>

<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true"/>
</system.webServer>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true"/>
</system.web> </configuration>


And also Remove <system.codedom> tag from web config
# IIS Manage Pipeline error-


This error 500.23 translates to - An ASP.NET httpHandlers configuration does not apply in Managed Pipeline mode.
Check the httpHandlers configuration in IIS. Try following:
1. Open Server Manager
2. Select Roles>Web Server (IIS)>IIS Manager>Select the Server>Applocation Pools
3. Select the appPool that your asp.net app is running under>Click on 'Advanced Settings' from the right hand pane.
4. Under Advanced Settings>General>Managed Pipeline Mode, select "Classic"
5. Recycle app pool and test your app.

Adding Calander
http://fullcalendar.io/docs/  (adding calander methods)

google calendar-


1. get api-




#CRM-

Create CRM trial Account-


1.https://portal.office.com/Signup/Signup.aspx?OfferId=E070C229-C45D-433d-874A-6B5B3C54B291&dl=CRMSTANDARD&ali=1&culture=en-us&Country=US
//for create crm test account


2.https://portal.office.com/Signup/Signup.aspx?OfferId=E070C229-C45D-433d-874A-6B5B3C54B291&dl=CRMSTANDARD&ali=1&Country=GB&culture=en-GB&alo=1#0

link for crm plugin-




CRM Email Configuration for Gmail-




Workflows in crm :-


Imp link for workflow :-
https://msdn.microsoft.com/en-us/library/gg309458.aspx


1.Buissness work flow begginer-




2.Work flows example for begginer-


3.Email Configuration-


https://www.youtube.com/watch?v=bSC4AauuzG8


Unlock field from js-


var control = Xrm.Page.ui.controls.get("fieldname");
if (control != null)
{
control.setDisabled(false);
}

installation required for ssrs report (Buissness Intelegence tool for sql server 2014 report)-


Setting Details when create managed solution-




All entities Statecode and StatusCode


Get All Related Entitiesof an entity
QueryExpression quer = new QueryExpression();
                       quer.EntityName = "product";
                       quer.ColumnSet = new ColumnSet("name", "price", "sj_dealtype");
                       Relationship relationship1 = new Relationship();
                       quer.Criteria = new FilterExpression();
                       //quer.Criteria.AddCondition(new ConditionExpression("statecode", ConditionOperator.Equal, "Active"));
                       relationship1.SchemaName = "sj_product_opportunity";
                       RelationshipQueryCollection relatedEntity1 = new RelationshipQueryCollection();
                       relatedEntity1.Add(relationship1, quer);
                       RetrieveRequest request1 = new RetrieveRequest();
                       request1.RelatedEntitiesQuery = relatedEntity1;
                       request1.ColumnSet = new ColumnSet(true);
                       request1.Target = new EntityReference { Id = ld.Id, LogicalName = "opportunity" };
                       RetrieveResponse response1 = (RetrieveResponse)service.Execute(request1);
                       var RE = response1.Entity.RelatedEntities.Values;
                       var db = RE.First();
                       existngEntities = db;


CRM retieve optionset values from optionset text
string optionSetValue = Convert.ToString(((OptionSetValue)(ld.Attributes["sj_dealtype"])).Value);
                           ProductdealtypeVal = optionSetValue;
                           string returnValue = string.Empty;
                           if (!optionSetValue.Equals(string.Empty))
                           {
                               RetrieveAttributeRequest request = new RetrieveAttributeRequest();
                               request.EntityLogicalName = ld.LogicalName;
                               request.LogicalName = "sj_dealtype";
                               request.RetrieveAsIfPublished = true;
                               RetrieveAttributeResponse response = (RetrieveAttributeResponse)service.Execute(request);
                               PicklistAttributeMetadata picklist = (PicklistAttributeMetadata)response.AttributeMetadata;
                               var query = from option in picklist.OptionSet.Options
                                           where option.Value == int.Parse(optionSetValue)
                                           select option.Label.UserLocalizedLabel.Label;
                               returnValue = query.FirstOrDefault().ToString();
                               type = returnValue;
                           }

CRM N to N check if exists
 public static bool RelationshipExists(IOrganizationService service,string relationshipname, Guid entity1Id, string entity1Name,Guid entity2Id, string entity2Name)
       {
           string relationship1EtityName = string.Format("{0}id", entity1Name);
           string relationship2EntityName = string.Format("{0}id", entity2Name);


           //This check is added for self-referenced relationships
           if (entity1Name.Equals(entity2Name, StringComparison.InvariantCultureIgnoreCase))
           {
               relationship1EtityName = string.Format("{0}idone", entity1Name);
               relationship1EtityName = string.Format("{0}idtwo", entity1Name);
           }


           QueryExpression query = new QueryExpression(entity1Name)
           {
               ColumnSet = new ColumnSet(false)
           };


           LinkEntity link = query.AddLink(relationshipname,
               string.Format("{0}id", entity1Name), relationship1EtityName);
           link.LinkCriteria.AddCondition(relationship1EtityName,
               ConditionOperator.Equal, new object[] { entity1Id });
           link.LinkCriteria.AddCondition(relationship2EntityName,
               ConditionOperator.Equal, new object[] { entity2Id });


           return service.RetrieveMultiple(query).Entities.Count != 0;
       }

CRM Retrive All attributes of entity


RetrieveEntityRequest req = new RetrieveEntityRequest();
           req.RetrieveAsIfPublished = true;
           req.LogicalName = "product";
           req.EntityFilters = EntityFilters.Attributes;
           RetrieveEntityResponse resp = (RetrieveEntityResponse)service.Execute(req);



Crm Retrive optionset attribute  text
  RetrieveAttributeRequest retrieveAttributeRequest = new RetrieveAttributeRequest
           {
               EntityLogicalName = "product",
               LogicalName = attributeSchemaName,
               RetrieveAsIfPublished = true
           };
           RetrieveAttributeResponse retrieveAttributeResponse = (RetrieveAttributeResponse)service.Execute(retrieveAttributeRequest);
           BooleanAttributeMetadata retrievedBooleanAttributeMetadata = (BooleanAttributeMetadata)retrieveAttributeResponse.AttributeMetadata;
           string boolText = string.Empty;
           if (value)
           {
               boolText = retrievedBooleanAttributeMetadata.OptionSet.TrueOption.Label.UserLocalizedLabel.Label;
           }
           else
           {
               boolText = retrievedBooleanAttributeMetadata.OptionSet.FalseOption.Label.UserLocalizedLabel.Label;
           }
return boolText;
           


Filter Array Of Object By id or String :-


var uniques = _.map(_.groupBy($scope.timeslotArray, function (doc) {
             
           return doc.data.trim();
       }), function (grouped) {
           return grouped[0];
       });

Order By Array: -


ng-repeat="obj in Objects | orderBy:’ id ’ ''

Bulk Delete Record in Table Use Entity Framework


context.BlockAvailability.Where(c => c.AppointmentId == ap.Id).Delete();




//add by sumit
Update one field in List With Lambda Expression


var _data = appointmentApi.GetByUserId(GetTypeBy, Userid, Datewise, Timezone)
                   .Select(x =>
                   {
                       x.Date = DateTimeHelper.GetLocal(x.Date, Timezone);
                       return x;
                   }).ToList();

Get all table record count with name


SELECT
   TableName = t.NAME,
   TableSchema = s.Name,
   RowCounts = p.rows
FROM
   sys.tables t
INNER JOIN
   sys.schemas s ON t.schema_id = s.schema_id
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
WHERE
   t.is_ms_shipped = 0
GROUP BY
   t.NAME, s.Name, p.Rows
ORDER BY
   s.Name, t.Name

http://survivingcrm.com/2014/04/crm-reminder-workflows-done-right/


Get system date format-

function getLocaleDateString(){
var formats = { "ar-SA" : "dd/MM/yy", "bg-BG" : "dd.M.yyyy", "ca-ES" : "dd/MM/yyyy", "zh-TW" : "yyyy/M/d", "cs-CZ" : "d.M.yyyy", "da-DK" : "dd-MM-yyyy", "de-DE" : "dd.MM.yyyy", "el-GR" : "d/M/yyyy", "en-US" : "M/d/yyyy", "fi-FI" : "d.M.yyyy", "fr-FR" : "dd/MM/yyyy", "he-IL" : "dd/MM/yyyy", "hu-HU" : "yyyy. MM. dd.", "is-IS" : "d.M.yyyy", "it-IT" : "dd/MM/yyyy", "ja-JP" : "yyyy/MM/dd", "ko-KR" : "yyyy-MM-dd", "nl-NL" : "d-M-yyyy", "nb-NO" : "dd.MM.yyyy", "pl-PL" : "yyyy-MM-dd", "pt-BR" : "d/M/yyyy", "ro-RO" : "dd.MM.yyyy", "ru-RU" : "dd.MM.yyyy", "hr-HR" : "d.M.yyyy", "sk-SK" : "d. M. yyyy", "sq-AL" : "yyyy-MM-dd", "sv-SE" : "yyyy-MM-dd", "th-TH" : "d/M/yyyy", "tr-TR" : "dd.MM.yyyy", "ur-PK" : "dd/MM/yyyy", "id-ID" : "dd/MM/yyyy", "uk-UA" : "dd.MM.yyyy", "be-BY" : "dd.MM.yyyy", "sl-SI" : "d.M.yyyy", "et-EE" : "d.MM.yyyy", "lv-LV" : "yyyy.MM.dd.", "lt-LT" : "yyyy.MM.dd", "fa-IR" : "MM/dd/yyyy", "vi-VN" : "dd/MM/yyyy", "hy-AM" : "dd.MM.yyyy", "az-Latn-AZ" : "dd.MM.yyyy", "eu-ES" : "yyyy/MM/dd", "mk-MK" : "dd.MM.yyyy", "af-ZA" : "yyyy/MM/dd", "ka-GE" : "dd.MM.yyyy", "fo-FO" : "dd-MM-yyyy", "hi-IN" : "dd-MM-yyyy", "ms-MY" : "dd/MM/yyyy", "kk-KZ" : "dd.MM.yyyy", "ky-KG" : "dd.MM.yy", "sw-KE" : "M/d/yyyy", "uz-Latn-UZ" : "dd/MM yyyy", "tt-RU" : "dd.MM.yyyy", "pa-IN" : "dd-MM-yy", "gu-IN" : "dd-MM-yy", "ta-IN" : "dd-MM-yyyy", "te-IN" : "dd-MM-yy", "kn-IN" : "dd-MM-yy", "mr-IN" : "dd-MM-yyyy", "sa-IN" : "dd-MM-yyyy", "mn-MN" : "yy.MM.dd", "gl-ES" : "dd/MM/yy", "kok-IN" : "dd-MM-yyyy", "syr-SY" : "dd/MM/yyyy", "dv-MV" : "dd/MM/yy", "ar-IQ" : "dd/MM/yyyy", "zh-CN" : "yyyy/M/d", "de-CH" : "dd.MM.yyyy", "en-GB" : "dd/MM/yyyy", "es-MX" : "dd/MM/yyyy", "fr-BE" : "d/MM/yyyy", "it-CH" : "dd.MM.yyyy", "nl-BE" : "d/MM/yyyy", "nn-NO" : "dd.MM.yyyy", "pt-PT" : "dd-MM-yyyy", "sr-Latn-CS" : "d.M.yyyy", "sv-FI" : "d.M.yyyy", "az-Cyrl-AZ" : "dd.MM.yyyy", "ms-BN" : "dd/MM/yyyy", "uz-Cyrl-UZ" : "dd.MM.yyyy", "ar-EG" : "dd/MM/yyyy", "zh-HK" : "d/M/yyyy", "de-AT" : "dd.MM.yyyy", "en-AU" : "d/MM/yyyy", "es-ES" : "dd/MM/yyyy", "fr-CA" : "yyyy-MM-dd", "sr-Cyrl-CS" : "d.M.yyyy", "ar-LY" : "dd/MM/yyyy", "zh-SG" : "d/M/yyyy", "de-LU" : "dd.MM.yyyy", "en-CA" : "dd/MM/yyyy", "es-GT" : "dd/MM/yyyy", "fr-CH" : "dd.MM.yyyy", "ar-DZ" : "dd-MM-yyyy", "zh-MO" : "d/M/yyyy", "de-LI" : "dd.MM.yyyy", "en-NZ" : "d/MM/yyyy", "es-CR" : "dd/MM/yyyy", "fr-LU" : "dd/MM/yyyy", "ar-MA" : "dd-MM-yyyy", "en-IE" : "dd/MM/yyyy", "es-PA" : "MM/dd/yyyy", "fr-MC" : "dd/MM/yyyy", "ar-TN" : "dd-MM-yyyy", "en-ZA" : "yyyy/MM/dd", "es-DO" : "dd/MM/yyyy", "ar-OM" : "dd/MM/yyyy", "en-JM" : "dd/MM/yyyy", "es-VE" : "dd/MM/yyyy", "ar-YE" : "dd/MM/yyyy", "en-029" : "MM/dd/yyyy", "es-CO" : "dd/MM/yyyy", "ar-SY" : "dd/MM/yyyy", "en-BZ" : "dd/MM/yyyy", "es-PE" : "dd/MM/yyyy", "ar-JO" : "dd/MM/yyyy", "en-TT" : "dd/MM/yyyy", "es-AR" : "dd/MM/yyyy", "ar-LB" : "dd/MM/yyyy", "en-ZW" : "M/d/yyyy", "es-EC" : "dd/MM/yyyy", "ar-KW" : "dd/MM/yyyy", "en-PH" : "M/d/yyyy", "es-CL" : "dd-MM-yyyy", "ar-AE" : "dd/MM/yyyy", "es-UY" : "dd/MM/yyyy", "ar-BH" : "dd/MM/yyyy", "es-PY" : "dd/MM/yyyy", "ar-QA" : "dd/MM/yyyy", "es-BO" : "dd/MM/yyyy", "es-SV" : "dd/MM/yyyy", "es-HN" : "dd/MM/yyyy", "es-NI" : "dd/MM/yyyy", "es-PR" : "dd/MM/yyyy", "am-ET" : "d/M/yyyy", "tzm-Latn-DZ" : "dd-MM-yyyy", "iu-Latn-CA" : "d/MM/yyyy", "sma-NO" : "dd.MM.yyyy", "mn-Mong-CN" : "yyyy/M/d", "gd-GB" : "dd/MM/yyyy", "en-MY" : "d/M/yyyy", "prs-AF" : "dd/MM/yy", "bn-BD" : "dd-MM-yy", "wo-SN" : "dd/MM/yyyy", "rw-RW" : "M/d/yyyy", "qut-GT" : "dd/MM/yyyy", "sah-RU" : "MM.dd.yyyy", "gsw-FR" : "dd/MM/yyyy", "co-FR" : "dd/MM/yyyy", "oc-FR" : "dd/MM/yyyy", "mi-NZ" : "dd/MM/yyyy", "ga-IE" : "dd/MM/yyyy", "se-SE" : "yyyy-MM-dd", "br-FR" : "dd/MM/yyyy", "smn-FI" : "d.M.yyyy", "moh-CA" : "M/d/yyyy", "arn-CL" : "dd-MM-yyyy", "ii-CN" : "yyyy/M/d", "dsb-DE" : "d. M. yyyy", "ig-NG" : "d/M/yyyy", "kl-GL" : "dd-MM-yyyy", "lb-LU" : "dd/MM/yyyy", "ba-RU" : "dd.MM.yy", "nso-ZA" : "yyyy/MM/dd", "quz-BO" : "dd/MM/yyyy", "yo-NG" : "d/M/yyyy", "ha-Latn-NG" : "d/M/yyyy", "fil-PH" : "M/d/yyyy", "ps-AF" : "dd/MM/yy", "fy-NL" : "d-M-yyyy", "ne-NP" : "M/d/yyyy", "se-NO" : "dd.MM.yyyy", "iu-Cans-CA" : "d/M/yyyy", "sr-Latn-RS" : "d.M.yyyy", "si-LK" : "yyyy-MM-dd", "sr-Cyrl-RS" : "d.M.yyyy", "lo-LA" : "dd/MM/yyyy", "km-KH" : "yyyy-MM-dd", "cy-GB" : "dd/MM/yyyy", "bo-CN" : "yyyy/M/d", "sms-FI" : "d.M.yyyy", "as-IN" : "dd-MM-yyyy", "ml-IN" : "dd-MM-yy", "en-IN" : "dd-MM-yyyy", "or-IN" : "dd-MM-yy", "bn-IN" : "dd-MM-yy", "tk-TM" : "dd.MM.yy", "bs-Latn-BA" : "d.M.yyyy", "mt-MT" : "dd/MM/yyyy", "sr-Cyrl-ME" : "d.M.yyyy", "se-FI" : "d.M.yyyy", "zu-ZA" : "yyyy/MM/dd", "xh-ZA" : "yyyy/MM/dd", "tn-ZA" : "yyyy/MM/dd", "hsb-DE" : "d. M. yyyy", "bs-Cyrl-BA" : "d.M.yyyy", "tg-Cyrl-TJ" : "dd.MM.yy", "sr-Latn-BA" : "d.M.yyyy", "smj-NO" : "dd.MM.yyyy", "rm-CH" : "dd/MM/yyyy", "smj-SE" : "yyyy-MM-dd", "quz-EC" : "dd/MM/yyyy", "quz-PE" : "dd/MM/yyyy", "hr-BA" : "d.M.yyyy.", "sr-Latn-ME" : "d.M.yyyy", "sma-SE" : "yyyy-MM-dd", "en-SG" : "d/M/yyyy", "ug-CN" : "yyyy-M-d", "sr-Cyrl-BA" : "d.M.yyyy", "es-US" : "M/d/yyyy" }; return formats[navigator.language] || 'dd/MM/yyyy'; }


   Get custom date format-


<div><a href="#">dddd h:mmtt d MMM yyyy</a></div>
<div><a href="#">M/d/y</a></div>
<div><a href="#">HH:mm:ss</a></div>
<div><a href="#">hh:mm TT</a></div>
<div><a href="#">yy/M/d</a></div>
<div><a href="#">ddd MMM d \a\t h:mm TT</a></div>


For example-
outputDiv.innerHTML= formatDate(new Date(),'hh:mm TT',true)


function formatDate(date, format, utc) {
       var MMMM = ["\x00", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
       var MMM = ["\x01", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
       var dddd = ["\x02", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
       var ddd = ["\x03", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
       function ii(i, len) { var s = i + ""; len = len || 2; while (s.length < len) s = "0" + s; return s; }


       var y = utc ? date.getUTCFullYear() : date.getFullYear();
       format = format.replace(/(^|[^\\])yyyy+/g, "$1" + y);
       format = format.replace(/(^|[^\\])yy/g, "$1" + y.toString().substr(2, 2));
       format = format.replace(/(^|[^\\])y/g, "$1" + y);


       var M = (utc ? date.getUTCMonth() : date.getMonth()) + 1;
       format = format.replace(/(^|[^\\])MMMM+/g, "$1" + MMMM[0]);
       format = format.replace(/(^|[^\\])MMM/g, "$1" + MMM[0]);
       format = format.replace(/(^|[^\\])MM/g, "$1" + ii(M));
       format = format.replace(/(^|[^\\])M/g, "$1" + M);


       var d = utc ? date.getUTCDate() : date.getDate();
       format = format.replace(/(^|[^\\])dddd+/g, "$1" + dddd[0]);
       format = format.replace(/(^|[^\\])ddd/g, "$1" + ddd[0]);
       format = format.replace(/(^|[^\\])dd/g, "$1" + ii(d));
       format = format.replace(/(^|[^\\])d/g, "$1" + d);


       var H = utc ? date.getUTCHours() : date.getHours();
       format = format.replace(/(^|[^\\])HH+/g, "$1" + ii(H));
       format = format.replace(/(^|[^\\])H/g, "$1" + H);


       var h = H > 12 ? H - 12 : H == 0 ? 12 : H;
       format = format.replace(/(^|[^\\])hh+/g, "$1" + ii(h));
       format = format.replace(/(^|[^\\])h/g, "$1" + h);


       var m = utc ? date.getUTCMinutes() : date.getMinutes();
       format = format.replace(/(^|[^\\])mm+/g, "$1" + ii(m));
       format = format.replace(/(^|[^\\])m/g, "$1" + m);


       var s = utc ? date.getUTCSeconds() : date.getSeconds();
       format = format.replace(/(^|[^\\])ss+/g, "$1" + ii(s));
       format = format.replace(/(^|[^\\])s/g, "$1" + s);


       var f = utc ? date.getUTCMilliseconds() : date.getMilliseconds();
       format = format.replace(/(^|[^\\])fff+/g, "$1" + ii(f, 3));
       f = Math.round(f / 10);
       format = format.replace(/(^|[^\\])ff/g, "$1" + ii(f));
       f = Math.round(f / 10);
       format = format.replace(/(^|[^\\])f/g, "$1" + f);


       var T = H < 12 ? "AM" : "PM";
       format = format.replace(/(^|[^\\])TT+/g, "$1" + T);
       format = format.replace(/(^|[^\\])T/g, "$1" + T.charAt(0));


       var t = T.toLowerCase();
       format = format.replace(/(^|[^\\])tt+/g, "$1" + t);
       format = format.replace(/(^|[^\\])t/g, "$1" + t.charAt(0));


       var tz = -date.getTimezoneOffset();
       var K = utc || !tz ? "Z" : tz > 0 ? "+" : "-";
       if (!utc) {
           tz = Math.abs(tz);
           var tzHrs = Math.floor(tz / 60);
           var tzMin = tz % 60;
           K += ii(tzHrs) + ":" + ii(tzMin);
       }
       format = format.replace(/(^|[^\\])K/g, "$1" + K);


       var day = (utc ? date.getUTCDay() : date.getDay()) + 1;
       format = format.replace(new RegExp(dddd[0], "g"), dddd[day]);
       format = format.replace(new RegExp(ddd[0], "g"), ddd[day]);


       format = format.replace(new RegExp(MMMM[0], "g"), MMMM[M]);
       format = format.replace(new RegExp(MMM[0], "g"), MMM[M]);


       format = format.replace(/\\(.)/g, "$1");


       return format;
   };


Get Detail exception
  
catch (WebException e)
           {
               using (WebResponse response = e.Response)
               {
                   HttpWebResponse httpResponse = (HttpWebResponse)response;
                   Console.WriteLine("Error code: {0}", httpResponse.StatusCode);
                   using (Stream data = response.GetResponseStream())
                   using (var reader = new StreamReader(data))
                   {
                       string text = reader.ReadToEnd();
                       Errorlogger.Error("Error in row no: " + text);
                   }
               }
           }





No comments:

Post a Comment

Packaging and Deploying Web Resources: A Practical ALM Workflow for Dynamics 365 JavaScript

You've written the script. You've unit-tested the logic and stepped through it in dev tools. It works perfectly on your form. Now co...