Sunday, 9 September 2018

Opening Office apps Fails when run from Scheduled Task on Windows Server

When running under user account while the user is logged in, the task runs fine as it has access to the logged in "user desktop-profile". But when task runs under a service account as a job, it fails because the server COM issue which cannot access to "system desktop-profile". To fix the issue, add the following directory:

c:\windows\syswow64\config\systemprofile\desktop 


Monday, 6 August 2018

C# REST Server POST and Get Response

async Task Main()
{
    string outputfile = "output.csv";
  
    File.Delete (outputfile);
  
    var httpWebRequest = (HttpWebRequest)WebRequest.Create(URL);
    httpWebRequest.ContentType = "application/json";
    httpWebRequest.Method = "POST";
  
    using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
    {
        string json = new JavaScriptSerializer().Serialize(new
        {
            startDate = "7/1/2018",
            endDate = "6/30/2019",
            codes = new string[] { "value1", "value2" },
            skus= "",
            returnCSV = 1
        });
        streamWriter.Write(json);
    }

    var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
    using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
    {
        using (StreamWriter sw = new StreamWriter(outputfile))
            sw.Write(await streamReader.ReadToEndAsync());
    }
}

Sunday, 5 August 2018

Wednesday, 1 August 2018

Powershell: Quick Search

Measure-Command
{
    Get-AdUser -Filter {
        ExtensionAttribute11 -eq 'NON'
    }
    -SearchBase 'Desired OU,DC=xxxx,DC=xxxx,DC=xxxx,DC=xxxx' # OU and DC parts
    -Properties ExtensionAttribute11 |
        Select name, ExtensionAttribute11, ExtensionAttribute13, Department, ...
}



Friday, 20 July 2018

SQL Update target tables from 2 different databases

begin transaction;

update [destination database].[dbo].[destination table] 
set [destination database].[dbo].[destination table].'destination column' = source.'desired column'
from [source database].[dbo].[source table] source
inner join [destination database].[dbo].[destination table] destnation 
on destination.'column to join' = source.'column to join'

--rollback; 
--commit; 


Wednesday, 4 July 2018

Vue.js Get Json Data and Display

Index.html
<html>
<title></title>
    <head>
        <!-- Import Vue library -->
        <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    </head>
    <body>
        <div id="app">
            <li v-for="msg in json">
                {{msg}}
            </li>
            <input v-model="text"/>
            <button @click="DisplayData">Query</button>
        </div>
    <script src="index.js"></script>
    </body>
</html>


Index.js
var app = new Vue({
    el: "#app",
    data: {
        text: "",
        json: null
    },
    methods: {
        DisplayData: function () {
            if (this.text)
            {
                fetch("https://api.github.com/users/" + this.text)
                    .then(r => r.json())
                    .then(json => { this.json = json; });
            }
        }
    }
});


Friday, 6 April 2018

Button feature not working within update panel in ASP.NET

To resolve this, initiate a full page postback trigger on update panel:

<asp:UpdatePanel runat="server">
    <Triggers>
        <asp:PostBackTrigger ControlID="YourControlID" />
    </Triggers>
    <ContentTemplate>
        .....


Analysis Service in Power BI Report Server

 We couldn’t connect to the Analysis Services server. Make sure you’ve entered the connection string correctly... link