public void WriteValue(BinaryWriter writer, DateTime value) { if (value == default(DateTime)) { writer.Write(DataType.DateTimeDefault); return; } var objIdx = _cache.SerializerGet(value); if (objIdx > -1) { if (objIdx <= byte.MaxValue) { WriteHelper.WriteByte(writer, DataType.RefDateTimeByte, (byte)objIdx); } else { WriteHelper.WriteUshort(writer, DataType.RefDateTimeUShort, (ushort)objIdx); } } else { var longBinary = value.ToBinary(); WriteHelper.WriteLong(writer, DataType.DateTime, longBinary); _cache.SerializerSet(value); } }
public void TestMethod4() { var list = new List <int>() { 6, 7, 8, 9, 4, 5, 1, 2, 3, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; //线程运行 var tasks = list.RunTask(p => { Thread.Sleep(p * 100); return(p); }); //返回线程状态 var row = new List <int>(); tasks.TaskStatus(80, (total, rs) => { WriteHelper.Log(total.ToString() + " : " + string.Join(";", rs)); row.AddRange(rs); }); var b = row.Distinct().Count() == 20; Assert.IsTrue(b); }
public void TestMethod7() { var list = new List <int>() { 6, 7, 8, 9, 4, 5, 1, 2, 3, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 100, 20 }; var nums = new List <int>(); var thread = new List <bool>(); list.RunTaskLimite(new TaskParam <int>() { Method = p => Thread.Sleep(p * 50), MaxThread = 3, Sleep = 0, Report = (type, start, end, item, n) => { WriteHelper.Log($"{start}-{end}:{type.GetReportTypeName()}{item}"); //验证是否全部完成 nums.Add(item); //验证最大线程数 thread.Add(end - start == 3); } }); var num = nums.Distinct().Count(); var b1 = thread.Exists(p => !p); Assert.IsTrue(num == list.Count && b1); }
private static void Main(string[] args) { if (args.Length == 0) { args = new[] { @"C:\" }; Console.WriteLine("Called without any parameters, will scan by default drive C:"); } var resultsFilePath = "results.txt"; var command = "all"; switch (args.Length) { case 3: resultsFilePath = args[2]; break; case 2: command = args[1]; break; } var writer = new WriteHelper(args[0], resultsFilePath, command); Console.WriteLine("Started parsing the files, hold on to your seat"); Console.WriteLine(writer.WriteFile() ? "Files have been written successfully" : "Failed to write files"); Console.ReadKey(); }
/// <summary> /// </summary> /// <param name="pegPart"/> /// <param name="handled"/> /// <param name="prevReturnValue"/> /// <returns/> public PegPart PREPARE_TARGET0(PegPart pegPart, ref bool handled, PegPart prevReturnValue) { try { MergedPegPart mp = pegPart as MergedPegPart; foreach (MicronBEAssyBEMoMaster moMaster in InputMart.Instance.MicronBEAssyBEMoMaster.Values) { MicronBEAssyBEPegPart pp = new MicronBEAssyBEPegPart(moMaster, moMaster.Product); foreach (MicronBEAssyBEMoPlan moPlan in moMaster.MoPlanList) { MicronBEAssyBEPegTarget target = new MicronBEAssyBEPegTarget(pp, moPlan); pp.AddPegTarget(target); } mp.Merge(pp); } return(mp); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); return(default(PegPart)); } }
private void ProviderLoop() { WriteHelper.PrintAvaibleCommands(); var choosenCommand = ReadHelper.GetCommandFromUser(); CommandManager <IGameCommand> .GetInstance(System.Reflection.Assembly.GetExecutingAssembly()).Execute(choosenCommand); }
/// <summary> /// </summary> /// <param name="pegPart"/> /// <param name="isRun"/> /// <param name="handled"/> /// <param name="prevReturnValue"/> /// <returns/> public List <object> GET_PART_CHANGE_INFOS0(Mozart.SeePlan.Pegging.PegPart pegPart, bool isRun, ref bool handled, List <object> prevReturnValue) { try { MicronBEAssyBEStep currentStep = pegPart.CurrentStep as MicronBEAssyBEStep; MicronBEAssyBEPegPart pp = pegPart as MicronBEAssyBEPegPart; List <object> list = new List <object>(); if (isRun) { if (pp.Product is AssyMcpProduct) { AssyMcpProduct mcpProduct = pp.Product as AssyMcpProduct; string stepID = string.Empty; if (mcpProduct.HasPrevs && mcpProduct.Prevs.ElementAt(0) is AssyMcpPart) { stepID = (mcpProduct.Prevs.ElementAt(0) as AssyMcpPart).PartChangeStep; } if (stepID == currentStep.StepID) { list.AddRange(mcpProduct.Prevs); } } else if (pp.Product is AssyMcpPart) { #if DEBUG if (currentStep.StepID == "DIE ATTACH") { Console.WriteLine(); } #endif AssyMcpPart mcpPart = pp.Product as AssyMcpPart; if (mcpPart.IsMidPart) { string stepID = string.Empty; if (mcpPart.HasPrevs && mcpPart.Prevs.ElementAt(0) is AssyMcpPart) { stepID = (mcpPart.Prevs.ElementAt(0) as AssyMcpPart).PartChangeStep; } if (stepID == currentStep.StepID) { list.AddRange(mcpPart.Prevs); } } } } return(list); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); return(new List <object>()); } }
/// <summary> /// </summary> /// <param name="pegPart"/> /// <param name="handled"/> public void WRITE_UNPEG0(Mozart.SeePlan.Pegging.PegPart pegPart, ref bool handled) { try { foreach (MicronBEAssyPlanWip planWip in InputMart.Instance.MicronBEAssyPlanWip.Values) { if (planWip.Qty <= 0) { continue; } if (planWip.MapCount > 0) { WriteHelper.WriteUnpeg(planWip, UnpegReason.EXCESS); } else { WriteHelper.WriteUnpeg(planWip, UnpegReason.NO_TARGET); } } List <string> list = new List <string>(); foreach (var key in InputMart.Instance.MicronBEAssyBEMoMaster.Keys) { list.Add(key); } foreach (MicronBEAssyPlanWip wip in InputMart.Instance.MicronBEAssyActPlanWips.Values) { if (wip.Qty <= 0) { continue; } if (wip.MapCount > 0) { WriteHelper.WriteUnpeg(wip, UnpegReason.EXCESS); } else { if (list.Contains(wip.GetWipInfo().WipProductID)) { WriteHelper.WriteUnpeg(wip, UnpegReason.EXCESS); } else { WriteHelper.WriteUnpeg(wip, UnpegReason.NO_TARGET); } } } } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); } }
/// <summary> /// </summary> /// <param name="context"/> public void OnAction_ProcessStep(Mozart.Task.Execution.Persists.IPersistContext context) { try { InputMart.Instance.ProcessStep.DefaultView.Sort = "SEQUENCE ASC"; foreach (ProcessStep processStep in InputMart.Instance.ProcessStep.DefaultView) { MicronBEAssyProcess process; Tuple <string, string> key = Tuple.Create(processStep.LINE_ID, processStep.PROCESS_ID); if (InputMart.Instance.MicronBEAssyProcess.TryGetValue(key, out process) == false) { process = NewHelper.NewProcess(processStep.LINE_ID, processStep.PROCESS_ID); InputMart.Instance.MicronBEAssyProcess.Add(key, process); } MicronBEAssyBEStep step = CreateHelper.CreateStep(processStep); if (Constants.DieAttach == step.StepGroup) { process.DieAttachSteps.Add(step); } if (Constants.DieAttach == step.StepGroup || Constants.WireBond == step.StepGroup) { if (step.StepID.Length > 0) { process.BottleneckSteps += step.StepID[0]; } process.CR2OutStep = step; } step.DaThroughCount = process.DieAttachSteps.Count; process.Steps.Add(step); } foreach (MicronBEAssyProcess process in InputMart.Instance.MicronBEAssyProcess.Values) { process.LinkSteps(); if (process.DieAttachSteps.Count > 0 && process.CR2OutStep.StepGroup == Constants.DieAttach && process.CR2OutStep.StepID != "CONTRL SUB ATTACH") { WriteHelper.WriteMasterDataErrorLog(MasterDataErrorEventType.PROCESS, process.LineID, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, 0, string.Empty, "CR2 out step is not WIRE BOND", string.Format("PROCESS ID : {0}, BottleneckSteps : {1}", process.ProcessID, process.BottleneckSteps), "ProcessStep"); } } } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); } }
private Task WriteLog(string name) { return(Task.Run(() => { for (var i = 0; i < 100; i++) { WriteHelper.Log($"{name}: 测试内容"); } })); }
public static List <string> HitObjects(List <HitObject> hitObjects) { var list = BaseListFormat("HitObjects"); if (hitObjects != null) { list.AddRange(hitObjects.ConvertAll(obj => WriteHelper.HitObject(obj))); } return(list); }
/// <summary> /// </summary> /// <param name="pegPart"/> /// <param name="isOut"/> /// <param name="handled"/> public void WRITE_TARGET0(Mozart.SeePlan.Pegging.PegPart pegPart, bool isOut, ref bool handled) { try { WriteHelper.WriteStepTarget(pegPart, isOut); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); } }
/// <summary> /// </summary> /// <param name="hb"/> /// <param name="handled"/> /// <param name="prevReturnValue"/> /// <returns/> public WorkStep ADD_WORK_LOT0(IHandlingBatch hb, ref bool handled, WorkStep prevReturnValue) { try { MicronBEAssyBELot lot = hb as MicronBEAssyBELot; AssyMcpPart mcpPart = lot.Product as AssyMcpPart; if (mcpPart != null && mcpPart.IsBase == false) { return(null); } var agentInitControl = ServiceLocator.Resolve <JobChangeInit>(); var wagentName = agentInitControl.GetWorkAgentName(hb); if (string.IsNullOrEmpty(wagentName)) { return(null); } var wmanager = AoFactory.Current.JobChangeManger; var wagent = wmanager.GetAgent(wagentName); if (wagent == null) { return(null); } var wgroupKey = agentInitControl.GetWorkGroupKey(hb, wagent); if (wgroupKey == null) { return(null); } var wgroup = wagent.GetGroup(wgroupKey); var wstepKey = agentInitControl.GetWorkStepKey(hb, wgroup); if (wstepKey == null) { return(null); } var targetStep = agentInitControl.GetTargetStep(hb, wgroup, wstepKey); if (targetStep == null) { return(null); } var wstep = wgroup.GetStep(wstepKey, targetStep); var availableTime = agentInitControl.GetAvailableTime(hb, wstep, targetStep); MicronBEAssyWorkLot wlot = CreateHelper.CreateWorkLot(hb, availableTime, wstepKey, targetStep, lot.ReservationEqp); wstep.AddWip(wlot); return(wstep); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); return(default(WorkStep)); } }
/// <summary> /// </summary> /// <param name="wgroup"/> /// <param name="handled"/> public void INITIALIZE_WORK_GROUP0(WorkGroup wgroup, ref bool handled) { try { wgroup.Ordered = true; } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); } }
/// <summary> /// </summary> /// <param name="target"/> /// <param name="m"/> /// <param name="qty"/> /// <param name="handled"/> public void WRITE_PEG0(PegTarget target, IMaterial m, double qty, ref bool handled) { try { WriteHelper.WritePeg(m, target, qty); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); } }
/// <summary> /// </summary> /// <param name="wstep"/> /// <param name="list"/> /// <param name="handled"/> public void SORT_PROFILE_LOT0(WorkStep wstep, WorkEqp weqp, List <WorkLot> list, ref bool handled) { try { list.Sort(new ComparerHelper.LotCompare()); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); } }
private bool CheckIfImageFile(IFormFile file) { byte[] fileBytes; using (var ms = new MemoryStream()) { file.CopyTo(ms); fileBytes = ms.ToArray(); } return(WriteHelper.GetImageFormat(fileBytes) != WriteHelper.ImageFormat.unknown); }
public void WriteValue(BinaryWriter writer, char value) { if (value == default(char)) { writer.Write(DataType.CharDefault); } else { WriteHelper.WriteChar(writer, DataType.Char, value); } }
/// <summary> /// </summary> /// <param name="handled"/> /// <param name="prevReturnValue"/> /// <returns/> public Type GET_LOT_BATCH_TYPE0(ref bool handled, Type prevReturnValue) { try { return(default(Type)); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); return(default(Type)); } }
/// <summary> /// </summary> /// <param name="pegPart"/> /// <returns/> public PegPart INIT_SUPPLY_PLAN(PegPart pegPart) { try { return(pegPart); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); return(default(PegPart)); } }
/// <summary> /// </summary> /// <param name="da"/> /// <param name="hb"/> /// <param name="handled"/> /// <param name="prevReturnValue"/> /// <returns/> public bool INTERCEPT_IN0(DispatchingAgent da, IHandlingBatch hb, ref bool handled, bool prevReturnValue) { try { MicronBEAssyBEStep currentStep = hb.CurrentStep as MicronBEAssyBEStep; MicronBEAssyBELot lot = hb as MicronBEAssyBELot; if (lot.Product is AssyMcpPart) { AssyMcpPart mcpPart = lot.Product as AssyMcpPart; AssyMcpProduct mcpProduct = mcpPart.FinalProduct as AssyMcpProduct; if (mcpPart.PartChangeStep == lot.CurrentStepID) { Tuple <AssyMcpProduct, AssyMcpPart> baseKey = null; Tuple <AssyMcpProduct, AssyMcpPart> sourceKey = null; AssyMcpPart mergeMcpPart = McpHelper.GetMergeMcpPart(mcpPart); if (mcpPart.IsBase) { baseKey = Tuple.Create(mcpProduct, mcpPart); sourceKey = Tuple.Create(mcpProduct, mergeMcpPart); InputMart.Instance.MatchingLotList.Add(baseKey, lot); } else { baseKey = Tuple.Create(mcpProduct, mergeMcpPart); sourceKey = Tuple.Create(mcpProduct, mcpPart); InputMart.Instance.MatchingLotList.Add(sourceKey, lot); } List <MicronBEAssyBELot> matchLotList = SimulationHelper.MatchingMcpLot(da, baseKey, sourceKey); foreach (MicronBEAssyBELot matchLot in matchLotList) { da.ReEnter(matchLot); } return(true); } } return(false); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); return(default(bool)); } }
/// <summary> /// </summary> /// <param name="hb"/> /// <param name="handled"/> /// <param name="prevReturnValue"/> /// <returns/> public string GET_LOADING_EQUIPMENT0(IHandlingBatch hb, ref bool handled, string prevReturnValue) { try { return(null); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); return(default(string)); } }
private void Serializer(object o, SerializerType type = SerializerType.All) { using (var stream = new MemoryStream()) { var write = mWriteHelper; mWriteHelper = new WriteHelper(); StartWrite(o, type); write.Write(mWriteHelper.Length); write.Write(mWriteHelper.Bytes); mWriteHelper = write; } }
/// <summary> /// </summary> /// <param name="target"/> /// <param name="m"/> /// <param name="qty"/> /// <param name="handled"/> public void UPDATE_PEG_INFO0(PegTarget target, IMaterial m, double qty, ref bool handled) { try { MicronBEAssyPlanWip wip = m as MicronBEAssyPlanWip; wip.PegCount++; } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); } }
/// <summary> /// </summary> /// <param name="hb"/> /// <param name="handled"/> /// <param name="prevReturnValue"/> /// <returns/> public string GET_WORK_AGENT_NAME0(IHandlingBatch hb, ref bool handled, string prevReturnValue) { try { return(Constants.WorkAgentName); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); return(default(string)); } }
/// <summary> /// </summary> /// <param name="qty"/> /// <param name="handled"/> /// <param name="prevReturnValue"/> /// <returns/> public double ROUND_RESULT0(double qty, ref bool handled, double prevReturnValue) { try { qty = Math.Ceiling(qty); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); } return(qty); }
/// <summary> /// </summary> /// <param name="hb"/> /// <param name="handled"/> /// <param name="prevReturnValue"/> /// <returns/> public Time GET_TRANSFER_TIME0(Mozart.SeePlan.Simulation.IHandlingBatch hb, ref bool handled, Time prevReturnValue) { try { return(TimeSpan.Zero); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); return(default(Time)); } }
/// <summary> /// </summary> /// <param name="pegPart"/> /// <param name="currentStep"/> /// <returns/> public Step GETPREVPEGGINGSTEP(PegPart pegPart, Step currentStep) { try { return(currentStep.GetDefaultPrevStep()); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); return(default(Step)); } }
// ensure that the file is an image private bool CheckIfImageFile(IFormFile file) { byte[] fileBytes; using (var ms = new MemoryStream()) { file?.CopyTo(ms); fileBytes = ms.ToArray(); } // Convert byte[] to Base64 String //string base64String = Convert.ToBase64String(fileBytes); return(WriteHelper.GetImageFormat(fileBytes) != WriteHelper.ImageFormat.unknown); }
/// <summary> /// </summary> /// <param name="db"/> /// <param name="wips"/> /// <param name="ctx"/> /// <param name="handled"/> /// <param name="prevReturnValue"/> /// <returns/> public IList <IHandlingBatch> EVALUATE0(DispatcherBase db, IList <IHandlingBatch> wips, IDispatchContext ctx, ref bool handled, IList <IHandlingBatch> prevReturnValue) { try { wips.QuickSort(new ComparerHelper.LotCompare()); return(wips); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); return(default(IList <IHandlingBatch>)); } }