コード例 #1
0
        public static ObservableCollection <LinkInfo> GetLinkInfo(string sheetId)
        {
            ObservableCollection <LinkInfo> linkInfoCollection = new ObservableCollection <LinkInfo>();

            try
            {
                WorksheetEntry wsEntry = GetWorkSheetEntry(sheetId);
                if (null != wsEntry)
                {
                    AtomLink listFeedLink = wsEntry.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

                    ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString());
                    ListFeed  listFeed  = sheetsService.Query(listQuery);
                    foreach (ListEntry row in listFeed.Entries)
                    {
                        LinkInfo lf = new LinkInfo();
                        foreach (ListEntry.Custom element in row.Elements)
                        {
                            switch (element.LocalName)
                            {
                            case "itemtype":
                                lf.ItemType = lf.GetLinkItemType(element.Value);
                                break;

                            case "sourcename":
                                lf.SourceModelName = element.Value;
                                break;

                            case "sourcepath":
                                lf.SourceModelPath = element.Value;
                                break;

                            case "sourcemodelid":
                                lf.SourceModelId = element.Value;
                                break;

                            case "destinationpath":
                                lf.DestModelPath = element.Value;
                                break;

                            case "itemsourceid":
                                lf.SourceItemId = int.Parse(element.Value);
                                break;

                            case "itemsourcename":
                                lf.SourceItemName = element.Value;
                                break;

                            case "itemdestinationid":
                                lf.DestItemId = int.Parse(element.Value);
                                break;

                            case "itemdestinationname":
                                lf.DestItemName = element.Value;
                                break;

                            case "itemdestinationimage1":
                                lf.DestImagePath1 = element.Value;
                                break;

                            case "itemdestinationimage2":
                                lf.DestImagePath2 = element.Value;
                                break;
                            }
                        }
                        linkInfoCollection.Add(lf);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to get link information.\n" + ex.Message, "Get Link Information", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(linkInfoCollection);
        }