Search This Blog

Tuesday, 24 September 2013

RDP Clipboard not working - Solution

I've often faced this situation where my RDP settings have clipboard enabled to facilitate copy-paste feature while remotely connecting to a server but the functionality stops working all of a sudden.
I have often encountered this when the connection was lost during the copy-paste operations.

Why we face this issue is another topic, so I'd like to redirect you to this msdn link

Hope couple of you would have also faced similar situations.

Note: The clipboard redirection should be enabled for the server you are remotely connecting to. If the redirection is not enabled the following steps will not be of help. You will need to enable it through terminal services configuration.

First of all, always check your RDP settings to have clipboard checkbox ticked.


The process responsible for facilitating clipboard functionality while doing a remote desktop is rdpclip.exe.
This process might be unresponsive sometimes.

The way out is, to end this process and start it again as follows

In the Task manager of the RD connected server,

1. Open up task manager -> Processes tab -> Search for rdpclip.exe. Right-click and end this process.



2. Restart this process



Although this is a workaround to the problem, it does solve it.
I've still not able to get an exact reason for this issue though.


Although this should not happen frequently, but if it does happen every time then, 
you may want to create a .bat file with the command to kill the process and restart it.

1. Create a rdpclipboard.txt file
2. Add the following commands on separate lines
    Taskkill.exe /im rdpclip.exe
    rdpclip.exe
3. Save the file.
4. Change the extension of the file to rdpclipboard.bat.

You can have it on the quick lauch bar or the desktop. Double-click this bat file, to execute it.
Hope this helps.

Wednesday, 31 July 2013

Using Windows Services to simulate a workflow

There are technologies that support workflows for software systems like,
Windows Workflow Engine (WWF),
JBPM (in the open source. Tough learning curve though!)
but what if you wanted to do the same without any of the above technologies?

The options I could think of were,
  1. To use a design pattern like the state machine
  2. To use Windows services
The approach is what I would like to highlight here more than code.

Of-course the choice of technology would depend on the kind of project, the complexity of the workflows being handled and so on. But normally every software system does have some workflow associated.

For instance, say an Exit and Clearance Approval system for a small to mid-sized software company. It must be approved by the manager first, then goes for the clearance by the IT department, the Admin Department, then HR. It is important that the approval must go in the above sequence and should be tracked through software.

This is one of the simplest examples I could think of. But in a more complex scenario like a VFx company; which apparently works on a shot that passes from department to department, would use a much complex workflow.

  • State machine pattern can get complex with complex workflows. 
  • I have also worked on complex VFx workflows where we opted for Workflow Foundation (anyways we had to customize it a lot actually)
  • JBPM is one other technology which fascinated us because it was an open source.
Though I must confess to have opted for Windows services, which was simple traceable and has worked for a couple of years and for about 30+ customers now.

Firstly, if you are new to Windows Services, please refer to this link on Code Project for a step by step walk-through. Steps are pretty much the same for whatever versions of Visual Studio used above VS 2005 also.

A simple approval system which consists of multiple levels of approval and sharing of content in the form of files is shown below
  • A workflow processes an input and produces one or more outputs.
  • Input / Output could be some content in the form of files dropped into a folder which is watched by a windows service. This folder can be called a watch folder.
  • Input / Output could also be a database tables which are looked into for particular status or pre-conditions.


The Process
Say this is a case for the approval of VFx shot changes. The artist makes the changes, the supervisor reviews it approves / rejects it. The input to the next level of approval is the VFx shot (content) in a folder and a database approval status update.

  1. The user uploads his shot changes through the web portal.This triggers a database update. Status = Uploaded
  2. A windows service in the background keeps watching the database for records with Status=Uploaded. Once a matching record is found, it will trigger underlying business logic and put the content into a folder (watch folder) and also update the status in the database. Status = Approved By Supervisor
  3. A windows service in the background would be watching the folder (watch folder) in which the shot changes exist and the database tables for the Status = Approved By Supervisor to trigger the next set of operations and put the content and update the status for processing by the next windows service in line.
The steps in this workflow could be as many as possible.

Tips

  • It is recommended that a base framework is written to handle logging and error handling to track the workflow properly. 
  • At every step of the service, a text file should be created as a log of steps of the service. This can help in the event of support issues. This is important, as it is not possible to debug a windows service by doing a F5, and it would be a nightmare issues happen in production environment.

          Eg: [Fri 5 JUL 2013 1:10:00:00]Moving the file to destination folder E:\NextDeptWatch\ShotFile.m2t
                [Fri 5 JUL 2013 1:10:00:00]File moved to destination successfully


  • In case of issues, the log file with messages like above would be useful for the developer to trace where the code has failed and the entire stack trace of the the exception that occurred.


  • The OnStart() and OnStop() need to be handled to process the content of the watch folders or database table contents.

Hope this helps while making a choice of architecture and technology to be used for your projects.

Thursday, 9 May 2013

Image Protection Techniques

For a long time now, I was wondering of protecting images especially as the world comes online with social networks offering extensive sharing and multimedia editing options.

We are all aware of image thefts and morphing. There are a few techniques like Divs + Css, copyright, watermarking and robots.txt which I could think of and a few more, thanks to Google :)

  • Watermarking 
          In this technique the image can be added with text over the image    
          indicating the ownership. There are tools like Photoshop and a combination 
          of html and css can also do the magic.
  • Using Low Res Images 
          This is also one of the preferred techniques. If an image needs to be              
          tampered with it should have color profiles defined and should have high 
          resolution. Several websites adopt the low resolution technique for basic 
          viewing. Eg. Flicker re-sizes images to as low as 500 pixels (in the longest dimension) for basic viewing
  • Preventing Image Download: There are a few ways to do this.
          1.   Disallow Right-Click: This is not a nice option in my opinion. It will 
                annoy users and is not effective as screen capture will defeat the 
                purpose of image protection.

           2.  <Div> + CSS: This technique can be adopted for a start. But if used in 
                combination with Low Res Technique with watermark or copyrights 
                attached can offer better protection. This can be done in more than one 
                ways.
                 a. Single Div with transparent image and css. 
                     Styles are added inline for reference purposes only. They should be added to a separate css file. 
                    <html>
                       <style>
                             #OuterDiv
                                   {
                                     background-image: url('tulips.jpg');
                                     height: 50%;
                                     -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -o- 
                                     user-select: none; user-select: none; 
                                     }
                        </style>

                        <div id="OuterDiv">
                          <img src="transparent.jpg"/>
                        </div>
                       </html>

                 b. Single Div with CSS

                     This will not let the user download the image. The styles should be 
                     put into a separate css file. Styles are added inline for reference purposes only.
                     <html>

                       <style>
                             #OuterDiv
                                   {
                                     background-image: url('tulips.jpg');
                                     height: 50%;
                                     -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -o- 
                                     user-select: none; user-select: none; 
                                     }
                        </style>

                        <div id="OuterDiv">                          
                        </div>
                       </html>

                 c. Two Divs with Css
                     This technique will dim-out the underlying image on hover by adding an extra div to 
                     add contrast. If the user tries to make a screen capture while 

                     hovering over the image, the image will be dimmed out, so that the user does not
                     get a clear image. The drawback of this technique is the image is 
                     dimmed only when the user hovers the mouse pointer over it. The 
                     work around for this would be to use javascript to capture keycodes 
                     that are used to make a screen capture and produce a dim image. 
                     Eg: In Windows, Print Screen key or Windows + S key and so on. I 
                           cannot add it all to the following sample as it would make the 
                           sample code too large.
                     <html>

                       <style>
                             #OuterDiv
                                   {
                                     background-image: url('tulips.jpg');
                                     height: 50%;
                                     -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -o- 
                                     user-select: none; user-select: none; 
                                     }

                             #InnerDiv
                                     {
                                       background-color: transparent;
                                       height:100%;
                                       -webkit-user-select: none; -khtml-user-select: none; -
                                       moz-user-select: none; -o-user-select: none; user-select: none; 
                                       position:relative;
                                      }


                              #InnerDiv:hover, #OuterDiv:hover
                                     {
                                        background-color: rgba(65, 65, 61, 0.91);

                                     }
                        </style>

                        <div id="OuterDiv">
                            <div id="InnerDiv"/></div>                          
                        </div>
                       </html>
                   
                 d. Using <Table> tag and Css
                     <html>
                       <style>
                             #OuterDiv
                                   {
                                     background-image: url('tulips.jpg');
                                     height: 50%;
                                     -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -o- 
                                     user-select: none; user-select: none; 
                                     }
                        </style>

                        <table id="OuterDiv">
                           <tr>
                               <td>Some text here. Just to view the table with its background image</td>

                          </tr>
                        </table>
                       </html>

             I'm sure many more combinations are possible. The css image url can be encoded for additional protection. 
             I have not tried this way, but would like to give it a go.

  • Prevent search engines from indexing images on your website
          You can add a specification in the meta-tags to prevent search bots 
          from crawling images in your site. We made use of this and 
          robots.txt in our BE project while implementing a Web Crawler and mini 
          search engine. Robots.txt understanding is not in current scope as it is a 
          separate topic in itself. In short, robots.txt tells a crawler which pages and 
          what content of your site can / should not be indexed. 
          1. Using meta-tags
             <meta name="robots" content="noimageindex"></meta>

          2. Using Robots.txt
              Add the following in Robots.txt
              User-Agent:*
              Disallow:/images/
              Disallow:/tulips.jpg

  • Copyrights
          You can copyright your content. This is one of the most common ways used.
          Ofcourse, image theft still occurs where you need to take curative measures. I find
          WHOIS particularly useful. There may be other resources as well to detect copyright infringes.

The most important fact is, the above techniques (there could be many more) should always be used in combination. Using a single technique will do little to help you from image thefts

Friday, 22 February 2013

"Add Web Reference" option not appearing in the solution Explorer

Folks, just came accross a weird issue. I'm not sure how many of you guys have hit it.

My projects target different versions of the .Net framework.
Each of them use both the conventional asmx webservices and the WCF.

One of the issues I stumbled upon today, was not able to find the "Add Web Reference" option in the context menu in the solution explorer.

My target framework is 3.5.
If any of you have faced similar issues, you can try out the following.

  • Right-Click on the project in Solution Explorer. Select Add Service Reference.
  • Click the "Advanced" button as shown below
          
          
          

Here you can find the conventional dialog to add web references.

If you face the reverse case, that is Not able to find the "Add Service Reference" option, you need to check that your project targets .Net Framework 3.0 or above. (Right-click your project -> Select Properties)