コード例 #1
0
        public override void Process(HttpRequestArgs args)
        {
            // NOTE - no error handling added. Failed requests are expected to result in an unhandled exception, which should show friendly error page.

            // Only act on unauthenticated requests against the sign-in callback URL
            if (Context.User == null || Context.User.IsAuthenticated ||
                Context.User.Identity.GetType() == typeof(UserProfile) ||
                !args.Context.Request.Url.AbsoluteUri.StartsWith(Settings.SignInCallbackUrl))
            {
                return;
            }

            // Validate token and obtain claims
            //var tempCookie = args.Context.Request.Cookies[Settings.TempCookieName];
            var tempCookie     = new CookieHelper(Settings.TempCookieName, args.Context);
            var tempHttpCookie = tempCookie.GetCookie();
            var claims         = ValidateCodeAndGetClaims(args.Context.Request.QueryString["code"], args.Context.Request.QueryString["state"], tempHttpCookie).ToList();

            var userData = new UserIdamData(claims);

            _userDataService.SaveUserIdamDataToCookie(claims, args.Context);

            // Build sitecore user and log in - this will persist until log out or session ends.

            var user = BuildVirtualUser(userData);

            AuthenticationManager.LoginVirtualUser(user);

            var targetUrl = tempCookie.GetValue("returnUrl") ?? "/";

            tempCookie.Delete();

            WebUtil.Redirect(targetUrl);
        }
コード例 #2
0
        public void Delete_CookieDoesNotExistOnRequest_DoesNothing()
        {
            // Act
            CookieHelper.Delete("myKey");

            // Assert
            _context.Response.Cookies["myKey"].Should().BeNull();
        }
コード例 #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         CookieHelper.Delete(WebConfigurationManager.AppSettings["ManageDomain"]);
         Response.Redirect("admin_login.aspx");
     }
 }
コード例 #4
0
        public void Delete_CookieExistsOnRequest_ReaddsCookieToResponse_WithExpirationDateSetToYesterday()
        {
            // Arrange
            _context.Request.Cookies.Add(new HttpCookie("myKey")
            {
                Value = "myValue"
            });

            // Act
            CookieHelper.Delete("myKey");

            // Assert
            var cookie = _context.Response.Cookies["myKey"];

            cookie.Expires.Should().BeCloseTo(DateTime.Now.AddDays(-1));
        }
コード例 #5
0
        public static User GetCurrentUser()
        {
            if (HttpContext.Current.Session[SessionKeys.User] == null)
            {
                long uid;

                if (long.TryParse(CookieHelper.Get(CookieKeys.UserId), out uid))
                {
                    var user = DependencyResolver.Current.GetService <IUserService>().GetById(uid);

                    if (user != null && user.IsActive == true)
                    {
                        Login(user);
                    }
                    else
                    {
                        CookieHelper.Delete(uid.ToString());
                    }
                }
            }

            return((User)HttpContext.Current.Session[SessionKeys.User]);
        }
コード例 #6
0
        private void EnsureLoggedOut()
        {
            // If the request is (still) marked as authenticated we send the user to the logout action
            if (Request.IsAuthenticated)
            {
                // First we clean the authentication ticket like always
                //required NameSpace: using System.Web.Security;
                FormsAuthentication.SignOut();

                // Second we clear the principal to ensure the user does not retain any authentication
                //required NameSpace: using System.Security.Principal;
                HttpContext.User = new GenericPrincipal(new GenericIdentity(string.Empty), null);

                Session.Clear();
                System.Web.HttpContext.Current.Session.RemoveAll();
            }

            //Remove cookie
            CookieHelper.Delete(StaticValues.SessionFullName);
            CookieHelper.Delete(StaticValues.SessionProfileImg);
            CookieHelper.Delete(StaticValues.SessionRoleId);
            CookieHelper.Delete(StaticValues.SessionUserId);
        }
コード例 #7
0
 public void Delete(CookieType CookieName)
 {
     cookie.Delete(CookieName.ToString());
 }
        public ActionResult Matriz(int WorkzoneID, bool catchValueFromOficial = true)
        {
            CookieHelper.Delete("userId");
            var workzone = _workzone.GetWorkzoneById(WorkzoneID);

            try
            {
                //Veriica se o cara possui permissão para acessar a matriz de acordo com o CC
                //if (!AllowCC(workzone.idCC))
                //{
                //    //Response.Write("<script>alert('Sem acesso a esta tela. Verificar CC cadastrado no AutSis');</script>");
                //    //Thread.Sleep(3000);
                //    return RedirectToAction("Index", new { error = true });
                //}

                // DESCOMENTA ESSA LINHA DE CIMAAAAAAAAAAAAA DEPOIS
                SetImage();

                var exits        = _matrizService.GetMatrizByWZId(WorkzoneID);
                var matrizWz     = new tblMatrizWorkzone();
                var matrizWzTemp = new tblMatrizWorkzoneTemp();
                matrizWz.idMatrizWZ         = 0;
                matrizWzTemp.idMatrizWZTemp = 0;

                //VERIFICA SE A MATRIZ TEMPORÁRIA ESTÁ LIMPA
                var matrizTemp = _matrizTempService.GetMatrizTempByWZId(WorkzoneID);
                if (matrizTemp != null)
                {
                    _matrizFuncActivityTempService.DeleteMatrizTempAll(matrizTemp.idMatrizWZTemp);
                    _matrizFuncTrainingTempService.DeleteMatrizTempAll(matrizTemp.idMatrizWZTemp);
                    _matrizTempService.DeleteMatrizTemp(matrizTemp.idMatrizWZTemp);
                }


                if (exits == null)
                {
                    var username = "";
                    try
                    {
                        username = AuthorizationHelper.GetSystem().Usuario.ChaveAmericas;
                    }
                    catch
                    {
                        username = "";
                    }
                    // CRIA MATRIZ OFICIAL SE ELA N EXISTIR
                    tblMatrizWorkzone matrizXworzoneTemp = new tblMatrizWorkzone();
                    matrizXworzoneTemp.Usuario     = username;
                    matrizXworzoneTemp.DataCriacao = DateTime.Now;
                    matrizXworzoneTemp.idWorkzone  = WorkzoneID;
                    matrizWz = _matrizService.CreateMatriz(matrizXworzoneTemp);
                }
                else
                {
                    matrizWz = exits;
                }
                var exitsMTemp = _matrizTempService.GetMatrizTempByWZId(WorkzoneID);

                if (exitsMTemp == null)
                {
                    var username = "";
                    try
                    {
                        username = AuthorizationHelper.GetSystem().Usuario.ChaveAmericas;
                    }
                    catch
                    {
                        username = "";
                    }

                    // CRIA MATRIZ TEMPORÁRIA ONDE A EDIÇÃO SERÁ FEITA
                    tblMatrizWorkzoneTemp matrizXworzoneTempTemp = new tblMatrizWorkzoneTemp();
                    matrizXworzoneTempTemp.Usuario     = username;
                    matrizXworzoneTempTemp.DataCriacao = DateTime.Now;
                    matrizXworzoneTempTemp.idWorkzone  = WorkzoneID;
                    matrizWzTemp = _matrizTempService.CreateMatrizTemp(matrizXworzoneTempTemp);
                    exitsMTemp   = _matrizTempService.GetMatrizTempByWZId(WorkzoneID);

                    // VERIFICA SE A MATRIZ POSSUI AVALIAÇÕES EM ATIVIDADE
                    var avalAtiv = _matrizFuncActivityService.GetMatrizByMWZId(matrizWz.idMatrizWZ);
                    var idsActv  = new List <int>();

                    if (avalAtiv.Count() > 0)
                    {
                        tblMatrizFuncXAtividadesTemp newAvalObj = new tblMatrizFuncXAtividadesTemp();
                        var existInActivityAssociation          = _workzoneXActivity.GetWorzoneXActivityListByIdWz(matrizWz.idWorkzone);

                        foreach (var aval in avalAtiv)
                        {
                            if (existInActivityAssociation.Where(a => a.tblAtividades.idAtividade == aval.idAtividade) != null)
                            {
                                newAvalObj = new tblMatrizFuncXAtividadesTemp();

                                newAvalObj.idAtividade          = aval.idAtividade;
                                newAvalObj.idFuncionario        = aval.idFuncionario;
                                newAvalObj.idItemPerfil         = aval.idItemPerfil;
                                newAvalObj.idMatrizWorkzoneTemp = matrizWzTemp.idMatrizWZTemp;

                                _matrizFuncActivityTempService.CreateMatrizTemp(newAvalObj);
                            }
                            else
                            {
                                idsActv.Add(aval.idAtividade);
                            }
                        }
                    }


                    // VERIFICA SE A MATRIZ POSSUI AVALIAÇÕES EM TREINAMENTOS
                    var avalTrein = _matrizFuncTrainingService.GetMatrizByIdMWZ(matrizWz.idMatrizWZ);

                    if (avalTrein.Count() > 0)
                    {
                        tblMatrizFuncXTreinamentoTemp newTreinObj = new tblMatrizFuncXTreinamentoTemp();


                        foreach (var aval in avalTrein)
                        {
                            var training = _training.GetTrainingById(aval.idTreinamento);
                            var existTrainingInAssociation = true;

                            //VERIFICA SE AQUELE TREINAMENTO[N] QUE POSSUI AVALIAÇÃO EXISTE AINDA NA ASSOCIAÇÃO
                            // OU SE FOI DESASSOCIADO
                            foreach (var id in idsActv)
                            {
                                var returned = training.tblAtividadeXTreinamentos.Where(a => a.tblAtividades.idAtividade == id);
                                if (returned.Count() > 0)
                                {
                                    existTrainingInAssociation = true;
                                }
                            }

                            if (idsActv.Count == 0)
                            {
                                existTrainingInAssociation = true;
                            }

                            if (existTrainingInAssociation)
                            {
                                newTreinObj = new tblMatrizFuncXTreinamentoTemp();

                                newTreinObj.idTreinamento        = aval.idTreinamento;
                                newTreinObj.idFuncionario        = aval.idFuncionario;
                                newTreinObj.idItemPerfil         = aval.idItemPerfil;
                                newTreinObj.idMatrizWorkzoneTemp = matrizWzTemp.idMatrizWZTemp;

                                _matrizFuncTrainingTempService.CreateMatrizTemp(newTreinObj);
                            }
                        }
                    }
                }

                var activiesList = _workzoneXActivity.SetUpActivitiesList(WorkzoneID);
                List <tblTreinamento>     trainingList = new List <tblTreinamento>();
                List <tblTipoTreinamento> ttList       = new List <tblTipoTreinamento>();


                // OBTER TODAS OS TREINAMENTOS DE TODAS ATIVIDADES DA ZONA
                // E OS SEUS TIPOS
                foreach (var aList in activiesList)
                {
                    //Pega todos IDs de atividades associados a treinamentos DA ZONA
                    foreach (var aXt in aList.tblAtividadeXTreinamentos.OrderBy(t => t.tblTreinamento.idTipoTreinamento))
                    {
                        var x = aList.tblAtividadeXTreinamentos.OrderBy(t => t.tblTreinamento.idTipoTreinamento);

                        var aux = _training.GetTrainingById(aXt.idTreinamento);


                        //Verifica se o treinamento já existe na Lista
                        if (trainingList.Exists(t => t.IdTreinamento == aux.IdTreinamento) == false)
                        {
                            trainingList.Add(aux);
                        }

                        if (ttList.Exists(t => t.IdTipoTreinamento == aux.tblTipoTreinamento.IdTipoTreinamento) == false)
                        {
                            ttList.Add(aux.tblTipoTreinamento);
                        }
                    }
                }

                if (activiesList.Count() > 0 && trainingList.Count() > 0 && workzone.tblWorkzoneXFuncionario.Count() > 0)
                {
                    ViewBag.show = true;
                }
                else
                {
                    ViewBag.show = false;
                }

                ViewBag.trainingList  = trainingList.OrderBy(t => t.idTipoTreinamento);
                ViewBag.activiesList  = activiesList;
                ViewBag.ttList        = ttList.OrderBy(t => t.IdTipoTreinamento);
                ViewBag.tListCount    = trainingList.Count();
                ViewBag.activiesCount = activiesList.Count();
                ViewBag.ttListCount   = ttList.Count();
                ViewBag.MWZID         = matrizWz.idMatrizWZ;
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message.ToString());
            }

            return(View("Matriz", workzone));
        }
コード例 #9
0
ファイル: MemberCenter.cs プロジェクト: zhongshuiyuan/MT2017
 /// <summary>
 /// 退出
 /// </summary>
 public static void SignOut()
 {
     CookieHelper.Delete("member");
     HttpContext.Current.Session.Clear();
     HttpContext.Current.Session.Abandon();
 }
コード例 #10
0
 public void LogOff()
 {
     CookieHelper.Delete(CookieKeys.UserId);
     Session.Remove(SessionKeys.User);
     Response.Redirect("~/Backend/Login", true);
 }
コード例 #11
0
        public JsonResult Checkout(string name, string email, string phone)
        {
            try
            {
                using (db)
                {
                    var cookieCart = CookieHelper.Get(StaticValues.CookieNameCartCookie);

                    if (!string.IsNullOrWhiteSpace(cookieCart))
                    {
                        var contact = new Contact
                        {
                            Name             = name,
                            CreatedDate      = DateTime.UtcNow,
                            Email            = email,
                            Mobile           = phone,
                            IsProductInquiry = true
                        };
                        db.Contacts.Add(contact);
                        db.SaveChanges();

                        var cartDetails = db.CartDetails.Where(s => s.CartCookie == cookieCart).ToList();

                        if (cartDetails.Any())
                        {
                            foreach (var item in cartDetails)
                            {
                                item.ContactId       = contact.ContactId;
                                db.Entry(item).State = EntityState.Modified;
                                db.SaveChanges();
                            }
                        }

                        //Send Email
                        var tabledata = string.Empty;

                        if (cartDetails.Any())
                        {
                            tabledata =
                                "<table class=\"one-column\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100% \" style=\"border-spacing:0; border-left:1px solid #e8e7e5; border-right:1px solid #e8e7e5; border-bottom:1px solid #e8e7e5; border-top:1px solid #e8e7e5\" bgcolor=\"#FFFFFF\"> <tbody>";
                            double finalTotal = 0;

                            foreach (var item in cartDetails)
                            {
                                var    offerApplied = string.Empty;
                                double price        = item.Price;
                                price = price * item.Quantity;

                                if (item.Discount > 0)
                                {
                                    price        = price - item.Discount;
                                    offerApplied = "<br / ><label style='color: green; font-weight: 400; display: block; font-size: 12px;'>Discount: Rs " + item.OfferTitle + "</label>";
                                }

                                double tax = (price * item.TAX) / 100;
                                price += tax;

                                tabledata += "<tr> " +
                                             "<td style=\"width: 65%; padding: 8px\"> " + item.Product.ProductName +
                                             "" + offerApplied + "</td> " +
                                             "<td style=\"width: 10%; padding: 8px;text-align: center\"> " + item.Product.Price +
                                             "</td> " +
                                             "<td style=\"width: 15%; padding: 8px; text-align: center\">Tax: " +
                                             item.TAX + "%</td> " +
                                             "<td style=\"width: 10%; padding: 8px; text-align: center\">x " +
                                             item.Quantity + "</td> " +
                                             "<td style=\"width: 10%; padding: 8px; text-align: right\"><b>Rs " +
                                             price + "</b></td> </tr>";

                                finalTotal += price;
                            }

                            tabledata +=
                                "<tr> <td colspan=\"5\" style=\"padding: 8px; text-align: right\"><b>Total Amount : Rs " +
                                finalTotal + "</b></td> </tr> </tbody> </table>";
                        }

                        var replacement = new Dictionary <string, string>
                        {
                            { "#name#", name },
                            { "#email#", !string.IsNullOrEmpty(email)?"Email : " + email:"Email : No email provided" },
                            { "#phone#", "Phone : " + phone },
                            { "#tabledata#", tabledata }
                        };

                        var emailTemplete =
                            CommonFunctions.GetEmailTemplete((int)EnumList.EmailTemplete.ContactProduct, true,
                                                             replacement);

                        if (emailTemplete != null)
                        {
                            if (!string.IsNullOrEmpty(email))
                            {
                                //Send to user
                                SendEmail.Send(emailTemplete.Subject, emailTemplete.Body, email);
                            }

                            //Send to admin
                            SendEmail.Send(emailTemplete.Subject, emailTemplete.Body,
                                           @System.Web.HttpContext.Current.Application["email"].ToString());
                        }

                        CookieHelper.Delete(StaticValues.CookieNameCartCookie);
                    }

                    return(Json(new { status = true, JsonRequestBehavior.AllowGet }));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
コード例 #12
0
        public void DeleteUserIdamDataCookie(HttpContext context)
        {
            var cookie = new CookieHelper(Settings.UserDataCookieName, context);

            cookie.Delete();
        }