Exemplo n.º 1
0
        // 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);
        }
Exemplo n.º 2
0
 public int IndexOf(scriptItem scriptItem)
 {
     for (int i = 0; i < List.Count; i++)
     {
         if (this[i] == scriptItem)    // Found it
         {
             return(i);
         }
     }
     return(-1);
 }
Exemplo n.º 3
0
 // 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
 }
Exemplo n.º 4
0
 public int Add(scriptItem scriptItem)
 {
     return(List.Add(scriptItem));
 }
Exemplo n.º 5
0
 // TODO: If you changed the parameters to Find (above), change them here as well.
 public bool Contains(scriptItem scriptItem)
 {
     return(Find(scriptItem) != null);
 }
Exemplo n.º 6
0
 public void Remove(scriptItem scriptItem)
 {
     List.Remove(scriptItem);
 }
Exemplo n.º 7
0
 public void Insert(int index, scriptItem scriptItem)
 {
     List.Insert(index, scriptItem);
 }
Exemplo n.º 8
0
        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);
            }
        }