コード例 #1
0
ファイル: TemplateData.cs プロジェクト: AbnerTisa/Yhgd
        public bool SetData(
            TestInfoData data1,
            Dictionary <string, string> data2)
        {
            if (data1 == null)
            {
                ErrorString = "测试数据为空";
                return(false);
            }
            tempSetting = data1.TestInfo.TempSetting.Split(",");
            if (data2 != null)
            {
                foreach (var item in data2)
                {
                    exData.Add(item.Key, item.Value);
                }
            }

            testInfo = data1.TestInfo;
            classID  = data1.ProductInfo.ProductClassID;

            var ports = BaseSettingsManager.Get <SystemGroupSetting>().GetPorts(classID);
            var types = new List <string>();

            foreach (var source in data1.TestSources)
            {
                var type = source.SourceType;
                if (!BaseSettingsManager.Get <TestTypeSetting>().ContainsType(type))
                {
                    continue;
                }
                types.Add(type);
            }

            collection = new TestDataCollection(types.ToArray(), tempSetting, ports);

            foreach (var source in data1.TestSources)
            {
                var type = source.SourceType;
                if (!types.Contains(type))
                {
                    continue;
                }

                foreach (var tempData in source.SourceData)
                {
                    var temp = tempData.Key;
                    foreach (var portData in tempData.Value)
                    {
                        var port = portData.Key;
                        var list = new SortedList <double, PointTestItem>();
                        foreach (var wlData in portData.Value)
                        {
                            var wl   = wlData.Key;
                            var item = wlData.Value;
                            list.Add(wl, new PointTestItem(item));
                        }

                        collection.Add(type, temp, port, list);
                    }
                }
            }

            referenceData = new ReferenceData(Guid.Empty, false);
            for (int i = 0; i < data1.ReferenceData.Count; i++)
            {
                foreach (var portTemp in data1.ReferenceData[i])
                {
                    var port = portTemp.Key;
                    foreach (var item in portTemp.Value)
                    {
                        var d = new PointTestItem(item.Value);
                        referenceData.AddReference(i, port, d);
                    }
                }
            }

            exData["sn"]            = data1.TestInfo.SN;
            exData["csn"]           = data1.CustomerSN;
            exData["workorder"]     = data1.WorkInfo.WorkOrderID;
            exData["id"]            = data1.WorkInfo.WorkOrderID;
            exData["workorderid"]   = data1.WorkInfo.WorkOrderID;
            exData["productcode"]   = data1.ProductInfo.ProductCode;
            exData["productname"]   = data1.ProductInfo.ProductName;
            exData["stationname"]   = data1.StationInfo.StationName;
            exData["operator"]      = data1.WorkInfo.WorkInfoOperator;
            exData["room"]          = tempSetting.Length > 0 ? tempSetting[0] : "";
            exData["low"]           = tempSetting.Length > 1 ? tempSetting[1] : "";
            exData["high"]          = tempSetting.Length > 2 ? tempSetting[2] : "";
            exData["productremark"] = data1.ProductInfo.ProductRemark;
            var remarks = data1.ProductInfo.ProductRemark.Split("\r\n");

            for (int i = 0; i < remarks.Length; i++)
            {
                exData[$"productremark[{i}]"] = remarks[i];
            }
            return(true);
        }