Beispiel #1
0
 public Schema(SchemaColumn col, SchemaRow row, bool bBinaryValues, int nCellSize)
 {
     m_col           = col;
     m_row           = row;
     m_bBinaryValues = bBinaryValues;
     m_nCellSize     = nCellSize;
 }
Beispiel #2
0
        Schema loadSchema(DataConfigSettingCollection col)
        {
            string       strTagCol        = getConfigVal(col, "Tag Col");
            string       strDateCol       = getConfigVal(col, "Date Col");
            string       strDataStartCol  = getConfigVal(col, "Data Start Col");
            string       strDataEndCol    = getConfigVal(col, "Data End Col");
            string       strLabelStartCol = getConfigVal(col, "Label Start Col");
            string       strLabelEndCol   = getConfigVal(col, "Label End Col");
            string       strExtraStartCol = getConfigVal(col, "Extra Start Col");
            string       strExtraEndCol   = getConfigVal(col, "Extra End Col");
            int          nTagCol          = SchemaColumn.ConvertCol(strTagCol);
            int          nDateCol         = SchemaColumn.ConvertCol(strDateCol);
            int          nDataStartCol    = SchemaColumn.ConvertCol(strDataStartCol);
            int          nDataEndCol      = SchemaColumn.ConvertCol(strDataEndCol);
            int          nLabelStartCol   = SchemaColumn.ConvertCol(strLabelStartCol);
            int          nLabelEndCol     = SchemaColumn.ConvertCol(strLabelEndCol);
            int          nExtraStartCol   = SchemaColumn.ConvertCol(strExtraStartCol);
            int          nExtraEndCol     = SchemaColumn.ConvertCol(strExtraEndCol);
            SchemaColumn colS             = new SchemaColumn(nTagCol, nDateCol, nDataStartCol, nDataEndCol, nLabelStartCol, nLabelEndCol, nExtraStartCol, nExtraEndCol);

            int       nDataDescRow   = getConfigValAsInt(col, "Data Desc Row");
            int       nLabelStartRow = getConfigValAsInt(col, "Label Start Row");
            int       nLabelEndRow   = getConfigValAsInt(col, "Label End Row");
            int       nDataStartRow  = getConfigValAsInt(col, "Data Start Row");
            SchemaRow rowS           = new SchemaRow(nDataDescRow, nLabelStartRow, nLabelEndRow, nDataStartRow);

            DataConfigSetting s = col.Find("Use Binary Values");
            bool bBinaryValues  = ((int)s.Value == 0) ? false : true;

            s = col.Find("Cell Size");
            int nCellSize = (int)s.Value;

            Properties.Settings.Default.TagCol        = strTagCol;
            Properties.Settings.Default.DateCol       = strDateCol;
            Properties.Settings.Default.DataStartCol  = strDataStartCol;
            Properties.Settings.Default.DataEndCol    = strDataEndCol;
            Properties.Settings.Default.LabelStartCol = strLabelStartCol;
            Properties.Settings.Default.LabelEndCol   = strLabelEndCol;
            Properties.Settings.Default.ExtraStartCol = strExtraStartCol;
            Properties.Settings.Default.ExtraEndCol   = strExtraEndCol;
            Properties.Settings.Default.DataDescRow   = nDataDescRow + 1;
            Properties.Settings.Default.LabelStartRow = nLabelStartRow + 1;
            Properties.Settings.Default.LabelEndRow   = nLabelEndRow + 1;
            Properties.Settings.Default.DataStartRow  = nDataStartRow + 1;
            Properties.Settings.Default.UseBinary     = bBinaryValues;
            Properties.Settings.Default.CellSize      = nCellSize;
            Properties.Settings.Default.Save();

            return(new Schema(colS, rowS, bBinaryValues, nCellSize));
        }
Beispiel #3
0
        public DataItem(int nLine, string str, SchemaColumn col)
        {
            string[] rgstr = str.Split(',');

            if (col.Tag >= 0)
            {
                m_strTag = rgstr[col.Tag].Trim();
            }

            if (col.Date >= 0)
            {
                m_dt = DateTime.Parse(rgstr[col.Date].Trim());
            }

            if (m_dt.DayOfWeek == DayOfWeek.Saturday || m_dt.DayOfWeek == DayOfWeek.Sunday)
            {
                DateTime dt = m_dt;

                while (dt.DayOfWeek != DayOfWeek.Monday)
                {
                    dt += TimeSpan.FromDays(1);
                }

                Trace.WriteLine("Weekend date on line " + (nLine + 1).ToString() + ", use " + dt.ToShortDateString() + " instead.");
            }

            if (rgstr.Length < col.DataStart)
            {
                throw new Exception("LINE (" + (nLine + 1).ToString() + "): The data start '" + col.DataStart.ToString() + "' exceeds the row length of '" + rgstr.Length.ToString() + "!");
            }

            if (rgstr.Length < col.DataEnd)
            {
                throw new Exception("LINE (" + (nLine + 1).ToString() + "): The data end '" + col.DataEnd.ToString() + "' exceeds the row length of '" + rgstr.Length.ToString() + "!");
            }

            if (col.DataStart < 0 || col.DataEnd < 0 || col.DataStart > col.DataEnd)
            {
                throw new Exception("LINE (" + (nLine + 1).ToString() + "): The data start and end '" + col.DataStart.ToString() + ", " + col.DataEnd.ToString() + "' are out of range!");
            }

            for (int i = col.DataStart; i <= col.DataEnd; i++)
            {
                string strData = rgstr[i].Trim();

                if (string.IsNullOrEmpty(strData))
                {
                    m_rgData.Add(0);
                }
                else
                {
                    m_rgData.Add(double.Parse(strData));
                }
            }

            if (rgstr.Length < col.LabelStart)
            {
                throw new Exception("LINE (" + (nLine + 1).ToString() + "): The label start '" + col.LabelStart.ToString() + "' exceeds the row length of '" + rgstr.Length.ToString() + "!");
            }

            if (rgstr.Length < col.LabelEnd)
            {
                throw new Exception("LINE (" + (nLine + 1).ToString() + "): The label end '" + col.LabelEnd.ToString() + "' exceeds the row length of '" + rgstr.Length.ToString() + "!");
            }

            if (col.LabelStart < 0 || col.LabelEnd < 0 || col.LabelStart > col.LabelEnd)
            {
                throw new Exception("LINE (" + (nLine + 1).ToString() + "): The label start and end '" + col.LabelStart.ToString() + ", " + col.LabelEnd.ToString() + "' are out of range!");
            }

            m_nLabel = -1;

            for (int i = col.LabelStart; i <= col.LabelEnd; i++)
            {
                string strData = rgstr[i].Trim();

                if (!string.IsNullOrEmpty(strData))
                {
                    m_nLabel = i - col.LabelStart;
                    break;
                }
            }

            if (m_nLabel < 0)
            {
                throw new Exception("LINE (" + (nLine + 1).ToString() + "): Missing label specification!");
            }

            if (rgstr.Length < col.ExtraStart)
            {
                throw new Exception("LINE (" + (nLine + 1).ToString() + "): The extra start '" + col.ExtraStart.ToString() + "' exceeds the row length of '" + rgstr.Length.ToString() + "!");
            }

            if (rgstr.Length < col.ExtraEnd)
            {
                throw new Exception("LINE (" + (nLine + 1).ToString() + "): The extra end '" + col.ExtraEnd.ToString() + "' exceeds the row length of '" + rgstr.Length.ToString() + "!");
            }

            if (col.ExtraStart >= 0 && col.ExtraEnd > col.ExtraStart)
            {
                for (int i = col.ExtraStart; i <= col.ExtraEnd; i++)
                {
                    string strData = rgstr[i].Trim();

                    strData = strData.TrimEnd('%');

                    if (string.IsNullOrEmpty(strData))
                    {
                        m_rgExtra.Add(0);
                    }
                    else
                    {
                        m_rgExtra.Add(double.Parse(strData));
                    }
                }
            }
        }