public void PostUpdate5(int id, string docName, string fileName, string filePath, string tableName) { PRS_Process_BOM ppBom = new PRS_Process_BOMService().SelectPRS_Process_BOM(id.ToString()); if (docName.IndexOf('.').Equals(-1)) { throw new Exception("无法读取文件名!"); } else { DateTime newDT = DateTime.Now; fileName += Path.GetExtension(docName); //filePath = HttpContext.Current.Server.MapPath("~/Upload/" + filePath) + fileName; string FtpServer = "ftp://" + ConfigurationManager.AppSettings["FtpServer"] + ":" + ConfigurationManager.AppSettings["FtpPort"]; filePath = FtpServer + "/" + filePath + fileName; PRS_ProcessFigure model = new PRS_ProcessFigure() { ContractCode = ppBom.ContractCode, ProductID = ppBom.ProductID, PartCode = ppBom.PartCode, DocName = docName, FileName = fileName, FileAddress = filePath, IsEnable = 1, CreatePerson = MmsHelper.GetUserName(), CreateTime = newDT, ModifyPerson = MmsHelper.GetUserName(), ModifyTime = newDT }; string sql = WinFormClientService.GetInsertSQL(model); using (var db = Db.Context("Mms")) { db.Sql(sql).Execute(); } } }
private void PageProduceProce_Loaded(object sender, RoutedEventArgs e) { #region 加载基本数据 //lblProjectName.Content = StoreInfoModel.ProducePlanInfo.GetProject.ProjectName; #endregion #region 加载工步列表 List <object> WorkStepList = new List <object>(); workStepCount = StoreInfoModel.ProducePlanInfo.GetProcessWorkSteps.Count; for (int i = 0; i < StoreInfoModel.ProducePlanInfo.GetProcessWorkSteps.Count; i++) { WorkStepList.Add(new { WorkStepsTitle = string.Format("工步{0}", ToUpper(i + 1)), WorkStepsName = StoreInfoModel.ProducePlanInfo.GetProcessWorkSteps[i].WorkStepsName, WorkStepsInfo = StoreInfoModel.ProducePlanInfo.GetProcessWorkSteps[i].WorkStepsContent }); dataContext.WorkSteps.Add(new WorkStepModel() { LineNum = (i + 1), WorkStepsName = StoreInfoModel.ProducePlanInfo.GetProcessWorkSteps[i].WorkStepsName, WorkStepsInfo = StoreInfoModel.ProducePlanInfo.GetProcessWorkSteps[i].WorkStepsContent }); } dataContext.ProjectName = StoreInfoModel.ProducePlanInfo.GetProject.ProjectName; dataContext.WorkStep = dataContext.WorkSteps.Count > 0 ? dataContext.WorkSteps[0] : new WorkStepModel(); this.DataContext = dataContext; //var aaaaa = WorkStepsList.DataContext; // //ContentPresenter cp = WorkStepsList.ItemContainerGenerator.ContainerFromIndex(0) as ContentPresenter; //List<Border> gds = Helpers.WpfHelper.FindVisualChildren<Border>(WorkStepsList); //ContentPresenter cp = PlanCardItems.ItemContainerGenerator.ContainerFromIndex(FocusIndex) as ContentPresenter; //List<Border> gds = Helpers.WpfHelper.FindVisualChildren<Border>(cp); //List<TextBlock> tbs = Helpers.WpfHelper.FindVisualChildren<TextBlock>(cp); //WorkStepBar.ItemsSource = WorkStepList; #endregion #region 图纸列表 List <object> DrawList = new List <object>(); string[] fileTypeArr = new string[] { ".jpg", ".JPG", ".png", ".PNG", ".dwg", ".DWG", ".pdf", ".PDF" }; for (int i = 0; i < StoreInfoModel.ProducePlanInfo.GetQualityReportDocs.Count; i++) { QMS_QualityReportDoc qrd = StoreInfoModel.ProducePlanInfo.GetQualityReportDocs[i]; if (fileTypeArr.Contains(System.IO.Path.GetExtension(qrd.FileName))) { drawingCount++; drawFilePaths.Add(string.Format(@"{0}\{1}", ConfigInfoModel.DocDirName, qrd.FileName)); DrawList.Add(new { DrawName = qrd.FileName }); } } for (int i = 0; i < StoreInfoModel.ProducePlanInfo.GetProcessFigures.Count; i++) { PRS_ProcessFigure pf = StoreInfoModel.ProducePlanInfo.GetProcessFigures[i]; if (fileTypeArr.Contains(System.IO.Path.GetExtension(pf.FileName))) { drawingCount++; drawFilePaths.Add(string.Format(@"{0}\{1}", ConfigInfoModel.DocDirName, pf.FileName)); DrawList.Add(new { DrawName = pf.FileName }); } } //drawingCount = StoreInfoModel.ProducePlanInfo.GetPartFiles.Count; //for (int i = 0; i < drawingCount; i++) //{ // drawFilePaths.Add(string.Format(@"{0}\{1}", ConfigInfoModel.DocDirName, StoreInfoModel.ProducePlanInfo.GetPartFiles[drawingIndex].FileName)); // //DrawList.Add(new { DrawName = string.Format("图{0}", ToUpper(i + 1)) }); // DrawList.Add(new { DrawName = StoreInfoModel.ProducePlanInfo.GetPartFiles[i].FileName }); //} //for (int i = 0; i < StoreInfoModel.ProducePlanInfo.GetQualityReportDocs.Count; i++) //{ // if (new string[] { ".jpg", ".JPG", ".png", ".PNG", ".dwg", ".DWG", ".pdf", ".PDF" }.Contains(System.IO.Path.GetExtension(StoreInfoModel.ProducePlanInfo.GetQualityReportDocs[i].FileName))) // { // drawingCount++; // drawFilePaths.Add(string.Format(@"{0}\{1}", ConfigInfoModel.DocDirName, StoreInfoModel.ProducePlanInfo.GetQualityReportDocs[drawingIndex].FileName)); // DrawList.Add(new { DrawName = StoreInfoModel.ProducePlanInfo.GetQualityReportDocs[i].FileName }); // } //} DrawCardItems.ItemsSource = DrawList; #endregion #region 图纸展示 ((System.ComponentModel.ISupportInitialize)axMxDrawX).BeginInit(); System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost() { Child = axMxDrawX }; ((System.ComponentModel.ISupportInitialize)axMxDrawX).EndInit(); axMxDrawX.ShowCommandWindow = false; axMxDrawX.ShowModelBar = false; axMxDrawX.ShowStatusBar = false; axMxDrawX.ShowToolBars = false; axMxDrawX.Padding = new System.Windows.Forms.Padding(0); axMxDrawX.Margin = new System.Windows.Forms.Padding(0); axMxDrawX.IsFirstRunPan = true; axMxDrawX.IsDrawCoord = false; mxDraw.Children.Add(host); //if (StoreInfoModel.ProducePlanInfo.GetPartFiles.Count > 0) //{ // axMxDrawX.OpenDwgFile(string.Format(@"{0}\{1}", ConfigInfoModel.DocDirName, StoreInfoModel.ProducePlanInfo.GetPartFiles[0].FileName)); // axMxDrawX.GetMcDbDatabaseBound(ref pLbx, ref pLby, ref pRtx, ref pRty); // pointX = (pRtx - pLbx) / 2; // pointY = (pRty - pLby) / 2; // axMxDrawX.ZoomCenter(pointX, pointY); // axMxDrawX.ZoomScale(0.08); //} if (drawingCount > 0) { axMxDrawX.OpenDwgFile(drawFilePaths[0]); axMxDrawX.GetMcDbDatabaseBound(ref pLbx, ref pLby, ref pRtx, ref pRty); pointX = (pRtx - pLbx) / 2; pointY = (pRty - pLby) / 2; axMxDrawX.ZoomCenter(pointX, pointY); axMxDrawX.ZoomScale(0.08); } #endregion #region 录入生产日志,录入计划开始时间 #region 录入生产日志 //记录生产日志 ResultModel logResult = new BLL.ExtraBLL.ProducePlanInfoBLL().ProduceLog(BLL.ExtraBLL.ProducePlanInfoBLL.ProduceLogTypeEnum.Start); #endregion #region 录入计划开始时间 //录入计划实际开始时间 ResultModel actualDateResult = new BLL.ExtraBLL.ProducePlanInfoBLL().ActualProducePlanDate(BLL.ExtraBLL.ProducePlanInfoBLL.ProducePlanStateEnum.Start); #endregion #region 加载物料信息 materielItems.ItemsSource = GetMaterielItems(); //List<object> materielData = new List<object>(); //if (StoreInfoModel.MaterialChildInfos.Count <= 0) //{ // materielData.Add(new // { // PartCode = StoreInfoModel.MaterialInfo.GetMaterialDetail.PartCode, // PartName = StoreInfoModel.MaterialInfo.GetMaterialDetail.PartName, // PartQuantity = StoreInfoModel.MaterialInfo.GetMaterialDetail.PartQuantity // }); //} //else //{ // foreach (var item in StoreInfoModel.MaterialChildInfos) // { // materielData.Add(new // { // PartCode = item.GetMaterialDetail.PartCode, // PartName = item.GetMaterialDetail.PartName, // PartQuantity = item.GetMaterialDetail.PartQuantity // }); // } //} //materielItems.ItemsSource = materielData; #endregion #endregion #region 默认焦点区域、选择项 switch (focusArea) { case FocusAreaEnum.LeftFocus: RemoveTabBorder(tbDrawingList); AddTabBorder(tbWorkStepsInfo); break; case FocusAreaEnum.CenterFocus: RemoveTabBorder(tbWorkStepsInfo); AddTabBorder(mxDraw); break; case FocusAreaEnum.RightFocus: RemoveTabBorder(mxDraw); AddTabBorder(materielList); break; case FocusAreaEnum.DownFocus: RemoveTabBorder(materielList); AddTabBorder(tbDrawingList); break; default: break; } #endregion InputMethod.SetIsInputMethodEnabled(MainPage, false); InputMethod.SetPreferredImeState(MainPage, InputMethodState.Off); ShowWorkStepsInfo(); MainPage.Focus(); var temp = BLL.Helpers.ClientHelper.RecordOperateLog(string.Format(@"用户【{0}】进入了开始生产、查看图纸的页面!", StoreInfoModel.UserName)); }
//public void PostUpdate3() public void PostUpdate3(dynamic data) { int id = data.id; string docName = data.docName; string fileName = data.fileName; string filePath = data.filePath; //int id, string docName, string fileName, string filePath //HttpPostedFile fileData = HttpContext.Current.Request.Files["PrsFile"]; //var filestream = fileData.InputStream; //var filename = fileData.FileName; //byte[] FileBytes = FtpHelper.StreamToBytes(filestream); //var id = Convert.ToInt32(HttpContext.Current.Request["id"]); //var docName = HttpContext.Current.Request["docName"].ToString(); //var fileName = HttpContext.Current.Request["fileName"].ToString(); //var filePath = HttpContext.Current.Request["filePath"].ToString(); //var tableName = HttpContext.Current.Request["tableName"].ToString(); PRS_Process_BOM ppBom = new PRS_Process_BOMService().SelectPRS_Process_BOM(id.ToString()); if (docName.IndexOf('.').Equals(-1)) { throw new Exception("无法读取文件名!"); } else { DateTime newDT = DateTime.Now; fileName += Path.GetExtension(docName); //filePath = HttpContext.Current.Server.MapPath("~/Upload/" + filePath) + fileName; //string FtpServer = "ftp://" + ConfigurationManager.AppSettings["FtpServer"] + ":" + ConfigurationManager.AppSettings["FtpPort"]; //filePath = FtpServer + "/" + filePath + fileName; PRS_ProcessFigure model = new PRS_ProcessFigure() { ContractCode = ppBom.ContractCode, ProductID = ppBom.ProductID, PartCode = ppBom.PartCode, DocName = docName, FileName = fileName, FileAddress = filePath, IsEnable = 1, //CreatePerson = MmsHelper.GetUserName(), CreateTime = newDT, //ModifyPerson = MmsHelper.GetUserName(), ModifyTime = newDT }; SqlConnection conn; SqlCommand cmd; ConnectionStringSettings cs = ConfigurationManager.ConnectionStrings["Mms"]; conn = new SqlConnection(cs.ConnectionString); cmd = new SqlCommand(@" insert into PRS_ProcessFigure(ContractCode,ProductID,PartCode,DocName,FileName,FileAddress, IsEnable,CreatePerson,CreateTime,ModifyPerson,ModifyTime) values (@ContractCode,@ProductID,@PartCode,@DocName,@FileName,@FileAddress, @IsEnable,@CreatePerson,@CreateTime,@ModifyPerson,@ModifyTime)", conn); cmd.CommandType = CommandType.Text; cmd.Parameters.AddRange(new SqlParameter[] { new SqlParameter() { ParameterName = "@ContractCode", SqlDbType = SqlDbType.VarChar, Value = model.ContractCode }, new SqlParameter() { ParameterName = "@ProductID", SqlDbType = SqlDbType.Int, Value = model.ProductID }, new SqlParameter() { ParameterName = "@PartCode", SqlDbType = SqlDbType.VarChar, Value = model.PartCode }, new SqlParameter() { ParameterName = "@DocName", SqlDbType = SqlDbType.NVarChar, Value = model.DocName }, new SqlParameter() { ParameterName = "@FileName", SqlDbType = SqlDbType.NVarChar, Value = model.FileName }, new SqlParameter() { ParameterName = "@FileAddress", SqlDbType = SqlDbType.NVarChar, Value = model.FileAddress }, new SqlParameter() { ParameterName = "@IsEnable", SqlDbType = SqlDbType.Int, Value = model.IsEnable }, new SqlParameter() { ParameterName = "@CreatePerson", SqlDbType = SqlDbType.VarChar, Value = "" }, new SqlParameter() { ParameterName = "@CreateTime", SqlDbType = SqlDbType.DateTime, Value = model.CreateTime }, new SqlParameter() { ParameterName = "@ModifyPerson", SqlDbType = SqlDbType.VarChar, Value = "" }, new SqlParameter() { ParameterName = "@ModifyTime", SqlDbType = SqlDbType.DateTime, Value = model.ModifyTime }, //new SqlParameter(){ParameterName="@FileContent", SqlDbType= SqlDbType.Image,Value=model.FileContent } }); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); //string sql = WinFormClientService.GetInsertSQL(model); //using (var db = Db.Context("Mms")) //{ // //db.Insert("PRS_ProcessFigure").Column("FileContent", FileContent,DataTypes.by) // //db.Sql(sql).Execute(); //} } }