예제 #1
0
        public PatternEntry <TPattern> AddPattern(EntryKind kind, TPattern pattern)
        {
            PatternEntry <TPattern> p = new PatternEntry <TPattern>(kind, pattern);

            AddPattern(p);
            return(p);
        }
예제 #2
0
 /// <summary>
 /// Get the time that the last update was done for this user/machine/entryType
 /// </summary>
 /// <param name="aEntryKind">Kind to search for</param>
 /// <returns>Last time or Time.Min if never</returns>
 public static DateTime Latest(EntryKind aEntryKind)
 {
     SQLHistoryDataSetTableAdapters.HistoryTableAdapter TableAdapter = new SQLHistoryDataSetTableAdapters.HistoryTableAdapter();
     DateTime? re = TableAdapter.LatestQuery(Duplicati.Scheduler.Utility.User.UserName, Environment.MachineName, aEntryKind.ToString());
     if (re == null) return DateTime.MinValue;
     return (DateTime)re;
 }
예제 #3
0
 public LogEntry(EntryKind kind, int level, string text, Exception error = null)
 {
     Kind     = kind;
     LogLevel = level;
     Text     = text;
     Error    = error;
 }
예제 #4
0
 public IssueEntry(
     DataModelIssue issue, EntryKind kind,
     IEnumerable <Label> styledLabels = null,
     string styleName = null)
     : base(issue, styledLabels, styleName)
 {
     Kind          = kind;
     IsPullRequest = issue.IsPullRequest;
     IssueNumber   = issue.Number;
 }
예제 #5
0
 public Entry SearchEntry(string path, EntryKind stopAt)
 {
     if (rootNode == null)
     {
         InitRoot();
     }
     else if (System.IO.Directory.GetLastWriteTime(rootPath) > lastWriteTime)
     {
         UpdateRoot();
     }
     return(SearchEntry(path, rootNode, rootPath, stopAt));
 }
예제 #6
0
 private static string GetKindClassPrefix(EntryKind kind)
 {
     if (kind == EntryKind.New)
     {
         return("new");
     }
     if ((kind == EntryKind.Moved) || (kind == EntryKind.Closed))
     {
         return("gone");
     }
     throw new InvalidProgramException($"Unexpected issue kind {kind}");
 }
예제 #7
0
 /// <summary>
 /// Update a record
 /// </summary>
 /// <param name="aUserName">Domain/User</param>
 /// <param name="aMachineName">Yeah</param>
 /// <param name="aEntryType">Kind of entry to update</param>
 /// <param name="aModificationDate">Entry time</param>
 /// <param name="aContent">XML to send</param>
 public static void Update(string aUserName, string aMachineName, EntryKind aEntryType, DateTime aModificationDate, string aContent)
 {
     SQLHistoryDataSetTableAdapters.HistoryTableAdapter TableAdapter = new SQLHistoryDataSetTableAdapters.HistoryTableAdapter();
     SQLHistoryDataSet.HistoryDataTable Table = TableAdapter.GetDataBy(aUserName, aMachineName, aEntryType.ToString(), aModificationDate);
     HistoryRow Row = null;
     if (Table.Count == 0)
         Row = Table.AddHistoryRow(aUserName, aMachineName, aEntryType.ToString(), aModificationDate, aContent);
     else
         Row = ((HistoryRow)Table.Rows[0]);
     Row.XmlContent = aContent;
     TableAdapter.Update(Table);
     //Console.WriteLine(Row.EntryType + ":" + Row.XmlContent);
 }
 public PatternModel(EntryKind entryKind, string currentPattern, string metadata, ObservableCollection <PatternModel> owner, Func <Watcher <GlobPatternWithMetadata> > watcher)
 {
     _watcher             = watcher;
     _owner               = owner;
     Kind                 = entryKind;
     _currentPattern      = currentPattern;
     _metadata            = metadata;
     RawPattern           = new GlobPatternWithMetadata(currentPattern, metadata);
     RemovePatternCommand = new ActionCommand(() =>
     {
         _owner.Remove(this);
         _watcher()?.RemovePattern(Pattern);
     });
 }
예제 #9
0
 internal static int GetEntriesCount(Node node, EntryKind[] kinds)
 {
     int count = 0;
     foreach (var entry in node.Nodes)
     {
         foreach (var kind in kinds)
         {
             if (entry.Kind == kind)
             {
                 count++;
                 break;
             }
         }
     }
     return count;
 }
예제 #10
0
 public void Log(LogStreamerSession session, EntryKind kind, string msg)
 {
     if (session != null) {
         Log(new LogEntry() {
             SessionId = session.SessionId,
             When = DateTime.Now,
             Kind = kind,
             Guid = session.PeerGuid,
             Name = session.PeerDatabaseName,
             Message = msg
         });
         return;
     }
     Log(new LogEntry() {
         SessionId = 0,
         When = DateTime.Now,
         Kind = kind,
         Guid = Guid.Empty,
         Name = string.Empty,
         Message = msg
     });
 }
예제 #11
0
            // PushEntry
            // =========
            // input: loc, name, Type
            // output: Scope
            // returns a new scope with everything the same as this, excpet for a new entry
            //
            public Scope PushEntry(EntryKind loc, String name, ExprType type)
            {
                Scope scope = new Scope(this);

                switch (loc)
                {
                case EntryKind.STACK:
                    scope.esp_pos -= Utils.RoundUp(type.SizeOf, 4);
                    scope.locals.Add(new Utils.StoreEntry(name, type, scope.esp_pos));
                    break;

                case EntryKind.GLOBAL:
                    scope.globals.Add(new Utils.StoreEntry(name, type, 0));
                    break;

                case EntryKind.TYPEDEF:
                    scope.typedefs.Add(new Utils.StoreEntry(name, type, 0));
                    break;

                default:
                    return(null);
                }
                return(scope);
            }
예제 #12
0
 public Entry SearchEntry(string path, EntryKind stopAt)
 {
     if (rootNode == null)
         InitRoot();
     else if (System.IO.Directory.GetLastWriteTime(rootPath) > lastWriteTime)
     {
         UpdateRoot();
     }
     return SearchEntry(path, rootNode, rootPath, stopAt);
 }
예제 #13
0
        private static Entry SearchEntry(string path, Node parent, string rootPath, EntryKind? stopAt)
        {
            Entry result = null;
            string[] pathComponents = path.Split(System.IO.Path.DirectorySeparatorChar);
            Node currentNode = parent;
            for (int i = 0; i < pathComponents.Length; i++)
            {
                result = null;
                foreach (var entry in currentNode.Nodes)
                {
                    if (entry.Name == pathComponents[i])
                    {
                        result = entry;
                        break;
                    }
                }
                if (result == null)
                {
                    break;
                }
                if (((result.Kind == EntryKind.File) || (result.Kind == EntryKind.ZipFileEntry)) && (i + 1 < pathComponents.Length))
                {
                    throw new System.IO.DirectoryNotFoundException();
                }
                if (result.Node == null)
                {
                    if (rootPath == null)
                    {
                        throw new System.IO.IOException();
                    }
                    string elementPath = System.IO.Path.Combine(rootPath, string.Join(new string(System.IO.Path.DirectorySeparatorChar, 1), pathComponents, 0, i + 1));
                    if (result.Kind == EntryKind.Directory)
                    {
                        result.Node = DirectoryGenerator.Generate(new System.IO.DirectoryInfo(elementPath), false);
                        result.UpdateSize();
                    }
                    if (result.Kind == EntryKind.ZipFile)
                    {
                        result.Node = ZipFileGenerator.Generate(new System.IO.FileInfo(elementPath));
                        result.UpdateSize();
                    }
                }

                else if (rootPath != null)
                {
                    string elementPath = System.IO.Path.Combine(rootPath, string.Join(new string(System.IO.Path.DirectorySeparatorChar, 1), pathComponents, 0, i + 1));
                    if (result.Kind == EntryKind.Directory)
                    {
                        if (result.LastWriteTime < System.IO.Directory.GetLastWriteTime(elementPath))
                        {
                            System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(elementPath);
                            DirectoryGenerator.Update(di, result.Node);
                            Entry newEntry = new Entry(di);
                            newEntry.Node = result.Node;
                            newEntry.UpdateSize();
                            currentNode.Nodes.Remove(result);
                            currentNode.Nodes.Add(newEntry);
                            result = newEntry;
                        }
                    }
                    if (result.Kind == EntryKind.File)
                    {
                        if (result.LastWriteTime < System.IO.File.GetLastWriteTime(elementPath))
                        {
                            System.IO.FileInfo fi = new System.IO.FileInfo(elementPath);
                            Entry newEntry = new Entry(fi, false);
                            currentNode.Nodes.Remove(result);
                            currentNode.Nodes.Add(newEntry);
                            result = newEntry;
                        }
                    }
                }
                if (stopAt.HasValue && (result.Kind == stopAt.Value))
                    break;
                currentNode = result.Node;
            }
            if ((result != null) && stopAt.HasValue && (result.Kind != stopAt.Value))
                return null;
            return result;
        }
예제 #14
0
 // PushEntry
 // =========
 // input: loc, name, Type
 // ouput: Environment
 // return a new environment which adds a symbol entry
 // 
 public Env PushEntry(EntryKind loc, String name, ExprType type) {
     Scope top = this._scopes.Peek();
     return new Env(this._scopes.Pop().Push(top.PushEntry(loc, name, type)));
 }
예제 #15
0
        // PushEntry
        // =========
        // input: loc, name, Type
        // ouput: Environment
        // return a new environment which adds a symbol entry
        //
        public Env PushEntry(EntryKind loc, String name, ExprType type)
        {
            Scope top = this._scopes.Peek();

            return(new Env(this._scopes.Pop().Push(top.PushEntry(loc, name, type))));
        }
예제 #16
0
 public Entry(EntryKind kind, ExprType type, Int32 offset)
 {
     this.Kind   = kind;
     this.Type   = type;
     this.Offset = offset;
 }
예제 #17
0
 public void Add(EntryKind kind, string tableName, string columnName, string text)
 {
     entries.Add(new Entry { EntryKind = kind, TableName = tableName, ColumnName = columnName, Text = text });
 }
예제 #18
0
 public void Add(EntryKind kind, string tableName, string text)
 {
     Add(kind, tableName, null, text);
 }
예제 #19
0
 /// <summary>
 /// The Enum Operator For Has.
 /// </summary>
 /// <param name="Entry">The Source</param>
 /// <param name="Other">The Other Instance</param>
 /// <returns>The Results</returns>
 public static bool Has(this EntryKind Entry, EntryKind Other)
 {
     return((Entry & Other) == Other);
 }
예제 #20
0
 public Entry(EntryKind kind, ExprType type, Int32 offset)
 {
     this.kind = kind;
     this.type = type;
     this.offset = offset;
 }
예제 #21
0
 public PatternEntry(EntryKind kind, TPattern pattern)
 {
     Kind    = kind;
     Pattern = pattern;
 }
예제 #22
0
 // PushEntry
 // =========
 // input: loc, name, type
 // ouput: Environment
 // return a new environment which adds a symbol entry
 //
 public Env PushEntry(EntryKind loc, String name, ExprType type)
 {
     // note the nested copy constructor. this is because the constructor would reverse the elements.
     Stack<Scope> scopes = new Stack<Scope>(new Stack<Scope>(env_scopes));
     Scope top = scopes.Pop().PushEntry(loc, name, type);
     scopes.Push(top);
     return new Env(scopes);
 }
예제 #23
0
 public void Add(EntryKind kind, string text)
 {
     Add(kind, null, null, text);
 }
예제 #24
0
 // PushEntry
 // =========
 // input: loc, name, type
 // output: Scope
 // returns a new scope with everything the same as this, excpet for a new entry
 //
 public Scope PushEntry(EntryKind loc, String name, ExprType type)
 {
     Scope scope = new Scope(this);
     switch (loc) {
     case EntryKind.STACK:
         scope.esp_pos -= Utils.RoundUp(type.SizeOf, 4);
         scope.locals.Add(new Utils.StoreEntry(name, type, scope.esp_pos));
         break;
     case EntryKind.GLOBAL:
         scope.globals.Add(new Utils.StoreEntry(name, type, 0));
         break;
     case EntryKind.TYPEDEF:
         scope.typedefs.Add(new Utils.StoreEntry(name, type, 0));
         break;
     default:
         return null;
     }
     return scope;
 }
예제 #25
0
 /// <summary>
 /// The Enum Operator For Any.
 /// </summary>
 /// <param name="Entry">The Source</param>
 /// <param name="Other">The Other Instance</param>
 /// <returns>The Results</returns>
 public static bool Any(this EntryKind Entry, EntryKind Other)
 {
     return((Entry & Other) > 0);
 }