static void Main(string[] args) { Console.WriteLine("enter a text:"); String text = Console.ReadLine(); Input input = new InputDto(); input.setValue(text); CollectionProcess process = new WordCountProcess(); CollectionPresenter presenter = new ConsoleWordCount(); ManageCollection manage = new ControllerCollection(process, presenter); manage.execute(input); }
static void Main(string[] args) { Console.WriteLine("Enter the name of the file:"); string fileName = Console.ReadLine(); InputDto inputDto = new InputDto(fileName); ManageInput manageInput = new FileController(inputDto); Output response = manageInput.execute(); ManageOutput manageOutput = new PresenterNetflixResponse(); manageOutput.execute(response); }
public ExcModel GetDatesForApi(InputDto data) { List <DateTime> dates = new List <DateTime>(); foreach (var date in data.Dates) { dates.Add(DateTime.Parse(date)); } return(new ExcModel { StarDate = dates.Min().ToString("yyyy-MM-dd"), EndDate = dates.Max().ToString("yyyy-MM-dd") }); }
public async Task <IResult <OutputDto> > DoSomething(InputDto input) { _logger.LogInformation("log inside DoSomething"); await _bus.Publish(new TestEvent() { Content = "event content" }); // return new Fail<OutputDto>(new Exception("test")); // throw new Exception("something went wrong"); var result = await _httpClientHelper.Get <OutputDto>("http://localhost:5000/api/internal/do-something"); return(new Success <OutputDto>(result)); }
public void execute(InputDto input) { String shapeName = input.ShapeName; if ((!shapeName.Equals(ApplicationConstants.ShapeName.RECTANGLE, StringComparison.InvariantCultureIgnoreCase) && !shapeName.Equals(ApplicationConstants.ShapeName.TRIANGLE, StringComparison.InvariantCultureIgnoreCase) && !shapeName.Equals(ApplicationConstants.ShapeName.SQUARE, StringComparison.InvariantCultureIgnoreCase)) ) { throw new InvalidShapeNameException(); } }
public IHttpActionResult CreateInput(InputDto inputDto) { if (!ModelState.IsValid) { return(BadRequest()); } var input = Mapper.Map <InputDto, Input>(inputDto); _context.Inputs.Add(input); _context.SaveChanges(); inputDto.Id = input.Id; return(Created(new Uri(Request.RequestUri + "/" + input.Id), inputDto)); }
public ScriptDto ScriptGeneration(InputDto inputDto) { var templateDto = templateRetriever.ReadingTemplates(); var scriptDto = new ScriptDto(); scriptDto.WeekRange = weekRangeCalculator.CalculateWeekRange(); //scriptDto.EventsScript = GenerateEvents(inputDto, templateDto); scriptDto.NewsScript = GenerateNews(inputDto, templateDto); scriptDto.MainScript = GenerateMain(inputDto, templateDto, scriptDto); return(scriptDto); }
public ScriptDto ScriptGeneration(InputDto inputDto) { var templateDto = templateRetriever.ReadingTemplates(); var scriptDto = new ScriptDto(); ReadingLongGeneration(inputDto, templateDto, scriptDto); ReadingShortGeneration(inputDto, templateDto, scriptDto); ListeningLongGeneration(inputDto, templateDto, scriptDto); ListeningShortGeneration(inputDto, templateDto, scriptDto); return(scriptDto); }
private void Operation(InputDto inputDto) { var operationType = Enumeration.FromDisplayName <CalculationOperationType>(inputDto.Input, isThrowException: true); try { var(result, history, resultMemberCount) = operationType.Calculator.Calculate(CalculationData); CalculationData = result; HistoricalData.Push(new HistoricalData(history, operationType.Name, resultMemberCount)); } catch (ParameterCountNotMatchExceptions e) { throw new ParameterCountNotMatchExceptions(string.Format(e.Message, inputDto.Index)); } }
public IResponseOutput GetAll(InputDto input) { var result = _userManager.GetAll(input.PageIndex, input.PageSize); IList <UserOutputDto> dtos = new List <UserOutputDto>(); foreach (var item in result) { dtos.Add(_mapper.Map <UserOutputDto>(item)); } var count = _userManager.Count(); var output = new UserListOutputDto { List = dtos, TotalPageSize = count }; return(new ResponseOutput <UserListOutputDto>(output)); }
/// <summary> /// PutTest /// </summary> /// <param name="request"></param> /// <returns></returns> public TestResult PutTest(InputDto request) { DateTimeOffset now = DateTimeOffset.Now; Guid gid = Guid.NewGuid(); var gbs = gid.ToByteArray(); TestResult tr = new TestResult() { Date = now.ToString(), Timestamp = now.ToUnixTimeMilliseconds(), Gid = gid.ToString("N"), Base64 = Base64UrlEncoder.Encode(gbs), Myid = NewId(), Input = request, }; return(tr); }
public void execute(InputDto input) { presenter = new ConsoleListPresenter(); inputAdapter = new InputAdapterDto(); String[] colors = input.Colors; String[] removeColors = input.Removecolors; List <String> listColors = convertToList(colors); List <String> listRemoveColors = convertToList(removeColors); addAdaptedListsToInputAdapter(inputAdapter, listColors, listRemoveColors); performOperation(ApplicationConstants.Operation.COMPLETED_LIST); performOperation(ApplicationConstants.Operation.REMOVED_LIST); }
private InputDto GetInputDto(StreamReader reader) { var inputDto = new InputDto(); inputDto.CountSupplier = int.Parse(reader.ReadLine()); inputDto.CountCustomers = int.Parse(reader.ReadLine()); inputDto.CountTicks = int.Parse(reader.ReadLine()); reader.ReadLine(); inputDto.MaxSendBySupplier = reader.ReadLine() .Split(' ', StringSplitOptions.RemoveEmptyEntries) .Select(x => int.Parse(x)) .ToArray(); reader.ReadLine(); inputDto.MaxSendBySupplierInTick = new Dictionary <int, int[]>(inputDto.CountSupplier); for (var i = 0; i < inputDto.CountSupplier; i++) { inputDto.MaxSendBySupplierInTick.Add(i, reader.ReadLine() .Split(' ', StringSplitOptions.RemoveEmptyEntries) .Select(x => int.Parse(x)) .ToArray()); } reader.ReadLine(); inputDto.MaxGetByCustomerInTick = new Dictionary <int, int[]>(inputDto.CountCustomers); for (var i = 0; i < inputDto.CountCustomers; i++) { inputDto.MaxGetByCustomerInTick.Add(i, reader.ReadLine() .Split(' ', StringSplitOptions.RemoveEmptyEntries) .Select(x => int.Parse(x)) .ToArray()); } reader.ReadLine(); inputDto.SupplierIdsForCustomer = new Dictionary <int, int[]>(inputDto.CountCustomers); for (var i = 0; i < inputDto.CountCustomers; i++) { inputDto.SupplierIdsForCustomer.Add(i, reader.ReadLine() .Split(' ', StringSplitOptions.RemoveEmptyEntries) .Select(x => int.Parse(x) - 1) .ToArray()); } return(inputDto); }
//PUT/api/input/1 public IHttpActionResult UpdateInput(int id, InputDto inputDto) { if (!ModelState.IsValid) { return(BadRequest()); } var inputInDb = _context.Supliers .SingleOrDefault(s => s.Id == id); if (inputInDb == null) { return(NotFound()); } Mapper.Map(inputDto, inputInDb); _context.SaveChanges(); return(Ok()); }
private string GenerateEvents(InputDto inputDto, TemplateDto templateDto) { var eventsList = PopulateEventList(inputDto.Events); StringBuilder eventsRowBuilder = new StringBuilder(); for (int i = 0; i < eventsList.Count; i++) { string style = string.Empty; if (eventsList[i].StyleIndex % 2 == 1) { style = oddRowStyle; } string row = string.Format(templateDto.EventsRowTemplate, style, eventsList[i].Day, eventsList[i].Event); eventsRowBuilder.Append(row); } string eventsScript = string.Format(templateDto.EventsTemplate, eventsRowBuilder.ToString()); return(eventsScript); }
static void Main(string[] args) { Console.WriteLine("Enter the value of the shape:"); string shapeName = Console.ReadLine(); Console.WriteLine("Enter the values of the sides, " + "separated by comma if it's necessary(square:1, rectangle:2, triangle:3):"); string sideValues = Console.ReadLine(); Console.WriteLine("Enter the operation:"); string operation = Console.ReadLine(); InputDto inputDto = new InputDto(shapeName, operation, sideValues); ManageInput manageInput = new ControllerShape(inputDto); OutputDto response = manageInput.execute(); ManageOutput manageOutput = new PresenterResponse(); manageOutput.execute(response); }
public void when_the_input_is_not_correct_then_it_should_return_an_error_response() { OutputDto expectedOutput = new OutputDto( "squar", ApplicationConstants.Operation.AREA, 0, ApplicationConstants.Status.ERROR, "The name of the shape is not valid"); InputDto inputDto = new InputDto("squar", "area", "2"); ManageInput manageInput = new ControllerShape(inputDto); OutputDto response = manageInput.execute(); Assert.IsNotNull(response); Assert.AreEqual(expectedOutput.Shape, response.Shape); Assert.AreEqual(expectedOutput.Operation, response.Operation); Assert.AreEqual(expectedOutput.ResponseStatus, response.ResponseStatus); Assert.AreEqual(expectedOutput.ValueResponse, response.ValueResponse); Assert.AreEqual(expectedOutput.Message, response.Message); }
public TestTableDto CreateTest(InputDto inputDto) { TestTable testTable = new TestTable() { FullName = inputDto.FullName, Address = inputDto.Address, Company = inputDto.Company, PhoneNum = inputDto.PhoneNum }; var a = _testTablerepository.Insert(testTable); var db = abpRedis.redisDb("10.12.2.61:6379"); db.StringSet("test1", testTable.ToJsonString()); return(new TestTableDto() { FullName = a.FullName, Address = a.Address, Company = a.Company, PhoneNum = a.PhoneNum }); }
public void when_the_input_is_correct_then_it_should_return_a_successfull_response() { OutputDto expectedOutput = new OutputDto( ApplicationConstants.ShapeName.SQUARE, ApplicationConstants.Operation.AREA, 4, ApplicationConstants.Status.SUCCESS, "Operation ran successfully"); InputDto inputDto = new InputDto("square", "area", "2"); ManageInput manageInput = new ControllerShape(inputDto); OutputDto response = manageInput.execute(); Assert.IsNotNull(response); Assert.AreEqual(expectedOutput.Shape, response.Shape); Assert.AreEqual(expectedOutput.Operation, response.Operation); Assert.AreEqual(expectedOutput.ResponseStatus, response.ResponseStatus); Assert.AreEqual(expectedOutput.ValueResponse, response.ValueResponse); Assert.AreEqual(expectedOutput.Message, response.Message); }
public void when_the_input_is_not_correct_then_it_should_return_an_error_response() { List <VialDto> list = new List <VialDto>(); list.Add(expectedVial); Output output = new OutputVialDto( new List <VialDto>(), ApplicationConstants.Status.ERROR, "The given file name does not exist"); OutputVialDto expectedOutput = (OutputVialDto)output; InputDto inputDto = new InputDto("starwars.csv"); ManageInput manageInput = new FileController(inputDto); Output result = manageInput.execute(); OutputVialDto resultOutput = (OutputVialDto)result; Assert.IsNotNull(result); Assert.AreEqual(expectedOutput.getResponseStatus(), resultOutput.getResponseStatus()); Assert.AreEqual(expectedOutput.getMessage(), resultOutput.getMessage()); }
public async Task <OutPutDTO> GetWeatherAsync(InputDto input) { OutPutDTO model = new OutPutDTO(); // get city info string cityApiUrl = WeatherConst.HefengApiUrl + $"v2/city/lookup?location={input.City}&mode=fuzzy&key={input.Token}&gzip=n"; var client = _clientFactory.CreateClient(); var request = new HttpRequestMessage(HttpMethod.Get, cityApiUrl); var response = await client.SendAsync(request); if (response.IsSuccessStatusCode) { JObject cityObj = JObject.Parse(await response.Content.ReadAsStringAsync()); model.CityId = cityObj["location"][0]["id"].ToString(); model.CityName = cityObj["location"][0]["name"].ToString(); model.H5Url = $"https://widget-page.heweather.net/h5/index.html?bg=1&md=012345&lc={model.CityId}&key={input.Token}"; string nowApiUrl = $"https://devapi.heweather.net/v7/weather/now?location={model.CityId}&key={input.Token}&gzip=n"; var requestNow = new HttpRequestMessage(HttpMethod.Get, nowApiUrl); var responseNow = await client.SendAsync(requestNow); if (responseNow.IsSuccessStatusCode) { JObject _objectNow = JObject.Parse(await responseNow.Content.ReadAsStringAsync()); model.Text = _objectNow["now"]["text"].ToString(); model.FeelsLike = Convert.ToDouble(_objectNow["now"]["feelsLike"].ToString()); model.Humidity = Convert.ToDouble(_objectNow["now"]["humidity"].ToString()); } } return(model); }
public void when_the_name_of_the_file_is_null_then_throw_exception() { InputDto input = new InputDto(null); input.callValidations(); }
public IActionResult UrlSimilaritySubSemanticCalculate(InputDto input) { input.webSitePool.ForEach(p => p = _indexerService.WebSiteCalculate(p).Data); return(Ok(_indexerService.UrlSimilarityWithSemanticCalculate(_indexerService.WebSiteCalculate(input.webSite).Data, input.webSitePool))); }
public ActionResult Put(InputDto model) { return(Ok()); }
public ControllerShape(InputDto inputDto) { this.inputAdapterDto = new InputAdapterDto(); this.inputDto = inputDto; }
public Task <TestResult> PutTest([FromBody] InputDto request) { var tr = _manager.PutTest(request); return(Task.FromResult(tr)); }
//Stage Four - Ranking of a url with sub urls and url set with sub urls similarity public IDataResult <UrlSimilaritySubWebSiteDto> UrlSimilarityWithSubCalculate(WebSite webSite, List <WebSite> webSitePool) { //Sub Url Tree globalList = new List <WebSite>(); foreach (var item in webSitePool) { globalList.Add(item); } globalList.Add(webSite); List <UrlTreeDto> tempUrlTree = new List <UrlTreeDto>(); webSitePool.ForEach(p => tempUrlTree.Add(_webSiteOperation.SubUrlFinder(p, globalList).Data)); //Adding sub urls to webSitePool List <WebSite> tempSubUrls = new List <WebSite>(); webSitePool.ForEach(p => { p.SubUrls.ForEach(l => { tempSubUrls.Add(l); l.SubUrls.ForEach(m => { tempSubUrls.Add(m); }); }); }); webSitePool = webSitePool.Concat(tempSubUrls).ToList(); //Similarity calculating InputDto input = _keywordOperation.SimilarityCalculate(webSite, webSitePool, true).Data; //Return Object KeywordWebSiteDto tempWebSite = new KeywordWebSiteDto { Url = input.webSite.Url, Title = input.webSite.Title, Keywords = input.webSite.Keywords }; List <SimilarityScoreDto> tempWebSitesPool = new List <SimilarityScoreDto>(); input.webSitePool.ForEach(p => { tempWebSitesPool.Add(new SimilarityScoreDto { SimilarityScore = p.SimilarityScore, webSite = new KeywordWebSiteDto { Url = p.Url, Title = p.Title, Keywords = p.Keywords, } }); }); return(new SuccessDataResult <UrlSimilaritySubWebSiteDto>( data: new UrlSimilaritySubWebSiteDto { webSite = tempWebSite, webSitePool = tempWebSitesPool, UrlTree = tempUrlTree } )); }
//Stage Five - Stage four and Semantic Analysis public IDataResult <UrlSimilaritySubSemanticWebSiteDto> UrlSimilarityWithSemanticCalculate(WebSite webSite, List <WebSite> webSitePool) { globalList = new List <WebSite>(); foreach (var item in webSitePool) { globalList.Add(item); } globalList.Add(webSite); //Sub Url Tree List <UrlTreeDto> tempUrlTree = new List <UrlTreeDto>(); webSitePool.ForEach(p => tempUrlTree.Add(_webSiteOperation.SubUrlFinder(p, globalList).Data)); //Adding sub urls to webSitePool List <WebSite> tempSubUrls = new List <WebSite>(); webSitePool.ForEach(p => { p.SubUrls.ForEach(l => { tempSubUrls.Add(l); l.SubUrls.ForEach(m => { tempSubUrls.Add(m); }); }); }); webSitePool = webSitePool.Concat(tempSubUrls).ToList(); //Semantic keyword generate List <SemanticWordJsonDto> Dictionary = InMemoryGlobalSemanticWordDal.GetGlobalSemanticWordList(); webSite = _keywordOperation.SemanticKeywordGeneratorForTarget(webSite, ref Dictionary).Data; //Similarity calculating InputDto input = _keywordOperation.SimilarityCalculate(webSite, webSitePool, true, true).Data; //Return Object KeywordWebSiteDto tempWebSite = new KeywordWebSiteDto { Url = input.webSite.Url, Title = input.webSite.Title, Keywords = input.webSite.Keywords }; List <SimilarityScoreSemanticDto> tempWebSitesPool = new List <SimilarityScoreSemanticDto>(); input.webSitePool.ForEach(p => { tempWebSitesPool.Add(new SimilarityScoreSemanticDto { SimilarityScore = p.SimilarityScore, webSite = new KeywordWebSiteSemanticDto { Url = p.Url, Title = p.Title, Keywords = p.Keywords, SemanticKeywords = p.SemanticKeywords } }); }); return(new SuccessDataResult <UrlSimilaritySubSemanticWebSiteDto>( data: new UrlSimilaritySubSemanticWebSiteDto { webSite = tempWebSite, webSitePool = tempWebSitesPool, UrlTree = tempUrlTree })); }
private void button1_Click(object sender, EventArgs e) { //编号 4位,防止主键重复 var randNo = int.Parse(txtNo.Text.Trim()); //单据日期 var date = DateTime.Parse(txtDate.Text.Trim()); var dateStr = $"{date:yyyy-MM-dd}"; var endDate = new DateTime(date.Year, date.Month, 1).AddMonths(1).AddDays(-1); var input = new InputDto() { BillDate = date, Dwbm = "1009", DwbmParentId = "1002", DwbmCode = "SZN", NoTaxMoney = decimal.Parse(txtTotalMoney.Text.Trim()), RandNo = randNo, TaxRate = 13, Creator = "000166100000001HGVJC", DanJuNum = 5, HuiLv = 1, }; input.YFVouchid = $"{input.Dwbm}66{input.BillDate:yyyyMMdd}{randNo}FE"; input.FKVouchid = $"{input.Dwbm}{input.BillDate:yyyyMMdd}{randNo}EF"; input.FKBillNo = $"FK{input.DwbmCode}{date:yyMMdd}0{randNo}"; var settlementKey = $"{input.Dwbm}66{input.BillDate:yyyyMMdd}{randNo}AF"; //100966100000000SLAV3 //物料价格明细 var goodsList = GetGoodsCost(input); input.GoodsList = goodsList; #region param var _last = $"{input.BillDate:yyyyMMdd}{input.RandNo}"; //无税总额 保留两位小数 var noTaxTotal = input.NoTaxMoney; //税率 var shuilv = input.TaxRate; //kslb 扣税类别 1:应税外加 (TODO://0:应税内含 2:不计税) var kslb = 1; //dwbm 单位编码 1107 => 采云 [组织架构表.UniqueCode] 1009 深圳智能 var dwbm = input.Dwbm; //含税金额 var taxTotal = goodsList.Sum(x => x.TaxTotal); var taxTotalStr = $"{taxTotal:F2}"; //Math.Round(taxTotal, 2, MidpointRounding.AwayFromZero) //汇率 var huilv = input.HuiLv; //币种编码 var bizhong = "00010000000000000001"; //ywbm 单据类型 select djlxoid from arap_djlx where djdl='yf' and DJLXBM='D1' and DWBM='[公司账套编码]' and dr = 0; var ywbm_yf = "0001O11000000002CUYJ"; var ywbm_fk = "0001O11000000002TBQ5"; //采购部门 deptid 部门pk 部门.UniqueCode 1009O1100000000GCYO1 var deptid = "1009O1100000000GCYO1"; //附件 发票数量 var fjNum = input.DanJuNum; //录入人 000166100000001HGVJC => 采云 配置:NCOption.DZCreator var creator = "000166100000001HGVJC"; //其他_备注 var otherRemark = "其他_备注"; //提单地编号 0001O1100000000FMC20 = 深圳 var address = "0001O1100000000FMC20"; //是否研发 0001O11000000002S8KN 否( 0001O11000000002S8KM是) var yafa = "0001O11000000002S8KN"; //报销金额 var baoxiaoJinE = taxTotal; //100966100000000SLB87 var yf_vouchid = input.YFVouchid; var fk_vouchid = input.FKVouchid; var yfDanJuHao = $"YF{date:yyMMdd}{randNo}"; //付款单单据号 var fkDanJuHao = input.FKBillNo; //报销事由 var bxsy = $"报销事由:vouchid={yf_vouchid}"; //前期已付款 zyx7 var yifu = 0; //hbbm 伙伴编码,客商编码 => 采云 供应商.SupplierNCPK 0001O1100000000209N1 var hbbm = "0001O1100000000209N1"; //jobid 专项基本档案id NULL 0001O11000000002KEVV var jobid = "NULL"; //ywybm 业务员pk select * from bd_psndoc where pk_psndoc ='000166100000001HTLUV' => 采云 EmployeeLatestInfo.UniqueCode var ywybm = "1009A8100000000001DK"; //摘要 var zy = "SHL 华强方特(深圳)互联科技有限公司 | WHHQZN-024 1号仓库 | 芜湖市鸠江区赤铸山东路华强文化科技产业园动漫楼芜湖智能工厂 | 谢嗣峰 | 17775298975"; //======付款单===== //合同金额 结算金额 var hetongjine = taxTotal; //前期已报销 var yibaoxiao = 0; //实付金额 var shifujine = taxTotal; //付款协议主键 zyx30 0001O110000000008L57(关联付款协议表bd_payterm主键)=> 采云 SupplierPaymentWay表.NCPK var fukuanxieyi = "0001O110000000008L4S"; //输入合同号 合同号 var contractno = "21010569"; //订单号 var ddh = ""; //供应商 付款银行名称 var bankName = "工商银行安溪县支行"; var bankNumber = "11076610000000009NES"; //银行账户信息主键 //对方账户主键 var gongYingShangBankKey = "0001O110000000020CXC"; //fph 发票维护单据号 My_FaPiaoWeiHu_003 var fph = $"My_FaPiaoWeiHu_{randNo}"; //结算主键 var pk_settlement = $"C-JS{_last}"; //setlleno 结算号 CMP@210125000005 var setlleno = $"CMP@{DateTime.Now:yyMMdd}{randNo}"; //0001O11000000008F0B7 var F0B7 = "0001O11000000008F0B7"; #endregion var sb = new StringBuilder(); #region 应付单 主表sql sb.AppendLine(@$ " -- 应付单 主表 INSERT INTO arap_djzb ( bbje, djbh, djdl, djkjnd, djkjqj, djlxbm, djrq, djzt, dr, dwbm, effectdate, fbje, fj, hzbz, lrr, lybz, prepay , pzglh, qcbz, scomment, sxbz, vouchid , xslxbm, ybje, ywbm, zyx10, zyx11, zyx12, zyx17, zyx4, zyx6, zyx7 , zyx8, zyx9, zzzt, zgyf, isselectedpay, isnetready, isjszxzf, isreded ,ts ) VALUES ( {taxTotalStr} -- bbje 本币金额 , '{yfDanJuHao}' -- djbh 单据编号 C-YF2101210005
public void when_input_is_correct_then_validations_run_successfully() { InputDto input = new InputDto("vial-test.csv"); input.callValidations(); }