/// <summary> /// Compares files with the file list at the server. /// </summary> public void CompareFileList() { string pth = Application.dataPath; #if UNITY_EDITOR pth += "/.."; #endif string filePath = pth + "/" + GameName + "/"; string filePath2 = pth + "/v.thln"; string[] Files = null; List <byte[]> bts = new List <byte[]>(); try { Files = Directory.GetFiles(filePath, "*.*", SearchOption.AllDirectories); for (int i = 0; i < Files.Length; i++) { bts.Add(File.ReadAllBytes(Files[i])); } } catch (DirectoryNotFoundException) { return; } if (File.Exists(filePath2)) { FileStream fs = new FileStream(filePath2, FileMode.Truncate, FileAccess.Write); fs.Close(); } StreamWriter writer = new StreamWriter(filePath2, true); for (int i = 0; i < Files.Length; i++) { //Debug.Log(Files[i]); if (!Files[i].Substring(filePath.Length).Contains("output_log")) { if (Files[i].Substring(filePath.Length).Contains(GameName) || Files[i].Substring(filePath.Length).Contains("Unity") || Files[i].Substring(filePath.Length).Contains("Mono")) { writer.WriteLine(Encrypt.EncryptRJ256(Files[i].Substring(filePath.Length) + ":" + bts[i].Length), true); } } } writer.Close(); string[] lines = File.ReadAllLines(pth + "/v.thln"); string[] lines2 = File.ReadAllLines(pth + "/vT.thln"); bool filesGood = lines.SequenceEqual(lines2); if (!filesGood) { gameDownloaded = false; Debug.Log("File integrity problem. Needs redownload."); LogGenerator.GenerateDownloadLog("File integrity problem. Needs redownload."); DownloadStatus = LocalizationManager.LangStrings[11]; } else { updateRequired = false; gameDownloaded = true; Debug.Log("File Check Complete."); LogGenerator.GenerateDownloadLog("File Check Complete."); DownloadStatus = LocalizationManager.LangStrings[10]; } }
static void Main(string[] args) { JsonConfigurationDeserializer jsonConfigurationDeserializer = new JsonConfigurationDeserializer(); XmlConfigurationDeserializer xmlConfigurationDeserializer = new XmlConfigurationDeserializer(); RandomItemAccess randomItemAccess = new RandomItemAccess(); LogLineDirector logLineDirector = new LogLineDirector(); LogGenerator jsonConfigurationLogGenerator = new LogGenerator(jsonConfigurationDeserializer.Deserialize(@"..\..\InputData\LogConfiguration_.json"), randomItemAccess, logLineDirector); jsonConfigurationLogGenerator.GenerateLog(); LogGenerator xmlConfigurationLogGenerator = new LogGenerator(xmlConfigurationDeserializer.Deserialize(@"..\..\InputData\LogConfiguration_.xml"), randomItemAccess, logLineDirector); xmlConfigurationLogGenerator.GenerateLog(); /*string fileName = @"..\..\OutputData\json_correctlog1.txt"; * Mutator mutator = new Mutator(); * mutator.HideDateByRandomDate(fileName); * mutator.HideIpAddressByLocalhost(fileName); * * Analyzer analyzer = new Analyzer(); * analyzer.GetNumberOfClassStatusCodes(fileName, HttpStatusClass.ClientError); * * Validator validator = new Validator(); * validator.ValidateRandomLogs(fileName, "%h %l %u %t %r %s %b");*/ }
/// <summary> /// Gets the version file. /// </summary> public IEnumerator GetVersionFile() { if (!downloadInProgress) { LogGenerator.GenerateDownloadLog("Version File Download started..."); versionFile = new WWW(versionFileUrl); while (!versionFile.isDone) { downloadInProgress = true; progressFill.fillAmount = versionFile.progress; DownloadStatus = LocalizationManager.LangStrings [0]; yield return(null); } if (!string.IsNullOrEmpty(versionFile.error)) { LogGenerator.GenerateDownloadLog(versionFile.text + versionFile.error); Debug.Log(versionFile.text + versionFile.error); } else { downloadInProgress = false; Debug.Log("Version File Downloaded."); LogGenerator.GenerateDownloadLog("Version File Downloaded."); File.WriteAllBytes(Application.dataPath + "/version.flamacore", versionFile.bytes); string[] lines = File.ReadAllLines(Application.dataPath + "/version.flamacore"); currentVer = lines [4]; DownloadStatus = LocalizationManager.LangStrings [1]; StartCoroutine(CheckFileList()); progressFill.fillAmount = 0; } } }
public IRuleResult RuleExecuted(Solbot solbot) { var accountInfo = _binanceClient.General.GetAccountInfo(); var result = false; var baseMsg = string.Empty; var quoteMsg = string.Empty; if (accountInfo.Success) { var availableBase = accountInfo.Data.Balances.FirstOrDefault(e => e.Asset == solbot.Communication.Symbol.BaseAsset).Free; var availableQuote = accountInfo.Data.Balances.FirstOrDefault(e => e.Asset == solbot.Communication.Symbol.QuoteAsset).Free; solbot.Communication.AvailableAsset = new AvailableAssetMessage { Base = availableBase, Quote = availableQuote }; baseMsg = $"{solbot.Communication.Symbol.BaseAsset}:{availableBase}"; quoteMsg = $"{solbot.Communication.Symbol.QuoteAsset}:{availableQuote}"; result = true; } return(new ExchangeRuleResult { Success = result, Message = LogGenerator.ExchangeLog(baseMsg, quoteMsg, accountInfo.Error?.Message) }); }
public GenerateLogsPageViewModel(LogGenerator generator, ILogger logger) { _generator = generator; LoggerType = logger.GetType().Name; GenerateLogs = new DelegateCommand(OnGenerateLogsExecuted); }
public IRuleResult RuleExecuted(Solbot solbot) { _rules.Add(new AvailableAssetBaseRule()); _rules.Add(new AvailableEnoughAssetBaseRule()); _rules.Add(new SellPriceReachedRule()); _rules.Add(new BoughtPriceBeforeSellAndStopLossRule()); _rules.Add(new SellPriceHigherThanBoughtPriceRule()); var result = true; foreach (var item in _rules) { var resultOrderStep = item.RuleExecuted(solbot); if (resultOrderStep.Success) { Logger.Info($"{MarketOrder.GetDescription()} => {resultOrderStep.Message}"); } else { result = false; Logger.Warn($"{MarketOrder.GetDescription()} => {resultOrderStep.Message}"); } } solbot.Communication.Sell.IsReady = result; return(new MarketRuleResult() { Success = result, Message = result ? LogGenerator.PriceMarketSuccess(MarketOrder) : LogGenerator.PriceMarketError(MarketOrder) }); }
public IRuleResult RuleExecuted(Solbot solbot) { var result = new SequencedRuleResult(); if (solbot.Actions.StopLossReached && solbot.Actions.BoughtPrice == 0 && solbot.Actions.StopLossCurrentCycle < solbot.Strategy.AvailableStrategy.StopLossPauseCycles) { solbot.Actions.StopLossCurrentCycle++; result.Success = false; result.Message = LogGenerator.SequenceError(SequenceName, $"{solbot.Actions.StopLossCurrentCycle}/{solbot.Strategy.AvailableStrategy.StopLossPauseCycles}"); } else if (!solbot.Actions.StopLossReached && solbot.Actions.BoughtPrice > 0) { result.Success = true; result.Message = LogGenerator.SequenceSuccess(SequenceName, $"{solbot.Actions.StopLossCurrentCycle}"); } else { solbot.Actions.StopLossCurrentCycle = 0; solbot.Actions.BoughtPrice = 0; solbot.Actions.StopLossReached = false; result.Success = true; result.Message = LogGenerator.SequenceSuccess(SequenceName, $"{solbot.Actions.StopLossCurrentCycle}"); } return(result); }
public ProcessLogGeneratorCollection() { this.dict = new Dictionary <string, LogGenerator>(); this.AllProcessLog = new LogGenerator("all_process", "프로세스 로그"); this.AllProcessLog.OnOpen += this.AllProcessLogOpened; this.AllProcessLog.OnClose += this.AllProcessLogClosed; }
/// <summary> /// Initializes the channel set. /// </summary> /// <param name="log">The log.</param> /// <param name="indexList">The index list.</param> /// <param name="loggingMethod">The logging method.</param> /// <param name="numDataValue">The number data value.</param> public void InitChannelSet(Log log, List <ChannelIndex> indexList, LoggingMethod loggingMethod = LoggingMethod.computed, int numDataValue = 150) { ChannelSet channelSet = LogGenerator.CreateChannelSet(log); channelSet.Index = indexList; bool isDepth = log.TimeDepth.EqualsIgnoreCase(ObjectFolders.Depth); if (isDepth) { var pointMetadataList = List(LogGenerator.CreatePointMetadata("Quality", "Quality", EtpDataType.boolean)); channelSet.Channel.Add(LogGenerator.CreateChannel(log, indexList, "Rate of Penetration", "ROP", UnitOfMeasure.mh, "Velocity", EtpDataType.@double, pointMetadataList: pointMetadataList)); channelSet.Channel.Add(LogGenerator.CreateChannel(log, indexList, "Hookload", "HKLD", UnitOfMeasure.klbf, "Force", EtpDataType.@double, null)); } else { var pointMetadataList = List(LogGenerator.CreatePointMetadata("Confidence", "Confidence", EtpDataType.@float)); channelSet.Channel.Add(LogGenerator.CreateChannel(log, indexList, "Rate of Penetration", "ROP", UnitOfMeasure.mh, "Velocity", EtpDataType.@double, pointMetadataList: pointMetadataList)); } log.ChannelSet = new List <ChannelSet>(); log.ChannelSet.Add(channelSet); LogGenerator.GenerateChannelData(log.ChannelSet, numDataValue: numDataValue); }
/// <summary> /// Checks the file list. /// </summary> public IEnumerator CheckFileList() { if (!downloadInProgress) { LogGenerator.GenerateDownloadLog("File List Download started..."); vFile = new WWW(FileListUrl); while (!vFile.isDone) { downloadInProgress = true; progressFill.fillAmount = vFile.progress; DownloadStatus = LocalizationManager.LangStrings [8]; yield return(null); } if (!string.IsNullOrEmpty(vFile.error)) { LogGenerator.GenerateDownloadLog(vFile.text + vFile.error); Debug.Log(vFile.text + vFile.error); LogGenerator.GenerateDownloadLog(vFile.text + vFile.error); DownloadStatus = vFile.text + vFile.error; } else { downloadInProgress = false; Debug.Log("File List Downloaded."); LogGenerator.GenerateDownloadLog("File List Downloaded."); File.WriteAllBytes(Application.dataPath + "/vT.flamacore", vFile.bytes); DownloadStatus = LocalizationManager.LangStrings [9]; CompareFileList(); progressFill.fillAmount = 0; } } }
public IRuleResult RuleExecuted(Solbot solbot) { _rules.Add(new StopLossStepMarketRule(_marketService)); _rules.Add(new StopLossExecuteMarketTestRule(_pushOverNotificationService)); _rules.Add(new SellStepMarketRule(_marketService)); _rules.Add(new SellExecuteMarketTestRule(_pushOverNotificationService)); _rules.Add(new BuyStepMarketRule(_marketService, false)); _rules.Add(new BuyExecuteMarketTestRule(_pushOverNotificationService)); Logger.Info(LogGenerator.ModeStart(ModeName)); foreach (var item in _rules) { var result = item.RuleExecuted(solbot); Logger.Info($"{result.Message}"); } Logger.Info(LogGenerator.ModeEnd(ModeName)); return new ModeRuleResult { Message = LogGenerator.ModeExecuted(ModeName), Success = true }; }
public IRuleResult RuleExecuted(Solbot solbot) { var result = new SequencedRuleResult(); try { var currentPrice = _tickerPriceService.GetPriceValue(solbot.Strategy.AvailableStrategy); if (currentPrice.Success) { solbot.Communication.Price = new PriceMessage { Current = currentPrice.Result }; result.Success = true; result.Message = LogGenerator.SequenceSuccess(SequenceName, $"{currentPrice.Result}"); } else { result.Success = false; result.Message = LogGenerator.SequenceError(SequenceName, currentPrice.Message); } } catch (Exception e) { result.Success = false; result.Message = LogGenerator.SequenceException(SequenceName, e); } return(result); }
public IRuleResult RuleExecuted(Solbot solbot) { var result = _marketService.IsGoodToBuy( solbot.Strategy.AvailableStrategy.CommissionType, solbot.Strategy.AvailableStrategy.BuyDown, solbot.Communication.Average.Current, solbot.Communication.Price.Current); solbot.Communication.Buy = new ChangeMessage { Change = result.Changed, PriceReached = result.IsReadyForMarket }; if (_isInProductionMode) { var fundResponse = _marketService.AvailableQuote(solbot.Strategy.AvailableStrategy.FundPercentage, solbot.Communication.AvailableAsset.Quote, solbot.Communication.Symbol.QuoteAssetPrecision); solbot.Communication.Buy.AvailableFund = fundResponse.QuoteAssetToTrade; } var change = solbot.BuyChange(); return(new MarketRuleResult() { Success = result.IsReadyForMarket, Message = result.Changed < 0 ? LogGenerator.StepMarketSuccess(MarketOrder, solbot.Communication.Price.Current, solbot.Communication.Average.Current, change) : LogGenerator.StepMarketError(MarketOrder, solbot.Communication.Price.Current, solbot.Communication.Average.Current, change) }); }
public IRuleResult RuleExecuted(Solbot solbot) { var result = new SequencedRuleResult(); try { var count = _storageService.GetValues().Count; var storedPriceAverage = AverageContext.Average( solbot.Strategy.AvailableStrategy.AverageType, _storageService.GetValues(), solbot.Communication.Symbol.QuoteAssetPrecision, solbot.Strategy.AvailableStrategy.Average); solbot.Communication.Average = new PriceMessage { Current = storedPriceAverage, Count = count < solbot.Strategy.AvailableStrategy.Average ? count : solbot.Strategy.AvailableStrategy.Average }; result.Success = true; result.Message = LogGenerator.SequenceSuccess(SequenceName, $"{storedPriceAverage}"); } catch (Exception e) { result.Success = false; result.Message = LogGenerator.SequenceException(SequenceName, e); } return(result); }
public IRuleResult RuleExecuted(Solbot solbot) { var result = solbot.Communication.Buy.PriceReached && solbot.Actions.BoughtPrice == 0; if (result) { solbot.Actions.BoughtPrice = solbot.Communication.Price.Current; result = true; _pushOverNotificationService.Send( LogGenerator.NotificationTitle(WorkingType.TEST, MarketOrder, solbot.Strategy.AvailableStrategy.Symbol), LogGenerator.NotificationMessage( solbot.Communication.Average.Current, solbot.Communication.Price.Current, solbot.Communication.Buy.Change)); } return(new MarketRuleResult() { Success = result, Message = result ? LogGenerator.ExecuteMarketSuccess(MarketOrder, solbot.Actions.BoughtPrice) : LogGenerator.ExecuteMarketError(MarketOrder, solbot.Actions.BoughtPrice) }); }
public void OneTimeSetup() { LogGenerator.ConnfigureLogger(); LogGenerator.LogInfo(System.Reflection.MethodBase.GetCurrentMethod().Name); ReportTestManager.CreateParentTest(GetType().Name); }
public void Channel200DataAdapter_UpdateChannelData_With_Special_Characters() { AddParents(); // Initialize ChannelSet var mdChannelIndex = LogGenerator.CreateMeasuredDepthIndex(IndexDirection.increasing); DevKit.InitHeader(Log, LoggingMethod.MWD, mdChannelIndex); // Add special channels var channelSet = Log.ChannelSet.First(); channelSet.Channel.Add(LogGenerator.CreateChannel(Log, channelSet.Index, "Message", "MSG", null, "none", EtpDataType.@string, null)); channelSet.Channel.Add(LogGenerator.CreateChannel(Log, channelSet.Index, "Count", "CNT", null, "none", EtpDataType.@long, null)); // Initialize data block var uri = channelSet.GetUri(); var dataBlock = new ChannelDataBlock(uri); var channelId = 1; var numRows = ChannelDataBlock.BatchSize; var flushRate = ChannelDataBlock.BlockFlushRateInMilliseconds; foreach (var channelIndex in channelSet.Index) { dataBlock.AddIndex(channelIndex); } foreach (var channel in channelSet.Channel) { dataBlock.AddChannel(channelId++, channel); } LogGenerator.GenerateChannelData(dataBlock, numRows); var reader = dataBlock.GetReader(); Assert.IsTrue(reader.Read()); // Read the first value for mnemonic "MSG" var msgValue = reader["MSG"]; // Submit channel data _channelDataProvider.UpdateChannelData(uri, dataBlock.GetReader()); var mnemonics = channelSet.Index.Select(i => i.Mnemonic) .Concat(channelSet.Channel.Select(c => c.Mnemonic)) .ToList(); // Query channel data var dataOut = _channelDataProvider.GetChannelData(uri, new Range <double?>(0, null), mnemonics, null); // Assert Assert.AreEqual(numRows, dataOut.Count); Assert.AreEqual(numRows, dataBlock.Count()); Assert.AreEqual(2, dataOut[0].Count); Assert.AreEqual(5, dataOut[0][1].Count); Assert.AreEqual(msgValue, dataOut[0][1][3]); Assert.IsTrue(flushRate > 1000); }
public IRuleResult RuleExecuted(Solbot solbot) => new SequencedRuleResult { Success = Enum.IsDefined(typeof(AverageType), solbot.Strategy.AvailableStrategy.AverageType), Message = solbot.Strategy.AvailableStrategy.AverageType == AverageType.WITH_CURRENT ? LogGenerator.AverageTypeSuccess(SequenceName, solbot.Strategy.AvailableStrategy.AverageType.GetDescription()) : LogGenerator.AverageTypeError(SequenceName, solbot.Strategy.AvailableStrategy.AverageType.GetDescription()) };
public IRuleResult RuleExecuted(Solbot solbot) => new SequencedRuleResult { Success = solbot.Strategy.ModeType == ModeType.WORKING, Message = solbot.Strategy.ModeType == ModeType.WORKING ? LogGenerator.ModeTypeSuccess(SequenceName, solbot.Strategy.ModeType.GetDescription()) : LogGenerator.ModeTypeError(SequenceName, solbot.Strategy.ModeType.GetDescription()) };
public static ValidatedRuleResult New(bool result, string ruleAttribute, string attributeValue) => new ValidatedRuleResult { Success = result, Message = result ? LogGenerator.ValidationSuccess(ruleAttribute) : LogGenerator.ValidationError(ruleAttribute, attributeValue) };
private void LogClosed(object sender, EventArgs args) { LogGenerator logGenerator = sender as LogGenerator; if (this.dict.ContainsKey(logGenerator.Key)) { this.dict.Remove(logGenerator.Key); } }
public static void SaveLog(LogGenerator log, string path) { string directory = Path.GetDirectoryName(path); string exeDirectory = Application.dataPath; if (!Directory.Exists(directory) && directory != "") Directory.CreateDirectory(directory); path = Path.Combine(exeDirectory, path); File.WriteAllText(path, log.Log); }
private void LogOpened(object sender, EventArgs args) { LogGenerator logGenerator = sender as LogGenerator; if (!this.dict.ContainsKey(logGenerator.Key)) { this.dict.Add(logGenerator.Key, logGenerator); } }
public void Teardown() { LogGenerator.LogInfo(System.Reflection.MethodBase.GetCurrentMethod().Name); ReportTestManager.LogStatus(); // close the driver specific to thread Driver().Quit(); }
private void btnnext_Click(object sender, EventArgs e) { try { dt = con.getdataset("select * from tblRegistrationMaster where isactive=1 and srno='" + txtsystemid.Text + "'", constring); LogGenerator.Info("select * from tblRegistrationMaster where isactive=1 and srno='" + txtsystemid.Text + "'"); if (dt.Rows.Count > 0) { if (dt.Rows[0]["srno"].ToString() == txtsystemid.Text && dt.Rows[0]["isused"].ToString() == "False") { pnlreg.Visible = true; pnlserial.Visible = false; txtcname.Focus(); getmacserial(); if (sMacAddress == "To be filled by O.E.M.") { UUID(); } txtpartnercode.Text = dt.Rows[0]["partnercode"].ToString(); } else { getmacserial(); if (sMacAddress == "To be filled by O.E.M.") { UUID(); } if (dt.Rows[0]["mac"].ToString() == sMacAddress) { pnlreg.Visible = true; pnlserial.Visible = false; txtcname.Focus(); txtcname.Text = dt.Rows[0]["companyname"].ToString(); txtcaddress.Text = dt.Rows[0]["companyaddress"].ToString(); txtcontact.Text = dt.Rows[0]["contact"].ToString(); txtemail.Text = dt.Rows[0]["email"].ToString(); txtpartnercode.Text = dt.Rows[0]["partnercode"].ToString(); } else { MessageBox.Show("Invalid Serial No. Please Try Again"); txtsystemid.Focus(); } } } else { MessageBox.Show("Invalid Serial No. Please Try Again"); txtsystemid.Focus(); } } catch { } }
static void Main(string[] args) { //Assumption is Program should run infinitely with all the exception handled //Unless user closes the console application while (true) { try { Console.WriteLine("Please key in the path to the input file\n"); Console.Write(":>"); var path = Console.ReadLine(); if (string.IsNullOrEmpty(path)) { throw new FileNotFoundException(); } StreamReader streamReader = new StreamReader(path); List <string> inputList = new List <string>(); var inputLine = streamReader.ReadLine(); while (inputLine != null) { inputList.Add(inputLine); inputLine = streamReader.ReadLine(); } var inputRefactor = new InputRefactor(new InputValidator()); var result = inputRefactor.InputValidator(inputList); if (result) { ServiceProvider.GenerateFlightAsync(inputRefactor.input).Wait(); } } #region Exception Handlers catch (FileNotFoundException) { Console.WriteLine("Incorrect File format or wrong path! please retry!\n"); } catch (DirectoryNotFoundException) { Console.WriteLine("wrong path! please retry!\n"); } catch (UnauthorizedAccessException) { Console.WriteLine("Access to the path is denied! please retry!\n"); } catch (Exception e) { LogGenerator.GenerateLog(e); } #endregion } }
private void login() { ds = cl.getdata("select * from UserInfo where isActive=1 and UserName='******' and CompanyId='" + txthCompId.Text + "'"); dt = ds.Tables[0]; if (dt.Rows.Count > 0) { if (dt.Rows[0][5].ToString() == txtPassword.Text) { txtPassword.Text = ""; // master = new Master(this); Master.userid = dt.Rows[0]["Userid"].ToString(); try { master_1.setheader(companydt, dt.Rows[0]["UserName"].ToString()); master_1.enablemenu(true); master_1.disablecompany(false); master_1.compId(txthCompId.Text); } catch { } try { master.setheader(companydt, dt.Rows[0]["UserName"].ToString()); master.enablemenu(true); master.disablecompany(false); master.compId(txthCompId.Text); } catch { } //frm.Show(); // this.Close(); options = cl.getdataset("select * from options"); LogGenerator.Info("Company LogIN CompanyID=" + txthCompId.Text); LogGenerator.Info("User Login UserID=" + Master.userid); if (options.Rows[0]["userlog"].ToString() == "True") { cl.execute("INSERT INTO [dbo].[USerLog]([userid],[loginpalce],[Status],[isactive],[datetime])VALUES('" + Master.userid + "','" + "Company" + "','" + "Login" + "','" + "1" + "','" + DateTime.Now.ToString("MM/dd/yyyy h:mm:ss") + "')"); } int tabs = tabControl.TabPages.Count; if (tabs > 0) { master.RemoveCurrentTab(); Businessplus bus = new Businessplus(); master.AddNewTab(bus); } } else { MessageBox.Show("Password Incorrect. Try again!!!"); txtPassword.Text = ""; } } }
/// <summary> /// Creates the log. /// </summary> /// <param name="indexType">Type of the index.</param> /// <param name="isIncreasing">if set to <c>true</c> [is increasing].</param> /// <returns></returns> public Log CreateLog(ChannelIndexType indexType, bool isIncreasing) { Log log = new Log(); log.Citation = Citation("ChannelSet"); log.Uuid = Uid(); log.ChannelSet = new List <ChannelSet>(); log.Wellbore = DataObjectReference(ObjectTypes.Wellbore, Name("Wellbore"), Uid()); List <ChannelIndex> indexList = new List <ChannelIndex>(); IndexDirection direction = isIncreasing ? IndexDirection.increasing : IndexDirection.decreasing; if (LogGenerator.DepthIndexTypes.Contains(indexType)) { log.TimeDepth = ObjectFolders.Depth; ChannelIndex channelIndex = LogGenerator.CreateMeasuredDepthIndex(direction); if (indexType.Equals(ChannelIndexType.trueverticaldepth)) { channelIndex = LogGenerator.CreateTrueVerticalDepthIndex(direction); } else if (indexType.Equals(ChannelIndexType.passindexeddepth)) { channelIndex = LogGenerator.CreatePassIndexDepthIndex(direction); } indexList.Add(channelIndex); } else if (LogGenerator.TimeIndexTypes.Contains(indexType)) { log.TimeDepth = ObjectFolders.Time; if (indexType.Equals(ChannelIndexType.datetime)) { // DateTime should be increasing only indexList.Add(LogGenerator.CreateDateTimeIndex()); } else if (indexType.Equals(ChannelIndexType.elapsedtime)) { indexList.Add(LogGenerator.CreateElapsedTimeIndex(direction)); } } else { log.TimeDepth = ObjectFolders.Other; return(null); } InitChannelSet(log, indexList); return(log); }
//Now we can use Moq in our unit test to create a mock of an object implementing ILog: public void FooLogsCorrectly() { // Arrange var logMock = new Mock <ILog>(); var logGenerator = new LogGenerator(logMock.Object); // Act logGenerator.Foo(); // Assert logMock.Verify(m => m.WriteToLog("my log message")); }
private void btndelete_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Do you want to Delete Bill?", "Bill", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { getcon(); if (con.State == ConnectionState.Open) { con.Close(); } con.Open(); //SqlCommand cmd = new SqlCommand("update PurchaseOrderMaster set isactive=0 where VchNo='" + txtVchNo.Text + "' and CompanyId=" + compid + "", con); //cmd.ExecuteNonQuery(); string qry = "update PurchaseOrderMaster set isactive=0 where VchNo='" + txtVchNo.Text + "' and CompanyId=" + compid + ""; SqlCommand cmd = new SqlCommand(qry, con); LogGenerator.Info(qry); cmd.ExecuteNonQuery(); lcon.execute("Insert into sync values('" + qry.Replace("'", "\"") + "')"); SqlCommand cmd2 = new SqlCommand("update PurchaseOrderProductMaster set isactive=0 where VchNo='" + txtVchNo.Text + "'and CompanyId=" + compid, con); cmd2.ExecuteNonQuery(); string qry1 = "update PurchaseOrderProductMaster set isactive=0 where VchNo='" + txtVchNo.Text + "' and CompanyId=" + compid + ""; lcon.execute("Insert into sync values('" + qry1.Replace("'", "\"") + "')"); LogGenerator.Info(qry1); clearall(); clearitem(); LVFO.Clear(); this.Close(); DateWisePurchaseReport frm = new DateWisePurchaseReport(); frm.MdiParent = this.MdiParent; frm.StartPosition = FormStartPosition.CenterScreen; frm.Show(); } else { if (cmbPurchaseType.Text == "" || cmbCustName.Text == "" || cmbTerms.Text == "") { MessageBox.Show("Please fill all the information."); if (cmbPurchaseType.Text == "") { cmbPurchaseType.Focus(); } else if (cmbCustName.Text == "") { cmbCustName.Focus(); } else if (cmbTerms.Text == "") { cmbTerms.Focus(); } } } }
//Now we can use Moq in our unit test to create a mock of an object implementing ILog: public void FooLogsCorrectly() { // Arrange var logMock = new Mock<ILog>(); var logGenerator = new LogGenerator(logMock.Object); // Act logGenerator.Foo(); // Assert logMock.Verify(m => m.WriteToLog("my log message")); }
public IRuleResult RuleExecuted(Solbot solbot) { if (solbot.Strategy.AvailableStrategy.StopLossDown == 0) { solbot.Communication.StopLoss = new ChangeMessage { Change = 0, PriceReached = false }; return(new MarketRuleResult() { Success = false, Message = LogGenerator.Off(MarketOrder) }); } else { var boughtPrice = solbot.BoughtPrice(); var result = new MarketResponse(); if (boughtPrice > 0) { result = _marketService.IsStopLossReached( solbot.Strategy.AvailableStrategy.CommissionType, solbot.Strategy.AvailableStrategy.StopLossDown, boughtPrice, solbot.Communication.Price.Current); } else { result.IsReadyForMarket = false; result.Changed = 0; } solbot.Communication.StopLoss = new ChangeMessage { Change = result.Changed, PriceReached = result.IsReadyForMarket }; var change = solbot.StopLossChange(); return(new MarketRuleResult() { Success = result.IsReadyForMarket, Message = result.Changed < 0 ? LogGenerator.StepMarketSuccess(MarketOrder, solbot.Communication.Price.Current, boughtPrice, change) : LogGenerator.StepMarketError(MarketOrder, solbot.Communication.Price.Current, boughtPrice, change) }); } }
public static void Write(LogGenerator log, string message) { log.Log = log.Log + message + "\n"; }