Friday, December 23, 2022

Lock resources in Azure

As an administrator, we can lock an Azure subscription, resource group, or resource to protect them from accidental user deletions and modifications. The lock overrides any user permissions.

You can set locks that prevent either deletions or modifications. 

These locks are of 2 types 

1. Delete

2. Read-only


Delete means authorized users can read and modify a resource, but they can't delete it.

ReadOnly means authorized users can read a resource, but they can't delete or update it. Applying this lock is similar to restricting all authorized users to the permissions that the Reader role provides


When you apply a lock at a parent scope, all resources within that scope inherit the same lock. Even resources you add later inherit the same parent lock. The most restrictive lock in the inheritance takes precedence.


Tuesday, December 20, 2022

Common XSLT syntax

Declaring a variable

<xsl:variable name="CanonicalHeader" select="/n0:CanonicalPurchaseOrderAck/Header"/>


Fetching the value in XSL tag

<xsl:value-of select="$CanonicalHeader/PurchaseOrderNumber"/>


If condition in XSL

<xsl:value-of select="$CanonicalHeader/Addresses/Name[EntityIdentifierCode1 = 'ST']/IdentificationCode"/>

or

<xsl:value-of   select="/ns0:X12_00401_210/ns0:LXLoop1/ns0:L5[L502='FUEL SURCHARGE']/../ns0:L1/L104/text() div 100"/>


If - Else (Example 1)

<xsl:choose>

<xsl:when test="$CanonicalHeader/Addresses/Name[EntityIdentifierCode1 = 'ST']/IdentificationCode != ''">

<xsl:value-of select="$CanonicalHeader/Addresses/Name[EntityIdentifierCode1 = 'ST']/IdentificationCode"/>

</xsl:when>

<xsl:otherwise>

<Error>

Missing EntityIdentifierCode1 ST

</Error>

</xsl:otherwise>

</xsl:choose>


If - Else (Example 2)

<xsl:choose>

<xsl:when test="$CanonicalHeader/Dates[DateTimeQualifier = '004']/Date != ''">

<xsl:value-of select="$CanonicalHeader/Dates[DateTimeQualifier = '004']/Date"/>

</xsl:when>

<xsl:otherwise>

<Error>

Missing DateTimeQualifier 004

</Error>

</xsl:otherwise>

</xsl:choose>



Taking 1st/2nd from n tags

<xsl:variable name="FromAddressCity" select="/ns0:X12_00401_210/ns0:LXLoop1/ns0:N1Loop3/ns0:N4_3/N401"/>


<xsl:value-of   select="$FromAddressCity[1]"/>


Current time

<CreatedDateTime>

<xsl:value-of   select="current-dateTime()"/>

</CreatedDateTime>


For each loop

<AccessorialCharges>

<xsl:for-each select="./ns0:X12_00401_210/ns0:LXLoop1/ns0:L5">

<AccessorialCharge>

<Code>

<xsl:value-of select="../ns0:L5/L502"/>

</Code>

<Description>

<xsl:value-of select="../ns0:L5/L502"/>

</Description>

<Charge>

<xsl:value-of select="../ns0:L1/L104 div 100"/>

</Charge>

</AccessorialCharge>

</xsl:for-each>

</AccessorialCharges>

















Copy and paste the below code into notepad++ for better visualization.


Code:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="3.0"   

  xmlns:ns0="http://schemas.microsoft.com/BizTalk/EDI/X12/2006"  

  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:variable name='Valuee' select="/ns0:X12_00401_110/ns0:B3/B302"/>

<xsl:template match="/">

<ns0:Output>

<ns0:Header>

<ns0:Invoice_Number>

<xsl:value-of select="/ns0:X12_00401_110/ns0:B3/B302"/>

</ns0:Invoice_Number>

<ns0:Vendor_Code>

<xsl:value-of select="'U100004'"/>

</ns0:Vendor_Code>

<ns0:Comm_Date>

<xsl:value-of select="/ns0:X12_00401_110/ns0:B3/B312"/>

</ns0:Comm_Date>

<ns0:Total_Inv_Amt>

<xsl:value-of select="/ns0:X12_00401_110/ns0:B3/B307 div 100"/>

</ns0:Total_Inv_Amt>

<ns0:Inv_Date>

<xsl:value-of select="/ns0:X12_00401_110/ns0:B3/B312"/>

</ns0:Inv_Date>

<ns0:Detail>

<ns0:Invoice_Number>

<xsl:value-of select="/ns0:X12_00401_110/ns0:B3/B302"/>

</ns0:Invoice_Number>

<ns0:Vendor_Code>

<xsl:value-of select="'U100004'"/>

</ns0:Vendor_Code>

<ns0:Comm_Date>

<xsl:value-of select="/ns0:X12_00401_110/ns0:B3/B312"/>

</ns0:Comm_Date>

<ns0:Inv_Date>

<xsl:value-of select="/ns0:X12_00401_110/ns0:B3/B312"/>

</ns0:Inv_Date>

<ns0:Invoice_Line_No>

<xsl:value-of select="/ns0:X12_00401_110/ns0:B3A/B3A02"/>

</ns0:Invoice_Line_No>

<ns0:Frt_Amt>

<xsl:value-of select="/ns0:X12_00401_110/ns0:B3/B307 div 100"/>

</ns0:Frt_Amt>

<ns0:AirWayBill>

 <xsl:value-of select="/ns0:X12_00401_110/ns0:LXLoop1/ns0:N1Loop2/ns0:N9_2[N901 = 'AW']/N902/text()"/>  

</ns0:AirWayBill>

<ns0:Child_Acct_No>

<xsl:value-of select="/ns0:X12_00401_110/ns0:LXLoop1/ns0:N1Loop2/ns0:N9_2[N901='IT']/N902/text()"/>

</ns0:Child_Acct_No>

<ns0:Parent_Acct_No>

<xsl:value-of select="/ns0:X12_00401_110/ns0:N1Loop1/ns0:N9[N901='14']/N902/text()"/>

</ns0:Parent_Acct_No>



<xsl:choose>

  <xsl:when test="contains(./X12_00401_110/ns0:N9/N902,'SALE') or contains(./X12_00401_110/ns0:N9/N902,'Sale')">

  <xsl:variable name='ValueUSO' select="substring(./X12_00401_110/ns0:N9/N902,8,3)"/> <!--set value-->

  <xsl:choose>

    <xsl:when test="($ValueUSO='USO')">

       <xsl:variable name='ValueUSO2' select="substring(./X12_00401_110/ns0:N9/N902,12,8)"/> <!--set value-->

       <xsl:variable name='CustRef' select="concat('USO-',$ValueUSO2)" />

       <ns0:Cust_Ref>

        <xsl:value-of select="$CustRef"/>

       </ns0:Cust_Ref>       

    </xsl:when>

    <xsl:otherwise>

       <xsl:choose>

         <xsl:when test="contains(./X12_00401_110/ns0:N9/N902,'USR') or contains(./X12_00401_110/ns0:N9/N902,'Usr')">

         <xsl:variable name='CustRef' select="substring(./X12_00401_110/ns0:N9/N902,8,100)" />

         <ns0:Cust_Ref>

          <xsl:value-of select="$CustRef"/>

         </ns0:Cust_Ref>       

         </xsl:when>

         <xsl:otherwise>

         </xsl:otherwise>

       </xsl:choose>

    </xsl:otherwise>

  </xsl:choose>

  </xsl:when>

</xsl:choose>



<xsl:for-each select="./ns0:X12_00401_110/ns0:LXLoop1/ns0:L5Loop1/ns0:L1Loop1">

<ns0:Charge>

<ns0:Invoice_Number>

<xsl:value-of select="../../../ns0:B3/B302"/>

</ns0:Invoice_Number>

<ns0:Vendor_Code>

<xsl:value-of select="'U100004'"/>

</ns0:Vendor_Code>

<ns0:Comm_Date>

<xsl:value-of select="../../../ns0:B3/B312"/>

</ns0:Comm_Date>

<ns0:Inv_Date>

<xsl:value-of select="../../../ns0:B3/B312"/>

</ns0:Inv_Date>

<ns0:Charge_Amt>

<xsl:value-of select="ns0:L1/L104 div 100"/>

</ns0:Charge_Amt>

<ns0:Charge_Code>

<xsl:value-of select="ns0:L1/L108"/>

</ns0:Charge_Code>

</ns0:Charge>

</xsl:for-each>

</ns0:Detail>

</ns0:Header>

</ns0:Output>

</xsl:template>

</xsl:stylesheet>

Saturday, December 10, 2022

Shortcut keys for visual studio and windows to boost your productivity

 

Visual Studio:

Solution explorer > Ctrl + Alt + L

Team Explorer > Ctrl + \, Ctrl + M

Application Explorer > Ctrl + E, Ctrl + E

Properties > Alt + Enter

Open notifications > Window + N

Build > Ctrl + Shift + B


Windows:

Switch between windows > Alt + Tab || Alt + Shift + Tab

Switch between desktops > Ctrl + Window + Left arrow || Ctrl + Window + Right arrow

Create new desktop > Ctrl + Window + D

Lock windows > Window + L

Re-open closed browser window > Ctrl + Shift + Tab

Find > Ctrl + F

Bookmark a page in chrome > Ctrl + D

Rename a file > F2

Launch file explorer > Windows + E

Switch tabs > Ctrl + Tab

Snipping tool screenshot > Window + Shift + S


Friday, December 9, 2022

After restore the DB from UAT or Prod to Dev Environment to Copy the admin user from Dev backup to new restored DB



DECLARE @SID NVARCHAR(124)

DECLARE @NetworkAlias NVARCHAR(255)

–Get the SID, NetworkAlias from the original database
SELECT
@SID = [SID],
@NetworkAlias = NetworkAlias
FROM [AxDB_Orig].[dbo].[UserInfo]
WHERE Id = ‘Admin’

–Restore the SID, NetworkAlias to the restored database
UPDATE [AxDB].[dbo].[UserInfo] SET
[SID] = @SID,
NetworkAlias = @NetworkAlias
WHERE Id = ‘Admin’

Create a custom web service in D365FO Integration (Data Sending) Outbound

Share the data of a table using soap services

In our case let's create a table DAP_Worker with the fields Name, Phone, Address

Now create a class "GITSWorkerList"


[DataContractAttribute]

class GITSWorkerList

{

    Name    Name;

    Name    Phone;

    Name    Address;


    [DataMemberAttribute]

    public Name Name(Name _Name = Name)

    {

        Name = _Name;

        return Name;

    }


    public Name Phone(Name _Phone = Phone)

    {

        Phone = _Phone;

        return Phone;

    }


    public Name Address(Name _Address = Address)

    {

        Address = _Address;

        return Address;

    }


}



Now create a service class "GITSWorkerService"

class GITSWorkerService
{
    
    [AifCollectionTypeAttribute('return',Types::Class,classStr(GITSWorkerList)),SysEntryPointAttribute(true)]
    public list PublicWorker(DataAreaId _company)
    {
        
        List WorkerList = new List(Types::Class);
        GITSWorkerList              GITSWorkerList;
        PurchRFQCaseTable           RFQCaseTable;
        DAP_Worker                  DAP_Worker;
        changeCompany(_company)
        {
            while select DAP_Worker
            {
                GITSWorkerList= new GITSWorkerList();
                GITSWorkerList.Name(DAP_Worker.Name);
                GITSWorkerList.Phone(DAP_Worker.Phone);
                GITSWorkerList.Address(DAP_Worker.Address);
                WorkerList.addEnd(GITSWorkerList);
            }
            return WorkerList;
        }
    }

}



Now create a service "GITSWorkerService"
Set the external name "GITSWorkerService"
And Description "Worker"
And class name property "GITSWorkerService"

[Note: Soap > XML]

Now create a service operation in the service and select the method as "PublicWorker" and the name of the operation as same

Now create a service group "GITSWorkerServiceGroup" and set auto-deploy property to "Yes"
Now create a service in the service group "GITSWorkerService" and set the service "GITSWorkerService"

Link to access the service
REST {JSON,XML}access: https://usnconeboxax1aos.cloud.onebox.dynamics.com/api/services/GITSWorkerServiceGroup/GITSWorkerService/PublicWorker
Note: OData also comes under REST services

Soap {Only XML}access: https://usnconeboxax1aos.cloud.onebox.dynamics.com/soap/services/GITSWorkerServiceGroup?wsdl

Sunday, December 4, 2022

How to create a key vault in Azure

Go to Azure Portal

Click on "Create a resource"


Now in the search, search for "Key vault"


Now click on create,


A new form will open up, like below


Fill in the details as shown in the picture below,


Now click on "Review and create", a new window will open like below



Go to the resource created, you will see a window like the one below,


Now go to "Secrets"


Now click on "Generate/Import" as shown in the picture above, a new window will open like the one below, fill in the Name and secret value that you want to save and click on create


Now you can see the secret stored in the Key vault as shown below



Tada!!!

How to send a message in Service bus via service bus explorer

 Download Service bus explorer from the Link

Extract the zip file and Run the "Service bus explorer" as shown in the picture

"Service bus explorer" will be opened and will look like below, Now click on file connect


A new window will open like below


Go to the service bus, and Shared access policy, as shown in the picture


Copy the primary key,


Fill in the details in "Service bus explorer", like below


Click Ok

You will see all the topics and Queues on the left side panel, right click on it and select "Select messages"


Now click on select files, like below, and select the file that you want to send in the bus or topic


Now click "Start", it will send the required file to the Topics, that you want


Tada!!!