public virtual TblRedirects PrepareTblRedirects(RedirectModel rule)
        {
            var result = rule.Adapt <TblRedirects>();

            result.Name = string.IsNullOrWhiteSpace(rule.Name) ? rule.RequestedUrl : rule.Name;
            return(result);
        }
Esempio n. 2
0
        public async Task <ActionResult> EnterPasswordCallback(RedirectModel model)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Index"));
            }

            var guestType      = GuestStore.Helpers.GetGuestTypeFromPassword(model.Password);
            var guestTypeClaim = new Claim("GuestType", guestType.ToString());
            var guestId        = new Claim("GuestId", Guid.NewGuid().ToString());

            var identity = new ClaimsIdentity(new[] { guestTypeClaim, guestId }, DefaultAuthenticationTypes.ApplicationCookie);

            var guestManager = new GuestStore.GuestManager();
            var user         = new ApplicationUser();

            await SignInManager.SignInAsync(new ApplicationUser(), true, true);

            //var newGuest = new GuestViewModel { GuestType = guestType };

            //await guestManager.AddGuest(newGuest);
            IPasswordMapperRepository mapWriter = new CSVStorer();

            return(Redirect(model.ReturnUrl));
        }
Esempio n. 3
0
        private async Task <RedirectModel> CreateRedirectAsync(string logoutId)
        {
            LogoutRequest logout = await _interaction.GetLogoutContextAsync(logoutId);

            RedirectModel vm = new RedirectModel
            {
                RedirectUri      = logout?.PostLogoutRedirectUri,
                ClientName       = string.IsNullOrEmpty(logout?.ClientName) ? logout?.ClientId : logout?.ClientName,
                SignOutIframeUrl = logout?.SignOutIFrameUrl,
                LogoutId         = logoutId
            };

            if (User?.Identity.IsAuthenticated == true)
            {
                string idp = User.FindFirst(JwtClaimTypes.IdentityProvider)?.Value;

                if (idp != null && idp != IdentityServer4.IdentityServerConstants.LocalIdentityProvider)
                {
                    bool providerSupportsSignout = await HttpContext.GetSchemeSupportsSignOutAsync(idp);

                    if (providerSupportsSignout)
                    {
                        if (vm.LogoutId == null)
                        {
                            vm.LogoutId = await _interaction.CreateLogoutContextAsync();
                        }

                        vm.ExternalAuthenticationScheme = idp;
                    }
                }
            }

            return(vm);
        }
Esempio n. 4
0
        public void UpdateRedirect(Guid id, DateTime lastUse)
        {
            if (id == Guid.Empty || lastUse == DateTime.MinValue)
            {
                return;
            }

            var redirect = new RedirectModel
            {
                RedirectId = id,
                LastUse    = lastUse,
            };

            var query          = Query.EQ("RedirectId", id);
            var redirectRecord = this.redirectsСollection.FindOne(query);

            if (redirectRecord != null)
            {
                if (lastUse.Date > redirectRecord.LastUse.Date)
                {
                    this.redirectsСollection.Remove(query);
                    this.redirectsСollection.Insert(redirect);
                }
            }
            else
            {
                this.redirectsСollection.Insert(redirect);
            }
        }
Esempio n. 5
0
        public IActionResult Index([FromForm] string postbackurl)
        {
            var model = new RedirectModel
            {
                Url = postbackurl
            };

            return(View(model));
        }
Esempio n. 6
0
        public ActionResult Add(int Type, string Pattern, string Destination, string Comment)
        {
            // Take the passed paraneters and create a Redirect Object with a null ID
            RedirectModel add = new RedirectModel(0, Pattern, Type, Comment, Destination);

            // pass the redirect to the UpdateDatabase method and specify true that it is a new redirect
            UpdateDatabase(add, true);
            return(RedirectToRoute("ViewRedirects", new { Type = Type, Alert = string.Format("The Redirect for: {0} has been created.", Pattern) }));
        }
    public static void UpdateRedirectList(RedirectModel redirect)
    {
        RedirectModel rm = RedirectList.Single(x => x.RedirectId == redirect.RedirectId);

        //rm.SourceType = redirect.SourceType;
        //rm.Source = redirect.Source;
        //rm.TargetType = redirect.TargetType;
        //rm.Target = redirect.Target;
        //rm.RedirectType = redirect.RedirectType;
    }
Esempio n. 8
0
        public ActionResult Delete(int Type, int RedirectID, string Pattern)
        {
            // Create a null Redirect with the passed ID
            RedirectModel delete = new RedirectModel(RedirectID, null, 0, null, null);

            // Connect to the database and Delete the Redirect
            SqlHelper.ExecuteNonQuery(ConfigurationManager.ConnectionStrings["RedirectsWriter"].ConnectionString, CommandType.StoredProcedure, "usp_Redirect_Delete", new SqlParameter("@redirectId", RedirectID));
            // Return the Success view and pass it the redirect to display
            return(RedirectToRoute("ViewRedirects", new { Type = Type, Alert = string.Format("Redirect {0} for: \"{1}\" has been deleted.", RedirectID, Pattern) }));
        }
Esempio n. 9
0
        public ActionResult Edit(int RedirectID, int Type, string Pattern, string Destination, string Comment)
        {
            // Take the passed parameters and create a Redirect object
            RedirectModel edit = new RedirectModel(RedirectID, Pattern, Type, Comment, Destination);

            // pass the redirect to the updateDatabase method, and specify false that it is not a new redirect
            UpdateDatabase(edit, false);
            // Return the Success view, and pass it the redirect to display
            return(RedirectToRoute("ViewRedirects", new { Type = Type, Alert = string.Format("Redirect {0} for: \"{1}\" has been updated.", RedirectID, Pattern) }));
        }
Esempio n. 10
0
        private void LoadProfile()
        {
            try
            {
                using (FileStream fs = new FileStream("D:\\MatServer\\CONFIG.XML", FileMode.Open))
                {
                    XmlSerializer formatter = new XmlSerializer(typeof(XmlData));
                    xmlData = (XmlData)formatter.Deserialize(fs);
                }
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load("D:\\MatServer\\REDIRECT.XML");
                XmlNode     xn  = xmlDoc.SelectSingleNode("Root");
                XmlNodeList xnl = xn.ChildNodes;
                redirectDict = new Dictionary <int, RedirectModel>();
                foreach (XmlNode cn in xnl)
                {
                    RedirectModel redirectModel = new RedirectModel();
                    XmlElement    xe            = (XmlElement)cn;
                    redirectModel.id           = int.Parse(xe.GetAttribute("ID").ToString());
                    redirectModel.redirectName = xe.GetAttribute("Name").ToString();
                    redirectModel.funcName     = xe.SelectSingleNode("funcName").InnerText;
                    redirectModel.connStr      = ConfigurationManager.ConnectionStrings[xe.SelectSingleNode("connStr").InnerText].ToString();
                    redirectModel.pkgName      = ConfigurationManager.AppSettings[xe.SelectSingleNode("pkgName").InnerText];
                    redirectModel.pFlag        = int.Parse(xe.SelectSingleNode("pflag").InnerText);
                    redirectModel.isCache      = xe.SelectSingleNode("isCache").InnerText;
                    redirectModel.area         = int.Parse(xe.SelectSingleNode("area").InnerText);
                    redirectModel.type         = int.Parse(xe.SelectSingleNode("type").InnerText);
                    redirectModel.command      = int.Parse(xe.SelectSingleNode("command").InnerText);
                    if (redirectDict.ContainsKey(redirectModel.id))
                    {
                        LoggerHelper.Info("重复加载处理模块 ID:" + redirectModel.id + " Name:" + redirectModel.redirectName);
                    }
                    else
                    {
                        redirectDict.Add(redirectModel.id, redirectModel);
                        LoggerHelper.Info("载入处理模块 ID:" + redirectModel.id + " Name:" + redirectModel.redirectName);
                    }
                }

                mainList = new Dictionary <string, actionByMain>();
                mainList.Add("nlscan_pkg", nlscan_pkg);
                mainList.Add("UpdateClientConfig", UpdateClientConfig);
                mainList.Add("CheckVersion", CheckVersion);


                LoggerHelper.Info("读取配置成功!");
            }
            catch (Exception e)
            {
                LoggerHelper.Info("读取配置失败!  " + e.Message);
            }
        }
Esempio n. 11
0
        public RedirectModel GetRedirect(int id)
        {
            // Create a new null Redirect
            RedirectModel redirect = new RedirectModel(0, null, 0, null, null);

            // Connect to the Database and use the usp_Redirect_Select stored procedure and id to get a single Redirect.
            using (var reader = SqlHelper.ExecuteReader(ConfigurationManager.ConnectionStrings["RedirectsWriter"].ConnectionString, CommandType.StoredProcedure, "usp_Redirect_Select", new SqlParameter("@redirectId", id)))
            {
                while (reader.Read())
                {
                    redirect = new RedirectModel(Int32.Parse(reader["RedirectId"].ToString()), reader["Pattern"].ToString(), Int32.Parse(reader["Type"].ToString()), reader["Comment"].ToString(), reader["Destination"].ToString());
                }
            }
            return(redirect);
        }
        public ActionResult Create(RedirectModel model)
        {
            if (ModelState.IsValid)
            {
                _redirectRepository.Create(new Redirect
                {
                    IsPermanent = !model.Temporary,
                    OldRoute    = model.From.TrimStart('/'),
                    NewRoute    = "/" + model.To.TrimStart('/'),
                    BlogId      = CurrentBlog.Id
                });
                return(Json(new { success = true }));
            }

            return(PartialView("CreateModal", model));
        }
Esempio n. 13
0
        public void UpdateDatabase(RedirectModel redirect, Boolean newEntry)
        {
            // bug fix #1
            // Strip the protocal and domain if entered by the user
            // Use try catch in case user types in a relative path
            string absolute = "";

            try
            {
                Uri from = new Uri(redirect.Pattern);
                absolute = from.AbsolutePath;
            }
            catch (Exception)
            {
                absolute = redirect.Pattern;
            }

            // bug fix #2
            // There can be trouble redirecting using URLs with a trailing /
            // Use TrimEnd() to remove any trailing / characters from the pattern and destination.
            absolute             = absolute.TrimEnd('/');
            redirect.Destination = redirect.Destination.TrimEnd('/');

            // Create an array of SqlParameters and populate the data from the passed Redirect Object.
            var values = new SqlParameter[5];

            values[0] = new SqlParameter("@pattern", absolute);
            values[1] = new SqlParameter("@destination", redirect.Destination);
            values[2] = new SqlParameter("@type", redirect.Type);
            values[3] = new SqlParameter("@comment", redirect.Comment);

            // If the redirect is not a new redirect
            if (newEntry == false)
            {
                // add an extra parameter for the ID
                values[4] = new SqlParameter("@redirectId", redirect.RedirectID);
                // connect to the database and update the Redirect
                SqlHelper.ExecuteNonQuery(ConfigurationManager.ConnectionStrings["RedirectsWriter"].ConnectionString, CommandType.StoredProcedure, "usp_Redirect_Update", values);
            }
            // if the redirect is a new redirect
            else
            {
                // connect to the database and insert the new redirect
                SqlHelper.ExecuteNonQuery(ConfigurationManager.ConnectionStrings["RedirectsWriter"].ConnectionString, CommandType.StoredProcedure, "usp_Redirect_Insert", values);
            }
        }
Esempio n. 14
0
        public ActionResult Index(RedirectModel model)
        {
            // Check that a file was indeed uploaded.
            var file = Request.Files.Get("userfile");

            if (file == null || string.IsNullOrEmpty(file.FileName))
            {
                throw new Exception("No files uploaded");
            }
            var extension = new FileInfo(file.FileName).Extension;

            // Save the file to the App_Data folder with the unique filename.
            var fileId = StorageMock.Store(file.InputStream, extension);

            // Redirect the user to the ReturnController, passing the name of the file as a URL argument.
            return(RedirectToAction("Index", model.ReturnController, new { userfile = fileId }));
        }
Esempio n. 15
0
        public IActionResult AddOrEdit(RedirectModel redirect)//[FromBody]
        {
            // OK
            if (redirect.DomainId == EnumDomain.FR_FR)
            {
                return(Ok(new ResultModel
                {
                    Success = true,
                    Message = "insert sucessful",
                    Data = new { RedirectId = 123 }
                }));
            }

            if (redirect.RedirectId == null)
            {
                return(Ok(new ResultModel
                {
                    Success = true,
                    Message = "insert voor " + redirect.DomainId.ToString(),
                    Data = new { RedirectId = 123 }
                }));
            }
            if (redirect.RedirectId.HasValue)
            {
                return(Ok(new ResultModel
                {
                    Success = true,
                    Message = "update voor " + redirect.DomainId.ToString() + " succes voll",
                    Data = new { RedirectId = 123 }
                }));
            }


            redirect = null;

            Thread.Sleep(10000);

            return(Ok(new ResultModel
            {
                Success = false,
                Message = ""
            }));
        }
Esempio n. 16
0
        private void analysis(UserToken token, SocketModel socketModel)
        {
            TransDTO      transDTO      = socketModel.message as TransDTO;
            RedirectModel redirectModel = new RedirectModel();

            if (Config.Instance.redirectDict.TryGetValue(transDTO.pflag, out redirectModel))
            {
                //跳转到对应的处理
                Config.Instance.mainList[redirectModel.funcName](transDTO, redirectModel);
            }
            else
            {
                Config.Instance.outStr = "找不到对应的处理模块!";
                LoggerHelper.Info(token.connectSocket.RemoteEndPoint.ToString() + "  --找不到对应的处理模块!");
                redirectModel.area    = 1;
                redirectModel.type    = 1;
                redirectModel.command = 1;
            }
            sendHandler.write(token, redirectModel.type, redirectModel.area, redirectModel.command, Config.Instance.outStr);
        }
        public virtual async Task <ActionResult> EntitySlugEditor(RedirectModel model)
        {
            model.Active = true;
            model.StopProcessingOfSubsequentRules = false;
            model.AppendQueryString = true;
            model.IgnoreCase        = true;
            model.Order             = 0;
            model.Name = model.RequestedUrl;

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var record = _redirectModelFactory.PrepareTblRedirects(model);

            try
            {
                if (model.Id == null)
                {
                    //Add new record
                    await _redirectsService.AddAsync(record);
                }
                else
                {
                    //Edit record
                    await _redirectsService.UpdateAsync(record);
                }
            }
            catch (Exception e)
            {
                var errorCode = ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(new Error(e, System.Web.HttpContext.Current));
                ModelState.AddModelError("", string.Format(_localizationService.GetResource("ErrorOnOperation"), e.Message, errorCode));
                return(View(model));
            }

            return(Content($@"<script language='javascript' type='text/javascript'>
                                window.close();
                                window.opener.refreshRedirectsGrid();
                             </script>"));
        }
        public virtual async Task <ActionResult> Editor(RedirectModel model, bool?saveAndContinue)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var record   = _redirectModelFactory.PrepareTblRedirects(model);
            var recordId = model.Id;

            try
            {
                if (model.Id == null)
                {
                    //Add new record
                    recordId = await _redirectsService.AddAsync(record);
                }
                else
                {
                    //Edit record
                    await _redirectsService.UpdateAsync(record);
                }
            }
            catch (Exception e)
            {
                var errorCode = ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(new Error(e, System.Web.HttpContext.Current));
                ModelState.AddModelError("", string.Format(_localizationService.GetResource("ErrorOnOperation"), e.Message, errorCode));
                return(View(model));
            }

            if (saveAndContinue != null && saveAndContinue.Value)
            {
                return(RedirectToAction("Editor", "ManageRedirects", new { id = recordId }));
            }

            return(Content(@"<script language='javascript' type='text/javascript'>
                                window.close();
                                window.opener.refreshRedirectsGrid();
                             </script>"));
        }
Esempio n. 19
0
        public IList <RedirectModel> GetRedirectsByDestination(string destinationUrl)
        {
            IList <RedirectModel> redirectsList = new List <RedirectModel>();

            // define connection and command, in using blocks to ensure disposal
            using (var conn = new SqlConnection(_dbConnString))
                using (var cmd = new SqlCommand("[dbo].[usp_Redirect_SelectByDestination]", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    var paramUrl = new SqlParameter
                    {
                        ParameterName = "@destination",
                        SqlDbType     = SqlDbType.VarChar,
                        Value         = destinationUrl
                    };

                    cmd.Parameters.Add(paramUrl);
                    conn.Open();

                    using (var rtn = cmd.ExecuteReader())
                    {
                        while (rtn.Read())
                        {
                            var redirectItem = new RedirectModel
                            {
                                RedirectId  = rtn.GetFieldValue <int>(0),
                                Pattern     = rtn.GetFieldValue <string>(1),
                                Destination = rtn.GetFieldValue <string>(2),
                                Type        = rtn.GetFieldValue <int>(3),
                                Comment     = rtn.GetFieldValue <string>(4),
                                DateCreated = rtn.GetFieldValue <DateTime>(5)
                            };

                            redirectsList.Add(redirectItem);
                        }
                    }

                    return(redirectsList);
                }
        }
        public ActionResult Delete(int id, RedirectModel model)
        {
            var redirect = _redirectRepository.GetBy(r => r.Id == id);

            if (redirect == null)
            {
                throw new HttpException((int)HttpStatusCode.NotFound, "The specified redirect was not found");
            }
            if (ModelState.IsValid)
            {
                _redirectRepository.Delete(redirect);
                return(Json(new { success = true }));
            }

            return(PartialView("DeleteModal", new RedirectModel
            {
                Id = redirect.Id,
                From = redirect.OldRoute,
                To = redirect.NewRoute,
                Temporary = !redirect.IsPermanent
            }));
        }
Esempio n. 21
0
    public async Task <IActionResult> Index(int id)
    {
        var publication = await _publicationRepository.GetPublication(id);

        if (publication == null)
        {
            return(NotFound());
        }

        var model = new RedirectModel
        {
            Title       = publication.Title,
            Description = publication.Description,
            Url         = new Uri(publication.Link),
            Image       = _settings.FacebookImage,
            Keywords    = _settings.DefaultDescription
        };

        Response.StatusCode = (int)HttpStatusCode.PermanentRedirect;
        Response.Headers.Add("location", publication.Link);

        return(View(model));
    }
Esempio n. 22
0
        public async Task <IActionResult> PostLogout(string logoutId)
        {
            RedirectModel redirect = await CreateRedirectAsync(logoutId);

            if (User?.Identity.IsAuthenticated == true)
            {
                await _signInManager.SignOutAsync();

                await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName()));
            }

            if (redirect.TriggerExternalSignout)
            {
                string url = Url.Action("Logout", new {
                    logoutId = redirect.LogoutId
                });

                return(SignOut(new AuthenticationProperties {
                    RedirectUri = url
                }, redirect.ExternalAuthenticationScheme));
            }

            return(Redirect(!string.IsNullOrWhiteSpace(redirect.RedirectUri) ? redirect.RedirectUri : "/"));
        }
Esempio n. 23
0
        public ActionResult HandleResponse(int optCode, int eventCode)
        {
            EventResponseModel erm      = new EventResponseModel();
            object             response = null;
            Event e;

            using (var service = new EventService())
            {
                e = service.Get(eventCode);
            }
            MessageResponseOption o;

            using (var service = new MessageResponseOptionService())
            {
                o = service.Get(optCode);
            }
            if (e != null && o != null)
            {
                response = EventProcessingService.HandleResponse(o, e);
            }
            if (response == null)
            {
                erm.ErrorMessage = "We're sorry, an application error has occurred. In order to process your request, please call your local pharmacy.";
            }
            else if (response is RedirectModel)
            {
                RedirectModel rm = (RedirectModel)response;
                return(RedirectToAction(rm.Action, rm.Controller));
            }
            else if (response.GetType() == typeof(string))
            {
                erm.SuccessMessage = (string)response;
            }

            return(View(erm));
        }
Esempio n. 24
0
        protected IEnumerable <RedirectModel> ExecuteSelect(IDbCommand cmd, SqlDataReader reader)
        {
            List <RedirectModel> l = new List <RedirectModel>();

            while (reader.Read())
            {
                RedirectModel rm = new RedirectModel();
                rm.RedirectId   = (int)reader["RedirectId"];
                rm.DomainId     = (EnumDomain)Convert.ToInt32(reader["DomainId_fk"]);
                rm.SourceType   = (EnumSourceTypeTargetType)Convert.ToInt32(reader["SourceType"]);
                rm.Source       = reader["Source"].ToString();
                rm.TargetType   = (EnumSourceTypeTargetType)Convert.ToInt32(reader["TargetType"]);
                rm.Target       = reader["Target"].ToString();
                rm.RedirectType = (EnumRedirectType)Convert.ToInt32(reader["RedirectType"]);
                rm.DeletionDate = reader["DeletionDate"] == DBNull.Value ? null : (DateTime?)reader["DeletionDate"];
                l.Add(rm);
            }

            if (!reader.IsClosed)
            {
                reader.Close();
            }
            return(l);;
        }
Esempio n. 25
0
        // [Authorize(Policy = AuthorizePolicyConsts.Redirect_Read_Write)] ddddddddddddd eeeeee
        //   [Route("redirect/import")]
        public ActionResult Import(IFormFile file, int?domainId = null)
        {
            return(Ok(new ResultModel
            {
                Message = $"upload for domain id {domainId} successful !"
            }));


            return(Ok("ddd"));

            var redirects = new List <RedirectModel>();

            var current_line = 2; //not 0 to skip header

            using (var stream = file.OpenReadStream())
            {
                var conf = new Configuration()
                {
                    Delimiter = ";",
                    // disable header and field validation, not all fields are present in the csv file
                    HeaderValidated   = null,
                    MissingFieldFound = null,
                    TrimOptions       = TrimOptions.Trim,
                    IgnoreBlankLines  = true,
                    // Deal with spotty headers, � characters appears sometimes (from Excel ?)
                    PrepareHeaderForMatch = (string header, int index) => header.Replace("�", string.Empty).ToLower().Trim()
                };

                using (var reader = new CsvReader(new StreamReader(stream), conf))
                {
                    // Ignore header case.
                    while (reader.Read())
                    {
                        RedirectModel dto = null;
                        try
                        {
                            var record = reader.GetRecord <RedirectModel>();
                        }
                        catch (ReaderException) // Le fichier est aussi corrompu que François Fillon.
                        {
                            // report.AddReport(RedirectResources.app_redirect_csvfile_invalidformat, 0);     sss
                            return(BadRequest());
                        }

                        catch (TypeConverterException e)
                        {
                            //    report.AddReport(e.Text + " " + RedirectResources.app_invalid_value, current_line);
                        }
                        catch (Exception) // Le fichier est aussi corrompu que François Fillon.
                        {
                            // report.AddReport(RedirectResources.app_redirect_csvfile_invalidformat, 0);
                            return(BadRequest());
                        }


                        if (dto != null)
                        {
                            redirects.Add(dto);
                        }
                        current_line++;
                    }
                }
            }


            return(Ok("ddd"));
        }
Esempio n. 26
0
 private void CheckVersion(TransDTO transDTO, RedirectModel redirectModel)
 {
     outStr = "CheckVersion";
     LoggerHelper.Info(transDTO.ip + "  --CheckVersion");
 }
Esempio n. 27
0
 private void nlscan_pkg(TransDTO transDTO, RedirectModel redirectModel)
 {
     outStr = OracleController.NlscanPkg(redirectModel.connStr, redirectModel.pkgName, redirectModel.pFlag
                                         , transDTO.codestr, transDTO.ip, transDTO.appName, transDTO.stockNo, redirectModel.isCache);
     LoggerHelper.Info(transDTO.ip + "  --nlscan_pkg:" + outStr);
 }
Esempio n. 28
0
 public void SaveInfo(RedirectModel log)
 {
     _logRepository.SaveLog(log);
 }
Esempio n. 29
0
 private void UpdateClientConfig(TransDTO transDTO, RedirectModel redirectModel)
 {
     outStr = "UpdateClientConfig";
     LoggerHelper.Info(transDTO.ip + "  --UpdateClientConfig");
 }