Friday, October 19, 2012

Doing the URL re-write in ASP.Net

So you want to re-write URLs in a ASP.NET application? Well here is one solution ....

Intelligencia.UrlRewriter (http://urlrewriter.net/)

Setup in your project is simple, just add the following to the Web.Config

<configSections>

<section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/>.

<httpHandlers>

<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>.

.. then you add a section like that below:

<rewriter>

<rewrite url="~/Contracts/?(.*)" to="~/Contracts.aspx?ID=$1" />

i.e. When the user tries to access the URL: /Contracts/">http://<server>/Contracts/ this will be converted to the application as /Contracts.aspx/">http://<server>/Contracts.aspx/

But what about the “?(.*)” ? I hear you cry .. Well this is a Regular Expression that lets you parse the rest of the URL entered. For example “/contracts/ABC” will be converted to “/contracts.aspx?ID=ABC”. You can of course get all fancy and take out specific values for things so the URL becomes far more meaningful, but that I’ll leave up to you to Google on the web.

One good into blog is here: http://www.blogiversity.org/blogs/blogdayafternoon/archive/2008/12/18/url-rewriting-using-intelligencia-urlrewriter.aspx)

So what are the Problems?

1) Well the biggest issue you get is with Post backs.. When you do an ASP.NET postback it sometimes plays around with the “action=” URL for your form. As an example it takes the converted URL : contracts.aspx and sets the forms “Post” action to “contracts.aspx”. that’s fine until it gets back to the rewriter which converts this to “contracts.aspx?ID=.aspx” !! which won’t work.

To get around this issue you just have to put the following in the site.master code behind.

masterform.Action = Request.RawUrl;

In your Master Page you make sure the form name matches this;

<form ID="masterform" runat="server">

2) Another issue you might face is that the URL rewriting is order specific, i.e. once it finds a URL that matches that entered it will assume you’re calling that page. For example “/contactsForMyApplication/” you may want to go to the “/contactsForMyApplication.aspx” page, but it the appears *after* the “/Contracts/ rewrite entry you’ll find yourself hitting the “contracts.aspx” page by mistake.

To get around this you need to be careful of the ordering in the web.config and you can put an attribute (which I can’t remember) option in the <rewrite> node which stops further processing.

Monday, August 13, 2012

OwnCloud Configuration Issues

Recently I was asked to look at OwnCloud (http://owncloud.org/) as an alternative to SharePoint for storing various files.  Everything was working fine but the Client Sync totally refused to work saying it was unable to find "webdav.php".

The solution was to reconfigure IIS as a PUT request was going wrong:
1) Open IIS and navigate down the tree to the host.
2) Double click Handler Mappings icon.
3) Find the PHP module you used "PHP53_via_FastCGI" and right click it and select Edit.
4) Click Request Restrictions.
5) Go to the Verbs tab.
6) Select the "ALL VERBS" radio dial.

7) Apply change and do an IISReset

Crazy fix and I'm not really sure what it's all about but it worked.

Friday, June 22, 2012

How to Sync an Android phone with Corporate Email

  • From Home screen menu click “Settings”

  • Click on 'Accounts & Sync' and select Exchange Active sync

  • Type in the email and password

  • Click Manual setup on the bottom left

  • Select 'Microsoft Exchange ActiveSync'

  • Change Domain\Username. For example: mydomain\richard.greene

  • Change server to 'email.mydomain.com’

  • Deselect the check boxes below for Tasks and Contacts (unless they are needed) and click next

  • Take all the standard settings from then on.

Killing User Sessions in P6

The first step is to find out the user_id of the user that we wish to remove. You can do this by running something like the following, but substituting the string in the LIKE expression to find the user in question:

SELECT *

FROM users

WHERE LOWER(user_name) LIKE LOWER('%PSN9954%');



Having got the user_id we disable their session. A few versions ago this involved removing rows from a number of tables, but with the introduction of the background jobs life has become far easier. All we need to do is mark the record from the USESSION table by setting the delete_session_id to zero and giving the delete_date column a value, which I take from the system date. The example code below assumes the user_id is 123.



UPDATE usession

SET delete_session_id=0, delete_date=GETDATE()

WHERE user_id = 999;



So long as background jobs are running properly, and they should be, they will delete the user session record within a minute at most.



In order to give users the option to override their own sessions the following can be added to their PM.ini file:



[Database]



DeleteCurrentUserSessions=TRUE 



Note in P6 8.0 this is now available in the user interface of the Web Application.



For  more details see this article.



http://usingp6.com/administrator/2011/10/14/end-p6-user-session.html

Wednesday, February 22, 2012

Error CVRJC-0348-8 on Primavera

Posts

A User reported an error on Primavera today and I found the fix on the Oracel support Knowledgebase #Bug 9796699: EVENT CODE: 'CVRJC-0348-8' WHEN ACCESSING PROJECT USERS DIALOG SCREEN.

Run the following on the database..

DECLARE @RC int
DECLARE @pret_val int
DECLARE @pret_msg varchar(4000)
EXECUTE @RC = [PMDB_KTT_Corrupt].[dbo].[usession_clear_logical_deletes] @pret_val OUTPUT ,@pret_msg OUTPUT

GO

delete from PROJSHAR where load_status = 'O' and session_id not in (select session_id from usession) or session_id in (select session_id from usession where delete_session_id is not null);

GO

Everything works fine after that....

Wednesday, February 1, 2012

Utility to check broken links on a website

Today I brushed off some old tech and downloaded a tool I’d used many years ago (I may even have blogged this before!) to check if the Intranet had any broken links.  That tool was called XENU (http://home.snafu.de/tilman/xenulink.html)
Download it from the website (http://home.snafu.de/tilman/xenulink.html#Download)
Extract the ZIP file and Run the install.exe
Installation

Click Next
Click “I Agree”
Click Next
Select the destination directory and click Next
Click Install

Click Next
Click Finish.
Running a link check
Start the application from the Start menu / Xenu Link Slewth / Xenu
From the menu screen click the “Check URL” button on the far left of the tool bar

In the dialogue box enter the URL you want to check, e.g. https://intranet.mydomain.com.au and uncheck the “Check external links” option, unless you want to check those sites.
Click OK.
Results are shown in a list where each link is tested to make sure it’s working correctly.

Press <CTRL>B to clear the view of everything except broken links.
Keep your eye on the progress using the status bar.

At the end you will see something like this:

Showing one broken link.

Monday, January 30, 2012

How to fix a Corrupted XER file

From the Oracle Support desk download the PATTLNK_782008_1412-xerFileParserBuilder.xls file.  It’s also available on the drive: \\ap-fs-02\data\EPF\BSG\Downloads\Primavera\Fix XER files.  Copy the Excel sheet to your local machine.
Open the Spread sheet
Enable all content
Click “Load XER file…”
If you get an error message; the reason is that you are missing the “Comdlg32.ocx” file on your machine.  Copy the file \\ap-fs-02\data\EPF\BSG\Downloads\Primavera\Fix XER files\Comdlg32.ocx file to your C:\Windows\System32 directory and try again.
Select the file you want to check and click OK, the Spread sheet with populate with all the information you need.  This can take a long time depending on the size of the export.

On the front page click the “Diagnostics” button.
On the dialogue select “cross check FK”; Task and task_id; TASKRSRC and task_id.

Click “Run Diagnostic”

You will then be shown all the “Task Resources” which have been assigned to “Tasks” that no longer exist.
Note the Row number in the results.

Go to the TASKRSRC tab and remove these rows from the Spread sheet.. Feel free to run the Diagnostics a few times to make sure you have everything covered.

Eventually you should see that no errors are displayed.
Go back to the front page and click the “Build XER File…” button.
Save the fixed XER file to another file and try the Import again.