public Control() { children = new ChildList(this); path = new Rectangle(100, 100); margin = new Margin(this, 0, 0, 0, 0); padding = new Padding(this, 0, 0, 0, 0); }
//Imprime los id de los archivos en la nube public static void PrintFilesInFolder(DriveService service, String folderId) { ChildrenResource.ListRequest request = service.Children.List(folderId); do { try { ChildList children = request.Execute(); foreach (ChildReference child in children.Items) { string prueba = ("File Id: " + child.Id); } request.PageToken = children.NextPageToken; } catch (Exception e) { Console.WriteLine("An error occurred: " + e.Message); request.PageToken = null; } } while (!String.IsNullOrEmpty(request.PageToken)); Console.Read(); }
public static string MatchCSVIssues(string Keys, string folder) { List <string> ret = new List <string>(); foreach (string s in Keys.Split(',')) { Item folderItem = Sitecore.Context.Database.GetItem(folder); ChildList children = folderItem.Children; string strippedString = removePunctuation(s); string MappedValue = MapCSMIssue(strippedString); foreach (Item i in children) { if (i.Fields["Content Title"].ToString().ToLower().Trim() == MappedValue.ToLower()) { if (!ret.Contains(i.ID.ToString())) { ret.Add(i.ID.ToString()); break; } } } } // Sitecore loves it's pipe-deliminated lists... return(string.Join("|", ret.ToArray())); }
public void Resolve_StylesheetUnderTheme_IncludesStylesheet() { // arrange var templateManager = TemplateFactory.CreateTemplateManager(StylesheetItem.TemplateId); var stylesheetItemMock = ItemFactory.CreateItem(templateId: StylesheetItem.TemplateId); ItemFactory.SetIndexerField(stylesheetItemMock, StylesheetItem.Fields.Url, "/url"); var itemMock = ItemFactory.CreateItem(); var children = new ChildList(itemMock.Object, new[] { stylesheetItemMock.Object }); itemMock.Setup(x => x.GetChildren()).Returns(children); var sut = new ThemeFileResolver(templateManager); // act var result = sut.Resolve(itemMock.Object); // assert Assert.That(result.Scripts, Is.Empty); Assert.That(result.Stylesheets.Count(), Is.EqualTo(1)); var stylesheet = result.Stylesheets.First(); Assert.That(stylesheet.Url, Is.EqualTo("/url")); }
public void Resolve_DerivedScriptUnderTheme_IncludesScript() { // arrange var derivedTemplateId = ID.NewID; var templates = new TemplateCollection(); var scriptTemplate = TemplateFactory.CreateTemplate(ScriptItem.TemplateId, null, templates); var derivedScriptTemplate = TemplateFactory.CreateTemplate(derivedTemplateId, ScriptItem.TemplateId, templates); var templateManager = TemplateFactory.CreateTemplateManager(new[] { scriptTemplate, derivedScriptTemplate }); var scriptItemMock = ItemFactory.CreateItem(templateId: derivedTemplateId); ItemFactory.SetIndexerField(scriptItemMock, FileItem.Fields.Url, "/url"); ItemFactory.SetIndexerField(scriptItemMock, ScriptItem.ScriptItemFields.FallbackUrl, "/fallbackurl"); ItemFactory.SetIndexerField(scriptItemMock, ScriptItem.ScriptItemFields.VerificationObject, "object"); var itemMock = ItemFactory.CreateItem(); var children = new ChildList(itemMock.Object, new[] { scriptItemMock.Object }); itemMock.Setup(x => x.GetChildren()).Returns(children); var sut = new ThemeFileResolver(templateManager); // act var result = sut.Resolve(itemMock.Object); // assert Assert.That(result.Stylesheets, Is.Empty); Assert.That(result.Scripts.Count(), Is.EqualTo(1)); var script = result.Scripts.First(); Assert.That(script.Url, Is.EqualTo("/url")); Assert.That(script.FallbackUrl, Is.EqualTo("/fallbackurl")); Assert.That(script.VerificationObject, Is.EqualTo("object")); }
protected List <IComponentMapping> GetComponentDefinitions(Item i) { List <IComponentMapping> d = new List <IComponentMapping>(); //check for templates folder Item temps = i.GetChildByTemplate(ComponentsFolderTemplateID); if (temps.IsNull()) { Logger.Log($"there is no 'Components' folder on '{i.DisplayName}'", i.Paths.FullPath); return(d); } //check for any children if (!temps.HasChildren) { Logger.Log($"there are no component mappings to import on '{i.DisplayName}'", i.Paths.FullPath); return(d); } ChildList c = temps.Children; foreach (Item child in c) { //create an item to get the class / assembly name from ComponentMapping cm = new ComponentMapping(child); cm.FieldDefinitions = GetFieldDefinitions(child); d.Add(cm); } return(d); }
private void ClearProperties() { RuleList.Clear(); BagList.Clear(); NodeList.Clear(); ChildList.Clear(); }
public static List <GoogleDriveFiles> GetContainsInFolder(String folderId) { List <string> ChildList = new List <string>(); Google.Apis.Drive.v2.DriveService ServiceV2 = GetService_v2(); ChildrenResource.ListRequest ChildrenIDsRequest = ServiceV2.Children.List(folderId); do { ChildList children = ChildrenIDsRequest.Execute(); if (children.Items != null && children.Items.Count > 0) { foreach (var file in children.Items) { ChildList.Add(file.Id); } } ChildrenIDsRequest.PageToken = children.NextPageToken; } while (!String.IsNullOrEmpty(ChildrenIDsRequest.PageToken)); //Get All File List List <GoogleDriveFiles> AllFileList = GetDriveFiles(); List <GoogleDriveFiles> Filter_FileList = new List <GoogleDriveFiles>(); foreach (string Id in ChildList) { Filter_FileList.Add(AllFileList.Where(x => x.Id == Id).FirstOrDefault()); } return(Filter_FileList); }
public static IList <File> GetFoldersByIdParentFolder(DriveService service, string idParentFolder) { IList <File> folders = new List <File>(); try { ChildrenResource.ListRequest list = service.Children.List(idParentFolder); list.Q = "mimeType = 'application/vnd.google-apps.folder' and trashed=false"; do { try { ChildList children = list.Execute(); foreach (ChildReference child in children.Items) { folders.Add(GetFileById(service, child.Id)); } list.PageToken = children.NextPageToken; } catch (Exception ex) { throw new Exception(ex.Message); } } while (!string.IsNullOrEmpty(list.PageToken)); } catch (Exception ex) { throw new Exception(ex.Message); } return(folders); }
public ActionResult IndexSection() { //create dictionary Dictionary <string, List <Item> > dict = new Dictionary <string, List <Item> >(); //get sections Item home = SitecoreContext.GetHomeItem <Item>(); ChildList sections = home.GetChildren(); foreach (Item section in sections) { dict.Add(section.DisplayName, new List <Item>()); ChildList items = section.GetChildren(); foreach (Item itm in items) { if (itm.TemplateID != Constants.Templates.Page) { dict[section.DisplayName].Add(itm); } } } return(View("~/Views/UsaCjj/IndexContent.cshtml", dict)); }
// Get files from the specified drive folder. private void GetFilesFromDriveMethod() { // Request all the children of the specified folder. ChildrenResource.ListRequest listRequest = DriveService.Children.List(DriveFolderId); do { try { // Execute the child list request. ChildList children = listRequest.Execute(); foreach (ChildReference child in children.Items) { driveFileVMs.Add(new DriveFileVM(child, DriveService)); } // set the token for the next page of the request. listRequest.PageToken = children.NextPageToken; } catch (Exception ex) { listRequest.PageToken = null; } } while (!String.IsNullOrEmpty(listRequest.PageToken)); }
bool IEnumerator.MoveNext() { if (0 == ncount) { return(false); } if (index >= ncount) { return(false); } int n = 0; int n1 = 0; int nlen = 0; ChildList clist = null; foreach (ChildList item in cKeyValues) { nlen = item.Count; n += nlen; if ((index < n) && (index >= n1)) { clist = item; break; } n1 += nlen; } n = nlen - (n - index); current = clist[n]; index++; return(true); }
public void Add(T cKeyValue) { lock (_obj) { ChildList keyValues = getContainer(cKeyValue, null); if (null == keyValues) { if (0 == cKeyValues.Count) { keyValues = new ChildList(cKeyValues); cKeyValues.Add(keyValues); } else { keyValues = cKeyValues[cKeyValues.Count - 1]; } } else { return; } if (keyValues.Count == UnitMaxNumber) { keyValues = new ChildList(cKeyValues); cKeyValues.Add(keyValues); } keyValues.Add(cKeyValue); } }
ChildList getContainer(T cKeyValue, Action <T> action) { ChildList keyValues = null; if (0 == cKeyValues.Count) { return(keyValues); } Task[] tasks = new Task[cKeyValues.Count]; int n = 0; foreach (ChildList item in cKeyValues) { tasks[n] = new Task((o) => { ChildList cKeys = (ChildList)o; CKeyValue kv = cKeys[cKeyValue.Key]; if (null != kv) { keyValues = cKeys; if (null != action) { action((T)kv); } } }, item); tasks[n].Start(); n++; } Task.WaitAll(tasks, -1); return(keyValues); }
public static File getfolderid(string foldername) { ChildrenResource.ListRequest request = service.Children.List("root"); do { try { ChildList children = request.Fetch(); foreach (ChildReference child in children.Items) { //Console.WriteLine("File Id: " + child.Kind+child.SelfLink); var file = service.Files.Get(child.Id).Fetch(); if (file.MimeType == mimetype.folder && file.Title == foldername && file.ExplicitlyTrashed != true) { return(file); } } request.PageToken = children.NextPageToken; } catch (Exception e) { Console.WriteLine("An error occurred: " + e.Message); request.PageToken = null; return(null); } } while (!String.IsNullOrEmpty(request.PageToken)); return(null); }
/// <summary> /// Retrieve the MariniProperty bound to the bind item /// </summary> /// <param name="bind">the property bound to the bind item</param> /// <returns></returns> public PropertyObject GetPropertyFromBoundItem(string bind) { return(ChildList .Where(mgo => mgo.GetType() == typeof(PropertyObject)) .Cast <PropertyObject>() .FirstOrDefault(mp => mp.bind == bind)); }
public static List <File> ListFolderContent(DriveService service, string idFolder) { ChildrenResource.ListRequest request = service.Children.List(idFolder); List <File> files = new List <File>(); request.Q = string.Format("'{0}' in parents", idFolder); do { try { ChildList children = request.Execute(); foreach (ChildReference child in children.Items) { files.Add(GetFileById(service, child.Id)); } request.PageToken = children.NextPageToken; } catch { request.PageToken = null; } } while (!string.IsNullOrEmpty(request.PageToken)); return(files); }
private void Page_Load(object sender, EventArgs e) { try { Item currentItem = Sitecore.Context.Item; ChildList childItems = currentItem.Children; string pageURL = Sitecore.Links.LinkManager.GetItemUrl(currentItem); string pageTitle = currentItem.Fields["Title"].ToString(); //string pageIntro = childItems fbLink.Text = string.Format("<a href=\"https://www.facebook.com/sharer/sharer.php?u={0}\" target=\"_blank\"><img src=\"/hyhh-assets/images/icon-facebook.png\" alt=\"Share on Facebook\" target=\"_blank\" title=\"Share on Facebook\"></a>", pageURL); //<a href="https://www.facebook.com/sharer/sharer.php?u=" target="_blank"><img src="/hyhh-assets/images/icon-facebook.png" alt="Share on Facebook" target="_blank" title="Share on Facebook"></a> twLink.Text = string.Format("<a href=\"https://twitter.com/home?status={0} - {1}\" target=\"_blank\"><img src=\"/hyhh-assets/images/icon-twitter.png\" alt=\"Share on Twitter\" target=\"_blank\" title=\"Share on Twitter\"></a>", pageTitle, pageURL); //<a href="https://twitter.com/home?status=" target="_blank"><img src="/hyhh-assets/images/icon-twitter.png" alt="Share on Twitter" target="_blank" title="Share on Twitter"></a> rptModules.DataSource = childItems; rptModules.DataBind(); } catch (Exception ex) { bool exHandled = handleException(ex); } }
private void Awake() { if (Instance == null) { Instance = this; } }
public static List <string> AllChildsInFolder(string folderId, DriveService service) { ChildrenResource.ListRequest request = service.Children.List(folderId); List <string> childIds = new List <string>(); do { try { ChildList children = request.Execute(); foreach (ChildReference child in children.Items) { var getRequest = service.Files.Get(child.Id); getRequest.Fields = "mimeType , id, labels"; var childInfo = getRequest.Execute(); string mimetype = childInfo.MimeType; bool isTrashed = (bool)childInfo.Labels.Trashed; if (mimetype != "application/vnd.google-apps.folder" && !isTrashed) { childIds.Add(child.Id); } } request.PageToken = children.NextPageToken; } catch (Exception e) { Console.WriteLine("An error occurred: " + e.Message); request.PageToken = null; } } while (!String.IsNullOrEmpty(request.PageToken)); return(childIds); }
public static string GetFolderID(DriveService service, String parentfolderId, string FolderName) { ChildrenResource.ListRequest request = service.Children.List(parentfolderId); request.Q = "mimeType='application/vnd.google-apps.folder' and title='" + FolderName + "' "; do { try { ChildList children = request.Execute(); if (children != null && children.Items.Count > 0) { return(children.Items[0].Id); } foreach (ChildReference child in children.Items) { Console.WriteLine("File Id: " + child.Id); } request.PageToken = children.NextPageToken; } catch (Exception e) { Console.WriteLine("An error occurred: " + e.Message); request.PageToken = null; } } while (!String.IsNullOrEmpty(request.PageToken)); return(string.Empty); }
public ActionResult SCNavigationBoxList() { List <SCNavigationBoxVM> navboxlist = new List <SCNavigationBoxVM>(); ChildList navBoxItems = Sitecore.Context.Database.GetItem("{2BDE8942-7089-46D4-A959-32A1C709B566}").Children; foreach (var navBox in navBoxItems) { Sitecore.Data.Items.Item navBoxItem = (Sitecore.Data.Items.Item)navBox; var navigationBoxVM = new SCNavigationBoxVM(navBoxItem); //var navboxitem = Sitecore.Context.Database.GetItem("{568325BB-0387-4FC2-90B5-6DE79965FDCF}"); //SCNavigationBoxVM navigationBoxVM = new SCNavigationBoxVM(navboxitem); List <SCNavigationVM> navList = new List <SCNavigationVM>(); MultilistField multilistField = Sitecore.Context.Database.GetItem(navBoxItem.ID.ToString()).Fields["NavigationList"]; if (multilistField != null) { Item[] navItems = multilistField.GetItems(); foreach (Item item in navItems) { navList.Add(new SCNavigationVM(item)); } } navigationBoxVM.NavigationList = navList; navboxlist.Add(navigationBoxVM); } return(PartialView(navboxlist)); }
bool TryGetItem(ChildList children, Func <Item, bool> predicate, out Item result) { result = null; if (children == null || !children.Any()) { return(false); } result = children.FirstOrDefault(predicate); if (result != null) { return(true); } var query = children.Where(n => n.HasChildren); if (!query.Any()) { return(false); } foreach (var child in query.ToArray()) { if (TryGetItem(child.Children, predicate, out result)) { return(true); } } return(false); }
private static void GoogleDir(DriveService service, string folderId, string path) { try { ChildrenResource.ListRequest request = service.Children.List(folderId); request.MaxResults = 1000; do { ChildList children = request.Execute(); foreach (ChildReference child in children.Items) { File file = service.Files.Get(child.Id).Execute(); if (file.MimeType == "application/vnd.google-apps.folder") { GoogleDir(service, file.Id, @"\" + path + @"\" + file.Title); } else { } Console.WriteLine("Title: " + file.Title); Console.WriteLine("MIME type: " + file.MimeType); Console.WriteLine(); } request.PageToken = children.NextPageToken; } while (!String.IsNullOrEmpty(request.PageToken)); } catch (Exception) { throw; } }
private void DownloadMediaFolder(Item item) { string folder = Settings.TempFolderPath + "/MediaDownload/" + item.Name + DateTime.Now.ToString("HHmmss"); string zipFile = FileUtil.MapPath(folder + ".zip"); if (!Directory.Exists(FileUtil.MapPath(folder))) { Directory.CreateDirectory(FileUtil.MapPath(folder)); } ChildList images = item.GetChildren(); using (ZipWriter zipWriter = new ZipWriter(zipFile)) { foreach (Item image in images) { AddFileToZip(zipWriter, image); } } Sitecore.Context.ClientPage.ClientResponse.Download(zipFile); // OR Files.Download(zipFile); }
public void AddChild(FmlNode l) { if (l == null) { return; } if (ChildList.Count > ChildCount) { for (int i = 0, imax = ChildList.Count; i < imax; ++i) { if (ChildList[i] == null) { ChildList[i] = l; break; } } } else { ChildList.Add(l); } l.AddBranch(this); ++ChildCount; SetDirty(); }
public string getchildInFolder(DriveService service, String folderId) { ChildrenResource.ListRequest request = service.Children.List(folderId); string file_id = ""; do { try { ChildList children = request.Execute(); foreach (ChildReference child in children.Items) { Google.Apis.Drive.v2.Data.File file1 = service.Files.Get(child.Id).Execute(); if (file1.Title.StartsWith("Build Plan")) { ListViewItem item = new ListViewItem(new string[2] { file1.Title, child.Id }); // googleshareDoc = file1.Title; this.spreadsheetListView.Items.Add(item); } } request.PageToken = children.NextPageToken; } catch (Exception e) { Console.WriteLine("An error occurred: " + e.Message); request.PageToken = null; } } while (!String.IsNullOrEmpty(request.PageToken)); return(file_id); }
public static int NumChildsInFolder(string folderId, DriveService service) { ChildrenResource.ListRequest request = service.Children.List(folderId); request.Fields = "items(id)"; request.Q = "mimeType != 'application/vnd.google-apps.folder' and trashed = false"; int totalChildren = 0; do { try { ChildList children = request.Execute(); totalChildren += children.Items.Count; request.PageToken = children.NextPageToken; } catch (Exception e) { Console.WriteLine("An error occurred: " + e.Message); request.PageToken = null; } } while (!String.IsNullOrEmpty(request.PageToken)); return(totalChildren); }
// TODO: magari da spostare in un eventuale altro oggetto agente che faccia cose // sul data model??? /// <summary> /// Retrieve the Property bound to the property prop_id /// </summary> /// <param name="prop_id">the property bound to the prop_id</param> /// <returns></returns> public PropertyObject GetPropertyFromId(string prop_id) { return(ChildList .Where(mgo => mgo.GetType() == typeof(PropertyObject)) .Cast <PropertyObject>() .FirstOrDefault(mp => mp.id == prop_id)); }
public override void FillField(IDataMap map, ref Item newItem, string importValue, string id = null) { List <string> selectedList = new List <string>(); if (string.IsNullOrEmpty(SelectionRootItem)) { return; } var master = Factory.GetDatabase("master"); Item root = master.GetItem(SelectionRootItem); if (root == null) { return; } ChildList selectionValues = new ChildList(root); if (string.IsNullOrEmpty(importValue) || !selectionValues.Any()) { return; } List <string> importvalues = importValue.Split(new string[] { Delimiter }, StringSplitOptions.RemoveEmptyEntries).ToList(); if (!importvalues.Any()) { return; } foreach (Item value in selectionValues) { foreach (var temp in importvalues) { Field t = value.Fields["Text"]; if (t == null) { continue; } if (!temp.Trim().ToLower().Equals(t.Value.Trim().ToLower())) { continue; } selectedList.Add(value.ID.ToString()); } } Field f = newItem.Fields[NewItemField]; if (f == null || !selectedList.Any()) { return; } f.Value = string.Join("|", selectedList); }
public void AddChild(StudyXmlNode child) { if (ChildList == null) { ChildList = new List <StudyXmlNode>(); } ChildList.Add(child); }
bool TryGetItem(ChildList children, Func<Item, bool> predicate, out Item result) { result = null; if (children == null || !children.Any()) return false; result = children.FirstOrDefault(predicate); if (result != null) return true; var query = children.Where(n => n.HasChildren); if (!query.Any()) return false; foreach (var child in query.ToArray()) { if (TryGetItem(child.Children, predicate, out result)) return true; } return false; }
public static int Test () { Z z = new Z (); X x = (X) z; Y y = (Y) z; Console.WriteLine (z [1]); Console.WriteLine (y [2]); Console.WriteLine (x [3]); if (z [1] != 4) return 1; if (y [1] != 2) return 2; if (x [1] != 1) return 3; double index = 5; Console.WriteLine (z [index]); Console.WriteLine (y [index]); if (z [index] != 4) return 4; if (y [index] != 3) return 5; int retval = z.InstanceTest (); if (retval != 0) return retval; B b = new B (); if (b [4] != 16) return 8; if (b [3,5] != 15) return 9; D d = new D (); if (d [4] != 16) return 10; if (d [3,5] != 15) return 11; // // Now test for bug 35492 // ChildList xd = new ChildList (); xd.Add (0); if (0 != (int)xd [0]) return 12; xd.Test (); if (1 != (int) xd [0]) return 13; return 0; }