public static int GetClosestSessionId(int teacherId) { try { var listOfSessions = GetSessionList(teacherId, null); TimeSpan minTimeSpan = TimeSpan.MaxValue; CSession closestSession = new CSession(); foreach (CSession session in listOfSessions) { var timeUntilOrAfterPresent = session.Date.Subtract(DateTime.Now).Duration(); if (timeUntilOrAfterPresent < minTimeSpan) { minTimeSpan = timeUntilOrAfterPresent; closestSession = session; } } return(closestSession.SessionId); } catch (Exception e) { var sException = new ServerException(e.Message, e, true); LogServerException(sException); } return(0); }
public string GetGridCoreStock(int currPage, int NumberRowOfPage, string inputValue, int refType) { CSession session = new CSession(); int userId = session.UserID; string result = ""; // string InputValue = CXmlPara.CreatePara(inputValue); string InputValue = CXmlPara.CreatePara(new CPara[] { new CPara("PageIndex", currPage.ToString()), new CPara("RowsPerPage", NumberRowOfPage.ToString()), new CPara("RefType", refType.ToString()), }, inputValue ); string InputValue1 = string.Format("<InputValue PageIndex=\"{0}\" RowsPerPage=\"{1}\" UserID=\"{2}\" RefType=\"{3}\" {4}/>", currPage, NumberRowOfPage, 1, refType, inputValue); ServiceREF.InventoryService.COutputValue outputValue = new ServiceREF.InventoryService.COutputValue(); if (refType == 7) { CInward[] list = iv_service.GetInwardList(InputValue, ref outputValue); result = CGrid.ToJsonForHandle <CInward>(userId, 14, list, currPage, outputValue.TotalPage, outputValue.TotalRow); } else if (refType == 8) { COutward[] list = iv_service.GetOutwardList(InputValue, ref outputValue); result = CGrid.ToJsonForHandle <COutward>(userId, 14, list, currPage, outputValue.TotalPage, outputValue.TotalRow); } if (refType == 9) { CTransactionsStock[] list = iv_service.GetTransferList(InputValue, ref outputValue); result = CGrid.ToJsonForHandle <CTransactionsStock>(userId, 31, list, currPage, outputValue.TotalPage, outputValue.TotalRow); } return(result); }
public string GetGrid(int currPage, int NumberRowOfPage, string inputValue, int refType) { CSession session = new CSession(); int userId = session.UserID; string result = ""; ServiceREF.InventoryService.COutputValue outputValue = new ServiceREF.InventoryService.COutputValue(); // string InputValue = string.Format("<InputValue PageIndex='{0}' RowsPerPage='{1}' UserID='{2}' {3}/>", currPage, NumberRowOfPage, 1, inputValue); string InputValue = CXmlPara.CreatePara(new CPara[] { new CPara("PageIndex", currPage.ToString()), new CPara("RowsPerPage", NumberRowOfPage.ToString()), }, inputValue ); if (refType == 7) { CInwardDetail[] list = iv_service.GetInwardDetailList(InputValue, ref outputValue); result = CGrid.ToJsonForHandle <CInwardDetail>(userId, 15, list, currPage, outputValue.TotalPage, outputValue.TotalRow); } else if (refType == 8) { COutwardDetail[] list = iv_service.GetOutwardDetailList(InputValue, ref outputValue); result = CGrid.ToJsonForHandle <COutwardDetail>(userId, 46, list, currPage, outputValue.TotalPage, outputValue.TotalRow); } else if (refType == 9) { CTransactionsStockDetails[] list = iv_service.GetTransferDetails(InputValue, ref outputValue); result = CGrid.ToJsonForHandle <CTransactionsStockDetails>(userId, 32, list, currPage, outputValue.TotalPage, outputValue.TotalRow); } return(result); }
public ActionResult UpdateProfileImage(EvernoteUser model, HttpPostedFileBase ProfileImage) { if (ProfileImage != null && (ProfileImage.ContentType == "image/jpeg" || ProfileImage.ContentType == "image/jpg" || ProfileImage.ContentType == "image/png")) { string fileName = $"user_{model.ID}.{ProfileImage.ContentType.Split('/')[1]}"; ProfileImage.SaveAs(Server.MapPath($"~/Images/{fileName}")); model.ProfileImageFileName = fileName; BuisnessLayerResult <EvernoteUser> res = evernoteUserManager.UpdatePersonImage(model); if (res.Errors.Count > 0) { errorObject.Title = "Kullanıcı Bulunamadı! "; errorObject.Items = res.Errors; return(View("Error", errorObject)); } CSession.Set("login", res.Result); return(RedirectToAction("ShowProfile", new { id = res.Result.ID })); } errorObject.Title = "Yalnızca JPEG,JPG Ve PNG Formatında Yükleme Yapabilirsiniz! "; return(View("Error", errorObject)); }
protected void Page_Load(object sender, EventArgs e) { try { string currentPage = System.IO.Path.GetFileName(Request.Url.AbsolutePath); if (currentPage == "Verify2FA") { if (Session["OptimflexPortalUserData"] != null) { CSession mySession = new CSession(); var varUserData = mySession.getCurrentUserData(); if (varUserData.USR_ISENABLED_2FA == 0) { Response.Redirect("~/"); } else { if (varUserData.USR_ISVERIFIED_2FA == 1) { Response.Redirect("~/"); } } } else { Response.Redirect("~/Login"); } } } catch (Exception ex) { } }
private static void LoadStudents(RecContext db, CSession session) { var students = from cts in db.ClassTermStudent join stu in db.Student on cts.StudentId equals stu.StudentId join ct in db.ClassTerm on cts.ClassTermId equals ct.ClassTermId join s in db.Session.Where(item => item.SessionId == session.SessionId) on ct.ClassTermId equals s.ClassTermId join att in db.Attendance on new { K1 = cts.StudentId, K2 = s.SessionId } equals new { K1 = att.StudentId, K2 = att.SessionId } into att1 from temp in att1.DefaultIfEmpty() select new CAttendance { StudentId = cts.StudentId, StudentName = stu.FirstName + " " + stu.LastName, AttendanceStatusId = temp == null ? 0 : temp.AttendanceStatusId, ReasonId = temp == null ? 0 : temp.ReasonId.GetValueOrDefault() }; foreach (var student in students) { var ca = new CAttendance { StudentId = student.StudentId, StudentName = student.StudentName, AttendanceStatusId = student.AttendanceStatusId == null ? 0 : student.AttendanceStatusId, ReasonId = student.ReasonId == null ? 0 : student.ReasonId }; session.Students.Add(ca); } }
protected void Page_Load(object sender, EventArgs e) { CSession session = new CSession(); string scriptServerConfig = CGrid.CreateGridConfig(session.UserID, 43, 1, "colModelActiveIngredient", "colNameActiveIngredient", "optionServerActiveIngredient"); ltrScriptClient.Text = "<script type='text/javascript'>" + scriptServerConfig + "</script>"; }
public async Task <bool> Logout() { string value = ""; if (m_IsLocked != 0) { m_LogOutRequested = true; return(true); } if (m_Session != null) { if (m_IsHeartBeatActive) { StopHeartbeat(); } value = await communicationManager.PostLogout(m_Url, m_Session.Id, serverName); communicationManager.TokenSource.Cancel(); m_Session = null; return(value != ""); } return(true); }
public static List <CSession> GetSessionList(int teacherId, DateTime?date) { try { using (var db = new RecContext()) { var query = from session in db.Session select new { session.SessionId, session.Date, session.ClassTerm.ClassId, session.ClassTerm.Class.Description, session.ClassTerm.Class.Name }; if (date != null) { var definiteDate = (DateTime)date; query = query.Where(item => item.Date.Month == definiteDate.Month && item.Date.Year == definiteDate.Year); } var restrictToTeachersClasses = db.ClassTeacher.Where(ct => ct.TeacherId == teacherId).Select(ct => ct.ClassId).ToArray(); //ClassId Array var restrictToTeachersClassTerms = db.ClassTermTeacher.Where(ctt => ctt.TeacherId == teacherId).Select(ctt => ctt.ClassTermId).ToArray(); //ClassTermId Array var restrictToTeachersSessions = db.SessionTeacher.Where(st => st.TeacherId == teacherId).Select(ctt => ctt.SessionId).ToArray(); //Session Array var list = new List <CSession>(); foreach (var item in query) { var session = new CSession { SessionId = item.SessionId, Date = item.Date }; session.ClassInfo = new CClass { ClassId = item.ClassId, ClassName = item.Name, ClassDescription = item.Description }; list.Add(session); } List <CSession> sessionsOfTeacher = new List <CSession>(); foreach (var session in list) { if (restrictToTeachersClasses.Contains(session.ClassInfo.ClassId) || restrictToTeachersClassTerms.Contains(session.ClassTermId) || restrictToTeachersSessions.Contains(session.SessionId)) { sessionsOfTeacher.Add(session); } } return(list); } } catch (Exception e) { var sException = new ServerException(e.Message, e, true); LogServerException(sException); } return(new List <CSession>()); }
public void Initialize() { if (Session != null) { Session.Dispose(); } Session = new CSession(this); }
private void _createSession(object sender, SocketAsyncEventArgs e) { if (eventAllEventLogger != null) { eventAllEventLogger(null, "Create Someting Client"); } CSession session = new CSession(); }
static void Main() { App app = new App(); CSession session = new CSession(); CBotClientManager botClientManager = new CBotClientManager(session); CDialogManager dialogManager = new CDialogManager(botClientManager); CMainWindowViewModel viewModel = new CMainWindowViewModel(dialogManager); MainWindow window = new MainWindow(); window.DataContext = viewModel; app.Run(window); }
/// <summary> /// 新建 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAdd_Click(object sender, EventArgs e) { try { CSession.setSession(CConst.PAGEID.PAGE_ID_B100, CConst.CSession.C_NewsId, string.Empty); Response.Redirect("B201.aspx"); } catch (Exception ex) { throw ex; } }
public IActionResult Post(CSession attendance) { if (DbActions.ValidateRequest(Request)) { DbActions.UpdateAttendance(attendance); } else { return(StatusCode(401)); } return(StatusCode(200)); }
public int OpenSession() { int ret = 0; string msg; STSession st = new STSession(); CSession clSession = new CSession(LocalData.UserId(), LocalData.CSDbUsers(), LocalData.LogPath()); int retvalue = clSession.OpenSession(out st, out msg); return(ret); }
public string LogoutAuth() { try { CJsonResponse jsonResClass = new CJsonResponse(); CSession mySession = new CSession(); mySession.setUserData(null); return(jsonResClass.JsonResponse(intJsonStatusSuccess, "Амжилттай", null)); } catch (Exception ex) { throw ex; } }
protected void Page_Load(object sender, EventArgs e) { try { CMain mainClass = new CMain(); mainClass.PageInit(); CSession mySession = new CSession(); var myUserData = mySession.getCurrentUserData(); spanUserLastname.InnerHtml = myUserData.USR_LASTNAME; spanUserFirstname.InnerHtml = myUserData.USR_FIRSTNAME; inputProfileData.Value = "{\"profile_selectUserType\": \"" + myUserData.USR_TYPE + "\", \"profile_inputUserMiddleName\": \"" + myUserData.USR_FAMILYNAME + "\", \"profile_inputUserLastName\": \"" + myUserData.USR_LASTNAME + "\", \"profile_inputUserFirstName\": \"" + myUserData.USR_FIRSTNAME + "\", \"profile_selectUserGender\": \"" + myUserData.USR_GENDER + "\", \"profile_inputUserEmail\": \"" + myUserData.USR_USERNAME + "\", \"profile_inputUserTel1\": \"" + myUserData.USR_TEL1 + "\", \"profile_inputUserTel2\": \"" + myUserData.USR_TEL2 + "\", \"profile_inputUserBirthday\": \"" + myUserData.USR_BIRTHDATE + "\", \"profile_check2FAuth\":\"" + myUserData.USR_ISENABLED_2FA + "\"}"; } catch (Exception ex) { throw ex; } }
public ActionResult UpdateProfile(ProfileViewModel model) { //Server-side validation yapılacak //Server-side validation yapılacak //Server-side validation yapılacak //Server-side validation yapılacak ModelState.Remove("Password"); ModelState.Remove("CreatedOn"); ModelState.Remove("ModifiedOn"); ModelState.Remove("ModifiedUserName"); if (ModelState.IsValid) { BuisnessLayerResult <EvernoteUser> res = evernoteUserManager.UpdatePersonProfile(model); if (res.Errors.Count > 0) { errorObject.Title = "Güncelleme Yapılırken Bir Hata Oluştu! Hesabınız Engellenmiş Veya Silinmiş Olabilir!"; errorObject.Items = res.Errors; return(View("Error", errorObject)); } CSession.Set("login", res.Result); ProfileViewModel ProfileModel = new ProfileViewModel() { ID = res.Result.ID, Username = res.Result.Username, Name = res.Result.Name, Surname = res.Result.Surname, ProfileImageFileName = res.Result.ProfileImageFileName, Description = res.Result.Description, Job = res.Result.Job, Country = res.Result.Country, DateOfBirth = res.Result.DateOfBirth, isAdmin = res.Result.isAdmin, Email = res.Result.Email }; return(new JsonResult { Data = JsonConvert.SerializeObject(ProfileModel) }); } return(View("ShowProfile", model)); }
public ActionResult Login(LoginViewModel model) { if (ModelState.IsValid) { BuisnessLayerResult <EvernoteUser> user = evernoteUserManager.Loginuser(model); if (user.Errors.Count > 0) { ErrorMessage err = user.Errors.Find(x => x.Code == ErrorMessageCode.UserisNotActive); ErrorMessage isBanned = user.Errors.Find(x => x.Code == ErrorMessageCode.Banned); if (err != null) { ViewBag.userIsNotActive = false; } else if (isBanned != null) { errorObject.IsRedirecting = false; errorObject.Header = "Hesabınız Admin Tarafından Askıya Alındı !"; errorObject.Title = "Hesabınız askıdan alınana kadar erişimiz kısıtlandı !"; return(View("Banned", errorObject)); } user.Errors.ForEach(x => ModelState.AddModelError("", x.Message)); ViewBag.valid = false; return(View(model)); } else { CSession.Set("login", user.Result); return(RedirectToAction("Index", "Home")); } } ViewBag.valid = false; return(View(model)); }
public async Task <CSession> Login() { if (m_IsLocked != 0 && m_LogOutRequested) { m_LogOutRequested = false; return(m_Session); } var json = await communicationManager.PostLogin(m_Url, serverName); if (json == null) { return(await Task.FromResult <CSession>(null)); } CSession session = new CSession(); session = JsonConvert.DeserializeObject <CSession>(json); m_Session = session; return(session); }
public static void UpdateAttendance(CSession sessionAttendance) { List <Attendance> attendanceList = new List <Attendance>(); try { using (var db = new RecContext()) { foreach (CAttendance student in sessionAttendance.Students) { var dbObject = db.Attendance.Where(a => a.SessionId == sessionAttendance.SessionId && a.StudentId == student.StudentId).FirstOrDefault(); bool doesNotExist = dbObject == null; if (doesNotExist) { db.Add(new Attendance { AttendanceStatusId = (int)student.AttendanceStatusId, ReasonId = student.ReasonId, SessionId = sessionAttendance.SessionId, StudentId = student.StudentId, CreationDtTm = DateTime.Now }); } else { db.Update(dbObject); dbObject.AttendanceStatusId = (int)student.AttendanceStatusId; dbObject.ReasonId = student.ReasonId; dbObject.CreationDtTm = DateTime.Now; } } db.SaveChangesAsync(); } } catch (Exception e) { var sException = new ServerException(e.Message, e, false); LogServerException(sException); } }
public static CSession GetSession(int sessionId) { try { using (var db = new RecContext()) { CSession session = LoadSession(sessionId, db); if (session != null) { LoadStudents(db, session); } return(session); } } catch (Exception e) { var sException = new ServerException(e.Message, e, true); LogServerException(sException); } return(new CSession()); }
unsafe void Run(KeyValuePair <Operation, Tensor>[] inputs, TF_Output[] outputs, int[] expected_results) { var csession = new CSession(host_graph_, s_); ASSERT_EQ(TF_OK, s_.Code, s_.Message); csession.SetInputs(inputs); csession.SetOutputs(outputs); csession.Run(s_); ASSERT_EQ(TF_OK, s_.Code, s_.Message); for (int i = 0; i < expected_results.Length; ++i) { var output = csession.output_tensor(i); ASSERT_TRUE(output != IntPtr.Zero); EXPECT_EQ(TF_DataType.TF_INT32, c_api.TF_TensorType(output)); EXPECT_EQ(0, c_api.TF_NumDims(output)); ASSERT_EQ(sizeof(int), (int)c_api.TF_TensorByteSize(output)); var output_contents = c_api.TF_TensorData(output); EXPECT_EQ(expected_results[i], *(int *)output_contents.ToPointer()); } }
public string Check2FAAuth(string pCode) { CJsonResponse jsonResClass = new CJsonResponse(); try { TwoFactorAuthenticator tfa = new TwoFactorAuthenticator(); CSession mySession = new CSession(); var varUserData = mySession.getCurrentUserData(); bool isCorrectPIN = tfa.ValidateTwoFactorPIN(varUserData.AUTH_2FA_SECRET_KEY, pCode); if (isCorrectPIN) { varUserData.USR_ISVERIFIED_2FA = 1; mySession.setUserData(varUserData); return(jsonResClass.JsonResponse(intJsonStatusSuccess, "Амжилттай", null)); } return(jsonResClass.JsonResponse(intJsonStatusFailed, "Код буруу байна", null)); } catch (Exception ex) { return(jsonResClass.JsonResponse(intJsonStatusFailed, "Системд алдаа гарлаа", null)); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["OptimflexPortalUserData"] != null) { CSession mySession = new CSession(); var varUserData = mySession.getCurrentUserData(); if (varUserData.USR_ISENABLED_2FA == 0) { Response.Redirect("~/"); } else { if (varUserData.USR_ISVERIFIED_2FA == 1) { Response.Redirect("~/"); } else { try { TwoFactorAuthenticator tfa = new TwoFactorAuthenticator(); var setupInfo = tfa.GenerateSetupCode(varUserData.AUTH_2FA_ISSUER_NAME, varUserData.AUTH_2FA_ISSUER_NOTE, varUserData.AUTH_2FA_SECRET_KEY, varUserData.AUTH_2FA_QRCODE_WIDTH, varUserData.AUTH_2FA_QRCODE_HEIGHT); //the width and height of the Qr Code in pixels verify2fa_imgQRCode.Src = setupInfo.QrCodeSetupImageUrl; verify2fa_spanEntryCode.InnerHtml = setupInfo.ManualEntryKey; } catch (Exception ex) { throw ex; } } } } else { Response.Redirect("~/Login"); } }
private void RunGraphsAndCompareOutputs(TF_Output[] grad_outputs, TF_Output[] expected_grad_outputs) { var csession = new CSession(graph_, s_); var expected_csession = new CSession(expected_graph_, s_); var grad_outputs_vec = grad_outputs; csession.SetOutputs(grad_outputs_vec); csession.Run(s_); ASSERT_EQ(TF_OK, TF_GetCode(s_)); var out0 = csession.output_tensor(0); var out1 = csession.output_tensor(1); var expected_grad_outputs_vec = expected_grad_outputs; expected_csession.SetOutputs(expected_grad_outputs_vec); expected_csession.Run(s_); ASSERT_EQ(TF_OK, TF_GetCode(s_)); var expected_out0 = expected_csession.output_tensor(0); var expected_out1 = expected_csession.output_tensor(1); //CompareTensors(out0, expected_out0); //CompareTensors(out1, expected_out1); }
public void ProcessRequest(HttpContext context) { HttpResponse response = context.Response; HttpRequest request = context.Request; try { string session = "", exportTo = "pdf", inputValue = "<InputValue ReportID=\"1\" UserID=\"1\"/>"; int userid = 1, languageid = 129; string requestFrom = "0"; CSession ses = new CSession(); try { if (request.QueryString["ExportTo"] != null) { exportTo = request.QueryString["ExportTo"].ToString(); } if (request.QueryString["InputValue"] != null) { inputValue = request.QueryString["InputValue"].ToString(); } userid = ses.UserID; session = ses.Session; try { XmlDocument doc = new XmlDocument(); doc.LoadXml(inputValue); XmlAttribute xmlUser = doc.CreateAttribute("UserID"); xmlUser.Value = userid.ToString(); doc.DocumentElement.SetAttributeNode(xmlUser); XmlAttribute xmlSession = doc.CreateAttribute("Session"); xmlSession.Value = session; doc.DocumentElement.SetAttributeNode(xmlSession); XmlElement node = (XmlElement)doc.SelectSingleNode("/InputValue"); languageid = int.Parse(node.Attributes["LanguageID"].Value); requestFrom = node.Attributes["RequestFrom"].Value; } catch (Exception ex) { string s = ex.Message; } } catch (Exception ex) { CLogManager.WritePL("CReportViewerUI.Request", ex.Message); } CReportService rfs = new CReportService(); CReport item = null; byte[] jsBytes = null; //Set time out call service rfs.Timeout = 1000 * 60 * 15; item = rfs.GetReport(userid, session, languageid, inputValue, exportTo); if (item != null && item.Content != null && item.Content.Length > 0) { response.ClearHeaders(); response.ClearContent(); response.ContentType = item.ExportName; response.Charset = ""; response.AddHeader("Content-Disposition", "inline Filename=" + item.Name.Replace(',', ' ') + session + "." + item.ExportType + ";"); //Parse out the file name in path here int ContentLength = item.Content.Length; //Add js to html: resize window, show image for browsers if (exportTo.ToLower() == "html") { string js = CReportServiceUI.GetHtmlFunction(requestFrom); jsBytes = new byte[js.Length]; System.Text.Encoding.ASCII.GetBytes(js.ToCharArray(), 0, js.Length, jsBytes, 0); ContentLength += jsBytes.Length; response.AddHeader("Content-Length", ContentLength.ToString()); //write js include header response.OutputStream.Write(jsBytes, 0, jsBytes.Length); response.Flush(); } else { response.AddHeader("Content-Length", ContentLength.ToString()); } //load data block 10MB int count = 1024 * 1024 * 10; if (ContentLength < count) { response.BinaryWrite(item.Content); } else { Stream s = new MemoryStream(item.Content); byte[] buffer = new byte[count]; while (ContentLength > 0 && response.IsClientConnected) { int lengthRead = s.Read(buffer, 0, count); response.OutputStream.Write(buffer, 0, lengthRead); response.Flush(); ContentLength -= lengthRead; } } //write image to web server if (exportTo.ToLower() == "html" && item.ListReportImage.Length > 0) { for (int i = 0; i < item.ListReportImage.Length; i++) { CReportImage image = item.ListReportImage[i]; CReportServiceUI.SaveFile(image.Content, "", image.FileName); } } } else { response.ContentType = "text/plain"; response.Write(item.Description); } } catch (Exception ex) { response.ClearHeaders(); response.ClearContent(); response.Charset = ""; response.ContentType = "text/plain"; response.Write("99. Report not found, please check again!!!"); CLogManager.WritePL("CReportViewerUI.GetReportDataById", ex.Message); } }
public void ProcessRequest(HttpContext context) { HttpResponse response = context.Response; HttpRequest request = context.Request; try { string exportTo = "pdf", requestFrom = "0", inputValue = "<InputValue ReportID=\"1\" UserID=\"1\"/>", filedlid = "", rsid = ""; int languageid = 129; CSession session = new CSession(); try { if (request.Form["ExportTo"] != null) { exportTo = request.Form["ExportTo"].ToString(); } else if (request.QueryString["ExportTo"] != null) { exportTo = HttpUtility.HtmlDecode(request.QueryString["ExportTo"].ToString()); } if (request.Form["InputValue"] != null) { inputValue = request.Form["InputValue"].ToString(); } else if (request.QueryString["InputValue"] != null) { inputValue = HttpUtility.UrlDecode(request.QueryString["InputValue"].ToString()); } if (request.QueryString["filedlid"] != null) { filedlid = request.QueryString["filedlid"].ToString(); } if (request.QueryString["rsid"] != null) { rsid = request.QueryString["rsid"].ToString(); } HttpContext.Current.Session.Timeout = 1 * 60 * 6; //download file excel if (filedlid != "") { if (filedlid == session.Session && HttpContext.Current.Session[session.Session + rsid] != null) { ExcelResponse excl = (ExcelResponse)HttpContext.Current.Session[session.Session + rsid]; string fileName = excl.Name + excl.Session + "." + excl.ExportType; response.ClearHeaders(); response.ClearContent(); response.ContentType = excl.ExportName; response.Charset = ""; response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\";inline Filename=\"{0}\";", fileName)); response.BinaryWrite(excl.Content); HttpContext.Current.Session[session.Session + rsid] = null; } else { string messageInfo = "Report session expired or export file has download. Please run new export again."; response.ClearHeaders(); response.ClearContent(); response.ContentType = "text/html"; response.AddHeader("Content-Length", messageInfo.Length.ToString()); response.Charset = ""; response.Write(messageInfo); } return; } try { XmlDocument doc = new XmlDocument(); doc.LoadXml(inputValue); XmlAttribute xmlUser = doc.CreateAttribute("UserID"); xmlUser.Value = session.UserID.ToString(); doc.DocumentElement.SetAttributeNode(xmlUser); XmlAttribute xmlSession = doc.CreateAttribute("Session"); xmlSession.Value = session.Session; doc.DocumentElement.SetAttributeNode(xmlSession); inputValue = doc.OuterXml; XmlElement node = (XmlElement)doc.SelectSingleNode("/InputValue"); languageid = int.Parse(node.Attributes["LanguageID"].Value); requestFrom = node.Attributes["RequestFrom"].Value; } catch (Exception ex) { string s = ex.Message; } } catch (Exception ex) { CLogManager.WritePL("CReportViewerUI.Request", ex.Message); } CReportService rfs = new CReportService(); CReport item = null; byte[] jsBytes = null; //Set time out call service rfs.Timeout = 1000 * 60 * 15; item = rfs.GetReport(session.UserID, session.Session, languageid, inputValue, exportTo); if (item != null && item.Content != null && item.Content.Length > 0) { if (item.ExportType != null) { exportTo = item.ExportType; } response.ClearHeaders(); response.ClearContent(); response.ContentType = item.ExportName; response.Charset = ""; response.AddHeader("Content-Disposition", String.Format("filename=\"{0}\";inline Filename=\"{0}\";", HttpUtility.UrlEncode(item.Name.Replace(',', ' ') + session.Session + "." + item.ExportType))); //Parse out the file name in path here int ContentLength = item.Content.Length; //Add js to html: resize window, show image for browsers if (exportTo.ToLower() == "html") { string js = CReportServiceUI.GetHtmlFunction(requestFrom); jsBytes = new byte[js.Length]; System.Text.Encoding.ASCII.GetBytes(js.ToCharArray(), 0, js.Length, jsBytes, 0); ContentLength += jsBytes.Length; response.AddHeader("Content-Length", ContentLength.ToString()); //write js include header response.OutputStream.Write(jsBytes, 0, jsBytes.Length); response.Flush(); } else if (exportTo.ToLower() == "xls" || exportTo.ToLower() == "xlsx") { //write text description when file download is excel ExcelResponse excelResponse = new ExcelResponse(item); HttpContext.Current.Session[session.Session + item.Session] = excelResponse; //write html file: export done and link download if (response.StatusCode == 200) { response.ClearHeaders(); response.ClearContent(); response.ContentType = "text/html"; response.AddHeader("Content-Disposition", "inline Filename=\"" + session.Session + ".htm\";"); response.Charset = ""; //response.AddHeader("Content-Length", ContentLength.ToString()); string _link = "ReportViewer.ashx?filedlid=" + session.Session + "&rsid=" + item.Session; response.Write("Export to EXCEL done..., <a href=\"" + _link + "\" target=\"_blank\">download</a>."); } return; } else { response.AddHeader("Content-Length", ContentLength.ToString()); } //load data block 10MB int count = 1024 * 1024 * 1; if (ContentLength < count) { response.BinaryWrite(item.Content); } else { Stream s = new MemoryStream(item.Content); byte[] buffer = new byte[count]; while (ContentLength > 0 && response.IsClientConnected) { int lengthRead = s.Read(buffer, 0, count); response.OutputStream.Write(buffer, 0, lengthRead); response.Flush(); ContentLength -= lengthRead; } } //write image to web server if (exportTo.ToLower() == "html" && item.ListReportImage.Length > 0) { for (int i = 0; i < item.ListReportImage.Length; i++) { CReportImage image = item.ListReportImage[i]; CReportServiceUI.SaveFile(image.Content, "", image.FileName); } } } else { response.ContentType = "text/plain"; response.Write(item.Description); } } catch (Exception ex) { response.ClearHeaders(); response.ClearContent(); response.Charset = ""; response.ContentType = "text/plain"; response.Write("99. Export error exception:: " + ex.Message + "\n" + ex.ToString()); CLogManager.WritePL("CReportViewerUI.GetReportDataById", ex.Message); } }
public void Session() { lock (Locks.ProcessWide) { var s = new Status(); var graph = new Graph().as_default(); // Make a placeholder operation. var feed = c_test_util.Placeholder(graph, s); // Make a constant operation with the scalar "2". var two = c_test_util.ScalarConst(2, graph, s); // Add operation. var add = c_test_util.Add(feed, two, graph, s); var csession = new CSession(graph, s); ASSERT_EQ(TF_Code.TF_OK, s.Code); // Run the graph. var inputs = new Dictionary <Operation, Tensor>(); inputs.Add(feed, new Tensor(3)); csession.SetInputs(inputs); var outputs = new TF_Output[] { new TF_Output(add, 0) }; csession.SetOutputs(outputs); csession.Run(s); Tensor outTensor = csession.output_tensor(0); EXPECT_EQ(TF_DataType.TF_INT32, outTensor.dtype); EXPECT_EQ(0, outTensor.NDims); ASSERT_EQ((ulong)sizeof(uint), outTensor.bytesize); var output_contents = outTensor.ToArray <int>(); EXPECT_EQ(3 + 2, output_contents[0]); // Add another operation to the graph. var neg = c_test_util.Neg(add, graph, s); ASSERT_EQ(TF_Code.TF_OK, s.Code); // Run up to the new operation. inputs = new Dictionary <Operation, Tensor>(); inputs.Add(feed, new Tensor(7)); csession.SetInputs(inputs); outputs = new TF_Output[] { new TF_Output(neg, 0) }; csession.SetOutputs(outputs); csession.Run(s); ASSERT_EQ(TF_Code.TF_OK, s.Code); outTensor = csession.output_tensor(0); ASSERT_TRUE(outTensor != IntPtr.Zero); EXPECT_EQ(TF_DataType.TF_INT32, outTensor.dtype); EXPECT_EQ(0, outTensor.NDims); // scalar ASSERT_EQ((ulong)sizeof(uint), outTensor.bytesize); output_contents = outTensor.ToArray <int>(); EXPECT_EQ(-(7 + 2), output_contents[0]); // Clean up csession.CloseAndDelete(s); ASSERT_EQ(TF_Code.TF_OK, s.Code); } }
// GET: Note public ActionResult Index() { var notes = noteManager.List().Where(x => x.Owner.ID == CSession.Get <EvernoteUser>("login").ID).OrderByDescending(x => x.ModifiedOn); return(View(notes.ToList())); }