public void ExecuteEncrypt() { Pixel firstCoordinates = getFirstRandomCoordinates(downloadedImage); string textBlock = Message.ToLower(); int offsetCount = CalcuteOffset(firstCoordinates, downloadedImage); var symbolsAndCoordinates = GetAllColors(textBlock, firstCoordinates, downloadedImage); var symbolsAndHashes = CreateOutputHashesInfo(symbolsAndCoordinates); var noise = GenerateSymbolNoise(symbolsAndCoordinates); OutputInfo outputInfo = new OutputInfo(firstCoordinates, offsetCount, symbolsAndHashes, noise, textBlock.Length); string outputData = CreateOutputString(outputInfo); byte[] dataForSaving = RijndaelAlgorithm.Encrypt(outputData); SaveOutput(dataForSaving); }
public override bool WriteGeneratedFile(Type type, FileInfo path, MemoryStream generated) { var rootPath = RemapRoot?.FullName ?? Path.GetPathRoot(path.FullName); var outFileInfo = new FileInfo(path.FullName.ReplaceHeadPath(rootPath, Output.FullName)); var refFileInfo = new FileInfo(path.FullName.ReplaceHeadPath(rootPath, Reference.FullName)); bool isDifferent = Util.IsFileDifferent(refFileInfo, generated); var outputInfo = new OutputInfo(refFileInfo.FullName, outFileInfo.FullName, isDifferent ? FileStatus.Different : FileStatus.Similar); _referenceDifferenceMap[refFileInfo.FullName] = outputInfo; Util.FileWriteIfDifferentInternal(outFileInfo, generated); return(isDifferent); }
protected override void WriteStartMatch(ICapture capture) { ResultStorage?.Add(capture.Value); if (MatchCount == 0 || Options.Separator?.EndsWith('\n') != false) { Write(Options.Indent); } if (OutputInfo != null) { Write(OutputInfo.GetText(capture, MatchCount + 1, groupName: Options.GroupName)); } }
protected override void WriteStartMatch(Capture capture) { ResultStorage?.Add(capture.Value); if (MatchCount == 0 || Options.Separator == "\n" || Options.Separator == "\r\n") { Write(Options.Indent); } if (OutputInfo != null) { Write(OutputInfo.GetText(capture, MatchCount + 1, groupName: Options.GroupName, captureNumber: -1)); } }
static void AddOutputEntry(DeviceInfo devInfo, OutputInfo outputInfo) { bool found = false; foreach (var o in devInfo.outputs) { if (o.width == outputInfo.width && o.height == outputInfo.height && o.pixelFormat == outputInfo.pixelFormat && o.framerate == outputInfo.framerate) { found = true; } } if (!found && ShouldAddOutputEntry(devInfo, outputInfo)) { devInfo.outputs.Add(outputInfo); } }
public void ReadData() { btnWrite.Enabled = HartDevice != null && HartDevice.IsConnected; button1.Enabled = HartDevice != null && HartDevice.IsConnected; if (HartDevice != null && HartDevice.IsConnected) { OutputInfo oi = HartDevice.ReadOutput(); if (oi != null) { cmbTranserFunction.SelectedIndex = oi.TransferFunctionCode; txtDampValue.Text = oi.DampingValue.ToString(); cmbPVUnit.SelectedIndex = (int)oi.PVUnitCode; } txtTrim4.Text = HartDevice.ReadCurrentTrim(0).ToString(); } }
public void ReadData() { btnDownloadTag.Enabled = HartDevice != null && HartDevice.IsConnected; btnDownloadMsg.Enabled = HartDevice != null && HartDevice.IsConnected; if (HartDevice != null && HartDevice.IsConnected) { DeviceTagInfo tag = HartDevice.ReadTag(); txtTag.Text = tag != null ? tag.Tag : string.Empty; txtDescr.Text = tag != null ? tag.Description : string.Empty; txtYear.IntergerValue = tag != null ? tag.Year : 0; txtMonth.IntergerValue = tag != null ? tag.Month : 0; txtDay.IntergerValue = tag != null ? tag.Day : 0; OutputInfo oi = HartDevice.ReadOutput(); txtMessage.Text = HartDevice.ReadMessage(); } }
/// <summary> /// tidy switching value parameters /// </summary> private static void TidySwitchingValueParameters(DataRow row, OutputInfo outputInfo) { var value = Convert.ToString(row[3]); if (!value.Contains("bit")) { return; } var item = new ItemInfo(); value = value.Replace("bit", ""); var id = Convert.ToInt32(value) / 8; item.ID = Convert.ToString(5000 + Convert.ToInt32(value)); item.Name = Convert.ToString(row[4]); if (item.Name.Contains("obligate")) { return; } item.Paramtype = Convert.ToString(row[6]).Contains("status") ? "0" : "1"; item.Permission = "1"; if (Convert.ToString(row[2]) == "/") { item.Permission = "0"; } item.Valuetype = "bool"; item.Precision = "0"; //byte0~bit7:P0b7 item.Expression = "P" + Convert.ToString(id) + "b" + Convert.ToString(Convert.ToInt32(value) % 8); item.Unit = ""; if (item.Paramtype == "0") { item.Result = Common.ReplaceChar(Convert.ToString(row[5])) + ","; } outputInfo.SwitchingValueList.Add(item); }
public IOutputInfo OnWrite() { List <IEnumerable <string> > bodyContents = new List <IEnumerable <string> >(); bodyContents.Add(new string[] { "Name", "Type", "Length", "Last Modified" }); if (Item is DirectoryInfo dirInfo) { bodyContents.Add(new string[] { dirInfo.Name, "Directory", "", dirInfo.LastWriteTime.ToString("yyyy/MM/dd hh:mm:ss") }); } else if (Item is FileInfo fileInfo) { bodyContents.Add(new string[] { fileInfo.Name, "File", fileInfo.Length.ToString(), fileInfo.LastWriteTime.ToString("yyyy/MM/dd hh:mm:ss") }); } List <IOutputBody> bodies = OutputInfo.CreateBodies(bodyContents); bodies.Insert(1, OutputInfo.CreateColumnLineSeperator()); return(OutputInfo.Create(null, bodies, "")); }
private static void ParseOutput(HtmlNode node, OutputInfo info) { for (var i = 0; i < node.ChildNodes.Count; i++) { var child = node.ChildNodes[i]; if (child.Name == "img") { var src = child.Attributes["src"].Value; if (src.IndexOf("[imageHost]") > -1) { var imageHost = DomainUtil.GetDomain("image"); //重写地址 child.Attributes["src"].Value = src.Replace("[imageHost]", imageHost); } } ParseOutput(child, info); } }
public void StartRender(RayTracingInfo rtInfo, OutputInfo outputInfo) { int sample = rtInfo.sampleCount; int sq_sample = (int)Mathf.Sqrt(sample); // for test Vector2 resol = new Vector2(20, 20); //Vector2 resol = outputInfo.Resolution; Vector2 scResol = new Vector2(Screen.width, Screen.height); Vector2 ratio = new Vector2(scResol.x / resol.x, scResol.y / resol.y); Vector2 s_ratio = new Vector2(ratio.x / sq_sample, ratio.y / sq_sample); rect = new Rect(0, 0, resol.x, resol.y); tex = new Texture2D((int)rect.width, (int)rect.height, TextureFormat.RGB24, false); for (int w = 0; w < resol.x; w++) { for (int h = 0; h < resol.y; h++) { Vector2 rayPoint = new Vector2(w * ratio.x, h * ratio.y); Color pixelColor = new Color(0, 0, 0); for (int sw = 0; sw < sq_sample; sw++) { for (int sh = 0; sh < sq_sample; sh++) { int reflCount = 0; Vector2 scRayPoint = new Vector2(rayPoint.x + sw * s_ratio.x, rayPoint.y + sh * s_ratio.y); Ray ray = cam.ScreenPointToRay(scRayPoint); // box filter bool RayFromGlass = false; Collider GlassCollider = null; pixelColor += RayTrace(ray, 0, ref reflCount, ref RayFromGlass, ref GlassCollider) / sample; } } TextureHelper.SetPixel(tex, w, h, pixelColor); } } TextureHelper.SaveImg(tex, "Img/output.png"); }
public static bool ShouldAddOutputEntry(DeviceInfo devInfo, OutputInfo output) { bool valid = false; if (((int)output.width) % 32 == 0) { valid = true; } if (valid && devInfo.name.ToLower().Contains("realsense") && realSenseDepthOutputs.Count > 0) { // filter out resolutions that are below the depth outputs. int index = realSenseDepthOutputs.FindIndex(rso => rso.width <= output.width && rso.height <= output.height); if (index >= 0) { return(true); } valid = false; } return(valid); }
public void ReadData() { btnBackToDevice.Enabled = HartDevice != null && HartDevice.IsConnected; btnRestoreFromDecice.Enabled = HartDevice != null && HartDevice.IsConnected; if (HartDevice != null && HartDevice.IsConnected) { OutputInfo oi = HartDevice.ReadOutput(); txtOutputLower.Text = oi != null?oi.LowerRangeValue.ToString() : null; txtOutputUpper.Text = oi != null?oi.UpperRangeValue.ToString() : null; lblPVU1.Text = oi != null ? ((UnitCode)oi.PVUnitCode).ToString() : null; lblPVU2.Text = oi != null ? ((UnitCode)oi.PVUnitCode).ToString() : null; SensorInfo si = HartDevice.ReadPVSensor(); txtSensorLower.Text = si != null?si.LowerLimit.ToString() : null; txtSenserUpper.Text = si != null?si.UpperLimit.ToString() : null; lblSU1.Text = si != null ? ((UnitCode)si.UnitCode).ToString() : null; lblSU2.Text = si != null ? ((UnitCode)si.UnitCode).ToString() : null; txtTrim4.Text = HartDevice.ReadCurrentTrim(0).ToString(); } }
public IOutputInfo OnWrite() { List <IEnumerable <string> > contents = new List <IEnumerable <string> >(); if (Objects.Count > 0) { string[] properties = Objects[0].Properties.Select(p => p.Name).ToArray(); contents.Add(properties); string[] values; foreach (ObjectPropertySet obj in Objects) { values = obj.Properties.Select(p => p.Value?.ToString()).ToArray(); contents.Add(values); } } List <IOutputBody> bodies = OutputInfo.CreateBodies(contents); if (bodies.Count > 0) { bodies.Insert(1, OutputInfo.CreateColumnLineSeperator()); } return(OutputInfo.Create(null, bodies, "")); }
private void ReportOutputDataHandler(object sender, DataReceivedEventArgs dataReceivedEventArgs) { if (string.IsNullOrEmpty(dataReceivedEventArgs.Data)) { return; } OutputInfo outputInfo = GetOutputInfo(((Process)sender).Id); if (outputInfo == null) { return; } if (outputInfo.ReportOutput) { mActivityProvider.EventProvider.OnActivityLog(new ActivityLogEventArgs(dataReceivedEventArgs.Data + Environment.NewLine)); } outputInfo += dataReceivedEventArgs.Data; Log.V(cLogTag, "[Process {0}] * {1}", ((Process)sender).Id, outputInfo); }
/// <summary> /// output code /// </summary> public static void OutputInternal(OutputInfo outputInfo) { OutputAnalogQuantities(outputInfo); OutputSwitchingValues(outputInfo); }
public string GetResultText(int processId) { OutputInfo outputInfo = GetOutputInfo(processId); return(outputInfo?.Output.Trim()); }
private string ExecuteAdbCommand(string command, bool reportOutput, IExecuteAdbCommandTracker tracker) { ProcessStartInfo processInfo = new ProcessStartInfo(GetADBPath(), command) { CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden, UseShellExecute = false, RedirectStandardError = true, RedirectStandardOutput = true }; int processId = -1; DataReceivedEventHandler dataHandler = tracker.DataHandler; try { lock (tracker.ProcessLock) { using (Process process = Process.Start(processInfo)) { Log.I(cLogTag, "[Process {0}] Executing command: {1}", process.Id, command); tracker.SetProcessData(process, reportOutput); process.OutputDataReceived += dataHandler; process.ErrorDataReceived += dataHandler; OutputInfo outputInfo = new OutputInfo(reportOutput); processId = process.Id; process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); Log.V(cLogTag, "[Process {0}] Process {1} {2} ended with exit code {3}", processId, GetADBPath(), command, process.ExitCode); string returnValue = tracker.GetResultText(processId); if (process.ExitCode == 0) { return(returnValue); } throw new AdbExeException(ADBState.Error, returnValue); } } } catch (AdbExeException) { throw; } catch { } finally { tracker.ClearProcessData(processId); } Log.E(cLogTag, "Unable to execute {0} {1}", GetADBPath(), command); throw new AdbExeException(ADBState.CannotRun); }
private void UpdateResults() { float craftTime = 0; if (ingredients.Count >= 2) { int minQ = 16; int maxQ = 0; float avgTargetQ = 0; List <InputInfo> inputValues = new List <InputInfo>(); Dictionary <int, int> qualities = new Dictionary <int, int>(); int highestQuality = 0; List <string> diffItems = new List <string>(); //analyze input foreach (InventoryItemProxy iip in ingredients) { ItemData itemData = Game.instance.data.FindItem(iip.Uid); minQ = Mathf.Min(minQ, iip.Quality); maxQ = Mathf.Max(maxQ, iip.Quality); avgTargetQ += iip.Quality + 1; if (qualities.ContainsKey(iip.Quality)) { qualities[iip.Quality] = Mathf.Max(itemData.level, qualities[iip.Quality]); } else { qualities[iip.Quality] = itemData.level; } InputInfo i = new InputInfo(); i.itemData = itemData; i.quality = iip.Quality; inputValues.Add(i); if (diffItems.IndexOf(i.key) < 0) { diffItems.Add(i.key); } craftTime = Math.Max(craftTime, Game.instance.data.itemLevels[itemData.level - 1].fusionTime); highestQuality = Mathf.Max(highestQuality, iip.Quality); } avgTargetQ /= ingredients.Count; float successPercent = GetSuccessRate(avgTargetQ) + Convert.ToSingle(Game.instance.user.Modifier.value["fusesuccess_multiplier"]); successRateText.text = String.Format("{0:0}%", Mathf.Clamp01(successPercent) * 100); craftTime *= Mathf.Pow(highestQuality + 1.0f, 1.25f); craftTime /= diffItems.Count; bool isLiveOpsFusion = Game.instance.user.LiveOps.bonuses.fusionTimeMultiplier.value != LiveOpsBonus.DEFAULT_VALUE; if (isLiveOpsFusion) { craftTime *= (float)Game.instance.user.LiveOps.bonuses.fusionTimeMultiplier.value; } float fusionMultiplier = Convert.ToSingle(Game.instance.user.Modifier.value["fusetime_multiplier"]); craftTime *= 1 - fusionMultiplier; //create output points List <OutputInfo> outputValues = new List <OutputInfo>(); foreach (InputInfo info in inputValues) { for (int q = minQ; q <= maxQ; ++q) { if (q >= info.quality) { OutputInfo o = new OutputInfo(); o.itemData = info.itemData; o.quality = q + 1; outputValues.Add(o); } } } //assign weights to output values for (int x = 0; x < outputValues.Count; ++x) { OutputInfo info = outputValues[x]; info.weight = GetFusionWeight(info.quality); info.weight *= GetNearestQualityLevel(info.quality, qualities); info.weight /= Math.Pow(info.level, GetFusionPower(info.quality)); } Dictionary <string, OutputInfo> mergedOutputValues = new Dictionary <string, OutputInfo>(); double totalWeights = 0; for (int x = 0; x < outputValues.Count; ++x) { OutputInfo info = outputValues[x]; totalWeights += info.weight; if (mergedOutputValues.ContainsKey(info.key)) { mergedOutputValues[info.key].weight += info.weight; } else { mergedOutputValues.Add(info.key, info); } } foreach (KeyValuePair <string, OutputInfo> kvp in mergedOutputValues) { kvp.Value.probability = kvp.Value.weight / totalWeights; } List <OutputInfo> results = mergedOutputValues.Values.ToList(); List <OutputInfo> ioe = results.OrderByDescending(x => x.probability).Take(mostProbableResults.Length).ToList(); for (int i = 0; i < mostProbableResults.Length; i++) { if (ioe.Count > i) { mostProbableResults[i].data = ioe[i]; } else { mostProbableResults[i].data = null; } } results.Sort((x, y) => { if (x.level == y.level) { return(y.quality.CompareTo(x.quality)); } return(y.level.CompareTo(x.level)); }); bestResult.data = results.FirstOrDefault(); } else { successRateText.text = string.Empty; for (int i = 0; i < mostProbableResults.Length; i++) { mostProbableResults[i].data = null; } bestResult.data = null; } if (craftTime > 0) { TimeSpan timeToCraft = TimeSpan.FromMilliseconds(craftTime * 1000); startButton.text = Utils.FormatTimeSpan(timeToCraft); } else { startButton.text = string.Empty; } }
/// <summary> /// output switching value /// </summary> private static void OutputSwitchingValues(OutputInfo outputInfo) { Antlr4.StringTemplate.Template template = InitializeTemplate(); template.Add("ItemInfos", outputInfo.SwitchingValueList); AutoOutput.WriteFile(OutputPath + "SwitchingValues.xml", template.Render()); }
public ActionResult Buy(BuyModel model) { // If haven't login => login and come back if (Session["UserID"] == null) { return(RedirectToAction("Login", "Users", new { @returnUrl = Request.Url.OriginalString })); } if (ModelState.IsValid) { string userid = Session["UserID"].ToString(); string hashPass = DataProvider.getHashPass(model.Password); User user = DataProvider.Instance.DataBase.Users.Where(x => x.Id == userid && x.Password == hashPass).SingleOrDefault(); if (user != null) { // Add new output var output = DataProvider.Instance.DataBase.Outputs.Where(x => x.IdCustomer == userid).SingleOrDefault(); if (output == null) { output = new Output() { Id = Guid.NewGuid().ToString(), IdCustomer = userid }; DataProvider.Instance.DataBase.Outputs.Add(output); DataProvider.Instance.DataBase.SaveChanges(); } var product = DataProvider.Instance.DataBase.Products.Where(x => x.Id == model.ProductID).SingleOrDefault(); OutputInfo outputinfo = new OutputInfo() { Id = Guid.NewGuid().ToString(), IdProduct = model.ProductID, IdOutput = output.Id, OutputPrice = product.Price.Value * (100 - product.Discount.Value) / 100, Count = model.Count, DateOutput = DateTime.Now, IsCheckOut = 0, }; DataProvider.Instance.DataBase.OutputInfoes.Add(outputinfo); // remove from basket if (model.FromBasket) { var basket = DataProvider.Instance.DataBase.Baskets.Where(x => x.IdCustomer == userid).SingleOrDefault(); if (basket != null) { var bi = DataProvider.Instance.DataBase.BasketInfoes.Where(x => x.IdProduct == model.ProductID && x.IdBasket == basket.Id).SingleOrDefault(); if (bi != null) { DataProvider.Instance.DataBase.BasketInfoes.Remove(bi); if (basket.BasketInfoes.Count == 0) { DataProvider.Instance.DataBase.Baskets.Remove(basket); } } } } DataProvider.Instance.DataBase.SaveChanges(); ViewBag.Bought = true; return(View(model)); } else { ModelState.AddModelError("", "Your password is incorrect!"); } } ViewBag.Bought = null; return(View(model)); }
private void MainProgram() { if (ProgramParameter.ArchiveFile.Extension.ToLower().Contains("rar")) { Console.WriteLine("RAR格式压缩包!由于RAR专利问题需要调用完整版7Zip!"); Console.WriteLine("本程序将会读取注册表中的7Zip安装路径,如果不想程序读取,请直接关闭本程序。"); Console.WriteLine("请确保已安装完整版7zip!(按任意键继续!)"); Console.ReadKey(); if (string.IsNullOrEmpty(ReadRegeditValue("SOFTWARE\\7-Zip", "Path").ToString())) { Console.WriteLine("调用完全体7Zip失败,请检查7Zip安装情况!"); Process.Start("https://sparanoid.com/lab/7z/"); throw new Exception("7Zip Error!"); } else { ProgramParameter.ArchiveDecryptionProgram = new FileInfo(ReadRegeditValue("SOFTWARE\\7-Zip", "Path").ToString() + "7z.exe"); } } if (!RunProgram(ProgramParameter.ArchiveDecryptionProgram, new string[] { "t", "\"" + ProgramParameter.ArchiveFile.FullName + "\"", "-p" }).TryGetValue("Output", out List <string> Output)) { Console.WriteLine("压缩包损坏 或 不是支持的压缩包!"); throw new Exception("ArchiveFile Error!"); } else { if (Output.Where(p => p != null && p.Contains("Everything is Ok")).Any()) { Console.WriteLine("非加密压缩包!(按任意键退出)"); Console.ReadKey(); return; } } List <Parameter> Dictionary = new List <Parameter>(); try { string[] NewLine = new string[] { Environment.NewLine, "\r\n", "\n", "\r" }; using (StreamReader sr = new StreamReader(ProgramParameter.Dictionary.FullName, Encoding.UTF8)) { Random r = new Random(); foreach (var item in sr.ReadToEnd().Split(NewLine, StringSplitOptions.RemoveEmptyEntries).Distinct()) { Dictionary.Add(new Parameter(r.Next(0, ProgramParameter.DecryptArchiveThreadCount), item)); } } } catch (Exception ex) { Console.WriteLine("尝试读取密码字典时出现错误!"); if (ProgramParameter.DebugMode) { Console.Write(ex.ToString()); } throw ex; } Stopwatch sw = new Stopwatch(); sw.Restart(); using (ConsoleExpand ConsoleCanvas = new ConsoleExpand()) { for (int i = 0; i < ProgramParameter.DecryptArchiveThreadCount; i++) { ConsoleCanvas.Print(0, i, "[" + i + "] 启动中..."); } Random random = new Random(); Parallel.ForEach(Dictionary, new ParallelOptions() { MaxDegreeOfParallelism = ProgramParameter.DecryptArchiveThreadCount }, (i, loopState) => { ConsoleCanvas.Print(0, i.Thread, "[" + i.Thread + "] 密码: [" + i.PassWord + "] 测试中..."); /* * Dictionary<string, List<string>> returnDataA = new Dictionary<string, List<string>> { ["Output"] = new List<string> { "test" } }; * */ //RunProgram(ProgramParameter.ArchiveDecryptionProgram, new string[] { "t", "\"" + ProgramParameter.ArchiveFile.FullName + "\"", "-p\"" + i.PassWord + "\"" }) Thread.Sleep(random.Next(2, 5)); if (new Dictionary <string, List <string> > { ["Output"] = new List <string> { "test" } }.TryGetValue("Output", out List <string> OutputInfo)) { if (OutputInfo.Where(p => p != null && p.Contains("Everything is Ok")).Any()) { ProgramParameter.EncryptArchivePassword = i.PassWord; loopState.Stop(); ConsoleCanvas.Print(0, i.Thread, "[" + i.Thread + "] 密码: [" + i.PassWord + "] 正确!"); } else { ConsoleCanvas.Print(0, i.Thread, "[" + i.Thread + "] 密码: [" + i.PassWord + "] 错误!"); } } else { ConsoleCanvas.Print(0, i.Thread, "[" + i.Thread + "] 密码: [" + i.PassWord + "] 错误!"); } }); } sw.Stop(); Console.SetCursorPosition(0, ProgramParameter.DecryptArchiveThreadCount + 1); if (ProgramParameter.EncryptArchivePassword != null) { Console.WriteLine("\r\n已找到解压密码: \r\n" + ProgramParameter.EncryptArchivePassword + "\r\n共耗时: " + sw.Elapsed.ToString(@"hh\:mm\:ss\.ffff")); } else { Console.WriteLine("已测试 [" + Dictionary.Count + "] 个密码, 没有找到正确的解压密码. 耗时: " + sw.Elapsed.ToString(@"hh\:mm\:ss\.ffff")); } Console.Write("是否保存测试结果?(按回车键保存并退出/按其他任意键不保存并退出)"); switch (Console.ReadKey().Key) { case ConsoleKey.Enter: using (StreamWriter file = new StreamWriter(ProgramParameter.AppPath + Path.GetFileName(ProgramParameter.ArchiveFile.Name) + "[测试报告].txt", false)) { file.WriteLine("加密压缩包: " + ProgramParameter.ArchiveFile); file.WriteLine("字典: " + ProgramParameter.Dictionary); if (ProgramParameter.EncryptArchivePassword != null) { file.WriteLine("解压密码: " + ProgramParameter.EncryptArchivePassword); } else { file.WriteLine("没有找到正确的解压密码!"); } file.Write("耗时: " + sw.Elapsed.ToString(@"hh\:mm\:ss\.ffff")); file.Close(); } Process.Start("Explorer.exe", "/select, \"" + ProgramParameter.AppPath + Path.GetFileName(ProgramParameter.ArchiveFile.Name) + "[测试报告].txt" + "\""); break; default: break; } return; }
/// <summary> /// clear resource /// </summary> private static void ClearResource(OutputInfo outputInfo) { outputInfo.SwitchingValueList.Clear(); outputInfo.AnalogQuantityList.Clear(); }
internal void Set(uint commandIndex, OutputInfo outputInfo, ref outputParameterType outputParameter) { this.CommandIndex = commandIndex & (Server.CommandIndexAnd | (uint)setCommandFlags); this.outputInfo = outputInfo; this.outputParameter = outputParameter; }
public OutputViewModel() { List = new ObservableCollection <OutputInfo>(DataProvider.Ins.Database.OutputInfo.Where(i => i.IsDelete != true)); Product = new ObservableCollection <Product>(DataProvider.Ins.Database.Product.Where(i => i.IsDelete != true)); Staff = new ObservableCollection <Staff>(DataProvider.Ins.Database.Staff.Where(i => i.IsDelete != true)); Customer = new ObservableCollection <Customer>(DataProvider.Ins.Database.Customer.Where(i => i.IsDelete != true)); CurrentDate = DateTime.Now; LoginWindow loginWindow = new LoginWindow(); var loginVM = loginWindow.DataContext as LoginViewModel; IdStaff = loginVM.staffid; loginWindow.Close(); AddCommand = new RelayCommand <object>((p) => { if (Count <= 0 || Count > SelectedProduct.ProductCount || SelectedProduct == null || SelectedCustomer == null || FinalPrice < 0) { return(false); } return(true); }, (p) => { var outputinfo = new OutputInfo() { IdOutputInfo = Guid.NewGuid().ToString(), IdProduct = SelectedProduct.IdProduct, IdCustomer = SelectedCustomer.IdCustomer, IdStaff = IdStaff, Count = Count, FinalPrice = FinalPrice, OutputDate = CurrentDate, OutputStatus = OutputStatus, OutputNote = OutputNote }; //var product = DataProvider.Ins.Database.OutputInfo.Where(x => x.IdProduct == SelectedProduct.IdProduct).SingleOrDefault(); DataProvider.Ins.Database.OutputInfo.Add(outputinfo); DataProvider.Ins.Database.SaveChanges(); List.Add(outputinfo); }); EditCommand = new RelayCommand <object>((p) => { if (Count <= 0 || Count > SelectedProduct.ProductCount || SelectedProduct == null || SelectedCustomer == null || FinalPrice < 0) { return(false); } return(true); }, (p) => { var outputinfo = DataProvider.Ins.Database.OutputInfo.Where(x => x.IdOutputInfo == SelectedItem.IdOutputInfo).SingleOrDefault(); outputinfo.IdProduct = SelectedProduct.IdProduct; outputinfo.Count = Count; outputinfo.FinalPrice = FinalPrice; outputinfo.IdCustomer = SelectedCustomer.IdCustomer; outputinfo.OutputDate = DateTime.Now; outputinfo.OutputNote = OutputNote; outputinfo.OutputStatus = OutputStatus; outputinfo.IdStaff = IdStaff; DataProvider.Ins.Database.SaveChanges(); }); DelCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { var outputinfo = DataProvider.Ins.Database.OutputInfo.Where(x => x.IdOutputInfo == SelectedItem.IdOutputInfo).SingleOrDefault(); outputinfo.IsDelete = true; DataProvider.Ins.Database.SaveChanges(); //ListA = new ObservableCollection<InputInfo>(DataProvider.Ins.Database.InputInfoes); List = new ObservableCollection <OutputInfo>(DataProvider.Ins.Database.OutputInfo.Where(i => i.IsDelete != true)); }); }
/// <summary> /// tidy analog quantity parameters /// </summary> private static void TidyAnalogQuantityParameters(DataRow row, OutputInfo outputInfo) { var value = Convert.ToString(row[0]); if (!value.Contains("word")) { return; } switch (value) { case "word0": outputInfo.UnitID = Convert.ToString(row[4]); return; case "word1": outputInfo.ProtocolVersion = Convert.ToString(row[4]); return; } var item = new ItemInfo(); value = value.Replace("word", ""); var id = Convert.ToInt32(value); item.ID = Convert.ToString(1000 + id); item.Name = Convert.ToString(row[3]); if (item.Name.Contains("obligate")) { return; } item.Paramtype = "0"; item.Permission = "1"; if (Convert.ToString(row[2]) == "/") { item.Permission = "0"; } value = Convert.ToString(row[5]); switch (value) { case "0.1": item.Precision = "1"; break; case "0.01": item.Precision = "2"; break; default: item.Precision = "0"; break; } item.Valuetype = item.Precision == "0" ? "int" : "float"; if (item.Valuetype == "int") { //word1:P2*256+P3 item.Expression = "P" + Convert.ToString(id * 2) + "*256+P" + Convert.ToString(id * 2 + 1); } else { //word1:W2/10, precision: 0.1 item.Expression = "W" + Convert.ToString(id * 2) + "/" + Convert.ToString(Math.Pow(10, Convert.ToInt32(item.Precision))); } item.Unit = Convert.ToString(row[6]); value = Convert.ToString(row[4]); if (!value.Contains("value")) { item.Result = Common.ReplaceChar(value) + ","; } outputInfo.AnalogQuantityList.Add(item); }
public override IEnumerable <object> Select() { var list = new List <OutputInfo>(); try { string sql = "select OutputInfo.*," + "InputInfo.IdInput," + "InputInfo.Count as InputCount," + "InputInfo.InputPrice," + "InputInfo.OutputPrice as DefaultOutputPrice," + "InputInfo.States as InputState," + "Input.DateInput," + "Product.Id as IdProduct," + "Product.DisplayName as ProductName," + "Product.BarCode, Product.IdUnit," + "Product.IdSuplier," + "Unit.DisplayName as UnitName," + "Suplier.DisplayName as SuplierName," + "Suplier.Address," + "Suplier.Phone, " + "Suplier.Email," + "Suplier.MoreInfo," + "Suplier.ContractDate," + "Product.States ProductStates," + "Outputs.DateOutput," + "Customer.DisplayName as CustomerName, " + "Customer.Address as CustomerAddress," + "Customer.Phone as CustomerPhone, " + "Customer.Email as CustomerEmail," + "Customer.MoreInfo as CustomerMoreInfo from OutputInfo " + "inner join InputInfo on InputInfo.Id = OutputInfo.IdInputInfo " + "inner join Product on Product.Id = InputInfo.IdProduct " + "inner join Unit on Unit.Id = Product.IdUnit inner join Suplier on Suplier.Id = Product.IdSuplier " + "inner join Outputs on Outputs.Id = OutputInfo.IdOutput " + "inner join Input on Input.Id = InputInfo.IdInput " + "left join Customer on Customer.Id = OutputInfo.IdCustomer"; SqlCommand command = new SqlCommand(sql, DataProvider.Instance.DB); using (DbDataReader reader = command.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { int Id = reader.GetInt32(reader.GetOrdinal("Id")); int IdInputInfo = reader.GetInt32(reader.GetOrdinal("IdInputInfo")); int IdOutput = reader.GetInt32(reader.GetOrdinal("IdOutput")); int Count = reader.GetInt32(reader.GetOrdinal("Count")); double OutputPrice = reader.GetDouble(reader.GetOrdinal("OutputPrice")); string States = reader[reader.GetOrdinal("States")] as string; int IdCustomer = 0; if (!reader.IsDBNull(reader.GetOrdinal("IdCustomer"))) { IdCustomer = (int)reader[reader.GetOrdinal("IdCustomer")]; } int IdProduct = reader.GetInt32(reader.GetOrdinal("IdProduct")); int IdInput = reader.GetInt32(reader.GetOrdinal("IdInput")); int InputCount = reader.GetInt32(reader.GetOrdinal("InputCount")); double DefaultOutputPrice = reader.GetDouble(reader.GetOrdinal("DefaultOutputPrice")); double InputPrice = reader.GetDouble(reader.GetOrdinal("InputPrice")); string InputState = reader[reader.GetOrdinal("InputState")] as string; string ProductName = reader.GetString(reader.GetOrdinal("ProductName")); string BarCode = reader.GetString(reader.GetOrdinal("BarCode")); int IdUnit = reader.GetInt32(reader.GetOrdinal("IdUnit")); int IdSuplier = reader.GetInt32(reader.GetOrdinal("IdSuplier")); string UnitName = reader.GetString(reader.GetOrdinal("UnitName")); string SuplierName = reader.GetString(reader.GetOrdinal("SuplierName")); string Address = reader.GetString(reader.GetOrdinal("Address")); string Phone = reader.GetString(reader.GetOrdinal("Phone")); string Email = reader[reader.GetOrdinal("Email")] as string; string MoreInfo = reader[reader.GetOrdinal("MoreInfo")] as string; string ProductStates = reader[reader.GetOrdinal("ProductStates")] as string; DateTime ContractDate = reader.GetDateTime(reader.GetOrdinal("ContractDate")); DateTime DateOutput = reader.GetDateTime(reader.GetOrdinal("DateOutput")); DateTime DateInput = reader.GetDateTime(reader.GetOrdinal("DateInput")); string CustomerName = reader[reader.GetOrdinal("CustomerName")] as string; string CustomerAddress = reader[reader.GetOrdinal("CustomerAddress")] as string; string CustomerPhone = reader[reader.GetOrdinal("CustomerPhone")] as string; string CustomerEmail = reader[reader.GetOrdinal("CustomerEmail")] as string; string CustomerMoreInfo = reader[reader.GetOrdinal("CustomerMoreInfo")] as string; OutputInfo outputInfo = new OutputInfo() { Id = Id, IdInputInfo = IdInputInfo, IdOutput = IdOutput, Count = Count, OutputPrice = OutputPrice, States = States, InputInfo = new InputInfo() { Id = IdInputInfo, IdProduct = IdProduct, IdInput = IdInput, Count = InputCount, InputPrice = InputPrice, OutputPrice = DefaultOutputPrice, States = InputState, Product = new Product() { Id = IdProduct, DisplayName = ProductName, BarCode = BarCode, IdUnit = IdUnit, IdSuplier = IdSuplier, States = ProductStates, Unit = new Unit() { Id = IdUnit, DisplayName = UnitName }, Suplier = new Suplier() { Id = IdSuplier, DisplayName = SuplierName, Address = Address, Phone = Phone, Email = Email, MoreInfo = MoreInfo, ContractDate = ContractDate } }, Input = new Input() { Id = IdInput, DateInput = DateInput } }, Output = new Output() { Id = Id, DateOutput = DateOutput } }; if (IdCustomer > 0) { Customer Customer = new Customer() { Id = IdCustomer, DisplayName = CustomerName, Address = CustomerAddress, Email = CustomerEmail, Phone = CustomerPhone, MoreInfo = CustomerMoreInfo }; outputInfo.IdCustomer = IdCustomer; outputInfo.Customer = Customer; } list.Add(outputInfo); } } } } catch (Exception e) { Console.Write(e.Message.ToString()); return(null); } return(list); }
public bool IsOutput(int itemID) { return(OutputInfo.ContainsKey(itemID)); }
/// <summary> /// output analog quantity /// </summary> private static void OutputAnalogQuantities(OutputInfo outputInfo) { Antlr4.StringTemplate.Template template = InitializeTemplate(); template.Add("ItemInfos", outputInfo.AnalogQuantityList); AutoOutput.WriteFile(OutputPath + "AnalogQuantities.xml", template.Render()); }
public FFmpegScreenCapturer(InputInfo inputInfo, OutputInfo outputInfo) { this.outputInfo = outputInfo; this.inputInfo = inputInfo; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("-y"); //overwrite existing file without asking //https://trac.ffmpeg.org/wiki/Capture/Desktop #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN stringBuilder.Append(" -f dshow -i audio=\"virtual-audio-capturer\":video=\"screen-capture-recorder\""); //one of audio recording plugin that can be used with directshow, you can download from here: https://github.com/rdp/virtual-audio-capture-grabber-device #elif UNITY_STANDALONE_LINUX stringBuilder.Append(String.Format(" -f alsa -i hw:{0}", outputInfo.audioDeviceIndex)); //audio options(details: https://ffmpeg.org/ffmpeg-devices.html#alsa) stringBuilder.Append(String.Format(" -f x11grab -draw_mouse {0} -i :0.0", outputInfo.recordCursor? 1:0)); //video options(details: https://ffmpeg.org/ffmpeg-devices.html#x11grab) #elif UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX stringBuilder.Append(String.Format(" -f avfoundation -video_device_index {0} -audio_device_index {1} -capture_cursor {2}", inputInfo.screenDeviceIndex, inputInfo.audioDeviceIndex, outputInfo.recordCursor? 1:0)); //details: https://ffmpeg.org/ffmpeg-devices.html#avfoundation #endif //the encoding parameters here are specialized for FB live. /** * Live Video Specs * Video Format * * We accept video in maximum 720p (1280 x 720) resolution, at 30 frames per second. (or 1 key frame every 2 seconds). * You must send an I-frame (keyframe) at least once every two seconds throughout the stream.. * Recommended max bit rate is 4000 Kbps. * Titles must be less than 255 characters otherwise the stream will fail. * The Live API accepts H264 encoded video and AAC encoded audio only. * Video Length * * 240 minute maximum length, with the exception of continuous live (see above). * 240 minute maximum length for preview streams (either through Live dialog or publisher tools). After 240 minutes, a new stream key must be generated. * Advanced Settings * * Pixel Aspect Ratio: Square. * Frame Types: Progressive Scan. * Audio Sample Rate: 44.1 KHz. * Audio Bitrate: 128 Kbps stereo. * Bitrate Encoding: CBR. */ //about AAC encoding: https://trac.ffmpeg.org/wiki/Encode/AAC //about H264 encoding: https://trac.ffmpeg.org/wiki/Encode/H.264 stringBuilder.Append(String.Format(" -c:v libx264 -vf scale=w=1280:h=720:force_original_aspect_ratio=decrease -framerate 30 -pix_fmt yuv420p -threads 0")); //video encoding parameters(maybe we can tune part of parameters like pix_fmt and crf to adjust quality) stringBuilder.Append(String.Format(" -c:a aac -ar 44100 -b:a 128k")); //audio encoding parameter stringBuilder.Append(" -f flv "); stringBuilder.Append(outputInfo.dest); //it should be an url with rtmp protocol var opt = stringBuilder.ToString(); UnityEngine.Debug.Log(opt); var process = new Process { StartInfo = { FileName = FFmpegConfig.BinaryPath, // Replace Command line arguments here. Arguments = opt, UseShellExecute = false, CreateNoWindow = true, RedirectStandardInput = true, // Redirect FFMpeg output. RedirectStandardError = true }, // Get notified when ffmpeg writes to error stream. EnableRaisingEvents = true }; // Event handler to receive written data. process.ErrorDataReceived += (s, e) => { UnityEngine.Debug.Log(e); }; process.Start(); // Start reading error stream. process.BeginErrorReadLine(); subProcess = process; }
public ParseInfo(string line, int line_number) { this.line = line; this.line_number = line_number; parse_index = 0; out_info = new OutputInfo(); out_info.error_list = new List<Tuple<ErrorCodes, string>>(); }