示例#1
0
        public override bool TransferFile(string path)
        {
            IniAccess ia          = new IniAccess("userconfig.ini");
            string    catalogfile = ia.ReadValue("catalog");
            QCatalog  catalog     = QCatalog.GetCatlog(File.Exists(catalogfile) ? catalogfile : "catalog.dfd");


            Workbook wb = new Workbook();

            wb.LoadFromFile(path);
            Worksheet sheet = wb.Worksheets[0];

            QFile qf = new QFile();

            qf[1001] = sheet[3, 2].Value;
            qf[1053] = sheet[3, 4].Value;
            qf[1086] = sheet[3, 5].Value;
            qf[1110] = sheet[3, 6].Value; // 1100 -> 1110
            qf[1101] = sheet[2, 1].Value;
            qf[1102] = sheet[3, 1].Value;

            int rowid = 5;

            while (true)
            {
                if (isEmpty(sheet, rowid))
                {
                    break;
                }

                QCharacteristic qc = new QCharacteristic();
                qf.Charactericstics.Add(qc);
                string pid = sheet[rowid, 1].Value != null ? sheet[rowid, 1].Value.ToString() : "";
                qc[2001] = pid.Replace('(', ' ').Replace(')', ' ').Trim();
                qc[2002] = sheet[rowid, 2].Value;
                qc[2005] = sheet[rowid, 13].Value.Contains("是") ? 4 : 1; // 不包括是时为 1 还是0 ,文档中有错误。
                qc[2022] = 4;
                qc[2101] = sheet[rowid, 3].Value;
                qc[2113] = sheet[rowid, 4].Value;
                qc[2112] = sheet[rowid, 5].Value;
                qc[2120] = 1;
                qc[2121] = 1;
                qc[2142] = "mm";
                qc[8500] = 5;
                qc[8501] = 0;



                QDataItem di = new QDataItem();
                di.SetValue(sheet[rowid, 6].Value);
                di.date  = sheet[3, 10].DateTimeValue;
                di[0006] = sheet[3, 3].Value;
                di[0008] = catalog.getCatalogPID("K4093", sheet[3, 11].Value);
                di[0010] = catalog.getCatalogPID("K4063", sheet[rowid, 11].Value);
                di[0011] = sheet[rowid, 10].Value;
                di[0012] = catalog.getCatalogPID("K4072", sheet[rowid, 10].Value);
                di[0061] = catalog.getCatalogPID("K4273", sheet[3, 7].Value);
                qc.data.Add(di);

                // Console.WriteLine("{0}, {0}, {0}, {0}", di[0008], di[0010], di[0012], di[0061]);

                rowid++;
            }

            qf.ToDMode();

            SaveDfqByFilename(qf, Path.GetFileNameWithoutExtension(path) + ".dfq");

            return(base.TransferFile(path));
        }
示例#2
0
        public override bool TransferFile(string infile)
        {
            COMReader reader = new COMReader(infile);

            string   K1900 = reader.GetCell("B5"); //
            string   K1041 = reader.GetCell("B8"); //
            string   K0008 = reader.GetCell("B11");
            double   days  = double.Parse(reader.GetCell("D5"));
            double   time  = double.Parse(reader.GetCell("D8"));
            DateTime K0004 = new DateTime(1900, 1, 1).AddDays(-2).AddDays(days + time);
            string   K0012 = reader.GetCell("D11");
            string   K1001 = reader.GetCell("F8");//
            string   K0014 = reader.GetCell("F11");

            QCatalog qlog = getCatlog();

            int startRow = 13;
            int endRow   = reader.GetRowCount();
            // A: char, B: Actual, C: Nominal, D: Upper Tol;  E: Lower Tol; F: Deviation

            QFile qf = new QFile();

            qf[1001] = K1001;
            qf[1041] = K1041;
            qf[1900] = K1900;

            for (int i = startRow; i < endRow; i++)
            {
                // Characteristic	Actual	Nominal	Upper Tol	Lower Tol	Deviation
                // K2002, K0001, K2101, K2113, K2112
                string K2002 = reader.GetCell(i, 0);
                string K0001 = reader.GetCell(i, 1);
                string K2101 = reader.GetCell(i, 2);
                string K2113 = reader.GetCell(i, 3);
                string K2112 = reader.GetCell(i, 4);

                QCharacteristic qc = new QCharacteristic();
                qc[2001] = qf.Charactericstics.Count + 1;
                qc[2002] = K2002;
                qc[2022] = "8";
                qc[2101] = K2101;
                qc[2112] = K2112;
                qc[2113] = K2113;
                qc[2120] = 1;
                qc[2121] = 1;
                qc[2142] = "mm";
                qc[8500] = 5;
                qc[8501] = 0;

                QDataItem di = new QDataItem();
                di.date = K0004;
                di.SetValue(K0001);
                di[0008] = qlog.getCatalogPID("K4093", K0008);
                di[0012] = qlog.getCatalogPID("K4073", K0012);
                di[0014] = K0014;
                qc.data.Add(di);

                qf.Charactericstics.Add(qc);
            }

            qf.ToDMode();

            return(SaveDfq(qf, string.Format("{0}\\{1}_{2}.dfq",
                                             pd.GetOutDirectory(infile),                   // output directory
                                             K1001,                                        // filename from all info.
                                             DateTimeHelper.ToFullString(DateTime.Now)))); // time stamp.
        }
示例#3
0
        public override bool TransferFile(string infile)
        {
            COMReader    reader = new COMReader(infile, ExcelVersion.Excel2003);
            string       K0012  = reader.GetCell("G3");
            QCatalog     qlog   = QCatalog.GetCatlog(@"Z:\Projects\QTransducer\2017年\2017_08_Antai_密度\P180116\CATALOG.dfd");
            List <QFile> qfs    = new List <QFile>();

            DateTime date = new DateTime(1900, 1, 1);

            for (int row = 5; row < reader.GetRowCount(); row++)
            {
                try
                {
                    DateTime dt    = date.AddDays(int.Parse(reader.GetCell("A" + row)) - 2);
                    string   K1002 = reader.GetCell("B" + row);
                    string   K0014 = reader.GetCell("C" + row);
                    string   K0016 = reader.GetCell("D" + row);
                    string   K0010 = reader.GetCell("E" + row);
                    string   K1001 = reader.GetCell("F" + row);
                    string   K0011 = reader.GetCell("I" + row) + '\\' + reader.GetCell("J" + row) + '\\' + reader.GetCell("K" + row) + '\\' + reader.GetCell("L" + row);
                    string   K0001 = reader.GetCell("M" + row);

                    double value = double.Parse(K0001);

                    string K2110 = "";
                    string K2111 = "";
                    string K2120 = "";

                    string colN = reader.GetCell(row, "N");
                    // 上下限写入同一单元格并用 "-"间隔,即:下限-上限。
                    // 将中横杠前的数据写入K2110,中横杠后的数据写入K2111。
                    // 1、当密度要求值出现中横杠"_"时,代表该行信息不需要输出
                    if (colN == null || colN.Trim().Length == 1)
                    {
                        continue;
                    }
                    else if (colN.Contains("-"))
                    {
                        K2110 = colN.Split('-')[0];
                        K2111 = colN.Split('-')[1];
                    }
                    // 2、当密度要求值出现中横杠”≥”时,该参数只有下限K2110,
                    // 例如≥30,输出K2110 = 30,K2111为空,K2120 = 1
                    else if (colN.Contains("≥"))
                    {
                        K2110 = colN.Split('≥')[1];
                        K2120 = "1";
                    }
                    // 3、当密度要求值出现中横杠” >”时,该参数只有下限,且为下自然界线。
                    // 例如 > 30,输出K2110 = 30,K2111为空,K2120 = 2
                    else if (colN.Contains(">"))
                    {
                        K2110 = colN.Split('>')[1];
                        K2120 = "2";
                    }

                    string K0008 = reader.GetCell("Q" + row);

                    if (K1001 == "" && K1002 == "")
                    {
                        LogList.Add(new TransLog(infile, "", "K1001 和 K1002 均为空。", LogType.Fail));
                        break;
                    }

                    QFile qf = getQFile(qfs, K1001, K1002);

                    if (qf.Charactericstics.Count == 0)
                    {
                        QCharacteristic qc = new QCharacteristic();
                        qf.Charactericstics.Add(qc);
                        qc[2002] = "密度g/cm³";
                        qc[2022] = 8;
                        if (K2110.Length > 0)
                        {
                            qc[2110] = K2110;
                        }
                        if (K2111.Length > 0)
                        {
                            qc[2111] = K2111;
                        }
                        qc[2120] = 1;
                        qc[2121] = 1;
                        if (K2120.Length > 0)
                        {
                            qc[2120] = K2120;
                        }
                        qc[2142] = "g/cm³";
                        qc[8500] = 5;
                        qc[8501] = 0;
                    }

                    QDataItem qdi = new QDataItem {
                        date = dt
                    };
                    qdi.SetValue(K0001);
                    qdi[0008] = qlog.getCatalogPID("K4093", K0008);
                    qdi[0010] = qlog.getCatalogPID("K4063", K0010);
                    qdi[0011] = K0011;
                    qdi[0012] = qlog.getCatalogPID("K4073", K0012);
                    qdi[0014] = K0014;
                    qdi[0016] = K0016;
                    qf.Charactericstics[0].data.Add(qdi);

                    // Console.WriteLine("K0008({0})->K4093={1}", K0008, qlog.getCatalogPID("K4093", K0008));
                }
                catch (Exception ex)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append("Row " + row + ": ");
                    for (int col = 0; col < reader.GetColumnCount(); col++)
                    {
                        sb.Append(reader.GetCell(row, col) + ", ");
                    }
                    Console.WriteLine(sb.ToString() + ". Error message: " + ex.Message);
                }
            }

            foreach (QFile qf in qfs)
            {
                qf.ToDMode();
                SaveDfqByFilename(qf, qf[1001] + "_" + qf[1002] + ".dfq");
            }

            return(true);
        }