Exemple #1
0
        private void AddViews(frm_Data_View viewForm, string listId, string siteAddress, string siteName)
        {
            Guid g = new Guid(listId);

            SP.ClientContext clientContext = SharePoint.GetClient(siteAddress, frm_Main_Menu.username, frm_Main_Menu.password);
            SP.List          oList         = clientContext.Web.Lists.GetById(g);

            // Load in the Views
            clientContext.Load(oList.Views);
            clientContext.ExecuteQuery();

            int i = 0;

            foreach (SP.View oView in oList.Views)
            {
                i++;

                clientContext.Load(oView.ViewFields);
                clientContext.ExecuteQuery();

                string viewName   = oView.Title;
                string viewId     = oView.Id.ToString();
                string fieldCount = oView.ViewFields.Count.ToString();
                string rowLimit   = oView.RowLimit.ToString();
                string viewQuery  = oView.ViewQuery;
                string url        = frm_Main_Menu.siteUrl + oView.ServerRelativeUrl;

                viewForm.AddRow(i, viewName, siteName, siteAddress, fieldCount, rowLimit, viewId, viewQuery, url);

                lbl_Row_Count.Text = i.ToString() + " record(s) found";
                lbl_Row_Count.Refresh();
            }
        }
Exemple #2
0
        private void cmd_Get_Views_Click(object sender, EventArgs e)
        {
            // Store selected row
            int row = dgv_Data.SelectedCells[0].RowIndex;

            // Store column of List Name
            int col = dgv_Data.Columns["listName"].Index;

            // Store site List Name
            string listName = dgv_Data[col, row].Value.ToString();

            // Store column of Site Name
            col = dgv_Data.Columns["siteName"].Index;

            // Store column of Site Address
            string siteName = dgv_Data[col, row].Value.ToString();

            // Store column of Site Address
            col = dgv_Data.Columns["siteAddress"].Index;

            // Store column of Site Address
            string siteAddress = dgv_Data[col, row].Value.ToString();

            // Store column of Site URL
            col = dgv_Data.Columns["url"].Index;

            // Store site URL if it exists
            string siteUrl = null;

            // Store site URL
            if (dgv_Data[col, row].Value != null)
            {
                siteUrl = dgv_Data[col, row].Value.ToString();
            }
            else
            {
                siteUrl = siteAddress;
            }

            // Open the List form
            frm_Data_View viewForm = OpenForm_View(listName, this.Name, this.lbl_Header.Tag.ToString(), siteUrl);

            // Store column of GUID
            col = dgv_Data.Columns["listId"].Index;

            // Store site GUID
            string listId = dgv_Data[col, row].Value.ToString();

            // Add records to the data grid
            AddViews(viewForm, listId, siteAddress, siteName);

            // Show the List form
            viewForm.Show();
        }
Exemple #3
0
        public frm_Data_View OpenForm_View(string listName, string tag, string subSiteName, string siteUrl)
        {
            // Create a new instance of the Site class
            frm_Data_View viewForm = new frm_Data_View();

            viewForm.Height      = 700;
            viewForm.Width       = 1500;
            viewForm.WindowState = FormWindowState.Maximized;

            viewForm.Text            = siteUrl;
            viewForm.lbl_Header.Text = "Views - " + listName + " (" + subSiteName + ")";
            viewForm.Tag             = tag;

            // Add columns to the data grid view
            viewForm.AddColumns();

            return(viewForm);
        }