// public methods... #region LoadFromFile public string LoadFromFile(string cFileName) { string cResults = ""; try { StreamReader oReader = new StreamReader(cFileName); string line; while ((line = oReader.ReadLine()) != null) { int iOrder = 1; try { if (!string.IsNullOrEmpty(line) && !line.StartsWith("#")) { scriptItem itm = new scriptItem(line); cResults += itm.Status; itm.Order = iOrder; Add(itm); iOrder += 1; } } catch (Exception ex) { cResults += string.Format("Error in LoadFromFile:{0} :: {1}", line, ex.Message); } } } catch (Exception ex) { cResults += "Error in Load From File: " + ex.Message; } return(cResults); }
public int IndexOf(scriptItem scriptItem) { for (int i = 0; i < List.Count; i++) { if (this[i] == scriptItem) // Found it { return(i); } } return(-1); }
// TODO: If desired, change parameters to Find method to search based on a property of scriptItem. public scriptItem Find(scriptItem scriptItem) { foreach (scriptItem scriptItemItem in this) { if (scriptItemItem == scriptItem) // Found it { return(scriptItemItem); } } return(null); // Not found }
public int Add(scriptItem scriptItem) { return(List.Add(scriptItem)); }
// TODO: If you changed the parameters to Find (above), change them here as well. public bool Contains(scriptItem scriptItem) { return(Find(scriptItem) != null); }
public void Remove(scriptItem scriptItem) { List.Remove(scriptItem); }
public void Insert(int index, scriptItem scriptItem) { List.Insert(index, scriptItem); }
internal static void EnsureListField(ClientContext ctx, scriptItem oWorkItem) { try { ClientContext workCTX = new ClientContext(oWorkItem.GetParm("url")) { Credentials = ctx.Credentials }; List lst = workCTX.Web.Lists.GetByTitle(oWorkItem.GetParm("listname")); FieldCollection flds = lst.Fields; workCTX.Load(lst); workCTX.Load(flds); workCTX.ExecuteQuery(); switch (oWorkItem.Command) { case "ensure-field": flds.EnsureField(oWorkItem.GetParm("InternalName"), oWorkItem.GetParm("Title"), oWorkItem.GetParm("Description"), oWorkItem.GetParm("Group")); break; case "ensure-fieldinteger": flds.EnsureFieldInteger(oWorkItem.GetParm("InternalName"), oWorkItem.GetParm("Title"), oWorkItem.GetParm("Description"), oWorkItem.GetParm("Group")); break; case "ensure-fielddatetime": flds.EnsureFieldDateTime(oWorkItem.GetParm("InternalName"), oWorkItem.GetParm("Title"), oWorkItem.GetParm("Description"), oWorkItem.GetParm("Group")); break; case "ensure-fieldcurrency": flds.EnsureFieldCurrency(oWorkItem.GetParm("InternalName"), oWorkItem.GetParm("Title"), oWorkItem.GetParm("Description"), oWorkItem.GetParm("Group")); break; case "ensure-fieldchoice": string[] aChoices = oWorkItem.GetParm("choices").Split(';'); flds.EnsureFieldChoice(oWorkItem.GetParm("InternalName"), oWorkItem.GetParm("Title"), oWorkItem.GetParm("Description"), oWorkItem.GetParm("Description"), aChoices); break; case "ensure-fieldboolean": flds.EnsureFieldBoolean(oWorkItem.GetParm("InternalName"), oWorkItem.GetParm("Title"), oWorkItem.GetParm("Description"), oWorkItem.GetParm("Group")); break; case "ensure-fieldnote": flds.EnsureFieldNote(oWorkItem.GetParm("InternalName"), oWorkItem.GetParm("Title"), oWorkItem.GetParm("Description"), oWorkItem.GetParm("Group")); break; case "ensure-fieldnnumber": flds.EnsureFieldNumber(oWorkItem.GetParm("InternalName"), oWorkItem.GetParm("Title"), oWorkItem.GetParm("Description"), oWorkItem.GetParm("Group")); break; default: break; } } catch (Exception ex) { throw new Exception("Error in Utility.EnsureListField - " + ex.Message, ex); } }