Exemplo n.º 1
0
        void AddDirectory()
        {
            TreeNode s = selected;

            if (s == null)
            {
                return;
            }
            IBufferDirectory d = s.Tag as IBufferDirectory;

            try
            {
                List <string> l = d.GetDirectoryNames();
                for (int i = 1; ; i++)
                {
                    string n = "New folder" + i;
                    if (!l.Contains(n))
                    {
                        IBufferDirectory ld = d.Create(n, "");
                        TreeNode         nd = ld.CreateNode(true);
                        s.Nodes.Add(nd);
                        return;
                    }
                }
            }
            catch (Exception exception)
            {
                exception.ShowError();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Performing the log with inprut from an IIterator
        /// </summary>
        /// <param name="iterator"></param>
        /// <param name="stop"></param>
        public void Perform(IIterator iterator, Func <object, bool> stop)
        {
            if (item is IBufferDirectory)
            {
                directory = item as IBufferDirectory;
                WriteTypes();

                /*                StaticExtensionDataPerformerEventPortable.PerformIterator(consumer, iterator as IIterator,
                 *                  iterator as ITimeMeasureProvider, StaticExtensionEventInterfaces.RealtimeLogAnalysis,
                 *                  () => { return stop(null); }); */
                IEnumerable <byte[]> data = Transform(iterator, () => { return(stop(null)); });
                string name;

                if (iterator is BufferReadWrite)
                {
                    name = (iterator as BufferReadWrite).ItemName;
                }
                else
                {
                    name = DateTime.Now.ToString();
                }

                IBufferData d = directory.CreateData(data, name, name, "");
                d.Types = typeBytes;
                StaticExtensionDataPerformerInterfaces.Data.SubmitChanges();
            }
        }
Exemplo n.º 3
0
        private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow row  = dataGridViewFiles.Rows[e.RowIndex];
            IBufferData     d    = row.Tag as IBufferData;
            int             ri   = e.ColumnIndex;
            string          text = row.Cells[ri].Value + "";

            if (ri == 1)
            {
                if (d.Comment.Equals(text))
                {
                    return;
                }
                d.Comment = text;
                return;
            }
            if (ri == 0)
            {
                if (d.Name.Equals(text))
                {
                    return;
                }
                IBufferDirectory dir  = d.Parent as IBufferDirectory;
                List <string>    l    = dir.GetDirectoryNames();
                string           name = d.Name;
                l.Remove(name);
                if (l.Contains(text))
                {
                    MessageBox.Show(this, "Name already exist");
                    row.Cells[ri].Value = name;
                    return;
                }
                d.Name = text;
            }
        }
Exemplo n.º 4
0
        private void UserControlEditDatadase_Load(object sender, EventArgs e)
        {
            IBufferDirectory dir = StaticExtensionDataPerformerInterfaces.Root;

            treeViewDir.ImageList = StaticExtensionDataPerformerUI.BufferDataImageList;
            TreeNode n = dir.CreateNode();

            treeViewDir.Nodes.Add(n);
        }
        /// <summary>
        /// Names of directory children
        /// </summary>
        /// <param name="directory"></param>
        /// <returns></returns>
        static public List <string> GetDirectoryNames(this IBufferDirectory directory)
        {
            List <string> list = new List <string>();

            foreach (IBufferItem it in directory.Children)
            {
                list.Add(it.Name);
            }
            return(list);
        }
        /// <summary>
        /// Creates a  directory
        /// </summary>
        /// <param name="parent">Parent</param>
        /// <param name="name">Name</param>
        /// <param name="comment">Comment</param>
        /// <returns>Rhe directory</returns>
        static public IBufferDirectory Create(this IBufferDirectory parent, string name,
                                              string comment)
        {
            if (parent.GetDirectoryNames().Contains(name))
            {
                throw new Exception(name + " already exists");
            }
            IBufferDirectory result = new BufferDirectoryWrapper(parent as BufferDirectoryWrapper,
                                                                 data.Create(parent.Id, name, comment));

            StaticExtensionDataPerformerInterfaces.Data.SubmitChanges();
            return(result);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Writes itself
        /// </summary>
        public void Write()
        {
            WriteTypes();
            if (!(item is IBufferDirectory))
            {
                "Select directory please".Show();
                return;
            }
            directory = item as IBufferDirectory;
            object log = Log;

            if (log == null)
            {
                "Select log please".Show();
                return;
            }
            change = GetItem(log);
            if (change != null)
            {
                change.Change += Change;
            }
            componentCollection = this.CreateCollection();
            componentCollection.ForEach((IInitialize initialize) =>
                                        { initialize.Initialize(); });
            try
            {
                Func <bool> stop = () => { return(true); };
                if (log is ILogReaderCollection)
                {
                    ILogReaderCollection c = log as ILogReaderCollection;
                    foreach (ILogReader reader in c.Readers)
                    {
                        Perform(reader);
                    }
                }
                else
                {
                    Perform(log as ILogReader);
                }
                StaticExtensionDataPerformerInterfaces.Data.SubmitChanges();
            }
            catch (Exception exception)
            {
                exception.ShowError();
            }
            if (change != null)
            {
                change.Change -= Change;
            }
            change = null;
        }
Exemplo n.º 8
0
 /// <summary>
 /// Performs operation
 /// </summary>
 /// <param name="reader">Reader</param>
 /// <param name="stop">Stop</param>
 public void Perform(ILogReader reader, Func <object, bool> stop)
 {
     if (item is IBufferDirectory)
     {
         directory = item as IBufferDirectory;
         WriteTypes();
         IEnumerable <object> en = consumer.RealtimeAnalysisEnumerable(reader, stop,
                                                                       StaticExtensionEventInterfaces.RealtimeLogAnalysis, TimeType.Second, true);
         IEnumerable <byte[]> data = Transform(en);
         IBufferData          d    = directory.CreateData(data, reader.Name, reader.FileName, "");
         d.Types = typeBytes;
         StaticExtensionDataPerformerInterfaces.Data.SubmitChanges();
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Writes types
        /// </summary>
        public void WriteTypes()
        {
            measurementsWrite = Measurements;
            Dictionary <string, object> dic = measurementsWrite.WriteTypes();

            typeBytes = objectToBytes(dic);
            object log      = Log;
            object iterator = Iterator;

            if (log is ILogReaderCollection | (item is IBufferDirectory & iterator != null))
            {
                directory       = (item as IBufferDirectory);
                directory.Types = typeBytes;
            }
        }
 /// <summary>
 /// Fills itself
 /// </summary>
  public void Fill()
 {
     treeViewMain.Nodes.Clear();
     IBufferDirectory dir = DataPerformer.Interfaces.StaticExtensionDataPerformerInterfaces.Root;
     if (dir == null)
     {
         return;
     }
     treeViewMain.ImageList = StaticExtensionDataPerformerUI.BufferDataImageList;
     List<TreeNode> l = new List<TreeNode>();
     l.Sort(StaticExtensionDataPerformerUI.BufferComparer);
     TreeNode n = dir.CreateNode();
         treeViewMain.Nodes.Add(n);
     GetUrl();
 }
        /// <summary>
        /// Creates a tree
        /// </summary>
        /// <param name="data">Database interface</param>
        /// <returns>roots of trees</returns>
        static IBufferDirectory[] CreateTree(this IDatabaseInterface data)
        {
            Dictionary <object, IParentSet> dictionary  = new Dictionary <object, IParentSet>();
            IEnumerable <object>            list        = data.Elements;
            List <IBufferDirectory>         directories = new List <IBufferDirectory>();

            foreach (object o in list)
            {
                IBufferItem item = data[o];
                IParentSet  ps   = null;
                if (item is IBufferData)
                {
                    ps = new BufferItemWrapper(item as IBufferData);
                }
                else
                {
                    ps = new BufferDirectoryWrapper(item);
                }
                dictionary[o] = ps;
            }
            foreach (IParentSet ps in dictionary.Values)
            {
                IBufferItem it = (ps as IBufferItem);
                object      o  = it.ParentId;
                if (!o.Equals(it.Id))
                {
                    if (dictionary.ContainsKey(o))
                    {
                        ps.Parent = dictionary[o] as IBufferItem;
                    }
                }
            }
            List <IBufferDirectory> l = new List <IBufferDirectory>();

            foreach (IParentSet ps in dictionary.Values)
            {
                if (ps is IBufferDirectory)
                {
                    IBufferDirectory item = (ps as IBufferDirectory);
                    if (item.Parent == null)
                    {
                        l.Add(item);
                    }
                }
            }
            return(l.ToArray());
        }
Exemplo n.º 12
0
        IEnumerable <object> Enumerable(IBufferDirectory directory)
        {
            IEnumerable <IBufferItem> en = directory.FullDirectory();

            foreach (IBufferItem item in en)
            {
                if (item is IBufferData)
                {
                    IBufferData          data = item as IBufferData;
                    IEnumerable <object> enu  = Enumerable(data);
                    foreach (object o in enu)
                    {
                        yield return(o);
                    }
                }
            }
        }
        /// <summary>
        /// Creates data
        /// </summary>
        /// <param name="directory">Directory</param>
        /// <param name="data">Data</param>
        /// <param name="name"></param>
        /// <param name="fileName">File name</param>
        /// <param name="comment">Comment</param>
        /// <returns>The data</returns>
        public static IBufferData CreateData(this IBufferDirectory directory,
                                             IEnumerable <byte[]> data, string name, string fileName, string comment)
        {
            IDatabaseInterface d = StaticExtensionDataPerformerInterfaces.data;

            /*  !!!    if (d.Filenames.Contains(fileName))
             *    {
             *        throw new Exception("File " + fileName + " already exists");
             *    }*/
            if (directory.GetDirectoryNames().Contains(name))
            {
                throw new Exception(name + " already exists");
            }
            IBufferData ld = d.Create(data, directory.Id, name, fileName, comment);

            return(new BufferItemWrapper(directory as BufferDirectoryWrapper, ld));
        }
Exemplo n.º 14
0
        private void treeViewDir_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            if (e.Label == null)
            {
                return;
            }
            TreeNode s = e.Node;

            if (s == null)
            {
                return;
            }
            object o = s.Tag;

            if (o == null)
            {
                return;
            }
            if (o is IBufferItem)
            {
                IBufferItem item = o as IBufferItem;
                IBufferItem p    = item.Parent;
                if (p == null | !(p is IBufferDirectory))
                {
                    MessageBox.Show("Prohibited");
                    return;
                }
                IBufferDirectory d     = p as IBufferDirectory;
                List <string>    names = d.GetDirectoryNames();
                string           name  = e.Label;
                if (names.Contains(name))
                {
                    MessageBox.Show("Name alredy exists");
                    return;
                }
                try
                {
                    item.Name = name;
                }
                catch (Exception exception)
                {
                    exception.ShowError();
                }
            }
        }
Exemplo n.º 15
0
        /*
         * void NewInterval()
         * {
         *  FormSelectItem form = new FormSelectItem(true);
         *  if (form.ShowDialog(this) != DialogResult.OK)
         *  {
         *      return;
         *  }
         *  AddInterval(form.Selected);
         * }
         *
         * void AddInterval(ILogData data)
         * {
         *  TreeNode s = selected;
         *  if (s == null)
         *  {
         *      return;
         *  }
         *  ILogDirectory d = s.Tag as ILogDirectory;
         *  if ((d == null) | (data == null))
         *  {
         *      return;
         *  }
         *  try
         *  {
         *      List<string> l = d.GetDirectoryNames();
         *      for (int i = 1; ; i++)
         *      {
         *          string n = "New interval" + i;
         *          if (!l.Contains(n))
         *          {
         *              ILogInterval ld = d.CreateIntrerval(data, n, "", 0, (uint)data.Length);
         *              ShowIntervalTable(d, false);
         *              return;
         *          }
         *      }
         *
         *  }
         *  catch (Exception exception)
         *  {
         *      exception.ShowError();
         *  }
         * }
         */

        void ShowContent(IBufferDirectory dir)
        {
            return;

            if (dir == current)
            {
                return;
            }
            current = dir;
            bool isFile = IsFile;
            Dictionary <string, IBufferData> d = new Dictionary <string, IBufferData>();

            foreach (object o in current.Children)
            {
                if (o is IBufferData)
                {
                    IBufferData ld = o as IBufferData;
                    d[ld.Name] = ld;
                }
            }
            List <string> lt = new List <string>(d.Keys);

            lt.Sort();
            bool isRoot = IsRoot;

            if (isFile)
            {
                dataGridViewFiles.Rows.Clear();
                foreach (string key in lt)
                {
                    DataGridViewRow row  = new DataGridViewRow();
                    IBufferData     data = d[key];
                    row.Tag = d[key];
                    row.CreateCells(dataGridViewFiles,
                                    new object[] { data.Name, data.Comment, data.Length, data.FileName });
                    dataGridViewFiles.Rows.Add(row);
                }
                toolStripLabelDrag.Visible = !isRoot;
                newToolStripButton.Visible = false;
                dataGridViewFiles.Visible  = true;
            }
        }
        /// <summary>
        /// Full directory
        /// </summary>
        /// <param name="item">Item</param>
        /// <param name="action">Action</param>
        /// <returns>Full directory</returns>
        public static IEnumerable <IBufferItem> FullDirectory(this IBufferItem item, Action <IBufferItem> action = null)
        {
            if (action != null)
            {
                action(item);
            }
            yield return(item);

            if (item is IBufferDirectory)
            {
                IBufferDirectory          ld  = item as IBufferDirectory;
                IEnumerable <IBufferItem> enu = ld.Children;
                foreach (IBufferItem it in enu)
                {
                    IEnumerable <IBufferItem> enn = it.FullDirectory(action);
                    foreach (IBufferItem itt in enn)
                    {
                        yield return(itt);
                    }
                }
            }
        }
Exemplo n.º 17
0
        void IIterator.Reset()
        {
            IEnumerable <object> enumerable = null;

            if (item is IBufferData)
            {
                enumerable = Enumerable(item as IBufferData);
            }
            else
            {
                directory = item as IBufferDirectory;
                if (directoryIteration)
                {
                    enumerable = DirectoryEnumerable;
                    enumerable.GetEnumerator().MoveNext();
                }
                else
                {
                    enumerable = Enumerable(directory);
                }
            }
            enumerator = enumerable.GetEnumerator();
        }