コード例 #1
0
        private void btn_Test_List_Click(object sender, EventArgs e)
        {
            SetStaticVars();
            frm_Test_List testForm = new frm_Test_List();

            testForm.Show();
        }
コード例 #2
0
        private void cmd_Open_List_Click(object sender, EventArgs e)
        {
            //dgv_Data.Columns[1].Visible = true;
            //dgv_Data.Columns[2].Visible = true;
            //dgv_Data.Refresh();

            int row = dgv_Data.CurrentRow.Index;

            string url  = dgv_Data["siteAddress", row].Value.ToString();
            string guid = dgv_Data["listId", row].Value.ToString();

            frm_Test_List testForm = new frm_Test_List();

            testForm.Show();

            testForm.txt_Guid.Text = guid;
            testForm.txt_Url.Text  = url;
        }
コード例 #3
0
        private void cmd_Versions_Click(object sender, EventArgs e)
        {
            if (clientContext == null)
            {
                return;
            }

            frm_Test_List testForm = new frm_Test_List();

            // Disable / hide irrelevant controls
            testForm.cmd_Open_List.Visible = false;
            testForm.cmd_Versions.Visible  = false;
            testForm.txt_Guid.Visible      = false;
            testForm.txt_Url.Visible       = false;
            testForm.lbl_Guid.Visible      = false;
            testForm.lbl_Url.Visible       = false;
            testForm.nud_Row_Limit.Value   = 0;
            testForm.nud_Row_Limit.Enabled = false;

            testForm.Show();

            int col = dgv_List.Columns["ID"].Index;
            int row = dgv_List.CurrentRow.Index;
            int id  = (int)dgv_List[col, row].Value;

            // Find the specified item
            SP.ListItem oListItem = oList.GetItemById(id);

            // Load the Item
            clientContext.Load(oListItem);

            // Load the Versions
            clientContext.Load(oListItem.Versions);

            // Do this bit
            clientContext.ExecuteQuery();

            // Loop through each Version
            foreach (SP.ListItemVersion versionItem in oListItem.Versions)
            {
                // Retrieve the fields
                SP.FieldCollection collField = versionItem.Fields;

                clientContext.Load(collField);
                clientContext.ExecuteQuery();

                int i = 0;

                // Loop through fields
                foreach (SP.Field oField in collField)
                {
                    string fieldName  = oField.Title;
                    string fieldValue = "null";

                    try
                    {
                        if (oListItem[oField.InternalName] != null)
                        {
                            fieldValue = versionItem[oField.InternalName].ToString();
                        }
                    }
                    catch (Exception ex)
                    {
                        fieldValue = "Error";
                    }
                    finally
                    {
                        i++;
                    }
                }
            }
        }