Saturday, 6 June 2020

Migration issues for SAP.Connector.dll from Win 2003 to Win 2019 server


Recently I got task of migration of asmx web services from windows 2003 to windows 2019 server. These web services fetch data from SAP using SAP.Connector dll version 2.0. One of the asks was to do apple to apple migration, no code changes and enhancements.
Following are the issues I faced and resolution for same. it might be helpful for someone.
    
1. After migration of service I tried to consume web service using console application, first error I got is Unable to load DLL librfc32.dll: The specified module could not be found. I searched dll on windows 2003 server and observed that it is part of SAP GUI installation, so I have installed it on windows 2019 server however still got the same error.




Resolution: There is new librfc32.dll version available for 64-bit machine which we need to put/replace in C:\Windows\System32. 

2. Second error I got is Connect to message server failed

Errors Occurred. Error Description: SAP.Connector.RfcCommunicationException: Connect to message server failed
Connect_PM  MSHOST=*****, R3NAME=****, GROUP=****

ERROR       service '?' unknown
TIME        Tue Jun 02 09:48:52 2020
RELEASE     720
COMPONENT   NI (network interface)
VERSION     40
RC          -3
DETAIL      NiErrSet
COUNTER     2

   at SAP.Connector.SAPConnection.ThrowRfcException(RFC_ERROR_INFO_EX rfcerrInfo, Encoding encoding)
   at SAP.Connector.SAPConnection.Open()

Resolution: We need to update ‘services’ file under ‘C:\Windows\System32\drivers\etc' with message server host name and port.

3. Third error I got is AccessViolationException

System.AccessViolationException
   at System.StubHelpers.MngdNativeArrayMarshaler.ConvertContentsToManaged(IntPtr, System.Object ByRef, IntPtr)
   at SAP.Connector.RfcApi.RfcCallReceive(Int32, System.String, SAP.Connector.RFC_PARAMETER[], SAP.Connector.RFC_PARAMETER[], SAP.Connector.RFC_TABLE[], System.String ByRef)
   at SAP.Connector.SAPClient.RfcInvoke(System.String, System.Object[])


Resolution: We need to configure web services application to run in 32-bit mode instead of
64- bit, due to old version of SAP.Connector.dll.  

Friday, 5 October 2018

How to tell what version of SQL Server you are running?



  1. One simple way to do this is to run SELECT @@version
SELECT @@VERSION 

Result:

Microsoft SQL Server 2017 (RTM-CU6) (KB4101464) - 14.0.3025.34 (X64)  
Apr  9 2018 18:00:41  
Copyright (C) 2017 Microsoft Corporation  
Standard Edition (64-bit) on Windows Server 2016 Standard 10.0 <X64> (Build 14393: ) (Hypervisor) 

Wednesday, 31 January 2018

SharePoint Framework Property Controls

Developers have started use of SharePoint framework for developing the client side web parts in SharePoint online(Office 365). Some of the code block is getting repeated across multiple client side web parts like selecting the list, date time selection, color picker, term set picker. Developers have noticed this to the PNP community. Hence Microsoft came up with reusable controls which are similar to our ASP.net concept of user controls. This controls can be added to the web part easily and can be used as custom property in property pane. I didn't find all steps in single blog so decided to summaries here starting from creating the client side web parts.



Step 3 : Install the following dependency to your project

Make sure that node.js command prompt is running and it is referring to your project. Execute the below command.
npm install @pnp/spfx-property-controls --save --save-exact
 Step 4 : Update the configuration file of your project

Go to Config folder, under that open config.json file and add the following line to the localizedresource property.
"PropertyControlStrings": "./node_modules/@pnp/spfx-property-controls/lib/loc/{locale}.js"
"localizedResources": {
    "CustomucwebpartWebPartStrings""lib/webparts/customucwebpart/loc/{locale}.js",
    "PropertyControlStrings""./node_modules/@pnp/spfx-property-controls/lib/loc/{locale}.js"
  }
Step 5 : Adding control to your web part

There are around 6 controls currently available.


  1. PropertyFieldColorPicker
  2. PropertyFieldDateTimePicker
  3. PropertyFieldListPicker
  4. PropertyFieldPeoplePicker
  5. PropertyFieldSpinButton
  6. PropertyFieldTermPicker
we will use PropertyFieldColorPicker control. Import the following module to your web part file.

import { 
  PropertyFieldColorPicker
  PropertyFieldColorPickerStyle 
from '@pnp/spfx-property-controls/lib/PropertyFieldColorPicker';

Add the new property in web part name it color of type string
export interface ICustomucwebpartWebPartProps {
  descriptionstring;
  colorstring
}

Add the custom property control to the group fields of the web part property configuration.
 PropertyFieldColorPicker('color', {
                  label: 'Color',
                  selectedColor: this.properties.color,
                  onPropertyChange: this.onPropertyPaneFieldChanged,
                  properties: this.properties,
                  disabled: false,
                  alphaSliderHidden: false,
                  style: PropertyFieldColorPickerStyle.Full,
                  iconName: 'Precipitation',
                  key: 'colorFieldId'
                })   
To test the web part, display the property value in Render method.
 <p class="${ styles.description }">${escape(this.properties.color)}</p>      
Now run the gulp serve to test property locally.

Add the web part on workbench page then click on edit and in property pane you will see the color property with color picker option available. You can select the color and same value will be displayed in the web part body.






Enjoy coding !!!
Reference:
  1. SharePoint framework property control

Thursday, 4 January 2018

PowerShell Start SharePoint incremental crawl

Many times we have scenario where we want to start the incremental crawl after updating some data in SharePoint using power shell, here we can use the below script.


Get-SPEnterpriseSearchCrawlContentSource -SearchApplication "Search Service Application" | where-object { ($_.CrawlStatus -eq "idle") } | foreach { $_.StartIncrementalCrawl() }

Enjoy coding !!!

Read file from FTP location using Powershell


To read the file from the FTP, we can use below script:

$webclient = New-Object System.Net.WebClient
$webclient.Credentials = New-Object System.Net.NetworkCredential('ftp username','ftp password')

$uri = New-Object System.Uri('ftp path')

$webClient.DownloadFile($uri, 'local path') 

Sunday, 15 March 2015

Setting Header and Footer as Image while creating PDF using iTextSharp


I have requirement in SharePoint 2013 project to create the PDF dynamically from the HTML having header and footer on every page. I have used open source iTextSharp dll to achieve the same, There are many samples available to add image to pdf using iTextSharp, however there is one specific scenario where you are creating the PDF by specifying the HTML and that too it should have header and footer on each page. Normally header and footer will be only appear once in case of HTML.

Following few tips you should consider while achieving this functionality:

1. You have specified the margin Top and margin Bottom while creating the document object of iTextSharp.

Document doc = new Document(PageSize.A4, 10, 10, 150, 150)

here the last two parameters are top and bottom margin.

2. You need to implement the event handler, In which you will override the OnEndPage event of the class by deriving it from PdfPageEventHelper class.

public override void OnEndPage(PdfWriter writer, iTextSharp.text.Document document)

3. You need add the image in header and footer using OnEndPage event only.

               PdfPTable footerTbl = new PdfPTable(1);

                footerTbl.TotalWidth = document.PageSize.Width;

                Image logo = Image.GetInstance(new Uri(string.Format("{0}/SiteCollectionImages/Footer.JPG", SiteCollectionUrl)));

                logo.SetAbsolutePosition(0, 0);

                PdfPCell cell = new PdfPCell(logo);

                cell.HorizontalAlignment = Element.ALIGN_RIGHT;

                cell.PaddingRight = 20;

                cell.Border = 0;

                footerTbl.AddCell(cell);

                footerTbl.WriteSelectedRows(0, -1, 0, 90, writer.DirectContent);

                PdfPTable headerTbl = new PdfPTable(1);

                headerTbl.TotalWidth = document.PageSize.Width;

                Image logo1 = Image.GetInstance(new Uri(string.Format("{0}/SiteCollectionImages/header.jpg", SiteCollectionUrl)));

                logo1.ScalePercent(90);

                logo1.SetAbsolutePosition(0, 0);

                PdfPCell cell1 = new PdfPCell(logo1);

                cell1.HorizontalAlignment = Element.ALIGN_RIGHT;

                cell1.Border = 0;

                headerTbl.AddCell(cell1);

                headerTbl.WriteSelectedRows(0, -1, 0, (document.PageSize.Height - 10), writer.DirectContent);

4. Specify the event handler in PdfWriter.

Wednesday, 28 May 2014

Rename column name in SharePoint online List View

To rename the Column name in SharePoint Online List view, use the following jQuery


<script type="text/javascript"
    src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js">
</script>
<script type="text/javascript">
    $(document).ready(function () {      
        renameColumnName('Title');
    });
    function renameColumnName(c) {
        $(".ms-formlabel h3 nobr").filter(function () {
            var thisText = $.trim($(this).clone().children().remove().end().text());
            return thisText.indexOf(c) === 0 && thisText.length === c.length;
        }).html('Title1');
    }
</script>

In the rename Column name function first we need to find out the title column and then using HTML function of jQuery we are replacing it.

Migration issues for SAP.Connector.dll from Win 2003 to Win 2019 server

Recently I got task of migration of asmx web services from windows 2003 to windows 2019 server. These web services fetch data from SAP us...