Hi,
Following code is running fine on Sql server 2008R2 64 bit machine, I am testing on 32 Bit machine to migrate it to 2012 Sql server I cannot bypass the following error which I have no idea.
Code Overview: After doing an API Call using Curl, to parse the results we are using Json dll and C# code to get the session id.
Code:
using System;using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.Collections.Generic;
//using System.Web.Script.Serialization.JavaScriptSerializer;
using Newtonsoft.Json;
namespace ST_f6f87af4693544648f91c847e055fee0.csproj
{
[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
#region VSTA generated code
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
#endregion
public class NetworkId
{
public int id { get; set; }
public string name { get; set; }
public string url { get; set; }
}
// authenticate object
public class authObject
{
public string responseStatus { get; set; }
public string sessionId { get; set; }
public int userId { get; set; }
public string networkId { get; set; }
public List<NetworkId> networkIds { get; set; }
}
public void Main()
{
Dts.TaskResult = (int)ScriptResults.Success;
authObject objJSON = JsonConvert.DeserializeObject<authObject>(Dts.Variables["curlResults"].Value.ToString());
Dts.Variables["SessionId"].Value = objJSON.sessionId==null?"":objJSON.sessionId;
if (objJSON.sessionId == null)
{
Dts.TaskResult = (int)ScriptResults.Failure;
}
using (System.IO.StreamWriter file =
new System.IO.StreamWriter(@"C:\Users\skonda\Documents\log.txt", true))
{
file.WriteLine(Environment.NewLine + DateTime.Now.ToString("MMM ddd d HH:mm yyyy") + " Get Session Id: " + Dts.Variables["curlResults"].Value.ToString());
}
return;
}
}
}