private bool GenerateInvoice(EightHundredEntities context, tbl_Job job, Guid userId) { ClearJobTasks(context, job.JobID); UpdatePaymentsInJob(context, job.JobID); var jsonData = context.tbl_HVAC_Answers.Single( item => item.tbl_HVAC_CustomersAnswers.JobID == job.JobID && item.tbl_HVAC_CustomersAnswers.UserID == userId && item.QuestionID == 35).Data; /*{"Jobs": * [ [ * {"Count":"1","JobCode":"LE-HPAH136","Description":"asd","ResAccountCode":"41000","Price":7380,"TotalPrice":"$7,380.00", * "Parts": * [ * {"PartCost":3690,"PartCode":"LE-HPAH136","PartName":"LE-3 Ton Air Handler Electric Heat - 10KW","PartStdPrice":7380,"PartID":503085,"Qty":1} * ],"id":1337316467855}, * {"Count":"1","JobCode":"LE-HPAH136","Description":"asd3","ResAccountCode":"41000","Price":7380,"TotalPrice":"$7,380.00", * "Parts": * [ * {"PartCost":3690,"PartCode":"LE-HPAH136","PartName":"LE-3 Ton Air Handler Electric Heat - 10KW","PartStdPrice":7380,"PartID":503085,"Qty":2,"TotalPrice":"$14,760.00"} * ],"id":1337316467857}, * {"id":"ACC-CMF001","isAccessory":true,"Code":"ACC-CMF001","JobCode":"ACC-CMF001","Description":"1\" Charged Media Filter, 20 x 25","ResAccountCode":"41000","Count":1,"Price":895,"TotalPrice":"$895.00"}, * {"id":"ACC-HUM001","isAccessory":true,"Code":"ACC-HUM001","JobCode":"ACC-HUM001","Description":"Humidifier","ResAccountCode":"41000","Count":3,"Price":595,"TotalPrice":"$1,785.00"} * ], * "MainSystem":{"Parts":[{"PartCost":3690,"PartCode":"LE-HPAH136","PartName":"LE-3 Ton Air Handler Electric Heat - 10KW","PartStdPrice":7380,"PartID":503085,"Qty":1}],"TotalPrice":7380,"id":"LE","AFUE":"80","SEER":"12","JobCodeId":0,"JobCode":"LE-HPAH136","ResAccountCode":"41000","Description":"SEER Rating 12, AFUE 80, LE-3 Ton Air Handler Electric Heat - 10KW","Count":1,"Price":7380},"TotalAmount":24820,"Tax":0,"GrandTotal":24820,"TaxRate":0} */ //{"Jobs":[{"Count":"1","Description":"SEER Rating 16, AFUE 29, SE-2.5 Ton Gas Furnace Vertical","Price":12488,"TotalPrice":"$12,488.00","Parts":[{"PartCost":6244,"PartCode":"SE-HPGFV30","PartName":"SE-2.5 Ton Gas Furnace Vertical","PartStdPrice":12488,"PartID":503287,"Qty":1}],"id":1331745863188},{"id":"ACC-CMF001","isAccessory":true,"Code":"ACC-CMF001","Description":"1\" Charged Media Filter, 20 x 25","Count":1,"Price":895,"TotalPrice":"$895.00"},{"Count":"1","Description":"SEER Rating 16, AFUE 29, SE-2.5 Ton Gas Furnace Vertical","Price":12488,"TotalPrice":"$12,488.00","Parts":[{"PartCost":6244,"PartCode":"SE-HPGFV30","PartName":"SE-2.5 Ton Gas Furnace Vertical","PartStdPrice":12488,"PartID":503287,"Qty":1}],"id":1331745863190}],"MainSystem":{"Parts":[{"PartCost":6244,"PartCode":"SE-HPGFV30","PartName":"SE-2.5 Ton Gas Furnace Vertical","PartStdPrice":12488,"PartID":503287,"Qty":1}],"TotalPrice":12488,"id":"SE","AFUE":"29","SEER":"16","JobCodeId":0,"JobCode":"SE-HPGFV30","Description":"SEER Rating 16, AFUE 29, SE-2.5 Ton Gas Furnace Vertical","Count":1,"Price":12488},"TotalAmount":25871,"Tax":0,"GrandTotal":25871,"TaxRate":0} //var jsonData = "{\"Jobs\":[" + // "{\"JobCode\":\"SE-HPGFV30\",\"Count\":\"1\",\"Description\":\"SEER Rating 16, AFUE 29, SE-2.5 Ton Gas Furnace Vertical\",\"Price\":12488,\"TotalPrice\":\"$12,488.00\",\"Parts\":[{\"PartCost\":6244,\"PartCode\":\"SE-HPGFV30\",\"PartName\":\"SE-2.5 Ton Gas Furnace Vertical\",\"PartStdPrice\":12488,\"PartID\":503287,\"Qty\":1}],\"id\":1331745863188}," + // "{\"id\":\"ACC-CMF001\",\"isAccessory\":true,\"Code\":\"ACC-CMF001\",\"JobCode\":\"ACC-CMF001\",,\"Description\":\"1\\\" Charged Media Filter, 20 x 25\",\"Count\":1,\"Price\":895,\"TotalPrice\":\"$895.00\"}," + // "{\"JobCode\":\"SE-HPGFV30\",\"Count\":\"1\",\"Description\":\"SEER Rating 16, AFUE 29, SE-2.5 Ton Gas Furnace Vertical\",\"Price\":12488,\"TotalPrice\":\"$12,488.00\",\"Parts\":[{\"PartCost\":6244,\"PartCode\":\"SE-HPGFV30\",\"PartName\":\"SE-2.5 Ton Gas Furnace Vertical\",\"PartStdPrice\":12488,\"PartID\":503287,\"Qty\":1}],\"id\":1331745863190}]," + // "\"MainSystem\":{\"Parts\":[{\"PartCost\":6244,\"PartCode\":\"SE-HPGFV30\",\"PartName\":\"SE-2.5 Ton Gas Furnace Vertical\",\"PartStdPrice\":12488,\"PartID\":503287,\"Qty\":1}],\"TotalPrice\":12488,\"id\":\"SE\",\"AFUE\":\"29\",\"SEER\":\"16\",\"JobCodeId\":0,\"JobCode\":\"SE-HPGFV30\",\"Description\":\"SEER Rating 16, AFUE 29, SE-2.5 Ton Gas Furnace Vertical\",\"Count\":1,\"Price\":12488}," + // "\"TotalAmount\":25871," + // "\"Tax\":0," + // "\"GrandTotal\":25871," + // "\"TaxRate\":0}"; //var jsonData33 = context.tbl_HVAC_Answers.Single( // item => // item.tbl_HVAC_CustomersAnswers.JobID == jobId && item.tbl_HVAC_CustomersAnswers.UserID == userId && // item.QuestionID == 33).Data; var prMainJobs = DeserialiseMainJobs(jsonData); var prAccessories = DeserialiseAccessoriesJobs(jsonData); SetJobTasks(context, prMainJobs, prAccessories); var pr = JSONHelper.Deserialise <PriceListModel <SystemInfoModelWithParts> >(jsonData); job.SubTotal = decimal.Parse(pr.TotalAmount); job.TaxAmount = decimal.Parse(pr.Tax); job.TotalSales = decimal.Parse(pr.GrandTotal); context.SaveChanges(); return(true); }
private Answer33 GetValue(EightHundredEntities context, int jobId) { var userId = GetUserID(); var jsonData = context.tbl_HVAC_Answers.Single( item => item.tbl_HVAC_CustomersAnswers.JobID == jobId && item.tbl_HVAC_CustomersAnswers.UserID == userId && item.QuestionID == 33).Data; var hvacPayments = JSONHelper.Deserialise <Answer33>(jsonData); return(hvacPayments); }
protected void Page_Load(object sender, EventArgs e) { GoogleSearchResults g1 = new GoogleSearchResults(); const string json = @"{""responseData"": {""results"":[{""GsearchResultClass"":""GwebSearch"",""unescapedUrl"":""http://www.cheese.com/"",""url"":""http://www.cheese.com/"",""visibleUrl"":""www.cheese.com"",""cacheUrl"":""http://www.google.com/search?q\u003dcache:bkg1gwNt8u4J:www.cheese.com"",""title"":""\u003cb\u003eCHEESE\u003c/b\u003e.COM - All about \u003cb\u003echeese\u003c/b\u003e!."",""titleNoFormatting"":""CHEESE.COM - All about cheese!."",""content"":""\u003cb\u003eCheese\u003c/b\u003e - everything you want to know about it. Search \u003cb\u003echeese\u003c/b\u003e by name, by types of milk, by textures and by countries.""},{""GsearchResultClass"":""GwebSearch"",""unescapedUrl"":""http://en.wikipedia.org/wiki/Cheese"",""url"":""http://en.wikipedia.org/wiki/Cheese"",""visibleUrl"":""en.wikipedia.org"",""cacheUrl"":""http://www.google.com/search?q\u003dcache:n9icdgMlCXIJ:en.wikipedia.org"",""title"":""\u003cb\u003eCheese\u003c/b\u003e - Wikipedia, the free encyclopedia"",""titleNoFormatting"":""Cheese - Wikipedia, the free encyclopedia"",""content"":""\u003cb\u003eCheese\u003c/b\u003e is a food consisting of proteins and fat from milk, usually the milk of cows, buffalo, goats, or sheep. It is produced by coagulation of the milk \u003cb\u003e...\u003c/b\u003e""},{""GsearchResultClass"":""GwebSearch"",""unescapedUrl"":""http://www.ilovecheese.com/"",""url"":""http://www.ilovecheese.com/"",""visibleUrl"":""www.ilovecheese.com"",""cacheUrl"":""http://www.google.com/search?q\u003dcache:GBhRR8ytMhQJ:www.ilovecheese.com"",""title"":""I Love \u003cb\u003eCheese\u003c/b\u003e!, Homepage"",""titleNoFormatting"":""I Love Cheese!, Homepage"",""content"":""The American Dairy Association\u0026#39;s official site includes recipes and information on nutrition and storage of \u003cb\u003echeese\u003c/b\u003e.""},{""GsearchResultClass"":""GwebSearch"",""unescapedUrl"":""http://www.gnome.org/projects/cheese/"",""url"":""http://www.gnome.org/projects/cheese/"",""visibleUrl"":""www.gnome.org"",""cacheUrl"":""http://www.google.com/search?q\u003dcache:jvfWnVcSFeQJ:www.gnome.org"",""title"":""\u003cb\u003eCheese\u003c/b\u003e"",""titleNoFormatting"":""Cheese"",""content"":""\u003cb\u003eCheese\u003c/b\u003e uses your webcam to take photos and videos, applies fancy special effects and lets you share the fun with others. It was written as part of Google\u0026#39;s \u003cb\u003e...\u003c/b\u003e""}],""cursor"":{""pages"":[{""start"":""0"",""label"":1},{""start"":""4"",""label"":2},{""start"":""8"",""label"":3},{""start"":""12"",""label"":4},{""start"":""16"",""label"":5},{""start"":""20"",""label"":6},{""start"":""24"",""label"":7},{""start"":""28"",""label"":8}],""estimatedResultCount"":""14400000"",""currentPageIndex"":0,""moreResultsUrl"":""http://www.google.com/search?oe\u003dutf8\u0026ie\u003dutf8\u0026source\u003duds\u0026start\u003d0\u0026hl\u003den-GB\u0026q\u003dcheese""}}, ""responseDetails"": null, ""responseStatus"": 200}"; g1 = JSONHelper.Deserialise <GoogleSearchResults>(json); foreach (Pages x in g1.responseData.cursor.pages) { // Anything you want to get Response.Write(x.label); } }
public ActionResult SendInvoiceByEmail() { var jobId = GetJobCode(); var context = new EightHundredEntities(); var userId = GetUserID(); var jsonData33 = context.tbl_HVAC_Answers.Single( item => item.tbl_HVAC_CustomersAnswers.JobID == jobId && item.tbl_HVAC_CustomersAnswers.UserID == userId && item.QuestionID == 33).Data; var em = JSONHelper.Deserialise <EmailClass>(jsonData33); if (SendInvoiceByEmail(em, userId, jobId).Success) { return(Json(new { result = true })); } return(Json(new { result = false })); }
public async Task <IActionResult> ULogin() { string link = string.Format("http://ulogin.ru/token.php?token={0}&host={1}", Request.Form["token"], Request.Host); Console.WriteLine(link); WebRequest reqGET = WebRequest.Create(link); string answer = ""; using (WebResponse resp = reqGET.GetResponse()) { using (Stream stream = resp.GetResponseStream()) { if (stream != null) { using (StreamReader sr = new StreamReader(stream)) { answer = sr.ReadToEnd(); Console.WriteLine(answer); } } } } if (!string.IsNullOrWhiteSpace(answer)) { var user = JSONHelper.Deserialise <ULoginUser>(answer); if (user != null) { var appUser = new ApplicationUser { Email = user.Email, UserName = $"{user.FirstName} {user.LastName}", SecurityStamp = user.Uid, }; await _signInManager.SignInAsync(appUser, true); } } return(RedirectToAction(nameof(HomeController.Index), "Home")); }
public void GetLatestMovie() { var url = "https://api.themoviedb.org/3/movie/upcoming?api_key=" + Config.ApiKey + "&language=en-US"; var syncClient = new WebClient(); string content = syncClient.DownloadString(url); MovieResults mr = new MovieResults(); // Create the Json serializer and parse the movie results response mr = JSONHelper.Deserialise <MovieResults>(content); var movieData = mr.results.FirstOrDefault(); //to get the first item of the results and parse m = new Movie(); m.id = movieData.id; m.overview = movieData.overview; m.title = movieData.title; m.poster_path = movieData.poster_path; if (MovieDbOps.checkValueExists(movieData.id)) { System.Diagnostics.Debug.WriteLine("Already Posted on Fb"); } else { MovieDbOps.UploadDbContent(m.id, m.title); System.Diagnostics.Debug.WriteLine("Data saved in db"); var videoUrl = "https://api.themoviedb.org/3/movie/" + m.id + "/videos?api_key=" + Config.ApiKey + "&language=en-US"; string videoContent = syncClient.DownloadString(videoUrl); VideoResults vr = new VideoResults(); // Create the Json serializer and parse the videourl response vr = JSONHelper.Deserialise <VideoResults>(videoContent); var videoData = vr.results.FirstOrDefault(); string videoKey = "https://www.youtube.com/watch?v=" + videoData.key.ToString(); PostOnFb(m, videoKey); } }
private IEnumerable <AccessoryModel> DeserialiseAccessoriesJobs(string jsonData) { var temp = JSONHelper.Deserialise <PriceListModel <AccessoryModel> >(jsonData); return(temp.Jobs.Where(i => !String.IsNullOrEmpty(i.Code)).ToArray()); }
private IEnumerable <SystemInfoModelWithParts> DeserialiseMainJobs(string jsonData) { var temp = JSONHelper.Deserialise <PriceListModel <SystemInfoModelWithParts> >(jsonData); return(temp.Jobs.Where(job => job.Parts.Count != 0).ToArray()); }
public MutualFundCalculator(String fundName, List <MutualFundView> transactions, Boolean isOpenFund, DateTime last12Start, InvestmentEntities entities) { FundName = fundName; if (ValueToday == null && isOpenFund) { var mutualFund = entities.MutualFunds.Single(mf => mf.MutualFundSymbol == fundName); if (mutualFund.IsGoogleTracked) { //http://ichart.yahoo.com/table.csv?s=FSDIX&a=2&b=1&c=2013&d=2&e=1&f=2014&g=d&ignore=.csv a=Month-1, b=day, c=year (d, e, f = m,d,y end date) String url = "http://finance.google.com/finance/info?client=ig&q=" + fundName; WebRequest request = WebRequest.Create(url); WebResponse response = request.GetResponse(); String responseString = ""; using (Stream stream = response.GetResponseStream()) { using (StreamReader answer = new StreamReader(stream)) { responseString = answer.ReadToEnd(); } } ValueToday = JSONHelper.Deserialise <GoogleResults>(responseString); } else { GoogleResults r = new GoogleResults(); r.l = mutualFund.LastKnownValue.ToString(); ValueToday = r; } } Decimal todaysValue = !isOpenFund?transactions.OrderByDescending(t => t.TransactionDate).First().PricePerShare : Decimal.Parse(ValueToday.l); CurrentValue = todaysValue * transactions.Sum(i => i.NumberOfShares); Investments = transactions.Where(i => i.ReturnType == "Investment").Sum(i => i.Amount); Gains = transactions.Where(i => i.ReturnType != "Investment").Sum(i => i.Amount); FirstPurchase = transactions.OrderBy(i => i.TransactionDate).First().TransactionDate; Dictionary <DateTime, Double> allTransactions = new Dictionary <DateTime, double>(); foreach (MutualFundView fund in transactions) { if (fund.ReturnType == "Investment") { allTransactions.Add(fund.TransactionDate, Convert.ToDouble(fund.Amount)); if (fund.TransactionDate > last12Start) { TransactionsLast12.Add(fund.TransactionDate, Convert.ToDouble(fund.Amount)); } } } try { ROI = Convert.ToDecimal(Calculations.IRR.solveIRR(allTransactions, Convert.ToDouble(CurrentValue), 1, 1000, DateTime.Now)); if (allTransactions.Count == TransactionsLast12.Count) { ROILast12 = ROI; Last12Valid = true; } else { MutualFundPriceHistory historicalPrice = entities.MutualFundPriceHistories.SingleOrDefault(h => h.MutualFundSymbol == fundName && h.QuoteDate == last12Start); if (historicalPrice != null) { Decimal numberOfSharesYearAgo = transactions.Sum(i => i.NumberOfShares) - transactions.Where(i => i.TransactionDate > last12Start).Sum(i => i.NumberOfShares); TransactionsLast12.Add(last12Start, Convert.ToDouble(numberOfSharesYearAgo * historicalPrice.DayPrice)); ROILast12 = Convert.ToDecimal(Calculations.IRR.solveIRR(TransactionsLast12, Convert.ToDouble(CurrentValue), 1, 1000, DateTime.Now)); Last12Valid = true; } else { ROILast12 = 0; Last12Valid = false; } } } catch { //ROI = -1; //ROILast12 = -1; } }
private void SendEmailForSharedWishList(AspxCommonInfo aspxCommonObj, WishItemsEmailInfo wishlistObj) { string serverHostLoc = "http://" + HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + "/"; string tdContent = string.Empty; var dataObj = JSONHelper.Deserialise <List <WishItemEmailInfo> >(wishlistObj.MessageBody); int length = dataObj.Count(); string[] tdContentArray = new string[length]; string shareWishMailHtml = ""; shareWishMailHtml += "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td>"; shareWishMailHtml += "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr>"; for (int i = 0; i <= length - 1; i++) { tdContent += "<td width='33%'><div style='border:1px solid #cfcfcf; background:#f1f1f1; padding:10px; text-align:center;'> <img src='" + serverHostLoc + dataObj[i].src + "' alt='" + dataObj[i].alt + "' width='80' height='50' />"; tdContent += "<p style='margin:0; padding:5px 0 0 0; font-family:Arial, Helvetica, sans-serif; font-size:12px; font-weight:normal; line-height:18px;'>"; tdContent += "<span style='font-weight:bold; font-size:12px; font-family:Arial, Helvetica, sans-serif; text-shadow:1px 1px 0 #fff;'>" + dataObj[i].title + "</span><br />"; //item name tdContent += "<span style='font-weight:bold; font-size:12px; font-family:Arial, Helvetica, sans-serif; text-shadow:1px 1px 0 #fff;'> <a href='" + serverHostLoc + dataObj[i].href + "'>" + dataObj[i].hrefHtml + "</a></span><br />"; //item name tdContent += "<span style='font-weight:bold; font-size:11px; font-family:Arial, Helvetica, sans-serif; text-shadow:1px 1px 0 #fff;'>Price:</span>" + dataObj[i].price + "<br />"; //price tdContent += "<span style='font-weight:bold; font-size:12px; font-family:Arial, Helvetica, sans-serif; text-shadow:1px 1px 0 #fff;'>Comments:</span> " + dataObj[i].htmlComment + "</p></div></td>"; //comment tdContentArray[i] = tdContent; tdContent = ""; } for (int j = 0; j <= length - 1; j++) { if (j % 3 == 0) { shareWishMailHtml += "</tr><tr>" + tdContentArray[j]; } else { shareWishMailHtml += tdContentArray[j]; } } shareWishMailHtml += "</tr></table></td></tr></table>"; StoreSettingConfig ssc = new StoreSettingConfig(); string logosrc = ssc.GetStoreSettingsByKey(StoreSetting.StoreLogoURL, aspxCommonObj.StoreID, aspxCommonObj.PortalID, aspxCommonObj.CultureName); List <MessageManagementInfo> template = MessageManagementController.GetMessageTemplateByMessageTemplateTypeID( SystemSetting.SHARED_WISHED_LIST, aspxCommonObj.PortalID); foreach (MessageManagementInfo messageToken in template) { string messageTemplate = messageToken.Body.ToString(); string src = HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + "/"; if (template != null) { string[] tokens = GetAllToken(messageTemplate); foreach (string token in tokens) { switch (token) { case "%DateTime%": messageTemplate = messageTemplate.Replace(token, System.DateTime.Now.ToString("MM/dd/yyyy")); break; case "%Username%": messageTemplate = messageTemplate.Replace(token, wishlistObj.SenderName); break; case "%UserEmail%": messageTemplate = messageTemplate.Replace(token, wishlistObj.SenderEmail); break; case "%MessageDetails%": messageTemplate = messageTemplate.Replace(token, wishlistObj.Message); break; case "%ItemDetailsTable%": messageTemplate = messageTemplate.Replace(token, shareWishMailHtml); break; case "%LogoSource%": string imgSrc = "http://" + src + logosrc; messageTemplate = messageTemplate.Replace(token, imgSrc); break; case "%ServerPath%": messageTemplate = messageTemplate.Replace(token, "http://" + src); break; case "%DateYear%": messageTemplate = messageTemplate.Replace(token, System.DateTime.Now.Year.ToString()); break; } } } char[] spliter = { ',' }; string[] receiverIDs = wishlistObj.ReceiverEmail.Split(spliter); for (int i = 0; i < receiverIDs.Length; i++) { string receiverEmailID = receiverIDs[i]; string emailSuperAdmin; string emailSiteAdmin; SageFrameConfig pagebase = new SageFrameConfig(); emailSuperAdmin = pagebase.GetSettingsByKey(SageFrameSettingKeys.SuperUserEmail); emailSiteAdmin = pagebase.GetSettingsByKey(SageFrameSettingKeys.SiteAdminEmailAddress); MailHelper.SendMailNoAttachment(wishlistObj.SenderEmail, receiverEmailID, wishlistObj.Subject, messageTemplate, emailSiteAdmin, emailSuperAdmin); } } }