Ejemplo n.º 1
0
        public int UpdateList(Int32 op_id, string op_title)
        {
            SPDataSource ds = new SPDataSource();

            ds.DataSourceMode  = SPDataSourceMode.List;
            ds.UseInternalName = true;

            string queryString;

            queryString      = "<View></View>";
            ds.UpdateCommand = queryString;

            Parameter dbParam_ListId = new Parameter("ListID");

            dbParam_ListId.DefaultValue = "DF806E7E-0073-4202-99E3-C4A269E2FA5D";
            ds.UpdateParameters.Add(dbParam_ListId);

            Dictionary <string, object> keys = new Dictionary <string, object>();

            keys.Add("ID", op_id);

            Dictionary <string, object> values = new Dictionary <string, object>();

            values.Add("Title", op_title);

            SPDataSourceView dsw = ds.GetView();

            dsw.Update(keys, values, null, null);

            return(1);
        }
Ejemplo n.º 2
0
        public List <ProductCatalogData> GetListsOld()
        {
            SPDataSource ds = new SPDataSource();

            ds.DataSourceMode  = SPDataSourceMode.List;
            ds.UseInternalName = true;
            ds.Scope           = SPViewScope.Recursive;
            ds.IncludeHidden   = true;

            string queryString;

            //queryString = "<View><ViewFields><FieldRef Name='ID'/><FieldRef Name='Title'/><FieldRef Name='PermMask'/></ViewFields><Query><Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>5</Value></Eq></Where></Query></View>";
            //queryString = "<View><ViewFields><FieldRef Name='ID'/><FieldRef Name='Title'/><FieldRef Name='PermMask'/></View>";
            queryString = "<View></View>";

            ds.SelectCommand = queryString;

            Parameter dbParam_ListId = new Parameter("ListID");

            dbParam_ListId.DefaultValue = "DF806E7E-0073-4202-99E3-C4A269E2FA5D";
            ds.SelectParameters.Add(dbParam_ListId);


            SPDataSourceView          dsw;
            List <ProductCatalogData> dt = new List <ProductCatalogData>();

            dsw = ds.GetView();

            SPList xlist = dsw.List;

            SPViewCollection colViews = xlist.Views;

            foreach (SPView vView in colViews)
            {
            }

            /*
             * SPListItem newFolder = xlist.Items.Add(xlist.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder, null);
             * if (newFolder != null)
             * {
             *  newFolder["Title"] = "Min Nye Folder";
             *  newFolder.Update();
             * }
             */
            System.Web.UI.DataSourceSelectArguments args = new System.Web.UI.DataSourceSelectArguments();

            SPDataSourceViewResultItem[] arrResult = (SPDataSourceViewResultItem[])dsw.Select(args);
            foreach (SPDataSourceViewResultItem Result in arrResult)
            {
                SPListItem oListItem = (SPListItem)Result.ResultItem;
                //SPField myField = xitem.Fields[new Guid("{FE7E79DD-DD68-438e-A960-E3686025D44B}")];

                ProductCatalogData r = new ProductCatalogData();
                foreach (SPField ofield in oListItem.Fields)
                {
                    string tekst;
                    try
                    {
                        tekst = ">" + ofield.Title + "< >" + ofield.InternalName + "<>" + oListItem[ofield.Id] + "<";
                    }
                    catch
                    {
                        //OK
                    }

                    switch (ofield.InternalName)
                    {
                    case "ID":
                        r.ID = (int)oListItem[ofield.Id];
                        break;

                    case "Title":
                        r.Title = (string)oListItem[ofield.Id];
                        break;
                    }
                }
                dt.Add(r);
            }

            return(dt);
        }
Ejemplo n.º 3
0
        protected override void BindDataSource()
        {
            var ds = new SPDataSource(List) {SelectCommand = BuildSelectCommand(false)};
            ds.SelectParameters.Add("nextpagedata", Page.Request.QueryString.ToString());
            ds.SelectParameters.Add("maximumrows", RowLimit.ToString());
            ds.SelectParameters.Add("rootfolder", Page.Request.QueryString["RootFolder"]);
            ds.SelectParameters.Add("prevpagedata", "");

            var view = ds.GetView();
            var args = new DataSourceSelectArguments();

            try
            {
                view.Select(args, DataSourceViewSelectCallback);
                NextPagePosition = ds.SelectParameters["nextpagedata"].DefaultValue;
                PrevPagePosition = ds.SelectParameters["prevpagedata"].DefaultValue;
            }
            catch (SPQueryThrottledException)
            {
                ThresholdException = true;
                ds = new SPDataSource(List) { SelectCommand = BuildSelectCommand(true) };
                ds.SelectParameters.Add("nextpagedata", Page.Request.QueryString.ToString());
                ds.SelectParameters.Add("maximumrows", RowLimit.ToString());
                ds.SelectParameters.Add("rootfolder", Page.Request.QueryString["RootFolder"]);
                ds.SelectParameters.Add("prevpagedata", "");

                view = ds.GetView();
                args = new DataSourceSelectArguments();

                try
                {
                    view.Select(args, DataSourceViewSelectCallback);
                    NextPagePosition = ds.SelectParameters["nextpagedata"].DefaultValue;
                    PrevPagePosition = ds.SelectParameters["prevpagedata"].DefaultValue;
                }
                catch (SPQueryThrottledException)
                {
                    // Empty data source
                    DataSource = new DataTable();
                }
            }

            if (RequiredAggregations)
            {
                BindAllDataSource();
            }
        }