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

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

            try
            {
                List <string> l = d.GetDirectoryNames();
                for (int i = 1; ; i++)
                {
                    string n = "New folder" + i;
                    if (!l.Contains(n))
                    {
                        ILogDirectory ld = d.Create(n, "");
                        TreeNode      nd = ld.CreateNode(true);
                        s.Nodes.Add(nd);
                        return;
                    }
                }
            }
            catch (Exception exception)
            {
                exception.ShowError();
            }
        }
Esempio n. 2
0
        private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow row  = dataGridViewFiles.Rows[e.RowIndex];
            ILogData        d    = row.Tag as ILogData;
            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;
                }
                ILogDirectory dir  = d.Parent as ILogDirectory;
                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;
            }
        }
Esempio n. 3
0
        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();
            }
        }
Esempio n. 4
0
        private void dataGridViewIntervals_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow row  = dataGridViewIntervals.Rows[e.RowIndex];
            ILogData        d    = row.Tag as ILogData;
            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;
                }
                ILogDirectory dir  = d.Parent as ILogDirectory;
                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;
                return;
            }
            ILogInterval interval = d as ILogInterval;

            try
            {
                uint number = uint.Parse(text);
                if (number == 1)
                {
                    number = 0;
                }
                if (ri == 2)
                {
                    interval.Begin = number;
                }
                if (ri == 3)
                {
                    interval.End = number;
                }
            }
            catch (Exception exception)
            {
                exception.ShowError();
            }
        }
Esempio n. 5
0
 /// <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 ILogDirectory Create(this ILogDirectory parent, string name,
                                    string comment)
 {
     if (parent.GetDirectoryNames().Contains(name))
     {
         throw new Exception(name + " already exists");
     }
     return(new LogDirectoryWrapper(parent as LogDirectoryWrapper,
                                    data.Create(parent.Id, name, comment)));
 }
Esempio n. 6
0
        /// <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 ILogInterval CreateIntrerval(this ILogDirectory directory,
                                                   ILogData data, string name, string comment, uint begin, uint end)
        {
            IDatabaseInterface d = StaticExtensionEventLogDatabase.data;

            if (directory.GetDirectoryNames().Contains(name))
            {
                throw new Exception(name + " already exists");
            }
            ILogInterval interval = d.CreateInterval(directory.Id, name, comment, data, begin, end);

            return(new LogIntervalWrapper(directory as LogDirectoryWrapper, interval, data));
        }
Esempio n. 7
0
        /// <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 ILogData CreateData(this ILogDirectory directory,
                                          IEnumerable <byte[]> data, string name, string fileName, string comment)
        {
            IDatabaseInterface d = StaticExtensionEventLogDatabase.data;

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

            d.Filenames.Add(fileName);
            return(new LogItemWrapper(directory as LogDirectoryWrapper, ld));
        }
Esempio n. 8
0
        private void treeViewDir_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            TreeNode s = e.Node;

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

            if (o == null)
            {
                return;
            }
            if (o is ILogItem)
            {
                ILogItem item = o as ILogItem;
                ILogItem p    = item.Parent;
                if (p == null | !(p is ILogDirectory))
                {
                    MessageBox.Show("Prohibited");
                    return;
                }
                ILogDirectory d     = p as ILogDirectory;
                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();
                }
            }
        }