Creating Search Alerts Programmatically
Windows Server Forum Index Windows Server
Server discussion on Windows platform.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web winserverhelp.com
Creating Search Alerts Programmatically

 
Post new topic   Reply to topic    Windows Server Forum Index -> Portal Server Development
Author Message
Vikram404@hotmail.com
Guest





Posted: Wed Jan 19, 2005 8:59 pm    Post subject: Creating Search Alerts Programmatically Reply with quote

Hi,

I am trying to extend SPS2003, by adding a custom webservice in which I can
add an alert to a search query using the SPS Object Model. Here is the code
snippet which I am using:
---------------------------------
CODE
---------------------------------
AlertManager objAlertManager = null;
AlertType objAlertType = null;
Alert objAlert = null;
AlertCollection objAlertCollection = null;
PortalChannelSettings objPortalChannelSettings = null;

//Retrieve the current Portal Context.
objAlertManager = new AlertManager(PortalContext.Current);
//Retrieve the Alerts Collection.
objAlertCollection = objAlertManager.GetMyAlerts();
//Create an object of type SearchAlert
objAlertType = new SearchAlertType();
//Create a New Alert by specifying the AlertType as SearchAlert
objAlert = objAlertCollection.CreateAlert(objAlertType);
objAlert.Name = "My New Alert101";
objAlert.ConditionText = "Alert for Search";
objAlert.UrlRenderingPortalZone = PortalZone.Intranet;
objAlert.Query = strQuery;
objPortalChannelSettings = new PortalChannelSettings();
objAlert.DeliveryChannels.Add(objPortalChannelSettings);

//Commit the AlertData
objAlert.Commit();
---------------------------------
The strQuery contains a full text sql query which is:
strQuery = "SELECT
\"DAV:displayname\",\"urn:schemas.microsoft.com:fulltextqueryinfo:displaytitle\",\"urn:schemas.microsoft.com:fulltextqueryinfo:description\",\"DAV:contentclass\",\"DAV:href\"
FROM ( TABLE Portal_Content..SCOPE() UNION ALL TABLE
Non_Portal_Content..SCOPE() ) WHERE ( FREETEXT(*, 'office') ) ORDER BY
\"urn:schemas.microsoft.com:fulltextqueryinfo:rank\" DESC";
---------------------------------

The error I am getting is:
"The query string is poorly formed. \nParsing Errors: \nErr: 80040e14,
80040e14, selectErr:80040e14, 80040e14, '(', '*', NOT, CAS"

Please let me know what could be wrong ?
Does anyone have a code sample for doing this ?

Thanks and Regards,
Vikram
Back to top
Vikram404@hotmail.com
Guest





Posted: Wed Jan 19, 2005 9:29 pm    Post subject: RE: Creating Search Alerts Programmatically Reply with quote

Ok, I need to send just the WHERE part of the query and it works fine...

Anyone has any idea how I can apply SCOPE in that case ?? I mean in terms of
the
FROM part of the query like Portal_Content and Non_portal_Content ...

Thanks,
Vikram


"Vikram404@hotmail.com" wrote:

Quote:
Hi,

I am trying to extend SPS2003, by adding a custom webservice in which I can
add an alert to a search query using the SPS Object Model. Here is the code
snippet which I am using:
---------------------------------
CODE
---------------------------------
AlertManager objAlertManager = null;
AlertType objAlertType = null;
Alert objAlert = null;
AlertCollection objAlertCollection = null;
PortalChannelSettings objPortalChannelSettings = null;

//Retrieve the current Portal Context.
objAlertManager = new AlertManager(PortalContext.Current);
//Retrieve the Alerts Collection.
objAlertCollection = objAlertManager.GetMyAlerts();
//Create an object of type SearchAlert
objAlertType = new SearchAlertType();
//Create a New Alert by specifying the AlertType as SearchAlert
objAlert = objAlertCollection.CreateAlert(objAlertType);
objAlert.Name = "My New Alert101";
objAlert.ConditionText = "Alert for Search";
objAlert.UrlRenderingPortalZone = PortalZone.Intranet;
objAlert.Query = strQuery;
objPortalChannelSettings = new PortalChannelSettings();
objAlert.DeliveryChannels.Add(objPortalChannelSettings);

//Commit the AlertData
objAlert.Commit();
---------------------------------
The strQuery contains a full text sql query which is:
strQuery = "SELECT
\"DAV:displayname\",\"urn:schemas.microsoft.com:fulltextqueryinfo:displaytitle\",\"urn:schemas.microsoft.com:fulltextqueryinfo:description\",\"DAV:contentclass\",\"DAV:href\"
FROM ( TABLE Portal_Content..SCOPE() UNION ALL TABLE
Non_Portal_Content..SCOPE() ) WHERE ( FREETEXT(*, 'office') ) ORDER BY
\"urn:schemas.microsoft.com:fulltextqueryinfo:rank\" DESC";
---------------------------------

The error I am getting is:
"The query string is poorly formed. \nParsing Errors: \nErr: 80040e14,
80040e14, selectErr:80040e14, 80040e14, '(', '*', NOT, CAS"

Please let me know what could be wrong ?
Does anyone have a code sample for doing this ?

Thanks and Regards,
Vikram
Back to top
 
Post new topic   Reply to topic    Windows Server Forum Index -> Portal Server Development All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




New Topics Powered by phpBB