Solved

C# Application linked to SharePoint List

Posted on 2009-04-01
5
432 Views
Last Modified: 2013-12-17
Hello,

I had created a tracking program that submitted data to a 2003 SharePoint List, he company has since recently upgraded to SharePoint 2007, of course the submit function of the program to the SharePoint list no longer functions.  Is it not as simple as changing the URL and the GUID or do I have to delete the reference and resources and start all over?  If thats the case, is anyone aware of a non application way of getting both the View GUID and the List GUID off of a list in SharePoint 2007?
0
Comment
Question by:Andrew Bass
  • 3
  • 2
5 Comments
 
LVL 16

Expert Comment

by:raybies
ID: 24044512
U need to give code for us to accurately tell you what's required.

If your app is sending/inserting then you don't need a view GUID... in fact you don't need any guid's. Get a reference to the SPWeb > SPList > SPListItem > Add().
0
 
LVL 1

Author Comment

by:Andrew Bass
ID: 24044526
Hey thanks let me check if that works for me then ill attach the code :)
0
 
LVL 1

Author Comment

by:Andrew Bass
ID: 24044683
Hey Raybies,
One thing I am concerned with is the open connection, I was using the ViewGUID to close the connection to SharePoint, there are strict guidelines in building apps that require the GUID to be used rather then the way you had defined above.  Is there anything else you can think of?

Below is the code, it is set currently with a service reference to the list.
using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Collections;

using System.Xml;

using System.ServiceModel;

using System.Net;
 

namespace Trigger_Tracker

{

    public partial class Form1 : Form

    {//form move on click and drag

        bool FormMoving;

        Point initialPoint;

        TriggerTrackerPictureBox frmPicture;
 

        public Form1()

        {//form move on click and drag

            InitializeComponent();

            comboBox1.SelectedIndex = 0;

            FormMoving = false;
 

            frmPicture = new TriggerTrackerPictureBox();

            frmPicture.localForm = this;

            frmPicture.Owner = this;

            frmPicture.Show();

            frmPicture.Width = 68;

            frmPicture.Height = 65;

            SetPositionOfPictureForm();

        }
 

        private void SetPositionOfPictureForm()

        {

            frmPicture.Top = this.Top + 26;

            frmPicture.Left = this.Left + 87;

        }
 

        private void TriggerTrackerLoad(object sender, EventArgs e)

        {
 

        }
 

        private void PolicyNumberLabel(object sender, EventArgs e)

        {
 

        }
 

        private void TrackerButton(object sender, EventArgs e)

        {

            string listGUID = "A93E1A7E-67D0-4D7D-A4ED-803D7DFE684B";

            string viewGUID = "6B2F3EF2-4B0C-41E1-B87E-0C3185B587DD";

            //string viewGUID2 = "6B2F3EF2-4B0C-41E1-B87E-0C3185B587DD";
 

            int ItemCounter = 1;

            ServiceList.Lists listService = new ServiceList.Lists();

           // RetentionLists.ListsSoapClient listService = new RetentionLists.ListsSoapClient();
 

            //////

           listService.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

           //listService.ChannelFactory.Credentials.Windows.ClientCredential   = System.Net.CredentialCache.DefaultNetworkCredentials;
 

            XmlNode activeItemData = listService.GetListItems(listGUID, viewGUID, null, null, "100", null);

            XmlDocument xDoc = new XmlDocument();

            string tmpString = activeItemData.InnerXml.Replace("\r\r", "");

            xDoc.LoadXml(tmpString);

            XmlNamespaceManager nsManager = new XmlNamespaceManager(xDoc.NameTable);

            nsManager.AddNamespace("z", "#RowsetSchema");

            nsManager.AddNamespace("rs", "urn:schemas-microsoft-com:rowset");
 

            XmlNodeList xNode = xDoc.SelectNodes("/rs:data/z:row", nsManager);
 

            foreach (XmlNode tmpNode in xNode)

                ItemCounter++;
 

            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append("<Method ID='" + ItemCounter + "' Cmd='New'>");

            strBuilder.Append("<Field Name='Attachments'>" + "0" + "</Field>");

            strBuilder.Append("<Field Name='Title'>" + PolicyNumber.Text + "</Field>");

            strBuilder.Append("<Field Name='Reason'>" + comboBox1.Text + "</Field>");

            strBuilder.Append("</Method>");
 

            string strBatch = strBuilder.ToString();
 

            XmlDocument newDoc = new XmlDocument();

            XmlElement newElement = newDoc.CreateElement("Batch");

            newElement.SetAttribute("OnError", "Continue");

            newElement.SetAttribute("ViewName", viewGUID);

            newElement.InnerXml = strBatch;

            

            XmlNode returnNode = listService.UpdateListItems(listGUID, newElement);
 

            this.comboBox1.Text = "Please Select....";

            this.PolicyNumber.Text = "";

            this.PolicyNumber.Mask = "0000000000";
 

            comboBox1.Focus();

        }
 

        private void PolicyNumberTextBox(object sender, EventArgs e)

        {
 

        }
 
 

        private void textBox1_KeyDown(object sender, KeyEventArgs e)

        {

            

        }
 

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)

        {           

            

        }
 

        private void maskedTextBox1_MaskInputRejected(object sender, MaskInputRejectedEventArgs e)

        {
 

        }
 
 

        public void Form1_MouseUp(object sender, MouseEventArgs e)

        {//form move on click and drag

            FormMoving = false;

        }
 

        public void Form1_MouseMove(object sender, MouseEventArgs e)

        {//form move on click and drag

            if (FormMoving)

            {

                if ((Left + e.X - initialPoint.X) <= 0)

                    Left = 0;

                else if ((Right + e.X - initialPoint.X) >= Screen.PrimaryScreen.Bounds.Right)

                    Left = Screen.PrimaryScreen.Bounds.Right - Width;

                else

                    Left = Left + e.X - initialPoint.X;

                if ((Top + e.Y - initialPoint.Y) <= 0)

                    Top = 0;

                else if ((Bottom + e.Y - initialPoint.Y) >= Screen.PrimaryScreen.Bounds.Bottom)

                    Top = Screen.PrimaryScreen.Bounds.Bottom - Height;

                else

                    Top = Top + e.Y - initialPoint.Y;

            }

            SetPositionOfPictureForm();

        }
 

        public void Form1_MouseDown(object sender, MouseEventArgs e)

        {//form move on click and drag

            FormMoving = true;

            initialPoint = new Point(e.X, e.Y);

        }
 

        public void pictureBox1_MouseDown(object sender, MouseEventArgs e)

        {//form move on click and drag

            FormMoving = true;

            initialPoint = new Point(e.X, e.Y);

        }
 

        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)

        {

        }
 

        private void pictureBox1_MouseHover(object sender, EventArgs e)

        {

        }
 

        public void label1_MouseHover(object sender, EventArgs e)

        {

            FormMoving = false;

        }
 

        public void label1_MouseUp(object sender, MouseEventArgs e)

        {

            FormMoving = false;

        }
 

        private void label1_MouseDown(object sender, MouseEventArgs e)

        {
 

        }
 

        private void label1_MouseMove(object sender, MouseEventArgs e)

        {
 

        }
 

        public void Form1_MouseHover(object sender, EventArgs e)

        {

            this.Opacity = 1;

        }
 

        public void Form1_MouseLeave(object sender, EventArgs e)

        {

            if(!PolicyNumber.Focused)

                this.Opacity = .25;

        }
 

        public void pictureBox1_MouseLeave(object sender, EventArgs e)

        {

            this.Opacity = 1;

        }
 

        public void pictureBox1_MouseHover_1(object sender, EventArgs e)

        {

            this.Opacity = 1;

        }
 

        public void Form1_Click(object sender, EventArgs e)

        {

            comboBox1.Focus();

        }

    }

}

Open in new window

0
 
LVL 16

Accepted Solution

by:
raybies earned 500 total points
ID: 24044854
OK, you're using the List web service.

In 2007 you can't do this while not on the actual server if you have "Web Page Security Validation" enabled... you need to SPWeb.AllowUnsafeUpdates = true;.


To get the View/List Guid you can use the HTML/Javascript page: http://www.users.on.net/~ray1/fireWS.zip (http://blog.ray1.net/2008/03/ajax-web-service-and-sharepoint.html)

Use the List web service > Operation: GetListAndView > Enter your list name and you're done.
0
 
LVL 1

Author Closing Comment

by:Andrew Bass
ID: 31565439
THanks!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now