static public List <DM_ModelProject> GetProjectArray(ServerConnection conn, ref string strError) { if (conn == null) { conn = new ServerConnection(); } PacketTable[] arrSendTable = new PacketTable[0]; Packet recvPacket = conn.ExecuteCommand(1, arrSendTable); PacketTable[] arrRecvTable = conn.ReadTable(recvPacket); if (arrRecvTable == null) { strError = conn.ErrorMessage; return(null); } PacketTable recvTable = arrRecvTable[0]; int nIndexProjectID = recvTable.GetFieldIndex("ProjectID"); int nIndexProjectName = recvTable.GetFieldIndex("ProjectName"); List <DM_ModelProject> arrProject = new List <DM_ModelProject>(); for (int i = 0; i < recvTable.Rows; i++) { DM_ModelProject project = new DM_ModelProject(); project.ProjectID = (uint)recvTable.GetValue(i, nIndexProjectID); project.ProjectName = (string)recvTable.GetValue(i, nIndexProjectName); arrProject.Add(project); } return(arrProject); }
static public List <DM_Factory> GetFactoryArray(ServerConnection conn, ref string strError) { if (conn == null) { conn = new ServerConnection(); } //查询工厂信息 PacketTable[] arrSendTable = new PacketTable[0]; Packet recvPacket = conn.ExecuteCommand(4, arrSendTable); PacketTable[] arrRecvTable = conn.ReadTable(recvPacket); if (arrRecvTable == null) { strError = conn.ErrorMessage; return(null); } List <DM_Factory> arrFactory = new List <DM_Factory>(); PacketTable recvTable = arrRecvTable[0]; int nIndexFactoryName = recvTable.GetFieldIndex("FactoryName"); int nIndexDatabaseID = recvTable.GetFieldIndex("DatabaseID"); int nIndexServerID = recvTable.GetFieldIndex("ServerID"); for (int nRow = 0; nRow < recvTable.Rows; nRow++) { DM_Factory factory = new DM_Factory(); factory.ServerID = (int)recvTable.GetValue(nRow, nIndexServerID); factory.DatabaseID = (int)recvTable.GetValue(nRow, nIndexDatabaseID); factory.FactoryName = (string)recvTable.GetValue(nRow, nIndexFactoryName); arrFactory.Add(factory); } return(arrFactory); }
static public List <DM_ModelSortClass> StatSortClass(ServerConnection conn, UInt32 nProjectID, UInt32 nPartID, int nTopN, Period period, ref string strError) { if (conn == null) { conn = new ServerConnection(); } List <DM_ModelSortClass> arrSortClass = new List <DM_ModelSortClass>(); PacketTable sendTable = new PacketTable(); sendTable.AddField("LastNum", PacketTable.FieldType.TypeInt); sendTable.AddField("FromDate", PacketTable.FieldType.TypeDateTime); sendTable.AddField("ToDate", PacketTable.FieldType.TypeDateTime); sendTable.AddField("ProjectID", PacketTable.FieldType.TypeUint); sendTable.AddField("PartID", PacketTable.FieldType.TypeUint); sendTable.AddField("ClassID", PacketTable.FieldType.TypeUint); sendTable.AddField("IsFD", PacketTable.FieldType.TypeByte); sendTable.AddField("DataStatus", PacketTable.FieldType.TypeByte); sendTable.AddField("TopN", PacketTable.FieldType.TypeInt); sendTable.AddField("PeriodUnit", PacketTable.FieldType.TypeInt); sendTable.MakeTable(1); sendTable.SetValue(0, 0, period.LastNum); sendTable.SetValue(0, 1, period.DateFrom); sendTable.SetValue(0, 2, period.DateTo); sendTable.SetValue(0, 3, nProjectID); sendTable.SetValue(0, 4, nPartID); sendTable.SetValue(0, 5, (uint)0); sendTable.SetValue(0, 6, (byte)0); sendTable.SetValue(0, 7, (byte)1); sendTable.SetValue(0, 8, period.LastNum); sendTable.SetValue(0, 9, (int)1); PacketTable[] arrSendTable = new PacketTable[1]; arrSendTable[0] = sendTable; Packet recvPacket = conn.ExecuteCommand(204, arrSendTable); PacketTable[] arrRecvTable = conn.ReadTable(recvPacket); if (arrRecvTable == null) { strError = conn.ErrorMessage; return(null); } PacketTable recvTable = arrRecvTable[4]; int nIndexClassName = recvTable.GetFieldIndex("ClassName"); int nIndexPassrate = recvTable.GetFieldIndex("Passrate"); for (int i = 0; i < recvTable.Rows && i < nTopN; i++) { DM_ModelSortClass passrate = new DM_ModelSortClass(); passrate.ClassName = (string)recvTable.GetValue(i, nIndexClassName); passrate.Passrate = (float)recvTable.GetValue(i, nIndexPassrate); arrSortClass.Add(passrate); } return(arrSortClass); }
//查询零件 static public List <DM_ModelPart> GetPartArray(ServerConnection conn, UInt32 nProjectID, ref string strError) { if (conn == null) { conn = new ServerConnection(); } PacketTable sendTable = new PacketTable(); sendTable.AddField("ProjectID", PacketTable.FieldType.TypeUint); sendTable.MakeTable(1); sendTable.SetValue(0, 0, nProjectID); PacketTable[] arrSendTable = new PacketTable[1]; arrSendTable[0] = sendTable; Packet recvPacket = conn.ExecuteCommand(2, arrSendTable); PacketTable[] arrRecvTable = conn.ReadTable(recvPacket); if (arrRecvTable == null) { strError = conn.ErrorMessage; return(null); } PacketTable recvTable = arrRecvTable[0]; int nIndexPartID = recvTable.GetFieldIndex("PartID"); int nIndexParentID = recvTable.GetFieldIndex("ParentID"); int nIndexPartName = recvTable.GetFieldIndex("PartName"); List <DM_ModelPart> arrPart = new List <DM_ModelPart>(); for (int i = 0; i < recvTable.Rows; i++) { DM_ModelPart part = new DM_ModelPart(); part.PartID = (uint)recvTable.GetValue(i, nIndexPartID); part.ParentID = (uint)recvTable.GetValue(i, nIndexParentID); part.PartName = (string)recvTable.GetValue(i, nIndexPartName); arrPart.Add(part); } return(arrPart); }
static public string OutReportPDF(Packet packet) { if (packet == null) { Export handler = new Export(); return(handler.Error("服务器错误")); } byte nResult = 0; if (!packet.Read(ref nResult)) { Export handler = new Export(); return(handler.Error("无法读取执行的结果")); } string strMessage = ""; if (!packet.Read(ref strMessage)) { Export handler = new Export(); return(handler.Error("无法读取执行结果提示信息!")); } int nTableCount = 0; if (!packet.Read(ref nTableCount)) { Export handler = new Export(); return(handler.Error("无法读取参数表的数量")); } if (nTableCount == 0) { Export handler = new Export(); return(null); } else { PacketTable paramTable = new PacketTable(); if (packet.Read(ref paramTable)) { int[] arrFieldIndex = new int[1]; arrFieldIndex[0] = paramTable.GetFieldIndex("PDF"); byte[] ByPDF = (byte[])paramTable.GetValue(0, arrFieldIndex[0]); string Fileurl = System.Web.HttpContext.Current.Server.MapPath("../"); string FileName = Fileurl + "Asset\\pluginPdf\\Test.pdf"; // 创建新的、空的数据文件. if (File.Exists(FileName)) { File.Delete(FileName); } try { FileStream fs = new FileStream(FileName, FileMode.CreateNew); // 创建数据编写器. BinaryWriter w = new BinaryWriter(fs); // 写数据来测试。 w.Write(ByPDF); w.Close(); fs.Close(); } catch (Exception e) { string see = e.Message; return(null); } } return(null); } }
static public List <DM_ModelPassRate> StatPassRate(ServerConnection conn, UInt32 nProjectID, UInt32 nPartID, Period period, ref string strError) { if (conn == null) { conn = new ServerConnection(); } PacketTable sendTable = new PacketTable(); sendTable.AddField("LastNum", PacketTable.FieldType.TypeInt); sendTable.AddField("FromDate", PacketTable.FieldType.TypeDateTime); sendTable.AddField("ToDate", PacketTable.FieldType.TypeDateTime); sendTable.AddField("ProjectID", PacketTable.FieldType.TypeUint); sendTable.AddField("PartID", PacketTable.FieldType.TypeUint); sendTable.AddField("ClassID", PacketTable.FieldType.TypeUint); sendTable.AddField("IsFD", PacketTable.FieldType.TypeByte); sendTable.AddField("DataStatus", PacketTable.FieldType.TypeByte); sendTable.MakeTable(1); sendTable.SetValue(0, 0, period.LastNum); sendTable.SetValue(0, 1, period.DateFrom); sendTable.SetValue(0, 2, period.DateTo); sendTable.SetValue(0, 3, nProjectID); sendTable.SetValue(0, 4, nPartID); sendTable.SetValue(0, 5, (uint)0); sendTable.SetValue(0, 6, (byte)0); sendTable.SetValue(0, 7, (byte)1); PacketTable[] arrSendTable = new PacketTable[1]; arrSendTable[0] = sendTable; Packet recvPacket = conn.ExecuteCommand(201, arrSendTable); PacketTable[] arrRecvTable = conn.ReadTable(recvPacket); if (arrRecvTable == null) { strError = conn.ErrorMessage; return(null); } PacketTable recvTable = arrRecvTable[0]; List <DM_ModelPassRate> arrPassrate = new List <DM_ModelPassRate>(); int nIndexDate = recvTable.GetFieldIndex("Date"); int nIndexSeriesNO = recvTable.GetFieldIndex("SeriesNO"); int nIndexFileName = recvTable.GetFieldIndex("FileName"); int nIndexPassrate = recvTable.GetFieldIndex("Passrate"); int nIndexFileID = recvTable.GetFieldIndex("FileID"); int nIndexPass = recvTable.GetFieldIndex("Pass"); int nIndexTotal = recvTable.GetFieldIndex("Total"); for (int i = 0; i < recvTable.Rows; i++) { //double dDateTime = (double)recvTable.GetValue(i, nIndexDate); DM_ModelPassRate passrate = new DM_ModelPassRate(); passrate.MeasureDate = (DateTime)recvTable.GetValue(i, nIndexDate); passrate.MeasureFileID = (uint)recvTable.GetValue(i, nIndexFileID); passrate.PassRate = (float)recvTable.GetValue(i, nIndexPassrate); passrate.PassTotal = (int)recvTable.GetValue(i, nIndexPass); passrate.SampleTotal = (int)recvTable.GetValue(i, nIndexTotal); passrate.SeriesNo = (string)recvTable.GetValue(i, nIndexSeriesNO); arrPassrate.Add(passrate); } return(arrPassrate); }
static public bool StatCII(ServerConnection conn, UInt32 nProjectID, UInt32 nPartID, Period period, ref string strError, ref float fCII, ref List <float> arrSigma) { if (conn == null) { conn = new ServerConnection(); } PacketTable sendTable = new PacketTable(); sendTable.AddField("LastNum", PacketTable.FieldType.TypeInt); sendTable.AddField("FromDate", PacketTable.FieldType.TypeDateTime); sendTable.AddField("ToDate", PacketTable.FieldType.TypeDateTime); sendTable.AddField("ProjectID", PacketTable.FieldType.TypeUint); sendTable.AddField("PartID", PacketTable.FieldType.TypeUint); sendTable.AddField("ClassID", PacketTable.FieldType.TypeUint); sendTable.AddField("IsFD", PacketTable.FieldType.TypeByte); sendTable.AddField("DataStatus", PacketTable.FieldType.TypeByte); sendTable.MakeTable(1); sendTable.SetValue(0, 0, period.LastNum); sendTable.SetValue(0, 1, period.DateFrom); sendTable.SetValue(0, 2, period.DateTo); sendTable.SetValue(0, 3, nProjectID); sendTable.SetValue(0, 4, nPartID); sendTable.SetValue(0, 5, (uint)0); sendTable.SetValue(0, 6, (byte)0); sendTable.SetValue(0, 7, (byte)1); PacketTable[] arrSendTable = new PacketTable[1]; arrSendTable[0] = sendTable; Packet recvPacket = conn.ExecuteCommand(203, arrSendTable); PacketTable[] arrRecvTable = conn.ReadTable(recvPacket); if (arrRecvTable == null) { strError = conn.ErrorMessage; return(false); } PacketTable recvTableCII = arrRecvTable[0]; if (recvTableCII.Rows > 0) { fCII = (float)recvTableCII.GetValue(0, 0); } else { fCII = 0; } PacketTable recvSigmaTable = arrRecvTable[1]; int nIndexPointDir = recvSigmaTable.GetFieldIndex("PointDir"); int nIndexSigma = recvSigmaTable.GetFieldIndex("Sigma"); int nIndexNominalID = recvSigmaTable.GetFieldIndex("NominalID"); for (int i = 0; i < recvSigmaTable.Rows; i++) { float fSigma6 = (float)recvSigmaTable.GetValue(i, nIndexSigma); arrSigma.Add(fSigma6); } return(true); }