dimanche 28 juin 2015

winscp Error occurred during logging. It's been turned off

I am developing a solution that uses winscp to upload zip file (contains multiple pdf files) to the remote sftp server. I am keep getting "Error occurred during logging, it's been turned off". Could anyone please tell me how to fix this error.

According to this http://ift.tt/1NoA9cB , I have created the log file.

The following class is the one that I am using.

 public class PSftp
{
    public void PutFile(string localfile)
    {
        //Send Ftp Files - same idea as above - try...catch and try to repeat this code 
        //if you can't connect the first time, timeout after a certain number of tries. 
        var sessionOptions = new SessionOptions
        {
            Protocol = Protocol.Sftp,
            HostName = ConfigurationManager.AppSettings["sFTPhost"],
            UserName = ConfigurationManager.AppSettings["sFTPuid"],
            Password = ConfigurationManager.AppSettings["sFTPpwd"],
            PortNumber = int.Parse(ConfigurationManager.AppSettings["sFTPport"]),
            SshHostKeyFingerprint = ConfigurationManager.AppSettings["sFTPhostkey"]

        };

        using (var session = new Session())
        {
            session.SessionLogPath = ConfigurationManager.AppSettings["sFTPlogPath"];
            session.DisableVersionCheck = false;
            session.DefaultConfiguration = false;
            session.Open(sessionOptions); //Attempts to connect to your sFtp site
            //Get Ftp File
            var transferOptions = new TransferOptions
            {
                TransferMode = TransferMode.Binary,
                FilePermissions = null,
                PreserveTimestamp = false
            };
            //<em style="font-size: 9pt;">Automatic, Binary, or Ascii  
            //null for default permissions.  Can set user, 
            //Group, or other Read/Write/Execute permissions. 
            //destination file to that of source file - basically change the timestamp 
            //to match destination and source files.   
            transferOptions.ResumeSupport.State = TransferResumeSupportState.Off;


            //the parameter list is: local Path, Remote Path, Delete source file?, transfer Options  
            TransferOperationResult transferResult = session.PutFiles(localfile, ConfigurationManager.AppSettings["sFTPInboxPath"], false, transferOptions);
            //Throw on any error 
            transferResult.Check();
            //Log information and break out if necessary
        };

    }
}

  //How to use the above class
  public void SaveFiletoFtp(string source)
    {
        var pftp = new PSftp();
        pftp.PutFile(source);
    }

Consuming .Net Generated Web Service from ColdFusion

I'm trying to consume a .net generated WS from ColdFusion Page. Soap binding style of the said WSDL is document.

<soap:operation soapAction="http://ift.tt/1ImdfCC" style="document"/>

In the CF documentation, it is clearly mentioned that it is not possible consume such Web services.

To consume a web service that is implemented in a technology other than ColdFusion, the web service must have one of the following sets of options:

rpc as the SOAP binding style and encoding as the encodingStyle

document as the SOAP binding style and literal as the encodingStyle

Is there any work around available?

Reference: http://ift.tt/1eRLJBJ

Move asp.net application out of IIS

We have a VS 2012/.NET 4.51 app, uses MVC, asp.net, and a bunch of other pieces.

For all the usual reasons, we are finding IIS to be a deploy/ops nightmare (how much script are we expected to write to install/configure IIS? crazy!)

Actually, the app is two web sites: - REST API, based on WCF - Web site, based on MVC, ASP.NET, and several other pieces (a whole big .js/handlebars rich js app)

I looked at moving to Nancy, but that would appear to be a lot of work. (It is not clear to me that asp.net would be happy under nancy. But in all events, it does not look like a drop in.)

What are my alternatives? (IIS is the biggest mess of our whole deploy process. Apache or nginx would be cake.)

OWIN + Katana looks close, but from my understanding you cannot (yet?) run a full ASP.NET app in OWIN/Katana.

We have done some work with powershell DSC. It can solve a lot (and is really great... the IIS part is the biggest pain).

We do not use TFS (we are a Visual Studio + Perforce shop).

Is there magic in the next VS/.NET/Windows/IIS to address this?

Alternate perspective : Migrate ASP.NET app on .net 4.5 to ASP.NET v5 - docs? concepts?

SignalR or simillar for winforms

I need to know if there is something like SignalR but for Winforms, some nuggets or library for paid, someone who can guide me please.

The beginning of my problem is that I have the need to obtain data automatically when the table is updated.

Thanks.

Parallel.ForEach stops being parallel for the last few items

I have an external singlethreaded program that needs to be run multiple hundred times with different parameters. To make it faster I want to run it once for each core at the same time. To do that I used Parallel.ForEach running on a list with the different parameters to pass to the external program:

var parallelOptions = new ParallelOptions {
    MaxDegreeOfParallelism = Environment.ProcessorCount // 8 for me
};

Parallel.ForEach(ListWithAllTheParams, parallelOptions, DoTheStuff);

...

private void DoTheStuff(ParamType parameter, ParallelLoopState parallelLoopState, long index)
{
    // prepare process parameters etc.
    theProcess.Start();
    theProcess.WaitForExit();
}

Pretty straightforward and works nicely... until the last ~10 items - they don't get parallelized for some reason and just run one after another. I've confirmed this by looking at the cpu usage and the running programs in the Task Manager.

This does not happen when I populate the parameter list with only a few (say, 10) items.

Can somebody explain this behavior to me? Any hints or tips appreciated!

Accuracy of the decimal number type versus the double type in .Net

Consider the following code:

    Dim doubleResult = (21 / 88) * 11
    Dim decimalResult = Decimal.Divide(21, 88) * 11

The doubleResult is 2.625, as it should.

The decimalResult is 2.6249999999999996, so when rounding this to two decimal places will give an incorrect result.

When I change the assignment to:

    Dim decimalResult = Decimal.Divide(21 * 11, 88) 

The result is 2.625!

We adopted the decimal type in our application hoping that it would give us increased accuracy. However, it seems that the decimal type just gives slightly incorrect results on other calculations than the double type does, due to the the fact that it is ten based, rather than two based.

So, how do we have to deal with this idiosyncrasies to avoid rounding errors as above?

Keeping graphics unaltered when TabPage changes

I have a form that displays a set of graphics using a Paint event on a Panel that is docked inside a particular TabPage of a TabControl.

The problem is the following:

When the user switches to a different TabPage and then decides to go back to the TabPage where the graphics were originally displayed, those graphics are invalidated by default so the Panel appears blank.

I would like those graphics to stay unaltered and totally independent from the user's action when switching between different TabPages.

One Requirement:

Since the graphics are complex and take some time to be drawn by the computer, I don't want to repaint the graphics each time by calling the Paint event repeatedly. Instead, I only need to avoid the default invalidation of the graphics.

I have read this other question which may be helpful to solve my problem but it goes beyond my knowledge.