public ActionResult Create(PSA datat) { // Check if all is ok? if (ModelState.IsValid) { // Go to new view, pass on info "PARAMETERPASSNING" return(View("Second", datat)); } else { // There is a validation error // Go back and check return(View()); } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog d = new OpenFileDialog { Filter = AnimationImporter.PSAFilter, Multiselect = false, CheckFileExists = true }; if (d.ShowDialog() == DialogResult.OK) { string path = d.FileName; psa = PSA.FromFile(path); CurrFile = path; RefreshTree(); } }
public async Task SignUp(IDialogContext context, IAwaitable <IMessageActivity> message, LuisResult result) { var messageToForward = await message; messageToForward.Text = result.Intents[0].Intent; EntityRecommendation er = new EntityRecommendation(); PSA psa = new PSA(); if (result.Entities.Count > 1) { await psa.Authenticate(false, result.Entities[1].Entity); } else { await psa.Authenticate(false, result.Entities[0].Entity); } var reply = context.MakeMessage(); reply.AttachmentLayout = AttachmentLayoutTypes.Carousel; reply.Attachments = PSA.attachments; // var message = activity.CreateReply(""); // message.Type = "message"; // message.Attachments = new List<Attachment>(); // var webClient = new WebClient(); // byte[] imageBytes = webClient.DownloadData("https://placeholdit.imgix.net/~text?txtsize=35&txt=image-data&w=120&h=120"); // string url = "data:image/png;base64," + Convert.ToBase64String(imageBytes) //message.Attachments.Add(new Attachment { ContentUrl = url, ContentType = "image/png" }); // await _client.Conversations.ReplyToActivityAsync(message); string title = reply.Attachments.Count > 1 ? "I found " + reply.Attachments.Count + " people with this first name": "Here's what I found"; if (reply.Attachments.Count == 0) { title = "Sorry! Couldn't find any one. Please try another name or check your name"; } await context.PostAsync(title); await context.PostAsync(reply, CancellationToken.None); }
private void button1_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); String fileName = openFileDialog1.FileName; search(fileName); Int32 row = 0; foreach (DataRow dr in ds.Tables["tbl"].Rows) { ++row; DataValues dataValue = new DataValues(); String plantName = dr[4].ToString(); String coopName = dr[3].ToString(); String coopAccrnym = dr[2].ToString(); String regionName = dr[1].ToString(); String areaName = dr[0].ToString(); Regions region = regionDataSession.getRegionByName(regionName); Plant plant = plantDataSession.getPlantByName(plantName); if (plant == null) { Cooperative coop = cooperativeDataSession.getCooperativeByName(coopName); if (coop == null) { if (region == null) { Area area = areaSessionData.getAreaByName(areaName); region = new Regions(regionName, area.areaId); coop = new Cooperative(coopName, coopAccrnym, region); } else { coop = new Cooperative(coopName, coopAccrnym, region.regionId); } plant = new Plant(plantName, coop); dataValue.plant = plant; } else { plant = new Plant(plantName, coop.cooperativeId); dataValue.plant = plant; } } else { Plant plantTemp = plantDataSession.getPlantByPlantNCoop(plantName, coopName); if (plantTemp == null) { var db = Dbase.getCurrentInstance(); Cooperative coop = cooperativeDataSession.getCooperativeByName(coopName); if (coop == null) { Regions regionTemp = regionDataSession.getRegionByName(regionName); if (regionTemp == null) { Area area = areaSessionData.getAreaByName(areaName); regionTemp = new Regions(regionName, area.areaId); db.regions.Add(regionTemp); db.SaveChanges(); } coop = new Cooperative(coopName, coopAccrnym, regionTemp.regionId); db.cooperatives.Add(coop); db.SaveChanges(); } Plant plantNew = new Plant(plantName, coop.cooperativeId); db.plants.Add(plantNew); db.SaveChanges(); dataValue.plantId = plantNew.plantId; } else { dataValue.plantId = plantTemp.plantId; } } dataValue.dataTypeId = dataTypeSessionData.getDataTypeByName(dr[8].ToString()).dataTypeId; using (var db = new Dbase()) { db.dataValues.Add(dataValue); db.SaveChanges(); PSA psa = new PSA(); ExcelUtil exc = new ExcelUtil(); exc.Open(fileName); exc.Worksheet("PSC_ECs"); foreach (PscEcsData kwh in psa.Kwh_Data) { DataContent content = new DataContent(); content.header = kwh.Name; //content.value = dr[Int32.Parse(kwh.Name) - 1999].ToString(); content.value = exc.ReadCell(kwh.Column + row); Console.WriteLine(row + " = " + content.value); content.dataValuesId = dataValue.dataValuesId; db.dataContents.Add(content); db.SaveChanges(); } } /* * dataValue.d2008 = Double.Parse("0" + dr[9].ToString()); * dataValue.d2009 = Double.Parse("0" + dr[10].ToString()); * dataValue.d2010 = Double.Parse("0" + dr[11].ToString()); * dataValue.d2011 = Double.Parse("0" + dr[12].ToString()); * dataValue.d2012 = Double.Parse("0" + dr[13].ToString()); * dataValue.d2013 = Double.Parse("0" + dr[14].ToString()); * dataValue.d2014 = Double.Parse("0" + dr[15].ToString()); * dataValue.d2015 = Double.Parse("0" + dr[16].ToString()); * dataValue.d2016 = Double.Parse("0" + dr[17].ToString()); * dataValue.d2017 = Double.Parse("0" + dr[18].ToString()); * dataValue.d2018 = Double.Parse("0" + dr[19].ToString()); * dataValue.d2019 = Double.Parse("0" + dr[20].ToString()); * dataValue.d2020 = Double.Parse("0" + dr[21].ToString()); * dataValue.d2021 = Double.Parse("0" + dr[22].ToString()); * dataValue.d2022 = Double.Parse("0" + dr[23].ToString()); */ using (var db = new Dbase()) { db.dataValues.Add(dataValue); db.SaveChanges(); } } Console.WriteLine("DONE!"); }
public void Pricing() { for (int i = 0; i < PRICES.Length; i++) { PILLAR_PUF[i] = new PointsUpFront(INDEX_COUPON, 1 - PRICES[i]); } int pos = 1; // target CDX is 5Y CDS targentCDX = CDX[pos]; int n = PILLAR_PUF.Length; double[] indexPUF = new double[n]; for (int i = 0; i < n; i++) { indexPUF[i] = PILLAR_PUF[i].getPointsUpFront(); } defaultedNames = new int[] { 2, 15, 37, 51 }; IntrinsicIndexDataBundle dataDefaulted = INTRINSIC_DATA.withDefault(defaultedNames); int accrualDays = targentCDX.getAccuredDays(); double accruedPremium = targentCDX.getAccruedPremium(INDEX_COUPON) * NOTIONAL * dataDefaulted.getIndexFactor(); /* * Using credit curves for constituent single name CDSs. * The curves are adjusted by using only the target CDX. */ IntrinsicIndexDataBundle adjCurves = PSA.adjustCurves(indexPUF[pos], CDX[pos], INDEX_COUPON, YIELD_CURVE, dataDefaulted); cleanPV = INDEX_CAL.indexPV(targentCDX, INDEX_COUPON, YIELD_CURVE, adjCurves) * NOTIONAL; dirtyPV = INDEX_CAL.indexPV(targentCDX, INDEX_COUPON, YIELD_CURVE, adjCurves, CdsPriceType.DIRTY) * NOTIONAL; // should be consistent with 1 - PRICES[pos] expectedLoss = INDEX_CAL.expectedDefaultSettlementValue(targentCDX.getProtectionEnd(), adjCurves) * NOTIONAL; cleanRPV01 = INDEX_CAL.indexAnnuity(targentCDX, YIELD_CURVE, adjCurves); dirtyRPV01 = INDEX_CAL.indexAnnuity(targentCDX, YIELD_CURVE, adjCurves, CdsPriceType.DIRTY); durationWeightedAverageSpread = INDEX_CAL.intrinsicIndexSpread(targentCDX, YIELD_CURVE, adjCurves) * TEN_THOUSAND; parallelIR01 = INDEX_CAL.parallelIR01(targentCDX, INDEX_COUPON, YIELD_CURVE, adjCurves) * NOTIONAL; double[] jumpToDefault = INDEX_CAL.jumpToDefault(targentCDX, INDEX_COUPON, YIELD_CURVE, adjCurves); for (int i = 0; i < jumpToDefault.Length; ++i) { jumpToDefault[i] *= NOTIONAL; } recovery01 = INDEX_CAL.recovery01(targentCDX, INDEX_COUPON, YIELD_CURVE, adjCurves); //Build Cash flow QLNet.UnitedStates cal = new QLNet.UnitedStates(); CdsCoupon[] coupons = targentCDX.getCoupons(); int npayments = coupons.Count(); cashflow = new List <CouponPayment>(); for (int i = 0; i < npayments; i++) { CouponPayment cf = new CouponPayment(); cf.Amount = (-coupons[i].getEffStart() + coupons[i].getEffEnd()) * NOTIONAL * INDEX_COUPON; cf.Amount = Math.Round(cf.Amount, 2); double days = coupons[i].getEffEnd() * 365; cf.CashFlowDate = i == 0? CdsAnalyticFactory.getNextIMMDate(TRADE_DATE): CdsAnalyticFactory.getNextIMMDate(cashflow[i - 1].CashFlowDate); cf.CashFlowDate = cal.adjust(cf.CashFlowDate); cashflow.Add(cf); } for (int i = 0; i < recovery01.Length; ++i) { recovery01[i] *= NOTIONAL; } }