Saturday, April 28, 2018
Thursday, April 12, 2018
Re: Can´t create a relationship between two columns because one of the columns must have unique valu
encountered this issue when trying to establish the relationship between two tables, however when I used group by statement to find the duplication, nothing turned up.
I then imported these two tables into Power BI and use the countrows and distinctcount which revealed that there are indeed duplicated rows.
I then created a calculated column as below and put it into a grid , filter the RecordCount>1
RecordCount = COUNTROWS(filter(ALL('dw DmResources'), 'dw DmResources'[ResourceID]=EARLIER('dw DmResources'[ResourceID])) )
the above step showed what's duplicated.
I did a select with like statement in SQL to find the duplicated records, copy and paste to Excel and compare the two duplicated string char by char and Excel told me that the different was a space CHAR(32)
the funny thing started here, I used LTRIM in sql to remove the trailing space, I also tried repalce(xx, char(32),'') , no luck.
At the end I use the ASCII(SUBSTRING(xxx, m, k)) in the sql query and it told me that the difference is actually a TAB (CHAR(9) ), apparently when copying from SQL output to Excel, the process automatically convert the TAB to a space??? maybe it is due to the fact that in Excel you can't enter a tab because it is a reserved function key?
Problem finally solved after all these drama.
I then imported these two tables into Power BI and use the countrows and distinctcount which revealed that there are indeed duplicated rows.
I then created a calculated column as below and put it into a grid , filter the RecordCount>1
RecordCount = COUNTROWS(filter(ALL('dw DmResources'), 'dw DmResources'[ResourceID]=EARLIER('dw DmResources'[ResourceID])) )
the above step showed what's duplicated.
I did a select with like statement in SQL to find the duplicated records, copy and paste to Excel and compare the two duplicated string char by char and Excel told me that the different was a space CHAR(32)
the funny thing started here, I used LTRIM in sql to remove the trailing space, I also tried repalce(xx, char(32),'') , no luck.
At the end I use the ASCII(SUBSTRING(xxx, m, k)) in the sql query and it told me that the difference is actually a TAB (CHAR(9) ), apparently when copying from SQL output to Excel, the process automatically convert the TAB to a space??? maybe it is due to the fact that in Excel you can't enter a tab because it is a reserved function key?
Problem finally solved after all these drama.
Thursday, July 7, 2016
GitHub - IdentityServer/IdentityServer3: OpenID Connect Provider and OAuth 2.0 Authorization Server Framework
This opens up huge potential while developing on-premise and cloud apps, be it windows , web based or mobile app.
GitHub - IdentityServer/IdentityServer3: OpenID Connect Provider and OAuth 2.0 Authorization Server Framework:
'via Blog this'
GitHub - IdentityServer/IdentityServer3: OpenID Connect Provider and OAuth 2.0 Authorization Server Framework:
'via Blog this'
Monday, May 30, 2016
Configure Asp.net MVC 5 with Ninject
Configure Asp.net MVC 5 with Ninject:
How to get Ninject working with asp.net MVC 5
Install-Package Ninject.MVC5
This will create the file in your solution:
App_Start\NinjectWebCommon.cs
Then to wire up an interface for resolution to a concreate implementation, just:
private static void RegisterServices(IKernel kernel) {
kernel.Bind<ISomeService>().To<SomeConcreateImplementation>();
}
Unity:Modify UnityConfig.cs to register serviceAdd this to App_start: UnityConfig.RegisterComponents();
Wednesday, October 7, 2015
Download Oracle e-business suite Images on Windows using WGET
Here is a slightly modified version to download from Oracle edelivery site instead of the update site:
Download PeopleSoft Images on Windows using WGET | psadmin.io: "SO_USE"
'via Blog this'
rem ---------------------------------------------------------------------------
rem Usage: wget-batch.bat <inputFile> <email> <password>
rem
rem <inputFile> is a plain text file that has the URL and Output Filename
rem separated by a comma (no spaces)
rem
rem Dan Iverson - 2015-06-12
rem This script takes 3 parameters: inputFile, email, password.
rem Filename is a text file with URL,Filename from the Oracle wget.sh script.
rem Email and Password are your Oracle Support login credentials.
rem
rem The script assumes you have WGET for Windows installed at
rem J:\downloads\wget
rem ---------------------------------------------------------------------------
rem Input file with "URL,Filename"
set LIST=%1
rem SSO username and password
set SSO_USERNAME=%2
set SSO_PASSWORD=%3
rem Path to wget command
set WGET=J:\downloads\wget\bin\wget.exe
rem Output directory and file
set OUTPUT_DIR=J:\Downloads
rem Location of cookie file
set COOKIE_FILE=%OUTPUT_DIR%\pum.cookies
rem Log directory and file
set LOGDIR=J:\Downloads
set LOGFILE=$%LOGDIR%\wgetlog-pumdownload.log
rem
rem End of user configurable variable
rem
rem Contact updates site so that we can get SSO Params for logging in
%WGET% --user-agent='Mozilla/5.0' https://edelivery.oracle.com/osdc/faces/SearchSoftware --no-check-certificate -o %OUTPUT_DIR%\output.txt
rem Find the Location part of the response
for /F "delims=" %%a in ('findstr "Location" %OUTPUT_DIR%\output.txt') do @set SSO_RESPONSE=%%a
rem Strip the first and last portions (split by a space character)
for /f "tokens=1,2,3 delims= " %%a in ("%SSO_RESPONSE%") do @set location=%%b
rem Create the SSO_SERVER variable (by finding the first two instances of 'p')
for /f "tokens=1-2,3 delims=p" %%a in ("%location%") do @set server1=%%a&@set server2=%%b
set SSO_SERVER=%server1%p%server2%
rem Create the SSO_TOKEN variable (by finding everything after the '=')
for /f "tokens=2 delims==" %%a in ("%location%") do @set SSO_TOKEN=%%a
set SSO_AUTH_URL=sso/auth
set AUTH_DATA="ssousername=%SSO_USERNAME%&password=%SSO_PASSWORD%&site2pstoretoken=%SSO_TOKEN%"
ECHO %AUTH_DATA%
rem The following command to authenticate uses HTTPS. This will work only if the wget in the environment
rem where this script will be executed was compiled with OpenSSL. Remove the --secure-protocol option
rem if wget was not compiled with OpenSSL
rem Depending on the preference, the other options are --secure-protocol= auto|SSLv2|SSLv3|TLSv1
%WGET% --user-agent='Mozilla/5.0' --secure-protocol=auto --no-check-certificate --post-data %AUTH_DATA% --save-cookies=%COOKIE_FILE% --keep-session-cookies %SSO_SERVER%%SSO_AUTH_URL% -O sso.txt
for /f "delims=, tokens=1,2" %%a in (%LIST%) do (
%WGET% --user-agent="Mozilla/5.0" --no-check-certificate --load-cookies=%COOKIE_FILE% --save-cookies=%COOKIE_FILE% --keep-session-cookies "%%a" -O %OUTPUT_DIR%/%%b
)
del sso.txt
pause
Download PeopleSoft Images on Windows using WGET | psadmin.io: "SO_USE"
'via Blog this'
Wednesday, September 2, 2015
Upload files to SharePoint using Excel
This is a minor task I undertook quite a while ago, I think someone might want to do something similar and hence decided to share the vba code, note that some of the code was sourced form somewhere else unfortunately I can't find the original source any more.
Public Sub CallWebService()
'Set and instantiate our working objects
Dim fileName As String
Dim fileName2 As String
Dim base64_data As String
fileName = Application.GetOpenFilename("Comma Separated Values (*.pdf),*.pdf")
If fileName <> "False" Then
'Workbooks.Open fileName, Format:=2
'Sheets1.Range("A2").Value = EncodeFile(fileName)
fileName2 = Dir(fileName, vbDirectory)
'MsgBox fileName2
base64_data = EncodeFile(fileName)
Else
Return
End If
Dim Req As Object
Dim sEnv As String
Dim Resp As New MSXML2.DOMDocument60 '60
Set Req = CreateObject("MSXML2.XMLHTTP")
Set Resp = CreateObject("MSXML2.DOMDocument.6.0")
Req.Open "Post", "https://home.contoso.com/_vti_bin/copy.asmx", False
' need to get the filename part
' we create our SOAP envelope for submission to the Web Service
sEnv = ""
sEnv = sEnv + ""
sEnv = sEnv + ""
sEnv = sEnv + "" + fileName + " "
sEnv = sEnv + ""
sEnv = sEnv + "https://home.contoso.com/sites/ITCDev/InvoiceDemo/" + fileName2 + " "
sEnv = sEnv + "
" sEnv = sEnv + ""
sEnv = sEnv + ""
sEnv = sEnv + ""
sEnv = sEnv + ""
sEnv = sEnv + ""
sEnv = sEnv + ""
sEnv = sEnv + ""
sEnv = sEnv + ""
sEnv = sEnv + "
" sEnv = sEnv + "" + base64_data + " "
sEnv = sEnv + "
" sEnv = sEnv + "
" sEnv = sEnv + "
"
'sEnv = sEnv & ";"
'sEnv = sEnv & ""
'sEnv = sEnv & ""
'sEnv = sEnv & ""
'sEnv = sEnv & "username "
'sEnv = sEnv & "password "
''Looks for SKU in active worksheet cell B3
'sEnv = sEnv & "" & Range("B3").Value & " "
'sEnv = sEnv & "
" 'sEnv = sEnv & "
" 'sEnv = sEnv & "
" ' Send SOAP Request
Req.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
Req.setRequestHeader "SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/CopyIntoItems"
Req.send (sEnv)
'oXMLHttp.open("POST", strSoapURL, false, "SVC_E4SE", "Ep1c@rIC#1.2");
'oXMLHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
'oXMLHttp.setRequestHeader("SOAPAction", "http://epicor.com/webservices/" + actionName);
'oXMLHttp.send(oReqXML.xml);
' Display results in MessageBox
'MsgBox Req.responseText
Resp.LoadXML Req.responseText
Range("B6").Value = Resp.XML
'clean up code
Set Req = Nothing
Set Resp = Nothing
End Sub
Public Function EncodeFile(strPicPath As String) As String
Const adTypeBinary = 1 ' Binary file is encoded
' Variables for encoding
Dim objXML
Dim objDocElem
' Variable for reading binary picture
Dim objStream
' Open data stream from picture
Set objStream = CreateObject("ADODB.Stream")
objStream.Type = adTypeBinary
objStream.Open
objStream.LoadFromFile (strPicPath)
' Create XML Document object and root node
' that will contain the data
Set objXML = CreateObject("MSXml2.DOMDocument")
Set objDocElem = objXML.createElement("Base64Data")
objDocElem.DataType = "bin.base64"
' Set binary value
objDocElem.nodeTypedValue = objStream.Read()
' Get base64 value
EncodeFile = objDocElem.Text
' Clean all
Set objXML = Nothing
Set objDocElem = Nothing
Set objStream = Nothing
End Function
Public Sub CallWebService()
'Set and instantiate our working objects
Dim fileName As String
Dim fileName2 As String
Dim base64_data As String
fileName = Application.GetOpenFilename("Comma Separated Values (*.pdf),*.pdf")
If fileName <> "False" Then
'Workbooks.Open fileName, Format:=2
'Sheets1.Range("A2").Value = EncodeFile(fileName)
fileName2 = Dir(fileName, vbDirectory)
'MsgBox fileName2
base64_data = EncodeFile(fileName)
Else
Return
End If
Dim Req As Object
Dim sEnv As String
Dim Resp As New MSXML2.DOMDocument60 '60
Set Req = CreateObject("MSXML2.XMLHTTP")
Set Resp = CreateObject("MSXML2.DOMDocument.6.0")
Req.Open "Post", "https://home.contoso.com/_vti_bin/copy.asmx", False
' need to get the filename part
' we create our SOAP envelope for submission to the Web Service
sEnv = "
sEnv = sEnv + "
sEnv = sEnv + "
sEnv = sEnv + "
sEnv = sEnv + "
sEnv = sEnv + "
sEnv = sEnv + "
" sEnv = sEnv + "
sEnv = sEnv + "
sEnv = sEnv + "
sEnv = sEnv + "
sEnv = sEnv + "
sEnv = sEnv + "
sEnv = sEnv + "
sEnv = sEnv + "
sEnv = sEnv + "
" sEnv = sEnv + "
sEnv = sEnv + "
" sEnv = sEnv + "
" sEnv = sEnv + "
"
'sEnv = sEnv & "
'sEnv = sEnv & "
'sEnv = sEnv & "
'sEnv = sEnv & "
'sEnv = sEnv & "
'sEnv = sEnv & "
''Looks for SKU in active worksheet cell B3
'sEnv = sEnv & "
'sEnv = sEnv & "
" 'sEnv = sEnv & "
" 'sEnv = sEnv & "
" ' Send SOAP Request
Req.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
Req.setRequestHeader "SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/CopyIntoItems"
Req.send (sEnv)
'oXMLHttp.open("POST", strSoapURL, false, "SVC_E4SE", "Ep1c@rIC#1.2");
'oXMLHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
'oXMLHttp.setRequestHeader("SOAPAction", "http://epicor.com/webservices/" + actionName);
'oXMLHttp.send(oReqXML.xml);
' Display results in MessageBox
'MsgBox Req.responseText
Resp.LoadXML Req.responseText
Range("B6").Value = Resp.XML
'clean up code
Set Req = Nothing
Set Resp = Nothing
End Sub
Public Function EncodeFile(strPicPath As String) As String
Const adTypeBinary = 1 ' Binary file is encoded
' Variables for encoding
Dim objXML
Dim objDocElem
' Variable for reading binary picture
Dim objStream
' Open data stream from picture
Set objStream = CreateObject("ADODB.Stream")
objStream.Type = adTypeBinary
objStream.Open
objStream.LoadFromFile (strPicPath)
' Create XML Document object and root node
' that will contain the data
Set objXML = CreateObject("MSXml2.DOMDocument")
Set objDocElem = objXML.createElement("Base64Data")
objDocElem.DataType = "bin.base64"
' Set binary value
objDocElem.nodeTypedValue = objStream.Read()
' Get base64 value
EncodeFile = objDocElem.Text
' Clean all
Set objXML = Nothing
Set objDocElem = Nothing
Set objStream = Nothing
End Function
Subscribe to:
Posts (Atom)
Disable Microsoft Defender for Cloud for Visual Studio Subscription (MSDN)
I use a visual studio pro subscription which comes with $150 azure cloud credit, for some reason Microsoft Defender for Cloud was turned on ...
-
Error 15401: Windows NT user or group '%s' not found. Check the name again. SELECT name FROM syslogins WHERE sid = SUSER_SID ('Y...
-
/etc/ipsec.config conn ios keyexchange=ikev1 authby=xauthrsasig xauth=server lef...
-
Ever since I installed VMWare ESX server on my HP ML110 G4, I haven't got much chance playing it and it has been lying on the floor for ...