public void Insert(TcmsIfSurvey tcmsIfSurvey) { tcmsIfSurveyRepository.Insert(tcmsIfSurvey); }
public string sendSatisfaction(TcmsIfSurvey tcmsIfSurvey) { HttpContext.Response.AppendHeader("Access-Control-Allow-Origin", "*"); string result = ""; StatusModel statusModel = new StatusModel(); var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://tcms.igarim.com/Api/tcms_if_survey.php"); httpWebRequest.ContentType = "application/x-www-form-urlencoded"; httpWebRequest.Method = "POST"; httpWebRequest.CookieContainer = new CookieContainer(); HttpCookieCollection cookies = Request.Cookies; for (int i = 0; i < cookies.Count; i++) { HttpCookie httpCookie = cookies.Get(i); Cookie cookie = new Cookie(); cookie.Domain = httpWebRequest.RequestUri.Host; cookie.Expires = httpCookie.Expires; cookie.Name = httpCookie.Name; cookie.Path = httpCookie.Path; cookie.Secure = httpCookie.Secure; cookie.Value = httpCookie.Value; httpWebRequest.CookieContainer.Add(cookie); } using (var requestStream = httpWebRequest.GetRequestStream()) { string backSlash = ""; var dt = DateTime.Today; string dtc = String.Format("{0:yyyy-MM-dd ss:ss:ss}", dt); string jsont = new JavaScriptSerializer().Serialize(new { InfId = tcmsIfSurvey.InfId, CompLoginKey = tcmsIfSurvey.CompLoginKey, BaLoginKey = tcmsIfSurvey.BaLoginKey, MentorLoginKey = tcmsIfSurvey.MentorLoginKey, NumSn = tcmsIfSurvey.NumSn, SubNumSn = tcmsIfSurvey.SubNumSn, ConCode = tcmsIfSurvey.ConCode, SatisfactionGrade = tcmsIfSurvey.SatisfactionScore, Check01 = tcmsIfSurvey.Check01, Check02 = tcmsIfSurvey.Check02, Check03 = tcmsIfSurvey.Check03, Check04 = tcmsIfSurvey.Check04, Check05 = tcmsIfSurvey.Check05, Check06 = tcmsIfSurvey.Check06, Check07 = tcmsIfSurvey.Check07, Check08 = tcmsIfSurvey.Check08, Check09 = tcmsIfSurvey.Check09, Check10 = tcmsIfSurvey.Check10, Check11 = tcmsIfSurvey.Check11, Check12 = tcmsIfSurvey.Check12, Check13 = tcmsIfSurvey.Check13, Check14 = tcmsIfSurvey.Check14, Check15 = tcmsIfSurvey.Check15, Check16 = tcmsIfSurvey.Check16, Check17 = tcmsIfSurvey.Check17, Check18 = tcmsIfSurvey.Check18, Check19 = tcmsIfSurvey.Check19, Check20 = tcmsIfSurvey.Check20, Check21 = tcmsIfSurvey.Check21, Check22 = tcmsIfSurvey.Check22, Check23 = tcmsIfSurvey.Check23, Check24 = tcmsIfSurvey.Check24, Text01 = tcmsIfSurvey.Text01, Text02 = tcmsIfSurvey.Text02, InfDt = dtc }); backSlash = jsont.Replace("\\", ""); byte[] ba = Encoding.UTF8.GetBytes("json=" + backSlash); requestStream.Write(ba, 0, ba.Length); requestStream.Flush(); requestStream.Close(); } try { var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { JavaScriptSerializer js = new JavaScriptSerializer(); result = streamReader.ReadToEnd(); string[] rptSplit = result.Split('\n'); statusModel = (StatusModel)js.Deserialize(rptSplit[1], typeof(StatusModel)); } return(statusModel.status); } catch (Exception e) { return("E"); } }