public ActionResult Broadcast(Models.Index dados) { string retorno = string.Empty; var hub = GlobalHost.ConnectionManager.GetHubContext <Hubs.BroadcastHub>(); var hubConnection = new HubConnection("http://localhost:54132/"); IHubProxy serverHub = hubConnection.CreateHubProxy("BroadcastHub"); DateTime startBroadcast = DateTime.Now; RespostaRequisicaoSql resposta; try { resposta = new RespostaRequisicaoSql(); //Cria o objeto da requisicao RequisicaoSql requisicao = Requisicoes.CriarRequisicaoSql(dados.Codigo, dados.Consulta); //Serializa a requisicao em JSon para broadcast //string requisicaoJSON = Requisicoes.SerializaRequisicaoSql(requisicao); //Dispara o broadcast para os clients console hub.Clients.All.obterConsulta(requisicao); //Fica escutando o evento de retorno que será disparado pelos consoles serverHub.On <RespostaRequisicaoSql>("exibeResultado", (resp) => { resposta = resp; } ); hubConnection.Start().Wait(); serverHub.Invoke("Notify", "Controller Call", hubConnection.ConnectionId); while (resposta.CodigoRequisicaoSql <= 0) { if ((DateTime.Now - startBroadcast).TotalSeconds >= 15) { resposta.MensagemErro = "Time Out"; break; } } //resposta = Requisicoes.DeserializaRespostaRequisicaoSql(retorno); if (!(resposta.Retorno == null) && resposta.Retorno.Count > 0) { resposta.Retorno[0] = JsonConvert.DeserializeObject <DataTable>(resposta.Retorno[0].ToString()); } return(View(resposta)); } catch (Exception ex) { throw new Exception(ex.Message); } finally { hubConnection.Dispose(); } }
public void Add_record(Models.Index emp) { SqlCommand com = new SqlCommand("Sp_empAdd2", con); com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@Emp_Name", emp.Emp_Name); con.Open(); com.ExecuteNonQuery(); con.Close(); }
public void CreateStatementForIndex(CreateStatement createStatement, int rootPage) { //if the index already exists,then return false if (this.If_in(createStatement.IndexName)) { throw new TableOrIndexAlreadyExistsException("Index Already Exists"); } Models.Index b = new Models.Index(createStatement, rootPage); index.Add(b); Save_index(this.index); }
public bool TryCreateStatementForIndex(CreateStatement createStatement, int rootPage) { //if the index already exists,then return false if (this.If_in(createStatement.IndexName)) { return(false); } Models.Index b = new Models.Index(createStatement, rootPage); index.Add(b); Save_index(this.index); return(true); }
//Previous city forecast public ViewResult PreviousCity(string city) { Index model = new Models.Index(); model.ResCityName = city; model.last = true; WeatherForecastService forecast = new WeatherForecastService(); var weather = forecast.GetWeather(model); ViewGen(weather.OWMForecast, weather.WUForecast); var cookieService = new CookieService(); cookieService.CookieAddCity(model, model.ResCityName, this); ViewBag.space = " "; return(View("ShowWeather", model)); }
public ActionResult Index() { Index model = new Models.Index(); SessionContext.Current.ActiveUser.MenuId = "0"; DataSet totalActiveTask = BaseDB.DBManager.AppConnection.GetDataSet("select count(*) kayit_sayisi from tsk_tasks_v where is_active_bit=@is_active_bit ", new ArrayList { "is_active_bit" }, new ArrayList { 1 }); DataSet totalActiveFinishedTask = BaseDB.DBManager.AppConnection.GetDataSet("select count(*) kayit_sayisi from tsk_tasks_v where is_active_bit=@is_active_bit and task_status_id=@task_status_id ", new ArrayList { "is_active_bit", "task_status_id" }, new ArrayList { 1, 6 }); DataSet totalActiveClosedTask = BaseDB.DBManager.AppConnection.GetDataSet("select count(*) kayit_sayisi from tsk_tasks_v where is_active_bit=@is_active_bit and task_status_id=@task_status_id ", new ArrayList { "is_active_bit", "task_status_id" }, new ArrayList { 1, 7 }); DataSet totalActiveProcessedTask = BaseDB.DBManager.AppConnection.GetDataSet("select count(*) kayit_sayisi from tsk_tasks_v where is_active_bit=@is_active_bit and task_status_id in (2,3,4,8) ", new ArrayList { "is_active_bit" }, new ArrayList { 1 }); model.totalActiveTask = (totalActiveTask != null && totalActiveTask.Tables[0].Rows.Count > 0) ? totalActiveTask.Tables[0].Rows[0]["kayit_sayisi"].ToString():"0"; model.totalActiveFinishedTask = (totalActiveFinishedTask != null && totalActiveFinishedTask.Tables[0].Rows.Count > 0) ? totalActiveFinishedTask.Tables[0].Rows[0]["kayit_sayisi"].ToString():"0"; model.totalActiveClosedTask = (totalActiveClosedTask != null && totalActiveClosedTask.Tables[0].Rows.Count > 0) ? totalActiveClosedTask.Tables[0].Rows[0]["kayit_sayisi"].ToString():"0"; model.totalActiveProcessedTask = (totalActiveProcessedTask != null && totalActiveProcessedTask.Tables[0].Rows.Count > 0) ? totalActiveProcessedTask.Tables[0].Rows[0]["kayit_sayisi"].ToString() : "0"; DataSet totalActiveTaskMy = BaseDB.DBManager.AppConnection.GetDataSet("select count(*) kayit_sayisi from tsk_tasks_v where is_active_bit=@is_active_bit and assigned_user_id=@assigned_user_id", new ArrayList { "is_active_bit", "assigned_user_id" }, new ArrayList { 1, SessionContext.Current.ActiveUser.UserUid }); DataSet totalActiveFinishedTaskMy = BaseDB.DBManager.AppConnection.GetDataSet("select count(*) kayit_sayisi from tsk_tasks_v where is_active_bit=@is_active_bit and task_status_id=@task_status_id and assigned_user_id=@assigned_user_id", new ArrayList { "is_active_bit", "task_status_id", "assigned_user_id" }, new ArrayList { 1, 6, SessionContext.Current.ActiveUser.UserUid }); DataSet totalActiveClosedTaskMy = BaseDB.DBManager.AppConnection.GetDataSet("select count(*) kayit_sayisi from tsk_tasks_v where is_active_bit=@is_active_bit and task_status_id=@task_status_id and assigned_user_id=@assigned_user_id", new ArrayList { "is_active_bit", "task_status_id", "assigned_user_id" }, new ArrayList { 1, 7, SessionContext.Current.ActiveUser.UserUid }); DataSet totalActiveProcessedTaskMy = BaseDB.DBManager.AppConnection.GetDataSet("select count(*) kayit_sayisi from tsk_tasks_v where is_active_bit=@is_active_bit and task_status_id in (2,3,4,8) and assigned_user_id=@assigned_user_id", new ArrayList { "is_active_bit", "assigned_user_id" }, new ArrayList { 1, SessionContext.Current.ActiveUser.UserUid }); model.totalActiveTaskMy = (totalActiveTaskMy != null && totalActiveTaskMy.Tables[0].Rows.Count > 0) ? totalActiveTaskMy.Tables[0].Rows[0]["kayit_sayisi"].ToString() : "0"; model.totalActiveFinishedTaskMy = (totalActiveFinishedTaskMy != null && totalActiveFinishedTaskMy.Tables[0].Rows.Count > 0) ? totalActiveFinishedTaskMy.Tables[0].Rows[0]["kayit_sayisi"].ToString() : "0"; model.totalActiveClosedTaskMy = (totalActiveClosedTaskMy != null && totalActiveClosedTaskMy.Tables[0].Rows.Count > 0) ? totalActiveClosedTaskMy.Tables[0].Rows[0]["kayit_sayisi"].ToString() : "0"; model.totalActiveProcessedTaskMy = (totalActiveProcessedTaskMy != null && totalActiveProcessedTaskMy.Tables[0].Rows.Count > 0) ? totalActiveProcessedTaskMy.Tables[0].Rows[0]["kayit_sayisi"].ToString() : "0"; #region Görev Bitiş Tarihi Geçmiş Olanların Bildirimleri Oluşturuluyor try { TaskRepository tskDB = RepositoryManager.GetRepository <TaskRepository>(); GenelRepository gnlDB = RepositoryManager.GetRepository <GenelRepository>(); DataSet dsExpireTask = tskDB.SendTaskExpireNotification(); foreach (DataRow row in dsExpireTask.Tables[0].Rows) { gnlDB.AddNotification(Guid.Parse(row["task_id"].ToString()), Guid.Parse(row["task_user_id"].ToString()), (int)Enums.NotificationType.Expire, (int)Enums.NotificationModuleType.Task, Resources.GlobalResource.task_expire_end_date_title, Resources.GlobalResource.task_expire_end_date_body); gnlDB.Kaydet(); gnlDB.AddNotification(Guid.Parse(row["task_id"].ToString()), Guid.Parse(row["assigned_user_id"].ToString()), (int)Enums.NotificationType.Expire, (int)Enums.NotificationModuleType.Task, Resources.GlobalResource.task_expire_end_date_title, Resources.GlobalResource.task_expire_end_date_body); gnlDB.Kaydet(); tsk_tasks task = new tsk_tasks(); task = tskDB.GetTask(Guid.Parse(row["task_id"].ToString())); tskDB.TaskMailSend(Guid.Parse(row["task_user_id"].ToString()), task.order_id.ToString(), task.task_name, task.task_id, "Task End Date Expired", "", "", "99"); tskDB.TaskMailSend(Guid.Parse(row["assigned_user_id"].ToString()), task.order_id.ToString(), task.task_name, task.task_id, "Task End Date Expired", "", "", "99"); } } catch (Exception exp) { } #endregion return(View(model)); }
//[AllowAnonymous] //[ValidateAntiForgeryToken] public async Task <IActionResult> Login(LoginViewModel login, string submit) { DAC dac = new DAC(appsetting, HttpContext); authData adata = new authData(); if (submit == "Login") { login.emailautofocus = "autofocus"; login.changepwdautofocus = ""; login.changediv = "none"; login.logindiv = "block"; login.resetdiv = "none"; login.passdiv = "block"; if (!ModelState.IsValid) { login.Message = "Login Failed"; return(View(login)); } try { adata = await dac.Login(login); } catch (Exception) { } login.Message = adata.message; if (adata.isAuth) { if (adata.isFirstLogin) { login.changediv = "block"; login.logindiv = "none"; login.emailautofocus = ""; login.changepwdautofocus = "autofocus"; login.Message = ""; login.Email = adata.email; login.Password = adata.password; login.id = adata.userid; return(View(login)); } HttpContext.Session.SetString("_email", adata.email); HttpContext.Session.SetString("_username", adata.username); Index index = new Models.Index() { authdata = adata, user = new Models.User() }; return(View("Index", index)); } } if (submit == "Change") { login.changepwdautofocus = "autofocus"; login.emailautofocus = ""; login.passwordautofocus = ""; login.confirmpwdautofocus = ""; login.changediv = "block"; login.logindiv = "none"; login.resetdiv = "none"; login.passdiv = "block"; if (string.IsNullOrEmpty(login.Email)) { login.changepwdautofocus = ""; login.emailautofocus = "autofocus"; login.passwordautofocus = ""; login.confirmpwdautofocus = ""; login.Message = "Enter Email"; return(View(login)); } if (string.IsNullOrEmpty(login.Password)) { login.changepwdautofocus = ""; login.emailautofocus = ""; login.passwordautofocus = "autofocus"; login.confirmpwdautofocus = ""; login.Message = "Enter Old Password"; return(View(login)); } if (string.IsNullOrEmpty(login.Changepwd)) { login.Message = "Enter New Password"; return(View(login)); } if (string.IsNullOrEmpty(login.Confirmpwd)) { login.changepwdautofocus = ""; login.emailautofocus = ""; login.passwordautofocus = ""; login.confirmpwdautofocus = "autofocus"; login.Message = "Confirm New Password"; return(View(login)); } if (login.Changepwd.Length < 8) { login.Message = "New Password must be at least 8 characters"; return(View(login)); } if (login.Changepwd != login.Confirmpwd) { login.Message = "Password Mismatch"; return(View(login)); } try { adata = await dac.activateUser(login); } catch (Exception ex) { Console.Write(ex.ToString()); } if (adata.isAuth) { login.emailautofocus = "autofocus"; login.changepwdautofocus = ""; login.changediv = "none"; login.logindiv = "block"; login.resetdiv = "none"; login.passdiv = "block"; Index index = new Models.Index() { authdata = adata, user = new Models.User() }; return(View("Index", index)); } else { login.Message = "Authentication Failed"; return(View(login)); } } return(View(login)); }