private static Packet writeMeasureFile(DM_ModelProject modelProject, DM_ModelPart modelPart, DM_WorkPlace modelWorkPalce, DM_ModelWorkshop modelWorkShop, DataTable dtPoint, DataTable dtInfo, string strProgressName, ref string strError) { DateTime dtNow = DateTime.Now; MeasureFile file = new MeasureFile(); string strFileName = FileFun.CreateFileName(dtNow, "MeasureFile.txt"); string strFilePath = HttpContext.Current.Server.MapPath("~") + "\\MeasureFile\\" + strFileName; MeasureFileHead head = new MeasureFileHead(); head.MeasureDate = dtNow.Year + "-" + dtNow.Month + "-" + dtNow.Day; head.MeasureTime = dtNow.Hour + ":" + dtNow.Minute + ":" + dtNow.Second; head.ProjectName = modelProject.ProjectName; head.ProjectNo = modelProject.ProjectNo; head.PartName = modelPart.PartName; head.PartNo = modelPart.PartNO; head.SerNumber = ""; head.ComPonent = ""; head.Progress = strProgressName; head.WorkPlace = modelWorkPalce.WorkPlaceName; head.WorkShop = modelWorkShop.WorkshopName; file.FileHead = head; for (int i = 0; i < dtPoint.Rows.Count; i++) { string strPointName = dtPoint.Rows[i]["PointName"].ToString(); string strPointID = dtPoint.Rows[i]["PointID"].ToString(); float fMeas = dtPoint.Rows[i]["Value"].ToString() == "" ? MeasureFileBase.GlobalData.NULL_NUM : Convert.ToSingle(dtPoint.Rows[i]["Value"]); DataRow[] nomRows = dtInfo.Select("PointID = " + strPointID); float fNom = nomRows[0]["Nominal"].ToString() == "" ? MeasureFileBase.GlobalData.NULL_NUM : Convert.ToSingle(nomRows[0]["Nominal"]); float fUpTol = nomRows[0]["UpTol"].ToString() == "" ? MeasureFileBase.GlobalData.NULL_NUM : Convert.ToSingle(nomRows[0]["UpTol"]); float fLowTol = nomRows[0]["LowTol"].ToString() == "" ? MeasureFileBase.GlobalData.NULL_NUM : Convert.ToSingle(nomRows[0]["LowTol"]); MeasurePoint point = new MeasurePoint(strPointName, fMeas, fNom, fUpTol, fLowTol); file.AddPoint(point); } if (file.Save(strFilePath)) { byte[] byFileData = null; using (FileStream fs = new FileStream(strFilePath, FileMode.Open, FileAccess.Read)) { byFileData = new byte[(int)fs.Length]; fs.Read(byFileData, 0, (int)fs.Length); } PacketTable table = new PacketTable(); table.AddField("FileName", PacketTable.FieldType.TypeString); table.AddField("File", PacketTable.FieldType.TypeImage); table.MakeTable(1); table.SetValue(0, 0, strFileName); table.SetValue(0, 1, byFileData); PacketTable[] TableArray = new PacketTable[1]; TableArray[0] = table; ServerConnection conn = new ServerConnection(); Packet recvPacket = conn.ExecuteCommand(10001, TableArray); return(recvPacket); } else { strError = "生成文件或者上传文件出错!"; return(null); } }
//查询图片所属分类 static public Packet GetClass(HttpContext context, int nCommand, ref string strError) { try { UInt32 nProjectID = CommandTool.ReqUint(context, "ProjectID"); UInt32 nPartID = CommandTool.ReqUint(context, "PartID"); UInt32 nImageID = CommandTool.ReqUint(context, "ImageID"); byte bIsFD = 0; PacketTable table = new PacketTable(); table.AddField("ProjectID", PacketTable.FieldType.TypeUint); table.AddField("PartID", PacketTable.FieldType.TypeUint); table.AddField("ImageID", PacketTable.FieldType.TypeUint); table.AddField("IsFD", PacketTable.FieldType.TypeByte); table.MakeTable(1); table.SetValue(0, 0, nProjectID); table.SetValue(0, 1, nPartID); table.SetValue(0, 2, nImageID); table.SetValue(0, 3, (byte)bIsFD); PacketTable[] arrTable = new PacketTable[1]; arrTable[0] = table; ServerConnection conn = new ServerConnection(); Packet recvPacket = conn.ExecuteCommand(nCommand, arrTable, 2); return(recvPacket); } catch (Exception ex) { strError = "CmdQuery-GetClass 错误:" + ex.Message; return(null); } }
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 private DM_WorkPlace getWorkInfo(UInt32 nProjectID, UInt32 nPartID, UInt32 nWorkProgressID) { PacketTable[] TableArray = new PacketTable[1]; PacketTable table = new PacketTable(); table.AddField("ProjectID", PacketTable.FieldType.TypeUint); table.AddField("PartID", PacketTable.FieldType.TypeUint); table.AddField("WorkProgressID", PacketTable.FieldType.TypeUint); table.MakeTable(1); table.SetValue(0, 0, nProjectID); table.SetValue(0, 1, nPartID); table.SetValue(0, 2, nWorkProgressID); TableArray[0] = table; ServerConnection connect = new ServerConnection(); Packet packet = connect.ExecuteCommand(26, TableArray, 2); DataTable dt = outWorkInfo(packet); DM_WorkPlace workPlace = new DM_WorkPlace(); workPlace.ParentID = (UInt32)dt.Rows[0]["ParentID"]; workPlace.Type = (int)dt.Rows[0]["Type"]; workPlace.WorkPlaceID = (UInt32)dt.Rows[0]["WorkPlaceID"]; workPlace.WorkPlaceName = dt.Rows[0]["WorkPlaceName"].ToString(); workPlace.WorkPlaceNO = dt.Rows[0]["WorkPlaceNO"].ToString(); workPlace.WorkshopID = (UInt32)dt.Rows[0]["WorkshopID"]; return(workPlace); }
static private DM_ModelPart getPartInfo(UInt32 nProjectID, UInt32 nPartID) { PacketTable[] TableArray = new PacketTable[1]; PacketTable table = new PacketTable(); table.AddField("ProjectID", PacketTable.FieldType.TypeUint); table.AddField("PartID", PacketTable.FieldType.TypeUint); table.AddField("PartName", PacketTable.FieldType.TypeString); table.MakeTable(1); table.SetValue(0, 0, nProjectID); table.SetValue(0, 1, nPartID); table.SetValue(0, 2, ""); TableArray[0] = table; ServerConnection connect = new ServerConnection(); Packet packet = connect.ExecuteCommand(14, TableArray); DataTable dt = outWorkInfo(packet); DM_ModelPart part = new DM_ModelPart(); part.PartOrder = (int)dt.Rows[0]["PartOrder"]; part.PartID = (UInt32)dt.Rows[0]["PartID"]; part.PartName = dt.Rows[0]["PartName"].ToString(); part.PartNO = dt.Rows[0]["PartNO"].ToString(); part.ParentID = (UInt32)dt.Rows[0]["ParentID"]; return(part); }
//查询文报告PDF文件 static public Packet GetReportPDF(HttpContext context, int nCommand, ref string strError) { try { string strFileUrl = CommandTool.ReqString(context, "PDFName"); PacketTable table = new PacketTable(); table.AddField("PDFName", PacketTable.FieldType.TypeString); table.MakeTable(1); table.SetValue(0, 0, strFileUrl); PacketTable[] arrTable = new PacketTable[1]; arrTable[0] = table; //连接服务器 ServerConnection conn = new ServerConnection(); Packet recvPacket = conn.ExecuteCommand(nCommand, arrTable); return(recvPacket); } catch (Exception ex) { strError = "CmdQuery-GetClass 错误:" + ex.Message; return(null); } }
static public Packet GetQueryUser(HttpContext context, int nCommand, ref string strError) { string strUserName = CommandTool.ReqString(context, "UserName"); string strPassword = CommandTool.ReqString(context, "Password"); ServerConnection conn = new ServerConnection(1);//连接主服务器 PacketTable table = new PacketTable(); table.AddField("UserNO", PacketTable.FieldType.TypeString); table.AddField("Password", PacketTable.FieldType.TypeString); table.MakeTable(1); table.SetValue(0, 0, strUserName); table.SetValue(0, 1, strPassword); PacketTable[] arrTable = new PacketTable[1]; arrTable[0] = table; Packet recvPacket = conn.ExecuteCommand(nCommand, arrTable); return(recvPacket); }
//查询所属分类的下点的名义值、上下公差 static public Packet GetNominal(HttpContext context, int nCommand, ref string strError, string strClassID) { try { if (strClassID == "") { return(null); } UInt32 nClassID = Convert.ToUInt32(strClassID); UInt32 nProjectID = CommandTool.ReqUint(context, "ProjectID"); UInt32 nPartID = CommandTool.ReqUint(context, "PartID"); UInt32 nPointID = 0; byte bIsFD = 0; PacketTable table = new PacketTable(); table.AddField("ProjectID", PacketTable.FieldType.TypeUint); table.AddField("PartID", PacketTable.FieldType.TypeUint); table.AddField("ClassID", PacketTable.FieldType.TypeUint); table.AddField("PointID", PacketTable.FieldType.TypeUint); table.AddField("IsFD", PacketTable.FieldType.TypeByte); table.MakeTable(1); table.SetValue(0, 0, nProjectID); table.SetValue(0, 1, nPartID); table.SetValue(0, 2, nClassID); table.SetValue(0, 3, nPointID); table.SetValue(0, 4, (byte)bIsFD); PacketTable[] arrTable = new PacketTable[1]; arrTable[0] = table; ServerConnection conn = new ServerConnection(); Packet recvPacket = conn.ExecuteCommand(nCommand, arrTable); return(recvPacket); } catch (Exception ex) { strError = "CmdQuery-GetNominal:错误 " + ex.Message; return(null); } }
static private DM_ModelWorkshop getWorkShop(UInt32 nWorkShopID) { PacketTable[] TableArray = new PacketTable[1]; PacketTable table = new PacketTable(); table.AddField("WorkshopID", PacketTable.FieldType.TypeUint); table.AddField("WorkshopName", PacketTable.FieldType.TypeString); table.MakeTable(1); table.SetValue(0, 0, nWorkShopID); table.SetValue(0, 1, ""); TableArray[0] = table; ServerConnection connect = new ServerConnection(); Packet packet = connect.ExecuteCommand(24, TableArray); DataTable dt = outWorkInfo(packet); DM_ModelWorkshop workshop = new DM_ModelWorkshop(); workshop.WorkshopID = (UInt32)dt.Rows[0]["WorkshopID"]; workshop.WorkshopNO = dt.Rows[0]["WorkshopNO"].ToString(); workshop.WorkshopName = dt.Rows[0]["WorkshopName"].ToString(); return(workshop); }
static private DM_ModelProject getProjectInfo(UInt32 nProjectID) { string strProjectName = ""; PacketTable[] TableArray = new PacketTable[1]; PacketTable table = new PacketTable(); table.AddField("ProjectID", PacketTable.FieldType.TypeUint); table.AddField("ProjectName", PacketTable.FieldType.TypeString); table.MakeTable(1); table.SetValue(0, 0, nProjectID); table.SetValue(0, 1, strProjectName); TableArray[0] = table; ServerConnection connect = new ServerConnection(); Packet packet = connect.ExecuteCommand(13, TableArray); DataTable dt = outWorkInfo(packet); DM_ModelProject model = new DM_ModelProject(); model.ProjectID = (UInt32)dt.Rows[0]["ProjectID"]; model.ProjectName = dt.Rows[0]["ProjectName"].ToString(); model.ProjectNo = dt.Rows[0]["ProjectNo"].ToString(); model.ProjectOrder = (int)dt.Rows[0]["ProjectOrder"]; return(model); }
//查询零件 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 Packet GetPartArray(HttpContext context, int nCommand, ref string strError) { try { UInt32 nProjectID = CommandTool.ReqUint(context, "ProjectID"); PacketTable table = new PacketTable(); table.AddField("ProjectID", PacketTable.FieldType.TypeUint); table.MakeTable(1); table.SetValue(0, 0, nProjectID); PacketTable[] arrTable = new PacketTable[1]; arrTable[0] = table; //连接服务器 ServerConnection conn = new ServerConnection(); Packet recvPacket = conn.ExecuteCommand(nCommand, arrTable); return(recvPacket); } catch (Exception ex) { strError = "CmdQuery_GetPartArray:错误" + ex.Message; return(null); } }
//统计报警 static public List <Packet> StatFileAlarm(HttpContext context, int nCommand, ref string strError) { try { List <Packet> arrPacket = new List <Packet>(); UInt32 nProjectID = CommandTool.ReqUint(context, "ProjectID"); int nLastNum = 30; string strPartID = CommandTool.ReqString(context, "PartID");; UInt32 nNominalID = 0; UInt32 nProgressID = 0; string strRuleIDs = ""; string[] nPartID = strPartID.Split(','); foreach (var PartID in nPartID) { PacketTable table = new PacketTable(); table.AddField("ProjectID", PacketTable.FieldType.TypeUint); table.AddField("LastNum", PacketTable.FieldType.TypeInt); table.AddField("PartID", PacketTable.FieldType.TypeUint); table.AddField("NominalID", PacketTable.FieldType.TypeUint); table.AddField("ProgressID", PacketTable.FieldType.TypeUint); table.AddField("RuleIDs", PacketTable.FieldType.TypeString); table.MakeTable(1); table.SetValue(0, 0, nProjectID); table.SetValue(0, 1, nLastNum); table.SetValue(0, 2, UInt32.Parse(PartID)); table.SetValue(0, 3, nNominalID); table.SetValue(0, 4, nProgressID); table.SetValue(0, 5, strRuleIDs); PacketTable[] arrTable = new PacketTable[1]; arrTable[0] = table; //连接服务器 ServerConnection conn = new ServerConnection(); Packet recvPacket = conn.ExecuteCommand(nCommand, arrTable); arrPacket.Add(recvPacket); } return(arrPacket); } catch (Exception ex) { strError = "CmdQuery_GetPartArray:错误" + ex.Message; return(null); } }
//统计分类合格率 static protected Packet StatGroupPassRate(byte nOption, HttpContext context, int nCommand, ref string strError) { try { UInt32 nProjectID = CommandTool.ReqUint(context, "ProjectID"); UInt32 nPartID = CommandTool.ReqUint(context, "PartID"); UInt32 nProgressID = CommandTool.ReqUint(context, "ProgressID"); UInt32 nClassID = 0; byte bIsFD = 0; int nLastNum = 10; PacketTable table = new PacketTable(); table.AddField("ProjectID", PacketTable.FieldType.TypeUint); table.AddField("PartID", PacketTable.FieldType.TypeUint); table.AddField("ProgressID", PacketTable.FieldType.TypeUint); table.AddField("ClassID", PacketTable.FieldType.TypeUint); table.AddField("IsFD", PacketTable.FieldType.TypeByte); table.AddField("LastNum", PacketTable.FieldType.TypeInt); table.MakeTable(1); table.SetValue(0, 0, nProjectID); table.SetValue(0, 1, nPartID); table.SetValue(0, 2, nProgressID); table.SetValue(0, 3, nClassID); table.SetValue(0, 4, (byte)bIsFD); table.SetValue(0, 5, nLastNum); PacketTable[] arrTable = new PacketTable[1]; arrTable[0] = table; //连接服务器 ServerConnection conn = new ServerConnection(); Packet recvPacket = conn.ExecuteCommand(nCommand, arrTable, nOption); return(recvPacket); } catch (Exception ex) { strError = "CmdQuery_GetPartArray:错误" + ex.Message; 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); }