6 Replies - 3181 Views - Last Post: 15 February 2012 - 03:18 PM Rate Topic: -----

#1 muan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 15-February 12

Console application in C# for fetching data from Live website

Posted 15 February 2012 - 01:37 AM

Hi,

I am new in programming. I put my code example which is console application below. I need help. I have a situation in which i need to access data from a live website and i need to get values of all arguments and then checking some fields and then generating an automatic email to the user about the task. I want a console application which check the website and fetch values of all items in the website. May be i am unable to explain in detail but if you need some more information i will let you know. Thanks in advance for help.

namespace Email
{
    
    class Program
    {
        static string siteUrl = "";
        //Todo - Get the appropriate arguments
        //Tip: List guids and other guids could be fetched from the SharePoint Web UI
        static void Main(string[] args)
        {

            try
            {
                using (SPSite testSite = new SPSite(siteUrl))
                {
                    Console.WriteLine("site url: " + testSite.Url);
                    using (SPWeb ourWeb = testSite.OpenWeb(new Guid("e94c0a67-7408-4413-a4d2-4f26275008ac")))
                    {
                        SPList ourList = ourWeb.Lists[new Guid("DEB874E1-8BE7-4AD5-A507-EE6C8DF27FDC")];
                        foreach (SPListItem ourItem in ourList.Items)
                        {
                            //todo check if a reminder is to be made
                            if (checkForRemind(ourItem))
                                Console.WriteLine("Remind!");
                            //todo remind the appropriate person by email!
                            //remindPerson();                            
                        }

                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("OOps: " + ex.Message);
            }
        }

        static bool checkForRemind(SPListItem ourItem)
        {
            bool remindIsSet = false;
            foreach (SPField ourField in ourItem.Fields)
            {
                Console.WriteLine("Field name: " + ourField.StaticName);
            }
            return remindIsSet;
        }
    }
}




Is This A Good Question/Topic? 0
  • +

Replies To: Console application in C# for fetching data from Live website

#2 negligible  Icon User is offline

  • D.I.C Regular

Reputation: 62
  • View blog
  • Posts: 302
  • Joined: 02-December 10

Re: Console application in C# for fetching data from Live website

Posted 15 February 2012 - 02:09 AM

I want a console application which check the website and fetch values of all items in the website.
This makes no sense. What items?
What are you trying to retrieve from the website. Elements? Text displayed on the webpage? Are you trying to send data between a website and application?
Was This Post Helpful? 0
  • +
  • -

#3 muan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 15-February 12

Re: Console application in C# for fetching data from Live website

Posted 15 February 2012 - 02:18 AM

View Postnegligible, on 15 February 2012 - 02:09 AM, said:

I want a console application which check the website and fetch values of all items in the website.
This makes no sense. What items?
What are you trying to retrieve from the website. Elements? Text displayed on the webpage? Are you trying to send data between a website and application?

Thanks for your response.

Actually i have a website which is in Share point. I need to active a email alert but not using Share point. I want to create a server scheduler and this application will get information from my website about the task lists. if some tasks deadline is near then my scheduler will send email to the specific user. This console application will help me to get list items from my share point website. I also want to fetch List guids from share point web application. In short i can say i need to fetch all list items and want to store them in the form of array. Later on i will use this information and will put a flag to check if the due date is close. If the due date is coming soon then i will send an automatic email to that specific user. If you see my code which i share in my post you will find some information about this. Please let me know if you need further information. Thanks in advance..
Was This Post Helpful? 0
  • +
  • -

#4 negligible  Icon User is offline

  • D.I.C Regular

Reputation: 62
  • View blog
  • Posts: 302
  • Joined: 02-December 10

Re: Console application in C# for fetching data from Live website

Posted 15 February 2012 - 03:57 AM

That is a lot clearer, although I am not sure why you wish to do this as a console application instead of including it on a part of your website personally I'd go for some web based management so you could change it or make new schedules from anywhere...

As far as I know, to allow this communication with your console application you would have to add to your website anyway to write a Web service class, this web service would make WebMethods available to outside applications.
When ever I've worked with a webservice they have communicated with XML via SOAP.

This post has been edited by negligible: 15 February 2012 - 03:58 AM

Was This Post Helpful? 0
  • +
  • -

#5 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4425
  • View blog
  • Posts: 7,693
  • Joined: 08-June 10

Re: Console application in C# for fetching data from Live website

Posted 15 February 2012 - 12:43 PM

Sharepoint already exposes web services. Look up Sharepoint web services and you should be able to find what you need.
Was This Post Helpful? 0
  • +
  • -

#6 muan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 15-February 12

Re: Console application in C# for fetching data from Live website

Posted 15 February 2012 - 01:28 PM

View PostCurtis Rutland, on 15 February 2012 - 12:43 PM, said:

Sharepoint already exposes web services. Look up Sharepoint web services and you should be able to find what you need.


Thanks..But can you please share me some link which include example of share point web services..
Was This Post Helpful? 0
  • +
  • -

#7 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4425
  • View blog
  • Posts: 7,693
  • Joined: 08-June 10

Re: Console application in C# for fetching data from Live website

Posted 15 February 2012 - 03:18 PM

Sure:

https://www.google.c...b+services+c%23
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1