Tuesday, 21 March 2017

Transfer PDF, Text file from one server to another server through code

We have a new requirement where we need to move the PDF file generated in one server and move it to another server
Create a new folder call Export in c drive and create text file to transfer in another server
After this try to execute this code, it will create sendTXTFile.bat file and execute it which will transfer in another server.
Static void UploadTxtFile(Args _args)
    TextIo            textIoFile;
    Set               permissionSet;
    FileName          filePath, filename;
    FileName          sharedLocation, batchFileName;
    InteropPermission interopPerm;
    System.Diagnostics.Process          process;
    System.Diagnostics.ProcessStartInfo processStartInfo;
    System.Exception netException;
    filePath       = 'c:\\Export'; //Create a Folder Export
    sharedLocation = 'Location';
    fileName       = filePath + '\\Abdulmajeed.txt';//used Txt file to transfer
    batchFileName  = filePath + '\\sendTxtFile.bat';
        if (System.IO.File::Exists(fileName))
            permissionSet = new Set(Types::Class);
            permissionSet.add(new FileIoPermission(batchFileName, #io_write));
            textIoFile = new TextIo(batchFileName , #io_write, 0);
            textIoFile.write(strFmt("net use %1 PWDxxxxxx /user:UserName", sharedLocation));
            textIoFile.write(strFmt("copy %1 %2", fileName ,sharedLocation));
            textIoFile.write(strFmt("net use %1 /delete", sharedLocation));
            textIoFile = null;
            new InteropPermission(InteropKind::ClrInterop).assert();
            process = new System.Diagnostics.Process();
            processStartInfo = new System.Diagnostics.ProcessStartInfo();
            interopPerm = new InteropPermission(InteropKind::ClrInterop);
            if (System.IO.File::Exists(batchFileName))
            if (System.IO.File::Exists(fileName))
           throw error("File does not exist");
    catch (Exception::CLRError)
        netException = CLRInterop::getLastException();
        throw error(netException.ToString());

SSRS Report Deployment Issue: 

When we try to deploy any report some time this kind of issue will occur. Even we have proper Privilege on URL ( Site setting and folder setting in Report url )

In order to resolve this issue if you configuration is correct. 
You can login as run as admin and deploy the report but user how have this property set to 1 will not be able to deploy the report. 
To resolve this 
Go to SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System and set EnableLUA values as 0 and restart the server and then go to DAT/System administration/Setup/Business intelligence/Reporting Services and open report server, Click on validate it will validate successfully and you can deploy the report with user

You can find complete detail about this key here: https://msdn.microsoft.com/en-us/library/cc232765.aspx
User roles and permission is very nicely explained here: http://bhushan.extreme-advice.com/user-roles-and-permissions-in-ssrs/