public void GetData() { MyEntity = TechnologicalProcess.GetEntity("请选择实体!"); if (MyEntity != null) { ResultBuffer tvList = new ResultBuffer() { new TypedValue((int)DxfCode.Text, "写个1进去!"), new TypedValue((int)DxfCode.Text, "写个2进去!"), new TypedValue((int)DxfCode.Text, "写个3进去!"), }; ExtendedDataHelper.ModObjXrecord(MyEntity.ObjectId, "Test", tvList); //写扩展属性 ResultBuffer resultBuffer = ExtendedDataHelper.GetObjXrecord(MyEntity.ObjectId, "Test"); //读扩展属性 if (resultBuffer != null) { var array = resultBuffer.AsArray(); if (array != null) { foreach (var content in array) { System.Windows.Forms.MessageBox.Show(content.Value.ToString()); } } } bool isSuccess = ExtendedDataHelper.DelObjXrecord(MyEntity.ObjectId, "Test");//删除扩展属性 if (isSuccess) { System.Windows.Forms.MessageBox.Show("删除成功!"); } } }
/// <summary> /// 获取工业主流程集合 /// </summary> /// <returns></returns> public TechnologicalProcessCollection GetTechnologicalProcesses() { try { TechnologicalProcessCollection infos = new TechnologicalProcessCollection(); string strSQL = "select *from p_mainprocess"; List <MySqlParameter> sqlParameters = new List <MySqlParameter>(); TechnologicalProcess info = new TechnologicalProcess(); CreateDataList <TechnologicalProcess>(infos, strSQL, sqlParameters, info, null); return(infos); } catch (Exception ex) { throw ex; } }
public async Task <TechnologicalProcessResponse> UpdateAsync(TechnologicalProcess technologicalProcess) { try { return(new TechnologicalProcessResponse(_context.TechnologicalProcesses .FromSqlRaw("EXEC dbo.UpdateTechnologicalProcess {0}, {1}", technologicalProcess.Id, technologicalProcess.Name) .AsEnumerable() .FirstOrDefault())); } catch (SqlException exception) { var messages = HandlingError(exception); return(new TechnologicalProcessResponse(messages)); } catch (Exception exception) { throw; } }
public void SelectAll() { List <string> list = new List <string>(); while (true) { Entity entity = TechnologicalProcess.GetEntity("请选择实体!"); if (entity != null) { list.Add(entity.Handle.ToString()); } else { break; } } if (list.Count > 0) { LocationService.FindPolyline(list); } }
internal static void GetPolyline(string num, string factor, string individualName, string stage, int index, ref System.Windows.Forms.DataGridView dataGridView1) { string polylineId = ""; Document doc = Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; Database db = doc.Database; DocumentLock m_DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument(); try { //PromptSelectionResult acSSPrompt = ed.GetSelection(); Entity acSSObj = null; while (true) { using (Transaction tr = db.TransactionManager.StartTransaction()) { //让CAD获取焦点 SetFocus(Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Window.Handle); acSSObj = TechnologicalProcess.GetEntity("请选择多段线!"); bool changeData = false; if (acSSObj != null && acSSObj is Polyline) { //如果扩展字典中已包含指定的扩展记录对象 ResultBuffer resultBuffer = ExtendedDataHelper.GetObjXrecord(acSSObj.ObjectId, "polylineNumber");//读扩展属性 if (resultBuffer != null) { if (System.Windows.Forms.DialogResult.Yes == System.Windows.Forms.MessageBox.Show("多段线已定义个体,是否覆盖信息!", "消息", System.Windows.Forms.MessageBoxButtons.YesNo)) { changeData = true; } } else { changeData = true; } if (changeData) //若没有包含扩展记录,则创建一个 { ResultBuffer valueBuffer = new ResultBuffer(); valueBuffer.Add(new TypedValue((int)DxfCode.Text, num)); valueBuffer.Add(new TypedValue((int)DxfCode.Text, factor)); valueBuffer.Add(new TypedValue((int)DxfCode.Text, individualName)); valueBuffer.Add(new TypedValue((int)DxfCode.Text, stage)); ExtendedDataHelper.ModObjXrecord(acSSObj.ObjectId, "polylineNumber", valueBuffer); //写扩展属性 polylineId = acSSObj.ObjectId.Handle.Value.ToString(); // +","; //System.Windows.Forms.MessageBox.Show("添加成功"); } } else if (acSSObj == null) { tr.Commit(); break; } //去除已添加的id if (changeData && dataGridView1.Rows.Count > 0) { //string[] vals = value.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); System.Windows.Forms.DataGridViewRow deleteRow = null; foreach (System.Windows.Forms.DataGridViewRow item in dataGridView1.Rows) { string gridData = ((string)item.Cells[0].Value); if (gridData != null) { //foreach (var val in vals) //{ if (gridData.Contains(polylineId)) { if (gridData.IndexOf(polylineId + ",") >= 0) { gridData = gridData.Replace(polylineId + ",", ""); } else { gridData = gridData.Replace(polylineId, ""); } int factorcount = 0; int.TryParse((string)item.Cells["entitycount"].Value, out factorcount); item.Cells["entitycount"].Value = (factorcount - 1).ToString(); System.Windows.Forms.Application.DoEvents(); if (factorcount == 1 && index != item.Index) { deleteRow = item; } } //} item.Cells[0].Value = gridData; } } dataGridView1.Rows[index].Cells[0].Value += polylineId + ","; //更新数量 int count = 0; int.TryParse((string)dataGridView1.Rows[index].Cells["entitycount"].Value, out count); dataGridView1.Rows[index].Cells["entitycount"].Value = (count + 1).ToString(); System.Windows.Forms.Application.DoEvents(); if (deleteRow != null) { dataGridView1.Rows.Remove(deleteRow); } } tr.Commit(); } } } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.ToString()); } finally { m_DocumentLock.Dispose(); } }
/// <summary> /// 生产线启动生产流程 /// </summary> /// <param name="strAssemblyLineId"></param> public void StartProcess(string strAssemblyLineId, string strCreateUser, DeviceAction deviceAction) { try { //读取生产线数据 DataHelper dataHelper = new DataHelper(); DataLogHelper logHelper = new DataLogHelper(); AssemblyLineInfo assembly = dataHelper.GetAssemblyLine(strAssemblyLineId); //线程休眠的基础单位 int iSleepUnit = 1000; if (assembly != null) { //获取生产线的所有设备信息 DeviceInfoCollection devices = dataHelper.GetAssemblyLineDevices(strAssemblyLineId); //获取相应的工艺流程信息 TechnologicalProcess process = dataHelper.GetTechnologicalProcess(assembly.ProcessId); DateTime dtMainStart = DateTime.Now; #region 主工艺流程日志记录 ProcessLog proLog = new ProcessLog() { AssemblyLineId = strAssemblyLineId, ProcessId = process.ProcessId, Created = DateTime.Now, CreateUser = strCreateUser, ProcessStatus = SysHelper.Enums.ProcessStatusType.Start, ProduceMaterialType = SysHelper.Enums.MaterialTypeEnum.Z, Production = decimal.Zero, TakeTime = 0 }; logHelper.AddMainProcessLog(proLog); #endregion //子工艺流程步骤数量 int iExProcessNum = 3; #region 工艺子流程循环 for (int iExIndex = 1; iExIndex <= iExProcessNum; iExIndex++) { //提取子工艺流程审批环节 TeExProcess exProcess = dataHelper.GetTeExProcess(process.ProcessId, iExIndex); if (exProcess != null) { //子工艺开始时间 DateTime dtExStart = DateTime.Now; #region 子工艺流程日志记录 ExProcessLog exLog = new ExProcessLog() { ProcessLogId = proLog.ProcessLogId, ExProcessId = exProcess.ExProcessId, Created = DateTime.Now, CreateUser = strCreateUser, ProcessStatus = SysHelper.Enums.ProcessStatusType.Start, ProduceMaterialType = SysHelper.Enums.MaterialTypeEnum.Z, Production = decimal.Zero, TakeTime = 0 }; //先记录数据 logHelper.AddExProcessLog(exLog); #endregion //是否达到启动条件 bool isStartExProcess = false; #region 判断启动的设备参数是否达到启动条件 DeviceProduceLog deviceLog = logHelper.GetDeviceProduceLog(exProcess.StartDeviceId, exProcess.ParType); if (deviceLog != null) { if (deviceLog.ParValue.Value >= exProcess.ParValue) { isStartExProcess = true; } } //循环等待达到启动条件 while (!isStartExProcess) { //每个循环先暂停10秒 int iStartSleep = iSleepUnit * 10; System.Threading.Thread.Sleep(iStartSleep); deviceLog = logHelper.GetDeviceProduceLog(exProcess.StartDeviceId, exProcess.ParType); if (deviceLog != null) { if (deviceLog.ParValue.Value >= exProcess.ParValue) { isStartExProcess = true; } } } #endregion if (isStartExProcess) { #region 循环启动设备 foreach (ExProcessStep step in exProcess.Steps) { //先找到需要操作的设备 foreach (DeviceInfo device in devices) { if (device.ProcessDeviceId == step.ProcessDeviceId) { string strDeviceId = device.DeviceId; //定义设备的操作类型 //提取步骤的参数控制数 foreach (ExProcessStepPars par in step.StepPars) { #region 记录操作的日志 DeviceActionLog actionLog = new DeviceActionLog() { DeviceId = strDeviceId, Created = DateTime.Now, CreateUser = strCreateUser, SensorId = par.SensorId, ActionType = par.ActionType, ParType = par.ParType, ParUnit = par.ParUnit, ParValue = par.ParValue, ToDeviceId = string.Empty, ToSensorId = string.Empty }; logHelper.AddDeviceActionLog(actionLog); #endregion //将操作放入委托里面进行执行(步骤执行完成才执行后续步骤) if (deviceAction(strDeviceId, par.SensorId, par.ActionType, par.ParType, par.ParValue)) { //判断是否需要等待 if (par.ParTime > 0) { int iSleepSet = par.ParTime * 60 * iSleepUnit; System.Threading.Thread.Sleep(iSleepSet); } //判断是否是完成参数 if (par.IsFinish) { } } } break; } } } #endregion } //子工艺完成时间 DateTime dtExEnd = DateTime.Now; TimeSpan tSpan = dtExEnd - dtExStart; //得到子工艺完成花费的分钟 exLog.TakeTime = Convert.ToInt32(tSpan.TotalMinutes); exLog.FinishTime = dtExEnd; exLog.ProcessStatus = SysHelper.Enums.ProcessStatusType.End; //exLog.ProduceMaterialType = SysHelper.Enums.MaterialTypeEnum. logHelper.UpdateExProcessLog(exLog); } } #endregion DateTime dtMainEnd = DateTime.Now; TimeSpan mSpan = dtMainEnd - dtMainStart; proLog.TakeTime = Convert.ToInt32(mSpan.TotalMinutes); proLog.FinishTime = dtMainEnd; proLog.ProcessStatus = SysHelper.Enums.ProcessStatusType.End; logHelper.UpdateMainProcessLog(proLog); } } catch (Exception ex) { throw ex; } }
public async Task <TechnologicalProcessResponse> UpdateAsync(TechnologicalProcess technologicalProcess) { return(await _technologicalProcesses.UpdateAsync(technologicalProcess)); }