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); }
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 UpLoadFile(HttpContext context, int nCommand, ref string strError) { try { //System.Diagnostics.Stopwatch w = new System.Diagnostics.Stopwatch(); //w.Start(); string strProgressName = CommandTool.ReqString(context, "ProgressName"); UInt32 nProjectID = CommandTool.ReqUint(context, "ProjectId"); UInt32 nPartID = CommandTool.ReqUint(context, "PartId"); UInt32 nWorkProgressID = CommandTool.ReqUint(context, "ProgressId"); UInt32 nPointCount = CommandTool.ReqUint(context, "PointCount"); UInt32 nInfoCount = CommandTool.ReqUint(context, "InfoCount"); string[] paramNames = new string[] { "PointID", "PointName", "Value" }; DataTable dtPoint = CommandTool.ReqDataTable(context, nPointCount, "point", "Value", paramNames); paramNames = new string[] { "PointID", "Nominal", "UpTol", "LowTol" }; DataTable dtInfo = CommandTool.ReqDataTable(context, nInfoCount, "info", "", paramNames); DM_ModelProject modelProject = getProjectInfo(nProjectID); DM_ModelPart modelPart = getPartInfo(nProjectID, nPartID); DM_WorkPlace modelWorkPlace = getWorkInfo(nProjectID, nPartID, nWorkProgressID); DM_ModelWorkshop modelWorkShop = getWorkShop(modelWorkPlace.WorkshopID); Packet recvPacket = writeMeasureFile(modelProject, modelPart, modelWorkPlace, modelWorkShop, dtPoint, dtInfo, strProgressName, ref strError); //w.Stop(); return(recvPacket); } catch (Exception ex) { strError = "CmdManager:UpLoadFile 错误" + ex.Message; return(null); } }
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); }