public override async Task <TraceEntity> NextTestcaseAsync(CancellationToken token)
        {
            // Generate random bytes
            byte[] random = new byte[_testcaseLength];
            do
            {
                _rng.GetBytes(random);
            }while(_knownTestcases.Contains(random));

            // Remember test case
            _knownTestcases.Add(random);

            // Store test case
            string testcaseFileName = Path.Combine(_outputDirectory.FullName, $"{_nextTestcaseNumber}.testcase");
            await File.WriteAllBytesAsync(testcaseFileName, random, token);

            // Create trace entity object
            var traceEntity = new TraceEntity
            {
                Id = _nextTestcaseNumber,
                TestcaseFilePath = testcaseFileName
            };

            // Done
            await Logger.LogDebugAsync("Testcase #" + traceEntity.Id);

            ++_nextTestcaseNumber;
            return(traceEntity);
        }
Example #2
0
        public static TraceEntity Logout(LogoutRequestEntity request)
        {
            TraceEntity response = new TraceEntity();

            try
            {
                UserLoginResponse userLogin = UserClass.AccessCheck(request.Username, request.Password);

                if (string.IsNullOrEmpty(userLogin.Trace.ErrorMsg))
                {
                    UserClass.Logout(request);
                }
                else
                {
                    response = userLogin.Trace;
                }
            }
            catch (Exception e)
            {
                response.ErrorMsg = e.Message;
                Common.LogIt(e.ToString());
            }

            return(response);
        }
Example #3
0
        public override async Task PreprocessTraceAsync(TraceEntity traceEntity)
        {
            // Output file
            string outputFileName = Path.Combine(_outputDirectory.FullName, Path.GetFileName(traceEntity.RawTraceFilePath) + ".txt");

            await using var outputStream = File.OpenWrite(outputFileName);
            await using var outputWriter = new StreamWriter(outputStream);

            // Base path of raw trace files
            string rawTraceFileDirectory = Path.GetDirectoryName(traceEntity.RawTraceFilePath);

            // Write image data
            string prefixDataFilePath = Path.Combine(rawTraceFileDirectory !, "prefix_data.txt"); // Suppress "possible null" warning
            await outputWriter.WriteLineAsync("-- Image data --");

            await outputWriter.WriteLineAsync(await File.ReadAllTextAsync(prefixDataFilePath));

            // Write prefix
            await outputWriter.WriteLineAsync("-- Trace prefix --");

            DumpRawFile(Path.Combine(rawTraceFileDirectory, "prefix.trace"), outputWriter);

            // Write trace
            await outputWriter.WriteLineAsync("-- Trace --");

            DumpRawFile(traceEntity.RawTraceFilePath, outputWriter);
        }
Example #4
0
        public TraceEntity Withdraw(WithdrawEntity entity)
        {
            TraceEntity result = new TraceEntity();

            //agent,sesscode,productno,productname 用户名,密码,产品代码,产品名称
            string[] config     = entity.IOC_Class_Parameters.Split(',');
            t_Case   caseEntity = Case.Get(entity.CaseNo);
            string   rep        = ws.CannelPolicyById(
                DESEncrypt(caseEntity.customerID), config[0], config[1], config[2], entity.PolicyNo, caseEntity.customerID);

            string[] array = rep.Split('|');
            if (array.Length > 1)
            {
                if (array[0] != "1")
                {
                    Common.LogIt(rep);
                    result.ErrorMsg = rep;
                }
            }
            else
            {
                Common.LogIt(rep);
                result.ErrorMsg = rep;
            }

            return(result);
        }
Example #5
0
        public static TraceEntity DiscardIt(string username, string password, string caseNo)
        {
            TraceEntity response = new TraceEntity();

            try
            {
                UserLoginResponse userLogin = UserClass.AccessCheck(username, password);

                if (string.IsNullOrEmpty(userLogin.Trace.ErrorMsg))
                {
                    response = Case.Discard(username, caseNo);
                }
                else
                {
                    response = userLogin.Trace;
                }
            }
            catch (Exception e)
            {
                Common.LogIt(e.ToString());
                response.ErrorMsg = "未能作废,请稍后重试。";
            }

            return(response);
        }
Example #6
0
        public async Task <TraceEntity> TraceHttpAsync(string method, string path)
        {
            try
            {
                // Create or reference an existing table
                CloudTable table = await CreateTableAsync("Trace");

                // Add new entity
                TraceEntity device = new TraceEntity(method, path);

                // Create the InsertOrReplace table operation
                TableOperation insertOrMergeOperation = TableOperation.InsertOrMerge(device);

                // Execute the operation.
                TableResult result = await table.ExecuteAsync(insertOrMergeOperation);

                TraceEntity insertedtrace = result.Result as TraceEntity;

                // Get the request units consumed by the current operation. RequestCharge of a TableResult is only applied to Azure Cosmos DB
                if (result.RequestCharge.HasValue)
                {
                    Console.WriteLine("Request Charge of InsertOrMerge Operation: " + result.RequestCharge);
                }

                return(insertedtrace);
            }
            catch (StorageException e)
            {
                Console.WriteLine(e.Message);
                Console.ReadLine();
                throw;
            }
        }
Example #7
0
        public override async Task PreprocessTraceAsync(TraceEntity traceEntity)
        {
            // Input check
            if (traceEntity.RawTraceFilePath == null)
            {
                throw new Exception("Raw trace file path is null. Is the trace stage missing?");
            }

            // Output file
            string outputFileName = Path.Combine(_outputDirectory.FullName, Path.GetFileName(traceEntity.RawTraceFilePath) + ".txt");

            await using var outputStream = File.Open(outputFileName, FileMode.Create);
            await using var outputWriter = new StreamWriter(outputStream);

            // Base path of raw trace files
            string rawTraceFileDirectory = Path.GetDirectoryName(traceEntity.RawTraceFilePath) ?? throw new Exception($"Could not determine directory: {traceEntity.RawTraceFilePath}");

            // Write image data
            string prefixDataFilePath = Path.Combine(rawTraceFileDirectory !, "prefix_data.txt"); // Suppress "possible null" warning
            await outputWriter.WriteLineAsync("-- Image data --");

            await outputWriter.WriteLineAsync(await File.ReadAllTextAsync(prefixDataFilePath));

            // Write prefix
            await outputWriter.WriteLineAsync("-- Trace prefix --");

            DumpRawFile(Path.Combine(rawTraceFileDirectory, "prefix.trace"), outputWriter);

            // Write trace
            await outputWriter.WriteLineAsync("-- Trace --");

            DumpRawFile(traceEntity.RawTraceFilePath, outputWriter);
        }
Example #8
0
    protected void btnSend_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            try
            {
                SMSEntity sms = new SMSEntity();
                sms.MobilePhone     = txtMobile.Text.Trim();
                sms.Content         = txtContent.Text.Trim();
                sms.CaseNo          = txtCaseNo.Text.Trim();
                sms.IOC_Class_Alias = "ShangTong";
                TraceEntity result = SMS.Send(sms);

                if (!string.IsNullOrEmpty(result.ErrorMsg))
                {
                    this.lblResult.Text = result.ErrorMsg;
                }
                else
                {
                    this.lblResult.Text = "发送成功!";
                }
            }
            catch (Exception ee)
            {
                Common.LogIt(ee.ToString());
                this.lblResult.Text = ee.ToString();
            }
        }
    }
Example #9
0
        public override async Task GenerateTraceAsync(TraceEntity traceEntity)
        {
            // Debug
            await Logger.LogDebugAsync("Trace #" + traceEntity.Id);

            // Send test case
            await _pinToolProcess.StandardInput.WriteLineAsync($"t {traceEntity.Id}");

            await _pinToolProcess.StandardInput.WriteLineAsync(traceEntity.TestcaseFilePath);

            while (true)
            {
                // Read Pin tool output
                await Logger.LogDebugAsync("Read from Pin tool stdout...");

                string pinToolOutput = await _pinToolProcess.StandardOutput.ReadLineAsync()
                                       ?? throw new IOException("Could not read from Pin tool standard output (null). Probably the process has exited early.");

                // Parse output
                await Logger.LogDebugAsync($"Pin tool output: {pinToolOutput}");

                string[] outputParts = pinToolOutput.Split('\t');
                if (outputParts[0] == "t")
                {
                    // Store trace file name
                    traceEntity.RawTraceFilePath = outputParts[1];
                    break;
                }

                await Logger.LogWarningAsync("Unexpected message from Pin tool.\nPlease make sure that the investigated program does not print anything on stdout, since this might interfere with the Pin tool's output pipe.");
            }
        }
Example #10
0
        public TraceEntity Withdraw(WithdrawEntity entity)
        {
            TraceEntity trace = new TraceEntity();

            XmlDocument xmlDoc = XMLString.Withdraw.Clone() as XmlDocument;

            xmlDoc.SelectSingleNode("OrderInfo/OrderNum").InnerText = entity.PolicyNo;
            string req = xmlDoc.OuterXml;
            string ret = "";

            //<?xml version="1.0" encoding="utf-8"?><OrderInfo><Flag>0</Flag><Message>订单不存在,或不是您的订单</Message></OrderInfo>
            try
            {
                ret = ws.CancelOrder(req);
                xmlDoc.LoadXml(ret);
                if (xmlDoc.SelectSingleNode("OrderInfo/Flag").InnerText == "0")
                {
                    Common.LogIt("退保参数:" + req + Environment.NewLine
                                 + "简单保返回:" + ret);
                }
            }
            catch (Exception e)
            {
                Common.LogIt(ws.Url + Environment.NewLine
                             + "退保异常:" + e.Message);
            }

            return(trace);
        }
Example #11
0
        private void Discard()
        {
            try
            {
                string      caseNo = this.dataGridView1.SelectedRows[0].Cells["colCaseNo"].Value.ToString();
                TraceEntity result = ws.DiscardIt(GlobalVar.IAUsername, GlobalVar.IAPassword, caseNo);

                if (string.IsNullOrEmpty(result.ErrorMsg))
                {
                    this.Invoke(new MethodInvoker(delegate()
                    {
                        MessageBox.Show(this, "作废成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.dataGridView1.SelectedRows[0].DefaultCellStyle.ForeColor = Color.Red;
                    }));
                }
                else
                {
                    this.Invoke(new MethodInvoker(delegate()
                    {
                        MessageBox.Show(this, result.ErrorMsg, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }));
                }
            }
            catch (Exception ee)
            {
                EagleString.EagleFileIO.LogWrite(ee.ToString());
            }

            this.Invoke(new MethodInvoker(delegate()
            {
                this.作废DToolStripMenuItem.Enabled = true;
                this.picLoading.Visible           = false;
            }));
        }
Example #12
0
        /// <summary>
        /// 退保
        /// </summary>
        /// <param name="policyNo"></param>
        /// <returns></returns>
        public TraceEntity Withdraw(WithdrawEntity entity)
        {
            TraceEntity result = new TraceEntity();

            result.ErrorMsg = "该产品仅支持退单。";
            return(result);
            //string ret = string.Empty;
            //try
            //{
            //    ret = webService.quitpolicy("hgy02", "hgy02", entity.PolicyNo);

            //    if (string.IsNullOrEmpty(ret))
            //        throw new Exception("WebService返回为空!");
            //    else
            //    {
            //        if (ret.Contains("已经退保"))
            //            return result;
            //        else
            //        {
            //            Common.LogIt("Huayubaoxian 退保:" + ret);
            //            result.ErrorMsg = ret;
            //            return result;
            //        }
            //    }
            //}
            //catch
            //{
            //    Common.LogIt(webService.Url);
            //    throw;
            //}
        }
Example #13
0
        public TraceEntity Withdraw(WithdrawEntity entity)
        {
            TraceEntity trace = new TraceEntity();

            trace.ErrorMsg = "该产品仅支持退单。";
            return(trace);
        }
Example #14
0
        public TraceEntity Validate(IssueEntity entity)
        {
            TraceEntity result = new TraceEntity();

            double age = (DateTime.Today - entity.Birthday).TotalDays / 365;

            if (age >= 20 && age <= 45)
            {
                if (!string.IsNullOrEmpty(entity.PhoneNumber))
                {
                    if (!Regex.IsMatch(entity.PhoneNumber, "^1[3458][0-9]{9}$"))
                    {
                        result.ErrorMsg = "请正确填写手机号码!";
                        return(result);
                    }
                }
                else
                {
                    result.ErrorMsg = "请填写手机号码!";
                    return(result);
                }
            }

            return(result);
        }
Example #15
0
        /// <summary>
        /// 退保
        /// </summary>
        /// <param name="policyNo"></param>
        /// <returns></returns>
        public TraceEntity Withdraw(WithdrawEntity entity)
        {
            TraceEntity result = new TraceEntity();

            string[] config = entity.IOC_Class_Parameters.Split(',');
            string   ret    = string.Empty;

            try
            {
                ret = webService.policyCancel(config[0], config[1], entity.PolicyNo);

                if (string.IsNullOrEmpty(ret))
                {
                    throw new Exception("西安奇易policyCancel返回为空!");
                }
            }
            catch
            {
                Common.LogIt(webService.Url);
                throw;
            }

            if (ret.Contains("撤销成功"))
            {
                return(result);
            }
            else
            {
                Common.LogIt("西安奇易policyCancel:" + ret);
                result.ErrorMsg = ret;
                return(result);
            }
        }
Example #16
0
        /// <summary>
        /// 退保(空函数,广州分公司在业务上不支持该功能)
        /// </summary>
        /// <param name="policyNo"></param>
        /// <returns></returns>
        public TraceEntity Withdraw(WithdrawEntity entity)
        {
            TraceEntity result = new TraceEntity();

            result.ErrorMsg = "该产品仅支持退单。";
            return(result);
        }
Example #17
0
        public override Task AddTraceAsync(TraceEntity traceEntity)
        {
            // Allocate dictionary for mapping instruction addresses to memory access hashes
            Dictionary <ulong, byte[]> instructionHashes = new Dictionary <ulong, byte[]>();

            // Hash all memory access instructions
            foreach (var traceEntry in traceEntity.PreprocessedTraceFile.Entries)
            {
                // Extract instruction and memory address
                ulong instructionAddress;
                ulong memoryAddress;
                switch (traceEntry.EntryType)
                {
                case TraceEntry.TraceEntryTypes.HeapMemoryAccess:
                {
                    var heapMemoryAccess = (TraceEntryTypes.HeapMemoryAccess)traceEntry;
                    instructionAddress = ((ulong)heapMemoryAccess.InstructionImageId << 32) | heapMemoryAccess.InstructionRelativeAddress;
                    memoryAddress      = ((ulong)heapMemoryAccess.MemoryAllocationBlockId << 32) | heapMemoryAccess.MemoryRelativeAddress;
                    break;
                }

                case TraceEntry.TraceEntryTypes.ImageMemoryAccess:
                {
                    var imageMemoryAccess = (TraceEntryTypes.ImageMemoryAccess)traceEntry;
                    instructionAddress = ((ulong)imageMemoryAccess.InstructionImageId << 32) | imageMemoryAccess.InstructionRelativeAddress;
                    memoryAddress      = ((ulong)imageMemoryAccess.MemoryImageId << 32) | imageMemoryAccess.MemoryRelativeAddress;
                    break;
                }

                case TraceEntry.TraceEntryTypes.StackMemoryAccess:
                {
                    var stackMemoryAccess = (TraceEntryTypes.StackMemoryAccess)traceEntry;
                    instructionAddress = ((ulong)stackMemoryAccess.InstructionImageId << 32) | stackMemoryAccess.InstructionRelativeAddress;
                    memoryAddress      = stackMemoryAccess.MemoryRelativeAddress;
                    break;
                }

                default:
                    continue;
                }

                // Update hash
                byte[] hash;
                if (!instructionHashes.TryGetValue(instructionAddress, out hash))
                {
                    hash = new byte[32];
                    instructionHashes.Add(instructionAddress, hash);
                }
                var hashSpan = hash.AsSpan();
                MemoryMarshal.Write(hashSpan, ref memoryAddress); // Will overwrite first 8 bytes of hash
                Blake2s.ComputeAndWriteHash(hashSpan, hashSpan);
            }

            // Store instruction hashes
            _testcaseInstructionHashes.AddOrUpdate(traceEntity.Id, instructionHashes, (t, h) => h);

            // Done
            return(Task.CompletedTask);
        }
Example #18
0
    /// <summary>
    /// 检查数据完整性
    /// </summary>
    /// <param name="entity"></param>
    /// <returns></returns>
    public static TraceEntity Validate(IssueEntity entity)
    {
        TraceEntity   result = new TraceEntity();
        IssuingFacade facade = new IssuingFacade();

        result = facade.Validate(entity);
        return(result);
    }
Example #19
0
        public TraceEntity Withdraw(WithdrawEntity entity)
        {
            TraceEntity result = new TraceEntity();

            RevokePolicy[] rp = new RevokePolicy[1];
            rp[0].certNo = entity.PolicyNo;
            string xmlRet = "";

            try
            {
                xmlRet = Withdraw(rp);
            }
            catch
            {
                Common.LogIt(url);
                throw;
            }

            try
            {
                if (string.IsNullOrEmpty(xmlRet))
                {
                    throw new Exception("平安退保返回为空!");
                }

                XmlDocument xd = new XmlDocument();
                xd.LoadXml(xmlRet);
                XmlNodeList nodes = xd.SelectNodes("Values/value");

                if (GetValue(nodes, "processFlag") == "1")
                {
                    return(result);
                }
                else
                {
                    Common.LogIt("平安退保返回:" + xmlRet);
                    string error = GetValue(nodes, "processMessage");
                    if (string.IsNullOrEmpty(error))
                    {
                        result.ErrorMsg = "未知错误";
                    }
                    else
                    {
                        result.ErrorMsg = error;
                    }
                    return(result);
                }
            }
            catch
            {
                if (!string.IsNullOrEmpty(xmlRet))
                {
                    Common.LogIt("平安退保返回:" + xmlRet);
                }
                throw;
            }
        }
Example #20
0
        public TraceEntity Validate(IssueEntity entity)
        {
            TraceEntity ret = new TraceEntity();

            //if (entity.EffectiveDate.Date == DateTime.Today)
            //{
            //    ret.ErrorMsg = "该产品不支持当日投保.";
            //}

            return(ret);
        }
Example #21
0
        public override async Task GenerateTraceAsync(TraceEntity traceEntity)
        {
            // Try to deduce trace file from testcase ID
            string rawTraceFilePath = Path.Combine(_inputDirectory.FullName, $"t{traceEntity.Id}.trace");

            if (!File.Exists(rawTraceFilePath))
            {
                await Logger.LogErrorAsync($"Could not find raw trace file for #{traceEntity.Id}.");

                throw new FileNotFoundException("Could not find raw trace file.", rawTraceFilePath);
            }

            traceEntity.RawTraceFilePath = rawTraceFilePath;
        }
Example #22
0
        /// <summary>
        /// 退保
        /// 注意可能返回该错误:“该保单尚未同步到核心系统,稍后退保”
        /// 永诚方面同步到核心系统的周期大约是5分钟
        /// </summary>
        /// <param name="certNo">保单号</param>
        /// <returns></returns>
        public TraceEntity Withdraw(WithdrawEntity entity)
        {
            TraceEntity result         = new TraceEntity();
            string      requestString  = GetWithdrawXML(entity.PolicyNo);
            string      responseString = GetResponse(requestString);

            result = ScanWithdrawResult(responseString);

            if (!string.IsNullOrEmpty(result.ErrorMsg))
            {
                Common.LogIt("永城接口 退保:" + responseString);
            }

            return(result);
        }
Example #23
0
        public override async Task <TraceEntity> NextTestcaseAsync(CancellationToken token)
        {
            // Create trace entity object
            var traceEntity = new TraceEntity
            {
                Id = _nextTestcaseNumber,
                TestcaseFilePath = _testcaseFileNames.Dequeue()
            };

            // Done
            await Logger.LogDebugAsync("Testcase #" + traceEntity.Id);

            ++_nextTestcaseNumber;
            return(traceEntity);
        }
Example #24
0
        public TraceEntity Withdraw(WithdrawEntity entity)
        {
            TraceEntity trace = new TraceEntity();

            return(trace);

            #region 邮件退保
            //string mailContent = "邮件内容";
            //string mailTo = config[4];//收件人地址

            //string mailFrom = "*****@*****.**";
            //string smtp = "smtp.gmail.com";
            //int smtpPort = 587;
            //string username = "******";
            //string password = "******";

            //MailMessage msg = new System.Net.Mail.MailMessage();
            //msg.To.Add(mailTo); //收件人

            ////发件人信息
            //msg.From = new MailAddress(mailFrom, "发送人姓名", System.Text.Encoding.UTF8);
            //msg.Subject = "这是测试邮件";   //邮件标题
            //msg.SubjectEncoding = System.Text.Encoding.UTF8;    //标题编码
            //msg.Body = mailContent; //邮件主体
            //msg.BodyEncoding = System.Text.Encoding.UTF8;
            //msg.IsBodyHtml = true;  //是否HTML
            //msg.Priority = MailPriority.High;   //优先级

            //SmtpClient client = new SmtpClient();
            ////设置邮箱账号和密码
            //client.Credentials = new System.Net.NetworkCredential(username, password);
            //client.Port = smtpPort;
            //client.Host = smtp;
            //client.EnableSsl = true;

            //try
            //{
            //    client.Send(msg);
            //}
            //catch (Exception ex)
            //{
            //    trace.ErrorMsg = "发送退保邮件失败(立刻保)!";
            //    trace.Detail = ex.ToString();
            //}
            //return trace;
            #endregion
        }
Example #25
0
        /// <summary>
        /// 扫描退保接口返回值
        /// </summary>
        /// <param name="xml"></param>
        /// <returns></returns>
        private static TraceEntity ScanWithdrawResult(string xml)
        {
            xml = xml.Trim();
            TraceEntity entity = new TraceEntity();

            if (string.IsNullOrEmpty(xml))
            {
                entity.ErrorMsg = "退保接口返回内容为空!";
                return(entity);
            }

            XmlDocument xd = new XmlDocument();

            try
            {
                xd.LoadXml(xml);
                XmlNode xn   = xd.SelectSingleNode("PACKET/HEAD/RESPONSECOMPLETEMESSAGESTATUS/MESSAGESTATUSCODE");
                string  code = xn.InnerText;

                if (code == "1")//成功!
                {
                    entity.Detail = xd.OuterXml;
                }
                else
                {
                    xn = xd.SelectSingleNode("PACKET/HEAD/RESPONSECOMPLETEMESSAGESTATUS/MESSAGESTATUSDESCRIPTION");
                    if (xn.InnerText.Contains("已退保"))
                    {
                        entity.Detail = xd.OuterXml;
                    }
                    else
                    {
                        entity.ErrorMsg = xn.InnerText;
                        entity.Detail   = xd.OuterXml;
                    }
                }
            }
            catch
            {
                entity.ErrorMsg = "解析退保接口返回xml字符串发生错误!";
                entity.Detail   = xml;
            }

            return(entity);
        }
Example #26
0
        /// <summary>
        /// 检查数据完整性
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public TraceEntity Validate(IssueEntity entity)
        {
            TraceEntity result = new TraceEntity();

            try
            {
                //注入实例
                instance = container.Resolve <IIssuing>(entity.IOC_Class_Alias);
            }
            catch (Exception e)
            {
                Common.LogIt(e.ToString());
                throw;
            }

            result = instance.Validate(entity);
            return(result);
        }
Example #27
0
        public TraceEntity Withdraw(WithdrawEntity entity)
        {
            TraceEntity result = new TraceEntity();

            WithdrawRequest req = new WithdrawRequest();

            string[] config = entity.IOC_Class_Parameters.Split(',');
            req.Username = config[0];
            req.Password = config[1];
            req.PolicyNo = entity.PolicyNo;
            req.CaseNo   = entity.CaseNo;
            string xml = Common.XmlSerialize <WithdrawRequest>(req);
            string ret = ws.Withdraw(xml);

            result = Common.XmlDeserialize <TraceEntity>(ret);

            return(result);
        }
Example #28
0
        public override async Task <TraceEntity> NextTestcaseAsync(CancellationToken token)
        {
            // Format argument string
            string testcaseFileName = $"{_nextTestcaseNumber}.testcase";
            string testcaseFilePath = Path.Combine(_outputDirectory.FullName, testcaseFileName);
            string args             = FormatCommand(_nextTestcaseNumber, testcaseFileName, testcaseFilePath);

            // Generate testcase
            ProcessStartInfo processStartInfo = new()
            {
                Arguments              = args,
                FileName               = _commandFilePath,
                WorkingDirectory       = _outputDirectory.FullName,
                UseShellExecute        = false,
                RedirectStandardInput  = true,
                RedirectStandardOutput = true,
                RedirectStandardError  = true,
                CreateNoWindow         = true
            };
            var process = Process.Start(processStartInfo);

            if (process == null)
            {
                throw new Exception("Could not start external command process.");
            }
            await process.StandardOutput.ReadToEndAsync();

            await process.StandardError.ReadToEndAsync();

            await process.WaitForExitAsync(token);

            // Create trace entity object
            var traceEntity = new TraceEntity
            {
                Id = _nextTestcaseNumber,
                TestcaseFilePath = testcaseFilePath
            };

            // Done
            await Logger.LogDebugAsync("Testcase #" + traceEntity.Id);

            ++_nextTestcaseNumber;
            return(traceEntity);
        }
Example #29
0
        public override async Task PreprocessTraceAsync(TraceEntity traceEntity)
        {
            // Try to deduce trace file from testcase ID
            string preprocessedTraceFilePath = Path.Combine(_inputDirectory.FullName, $"t{traceEntity.Id}.trace.preprocessed");

            if (!File.Exists(preprocessedTraceFilePath))
            {
                await Logger.LogErrorAsync($"Could not find preprocessed trace file for #{traceEntity.Id}.");

                throw new FileNotFoundException("Could not find preprocessed trace file.", preprocessedTraceFilePath);
            }

            traceEntity.PreprocessedTraceFilePath = preprocessedTraceFilePath;

            // Load trace
            var bytes = await File.ReadAllBytesAsync(preprocessedTraceFilePath);

            traceEntity.PreprocessedTraceFile = new TraceFile(_tracePrefix, bytes);
        }
Example #30
0
        public TraceEntity Send(SMSEntity entity)
        {
            TraceEntity result = new TraceEntity();

            //使用BASE64对用户名转码
            String userID = Convert.ToBase64String(System.Text.ASCIIEncoding.Default.GetBytes("bbfd"));
            //使用BASE64对密码转码
            String pwd = Convert.ToBase64String(System.Text.ASCIIEncoding.Default.GetBytes("bbfd123"));
            //使用BASE64对短信内容进行转码
            String smsContent = Convert.ToBase64String(System.Text.ASCIIEncoding.Default.GetBytes(entity.Content));

            //调用接口类中的send方法发送短信

            try
            {
                String ret = ws.send(userID, pwd, entity.MobilePhone, smsContent, "", "");

                switch (ret)
                {
                case "100":
                    break;

                case "102":
                    result.ErrorMsg = "用户或密码错误";
                    break;

                case "103":
                    result.ErrorMsg = "余额不足";
                    break;

                default:
                    result.ErrorMsg = "未知错误(系统异常)";
                    break;
                }
            }
            catch
            {
                Common.LogIt(ws.Url);
                throw;
            }

            return(result);
        }