コード例 #1
0
ファイル: MainForm.cs プロジェクト: gixslayer/darktech
        private void tvFrames_AfterSelect(object sender, TreeViewEventArgs e)
        {
            selectedSection = (SectionResult)e.Node.Tag;

            UpdateSectionGUI();
            UpdateSectionChildrenGUI();
        }
コード例 #2
0
ファイル: SectionRepository.cs プロジェクト: shanisara/SAT.HR
        public SectionResult GetPage(string filter, int?draw, int?initialPage, int?pageSize, string sortDir, string sortBy)
        {
            using (SATEntities db = new SATEntities())
            {
                var data = db.vw_Section.ToList();

                int recordsTotal = data.Count();

                if (!string.IsNullOrEmpty(filter))
                {
                    data = data.Where(x => x.DivName.Contains(filter) || x.DepName.Contains(filter) || x.SecName.Contains(filter)).ToList();
                }

                int recordsFiltered = data.Count();

                switch (sortBy)
                {
                case "DivName":
                    data = (sortDir == "asc") ? data.OrderBy(x => x.DivName).ToList() : data.OrderByDescending(x => x.DivName).ToList();
                    break;

                case "DepName":
                    data = (sortDir == "asc") ? data.OrderBy(x => x.DepName).ToList() : data.OrderByDescending(x => x.DepName).ToList();
                    break;

                case "SecName":
                    data = (sortDir == "asc") ? data.OrderBy(x => x.SecName).ToList() : data.OrderByDescending(x => x.SecName).ToList();
                    break;

                case "Status":
                    data = (sortDir == "asc") ? data.OrderBy(x => x.SecStatus).ToList() : data.OrderByDescending(x => x.SecStatus).ToList();
                    break;
                }

                int start  = initialPage.HasValue ? (int)initialPage / (int)pageSize : 0;
                int length = pageSize ?? 10;

                var list = data.Select((s, i) => new SectionViewModel()
                {
                    RowNumber = i + 1,
                    SecID     = s.SecID,
                    SecName   = s.SecName,
                    SecStatus = s.SecStatus,
                    DivID     = (int)s.DivID,
                    DivName   = s.DivName,
                    DepID     = (int)s.DepID,
                    DepName   = s.DepName,
                    Status    = s.SecStatus == true ? EnumType.StatusName.Active : EnumType.StatusName.NotActive
                }).Skip(start * length).Take(length).ToList();

                SectionResult result = new SectionResult();
                result.draw            = draw ?? 0;
                result.recordsTotal    = recordsTotal;
                result.recordsFiltered = recordsFiltered;
                result.data            = list;

                return(result);
            }
        }
コード例 #3
0
        /// <summary>
        /// Updates all data and notifies the wrapped section result.
        /// </summary>
        protected void UpdateInternalData()
        {
            Update();

            RowUpdated?.Invoke(this, EventArgs.Empty);
            SectionResult.NotifyObservers();
            RowUpdateDone?.Invoke(this, EventArgs.Empty);
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: gixslayer/darktech
        private void SelectFrame(int index)
        {
            selectedFrame   = frames.Count > index ? frames[index] : null;
            selectedIndex   = index;
            selectedSection = null;

            UpdateGUI();
        }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: gixslayer/darktech
 private void closeToolStripMenuItem_Click(object sender, EventArgs e)
 {
     frames.Clear();
     selectedIndex   = 0;
     selectedFrame   = null;
     selectedSection = null;
     UpdateGUI();
 }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: gixslayer/darktech
        private void AddChildSection(TreeNode parent, SectionResult section)
        {
            TreeNode sectionNode = new TreeNode(section.Name);

            sectionNode.Tag = section;

            foreach (SectionResult subSection in section.Children)
            {
                AddChildSection(sectionNode, subSection);
            }

            parent.Nodes.Add(sectionNode);
        }
コード例 #7
0
        /// <summary>
        /// Writes data to the stream.
        /// </summary>
        /// <param name="bytes">Buffer to write from.</param>
        /// <param name="offset">Offset in the buffer to write from.</param>
        /// <param name="count">Count of the bytes to write.</param>
        public override void Write(byte[] bytes, int offset, int count)
        {
            byte[] input;
            int    start = 0;
            int    end   = 0;

            // System.Diagnostics.Debug.WriteLine("Entering write");

            if (_buffer != null)
            {
                input = new byte[_buffer.Length + count];
                Buffer.BlockCopy(_buffer, 0, input, 0, _buffer.Length);
                Buffer.BlockCopy(bytes, offset, input, _buffer.Length, count);
            }
            else
            {
                input = new byte[count];
                Buffer.BlockCopy(bytes, offset, input, 0, count);
            }

            _position += count;

            while (true)
            {
                if (_headerNeeded)
                {
                    int prevStart = start;

                    start = IndexOf(input, BOUNDARY, start);

                    if (start >= 0)
                    {
                        end = IndexOf(input, EOF, start);

                        if (end == start)
                        {
                            // This is the end of the stream
                            WriteBytes(false, input, start, input.Length - start);
                            // System.Diagnostics.Debug.WriteLine("EOF");
                            break;
                        }

                        // Do we have the whole header?
                        end = IndexOf(input, EOH, start);

                        if (end >= 0)
                        {
                            Dictionary <string, string> headerItems;

                            // We have a full header
                            _inField      = true;
                            _headerNeeded = false;

                            headerItems = ParseHeader(input, start);

                            if (headerItems == null)
                            {
                                throw new Exception("Malformed header");
                            }

                            if (headerItems.ContainsKey("filename") && headerItems.ContainsKey("Content-Type"))
                            {
                                string fn = headerItems["filename"].Trim('"').Trim();

                                if (!String.IsNullOrEmpty(fn))
                                {
                                    try
                                    {
                                        object id;

                                        _fileName = headerItems["filename"].Trim('"');
                                        _inFile   = true;
                                        id        = _processor.StartNewFile(fn, headerItems["Content-Type"], headerItems, _previousFields);

                                        OnFileStarted(fn, id);
                                    }
                                    catch (Exception ex)
                                    {
                                        _fileError = true;
                                        OnError(ex);
                                    }
                                }
                            }
                            else
                            {
                                _inFile           = false;
                                _currentField     = new MemoryStream();
                                _currentFieldName = headerItems["name"];
                            }

                            start = end + 4;
                        }
                        else
                        {
                            _buffer = new byte[input.Length - start];
                            Buffer.BlockCopy(input, start, _buffer, 0, input.Length - start);
                            // System.Diagnostics.Debug.WriteLine("Breaking because no header found (2)");
                            break;
                        }
                    }
                    else
                    {
                        _buffer = new byte[input.Length - prevStart];
                        Buffer.BlockCopy(input, prevStart, _buffer, 0, input.Length - prevStart);
                        // System.Diagnostics.Debug.WriteLine("Breaking because no header found (1)");
                        break;
                    }
                }

                SectionResult res = null;

                if (_inField)
                {
                    _buffer = null; // Reset the buffer

                    // Process data
                    res = ProcessField(input, start);

                    if (res.NextAction == SectionResult.SectionAction.BoundaryReached)
                    {
                        // System.Diagnostics.Debug.WriteLine("Found a new boundary");
                        _headerNeeded = true;
                        _inField      = false;
                        start         = res.NextOffset;

                        if (_inFile)
                        {
                            _inFile = false;

                            try
                            {
                                _processor.EndFile();
                            }
                            catch (Exception ex)
                            {
                                OnError(ex);
                                _fileError = true;
                            }
                            finally
                            {
                                if (_fileError)
                                {
                                    OnFileCompletedError(_fileName, _processor.GetIdentifier(), _ex);
                                }
                                else
                                {
                                    OnFileCompleted(_fileName, _processor.GetIdentifier());
                                }
                            }
                        }
                    }
                    else if (res.NextAction == SectionResult.SectionAction.NoBoundaryKeepBuffer)
                    {
                        // System.Diagnostics.Debug.WriteLine("Keeping back " + (input.Length - res.NextOffset).ToString() + " bytes");
                        _buffer = new byte[input.Length - res.NextOffset];
                        Buffer.BlockCopy(input, res.NextOffset, _buffer, 0, input.Length - res.NextOffset);
                        break;
                    }
                }

                if (!_headerNeeded && !_inField)
                {
                    throw new Exception("Malformed input file- don't know what to do so aborting.");
                }
            }

            // System.Diagnostics.Debug.WriteLine("Leaving write");
        }
コード例 #8
0
ファイル: MainForm.cs プロジェクト: gixslayer/darktech
        private void UpdateSectionChildrenGUI()
        {
            tlChildSections.Controls.Clear();

            if (selectedSection == null || selectedSection.Children.Count == 0)
            {
                return;
            }

            tlChildSections.RowCount = selectedSection.Children.Count;
            tlChildSections.Controls.Clear();
            tlChildSections.RowStyles.Clear();
            tlChildSections.ColumnStyles.Clear();

            tlChildSections.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 138));
            tlChildSections.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));

            for (int i = 0; i < selectedSection.Children.Count; i++)
            {
                SectionResult child = selectedSection.Children[i];

                tlChildSections.RowStyles.Add(new RowStyle(SizeType.Absolute, 29));

                decimal childFrac = new decimal(child.SiblingFraction * 100f);
                childFrac = Decimal.Round(childFrac, 2, MidpointRounding.AwayFromZero);
                LinkLabel label = new LinkLabel();
                label.Text = string.Format("{0} ({1}%):", child.Name, childFrac.ToString());

                label.LinkBehavior = LinkBehavior.HoverUnderline;
                TreeNode linkDestination = null;

                if (tvFrames.SelectedNode != null)
                {
                    foreach (TreeNode childNode in tvFrames.SelectedNode.Nodes)
                    {
                        if (childNode.Text == child.Name)
                        {
                            linkDestination = childNode;

                            break;
                        }
                    }
                }

                if (linkDestination != null)
                {
                    LinkLabel.Link link = new LinkLabel.Link();
                    link.LinkData = linkDestination;
                    label.Links.Add(link);
                    label.LinkClicked += label_LinkClicked;
                }

                ProgressBar progressBar = new ProgressBar();
                progressBar.Style  = ProgressBarStyle.Continuous;
                progressBar.Width  = 125;
                progressBar.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
                progressBar.Value  = (int)(child.SiblingFraction * 100f);

                tlChildSections.Controls.Add(label, 0, i);
                tlChildSections.Controls.Add(progressBar, 1, i);
            }
        }