Ejemplo n.º 1
0
        public List <ChartData> GetSpDoughnutGraphDataObjects()
        {
            List <ChartData> chartData = new List <ChartData>();

            System.Net.NetworkCredential creds            = new System.Net.NetworkCredential("*****@*****.**", "helloWorld55!");
            Microsoft.SharePoint.Client.ClientContext ctx = new Microsoft.SharePoint.Client.ClientContext("http://sp16.geek-ish.com/")
            {
                Credentials = creds
            };
            string listName = "DoughnutGraphData";//"ADA_Eligibility_Status4";

            SP.ListItemCollection items = SpUtil.GetSpListItems(ctx, "http://sp16.geek-ish.com/", listName, string.Empty);
            if (items != null)
            {
                foreach (SP.ListItem li in items)
                {
                    ChartData cd = new ChartData();
                    {
                        double i = 0;
                        try
                        {
                            if (li["Title"] != null)
                            {
                                cd.xValue = li["Title"].ToString();
                                cd.yValue = li["yValue"] == null ? 0 :
                                            double.TryParse(li["yValue"].ToString(), out i) ? (int)(i * 100) : 0;
                                chartData.Add(cd);
                            }
                        }
                        catch (Exception e)
                        {
                            Debug.Print(e.Message);
                        }
                    }
                }
            }

            return(chartData);
        }
Ejemplo n.º 2
0
        public List <SplineGraphData> GetSpSplineGraphDataObjects()
        {
            List <SplineGraphData> splineGraphObjs = new List <SplineGraphData>();

            System.Net.NetworkCredential creds            = new System.Net.NetworkCredential("*****@*****.**", "helloWorld55!");
            Microsoft.SharePoint.Client.ClientContext ctx = new Microsoft.SharePoint.Client.ClientContext("http://sp16.geek-ish.com/")
            {
                Credentials = creds
            };
            string listName = "GraphWidgetTestData";//"ADA_Eligibility_Status4";

            SP.ListItemCollection items = SpUtil.GetSpListItems(ctx, "http://sp16.geek-ish.com/", listName, string.Empty);
            if (items != null)
            {
                foreach (SP.ListItem li in items)
                {
                    SplineGraphData dataObj = new SplineGraphData();
                    {
                        int i = 0;
                        try
                        {
                            int monthId = 1;
                            monthId         = li["Month"] == null ? 1 : ((SP.FieldLookupValue)(li["Month"])).LookupId;
                            dataObj.MonthId = monthId;
                            dataObj.Date    = new DateTime(DateTime.Now.Year, monthId, 1);
                            dataObj.Value   = li["Value"] == null ? 0 : int.TryParse(li["Value"].ToString(), out i) ? i : 0;
                        }
                        catch
                        {
                            // ignored
                        }
                        splineGraphObjs.Add(dataObj);
                    }
                }
            }

            return(splineGraphObjs);
        }