public virtual string SaveAction(TK_Action action) { string errors = ""; string sRepo = GetRepository(); if (sRepo != null) { DirectoryInfo repo = new DirectoryInfo(sRepo); if (repo.Exists) { DirectoryInfo actionDir = new DirectoryInfo(GetRepository() + "\\" + action.Name); if (!actionDir.Exists) { actionDir.Create(); } StreamWriter myWriter = null; try { //Export the xml myWriter = new StreamWriter(actionDir.FullName + "\\" + action.Name + ".act"); actionSerializer.Serialize(myWriter, action); } catch (Exception e) { errors += "Save xml " + ExceptionHelper.GetMessages(e); } myWriter.Close(); } } return(errors); }
public void DeleteAction(TK_Action inAction) { DirectoryInfo dInfo = new DirectoryInfo(inAction.GetPath()); if (dInfo.Exists) { dInfo.Delete(true); } if (Actions.Contains(inAction)) { Actions.Remove(inAction); } }
public string LoadActions() { string errors = ""; Actions.Clear(); string sRepo = GetRepository(); if (!string.IsNullOrEmpty(sRepo)) { DirectoryInfo repo = new DirectoryInfo(sRepo); if (repo.Exists) { DirectoryInfo[] subDirs = repo.GetDirectories(); foreach (DirectoryInfo dir in subDirs) { TK_Action action = null; FileInfo[] infos = dir.GetFiles("*.act"); if (infos.Length > 0) { FileStream stream = null; stream = infos[0].OpenRead(); try { action = (TK_Action)actionSerializer.Deserialize(stream); action.Library = this; if (action.Validate()) { Actions.Add(action); } } catch (Exception e) { errors += "Load xml " + ExceptionHelper.GetMessages(e); } stream.Close(); } } } } return(errors); }
public virtual void ShowSequence(TK_Action inAction) { }