Click here to Skip to main content
15,896,111 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to read tables in Excel Worksheet witc C# and XML Pin
Eddy Vluggen16-Oct-14 9:05
professionalEddy Vluggen16-Oct-14 9:05 
QuestionC#/C wrapper Pin
Nikolaj jensen16-Oct-14 2:39
Nikolaj jensen16-Oct-14 2:39 
AnswerRe: C#/C wrapper Pin
Richard MacCutchan16-Oct-14 2:59
mveRichard MacCutchan16-Oct-14 2:59 
GeneralRe: C#/C wrapper Pin
Nikolaj jensen16-Oct-14 3:52
Nikolaj jensen16-Oct-14 3:52 
GeneralRe: C#/C wrapper Pin
Richard MacCutchan16-Oct-14 3:56
mveRichard MacCutchan16-Oct-14 3:56 
GeneralRe: C#/C wrapper Pin
Nikolaj jensen16-Oct-14 21:43
Nikolaj jensen16-Oct-14 21:43 
QuestionHow to convert HTML Form data into RTF File Pin
mukulsharma114616-Oct-14 1:37
mukulsharma114616-Oct-14 1:37 
AnswerRe: How to convert HTML Form data into RTF File Pin
Richard MacCutchan16-Oct-14 2:55
mveRichard MacCutchan16-Oct-14 2:55 
AnswerRe: How to convert HTML Form data into RTF File Pin
Eddy Vluggen16-Oct-14 9:07
professionalEddy Vluggen16-Oct-14 9:07 
GeneralRe: How to convert HTML Form data into RTF File Pin
mukulsharma114616-Oct-14 19:56
mukulsharma114616-Oct-14 19:56 
AnswerRe: How to convert HTML Form data into RTF File Pin
BillWoodruff16-Oct-14 10:11
professionalBillWoodruff16-Oct-14 10:11 
QuestionHow to draw small circle in rectangle c# Pin
Member 1115802716-Oct-14 0:52
Member 1115802716-Oct-14 0:52 
AnswerRe: How to draw small circle in rectangle c# Pin
Richard MacCutchan16-Oct-14 1:32
mveRichard MacCutchan16-Oct-14 1:32 
GeneralRe: How to draw small circle in rectangle c# Pin
harold aptroot16-Oct-14 1:54
harold aptroot16-Oct-14 1:54 
GeneralRe: How to draw small circle in center rectangle c# Pin
Member 1115802716-Oct-14 23:37
Member 1115802716-Oct-14 23:37 
Questionhaw to upload image in c# code? Pin
biruk-bk16-Oct-14 0:03
biruk-bk16-Oct-14 0:03 
QuestionRe: uploading image in c# Pin
Eddy Vluggen16-Oct-14 0:26
professionalEddy Vluggen16-Oct-14 0:26 
Questionabout c# command for oralce Pin
yuscq15-Oct-14 18:26
professionalyuscq15-Oct-14 18:26 
QuestionRe: about c# command for oralce Pin
Eddy Vluggen16-Oct-14 0:27
professionalEddy Vluggen16-Oct-14 0:27 
AnswerRe: about c# command for oralce Pin
Praneet Nadkar16-Oct-14 0:45
Praneet Nadkar16-Oct-14 0:45 
GeneralRe: about c# command for oralce Pin
yuscq16-Oct-14 16:47
professionalyuscq16-Oct-14 16:47 
QuestionEdge.js problem driving me crazy | I can call code through WebApi route but not from node server Pin
Alaric_15-Oct-14 15:52
professionalAlaric_15-Oct-14 15:52 
So I've run into a snag that is driving me insane. I've built two async connectors: one is to a SQL Server database and have exposed it through WebApi (for a .NET sanity check) and through a Task<object> interface exposed for node consumers. The second uses a TaskCompletionSource that wraps an arbitrary list with a Task (for a node sanity check).

When I Debug the Web Api project and nav to my route that is attached to the database, everything does fine. The data from my database is returned to the browser.

When I node my server attached to the mocked async route, everything does fine. My mock is returned to my server and I spool the object to the console.

HOWEVER...when I try to wire node in to consume the attached data connector, when I browse to the open node port, my server crashes with an error "Process is terminated due to StackOverflowException."

The frustration comes from the fact that I'm doing nothing fancy and the connector retrieves data just fine from an api route.


My server:
JavaScript
var edge = require('edge');
var http = require('http');
var port = process.env.PORT || 8088;


var userRepository = {
        getUsers: edge.func({
            assemblyFile:'Edge.Test.dll',
            typeName: 'Edge.Test.DataConnector',
            methodName: 'Invoke'
        })
};

function logError(error, response){
    console.log('[Error]:{' + error+'}');
    response.writeHead(200, { 'Content-Type': 'text/plain'});
    response.write('[Error]:' + error);
    response.end("");
}

http.createServer(function(request,response){
    console.log('Creating Server...');
    response.writeHead(200, {'Content-Type':'text/html'});
    var payload = {};
    console.log('[Before][userRepository.getUsers]');
    userRepository.getUsers(payload, function(error, result){
        console.log('[Result][userRepository.getUsers]');
        if(error){logError(error, result);return;}
        if(result){
            response.write("<ul>");
            result.forEach(function(user){
                console.log("[Response contains User]{"+user.FirstName+"|"+user.LastName+"}");
                response.write("<li>" + user.FirstName + " " + user.LastName);
            });

            response.end("</ul>");
        }
        else{
            response.end("No users found");
        }
    });
}).listen(port);

console.log("Node server listening on port: " + port);




The async connection point
C#
public async Task<object> Invoke(object input)
        {
            var payload = (IDictionary<string, object>)input;
            return await GetUsers();
        }
        public async Task<List<Data.User>> GetUsers()
        {
            TaskCompletionSource<List<Data.User>> source = new TaskCompletionSource<List<Data.User>>();
            Task<List<Data.User>> task = source.Task;

            var connector = new Data.SqlServer();

            Task.Factory.StartNew(() =>
                {
                    source.SetResult(connector.GetUsersSync());
                });

            return await task;

        }


The ADO.NET calls
C#
public async Task<List<User>> GetUsers()
        {
            List<User> users = new List<User>();
            using (var connection = new SqlConnection(ConnectionString))
            {
                using (Command = connection.CreateCommand())
                {
                    await connection.OpenAsync();
                    Command.CommandType = System.Data.CommandType.Text;
                    Command.CommandText = "SELECT UserId, FirstName, LastName FROM [dbo].[User]";
                    using (Reader = await Command.ExecuteReaderAsync())
                    {
                        while (await Reader.ReadAsync())
                        {
                            User user = new User();
                            user.Id = Reader[0] as int? ?? default(int?);
                            user.FirstName = Reader[1] as string;
                            user.LastName = Reader[2] as string;

                            users.Add(user);
                        }
                    }
                }
            }
            return users;
        }

Again, the TaskCompletionSource returns to node when I put a hard coded List in it. SQL Server returns to the WebApi Controller, but SQL Server will not return to node; I get a Stack Overflow.
"I need build Skynet. Plz send code"


modified 15-Oct-14 23:35pm.

AnswerRe: Edge.js problem driving me crazy | I can call code through WebApi route but not from node server Pin
Alaric_16-Oct-14 6:42
professionalAlaric_16-Oct-14 6:42 
GeneralRe: Edge.js problem driving me crazy | I can call code through WebApi route but not from node server Pin
Alaric_16-Oct-14 7:21
professionalAlaric_16-Oct-14 7:21 
AnswerRe: Edge.js problem driving me crazy | I can call code through WebApi route but not from node server Pin
Alaric_16-Oct-14 9:24
professionalAlaric_16-Oct-14 9:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.