Exemplo n.º 1
0
        // Complete
        private string CalendarCondition()
        {
            StringBuilder sb = new StringBuilder(sSTX, 2000);

            int[] cpi = GetTextLengths(out int itemCount, out int totalChars);
            for (int i = 0; i < itemCount; i++)
            {
                if (cpi[i] > 0)
                {
                    int calCount = MB.GetDecAttribute(ccPF.Number_of_Calendar_Blocks, i);
                    if (calCount > 0)
                    {
                        int n = MB.GetDecAttribute(ccPF.First_Calendar_Block, i);
                        for (int j = 0; j < calCount; j++)
                        {
                            int             index = n + j - 1;
                            Section <ccCal> cs    = new Section <ccCal>(MB, ccCal.Offset_Year, index, 32, true);
                            string[]        cc    = new string[4];
                            sb.Append(sDLE + (char)('1' + i));

                            sb.Append(sESC2);
                            sb.Append(cs.Get(ccCal.Offset_Year, index, 2));
                            sb.Append(cs.Get(ccCal.Offset_Month, index, 2));
                            sb.Append(cs.Get(ccCal.Offset_Day, index, 4));
                            sb.Append(cs.Get(ccCal.Offset_Hour, index, 3));
                            sb.Append(cs.Get(ccCal.Offset_Minute, index, 3));

                            sb.Append(sESC2);
                            sb.Append(cs.Get(ccCal.Substitute_Year, index, 1));
                            sb.Append(cs.Get(ccCal.Substitute_Month, index, 1));
                            sb.Append(cs.Get(ccCal.Substitute_Day, index, 1));
                            sb.Append(cs.Get(ccCal.Substitute_Hour, index, 1));
                            sb.Append(cs.Get(ccCal.Substitute_Minute, index, 1));
                            sb.Append(cs.Get(ccCal.Substitute_Weeks, index, 1));
                            sb.Append(cs.Get(ccCal.Substitute_DayOfWeek, index, 1));

                            sb.Append(sESC2);
                            sb.Append(cs.Get(ccCal.Zero_Suppress_Year, index, 1));
                            sb.Append(cs.Get(ccCal.Zero_Suppress_Month, index, 1));
                            sb.Append(cs.Get(ccCal.Zero_Suppress_Day, index, 1));
                            sb.Append(cs.Get(ccCal.Zero_Suppress_Hour, index, 1));
                            sb.Append(cs.Get(ccCal.Zero_Suppress_Minute, index, 1));
                            sb.Append(cs.Get(ccCal.Zero_Suppress_Weeks, index, 1));
                            sb.Append(cs.Get(ccCal.Zero_Suppress_DayOfWeek, index, 1));

                            sb.Append(sESC2);
                            sb.Append("0");         // We do not have SOP-05

                            sb.Append(sESC2);
                            sb.Append(cs.Get(ccCal.Substitute_Rule, index, 2));
                        }
                    }
                }
            }

            return(sb.Append(sETX).ToString());
        }
Exemplo n.º 2
0
        // Complete
        private string LineSetting()
        {
            int[] cpi = GetTextLengths(out int itemCount, out int charCount);   //

            int        layout  = MB.GetDecAttribute(ccPF.Format_Setup);         // Message Layout
            int        n       = 0;
            List <int> rows    = new List <int>();                              // Holds the number of rows in each column
            List <int> spacing = new List <int>();                              // Holds the line spacing
            List <int> dups    = new List <int>();                              // Adjacent duplicate columns
            int        lc;                                                      // Line count
            int        ls;                                                      // Line spacing

            while (n < itemCount)                                               // Read all columns
            {
                Section <ccPF> pf = new Section <ccPF>(MB, ccPF.Line_Count, ccPF.Prefix_Code, n, true);
                lc = pf.GetDecAttribute(ccPF.Line_Count, n);                    // Number of lines for this column
                ls = pf.GetDecAttribute(ccPF.Line_Spacing, n);                  // Spacing between lines
                if (cpi[n] == 0)
                {
                    rows.Add(lc);                                               // Create a single entry for all remaining
                    spacing.Add(ls);
                    dups.Add((itemCount - n) / lc);
                    n = itemCount;
                }
                else
                {
                    if (rows.Count > 0 &&                                       // Is this a dup of previous column
                        rows[rows.Count - 1] == lc &&
                        spacing[spacing.Count - 1] == ls)
                    {
                        dups[dups.Count - 1]++;                                 // Just up the count
                    }
                    else
                    {
                        rows.Add(lc);                                           // Create a new entry
                        spacing.Add(ls);
                        dups.Add(1);
                    }
                    n += lc;                                                    // Move on to the next column
                }
            }

            StringBuilder sb = new StringBuilder(sSTX, 2000);

            sb.Append(sESC2);                                                   // Send Header
            sb.AppendFormat("{0:D1}", layout);
            for (int i = 0; i < rows.Count; i++)
            {
                sb.Append(sESC2);                                               // Send column info
                sb.Append(((char)(dups[i] + '0')).ToString());                  // 0x31 to 0x94
                sb.Append(((char)(rows[i] + '0')).ToString());
            }
            return(sb.Append(sETX).ToString());
        }