Ejemplo n.º 1
0
        public static WebRequest readRequestBody(HttpRequest Request)
        {
            WebRequest req = new WebRequest();

            req.requestId = Request.Headers.Get("requestId");
            var jsonString = String.Empty;

            Request.InputStream.Position = 0;
            using (var inputStream = new StreamReader(Request.InputStream))
            {
                jsonString = inputStream.ReadToEnd();
            }

            DebugConsole.Debug("Request Body: ", jsonString);

            if (jsonString == null || jsonString.Equals(""))
            {
                return(req);
            }

            req = (WebRequest)JsonConvert.DeserializeObject(jsonString, typeof(WebRequest));
            //IMPORTANT!!
            req.requestId = Request.Headers.Get("requestId");

            return(req);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更改节点
        /// </summary>
        /// <param name="xmlDoc"></param>
        /// <param name="xnsm"></param>
        /// <param name="codes"></param>
        public static void ChangeAutoItems(this XmlDocument xmlDoc, XmlNamespaceManager xnsm, List <CodeFile> codes)
        {
            var root = xmlDoc.DocumentElement;
            var node = root?.SelectSingleNode("/ns:Project/ns:ItemGroup/ns:Compile[@Include='Properties\\AssemblyInfo.cs']/..", xnsm);

            if (node == null)
            {
                throw new OperationCanceledException("工程文件异常,无法定位。请检查。");
            }

            foreach (var code in codes)
            {
                if (code.NoneAutoFile)
                {
                    var className = code.GetSubName(code.Name);
                    var xpath     = $"ns:Compile[@Include='{className}']";
                    var csNode    = node?.SelectSingleNode(xpath, xnsm);
                    if (csNode == null)
                    {
                        var classNode = xmlDoc.CreateElement("Compile", node.NamespaceURI);
                        classNode.SetAttribute("Include", className);
                        node.AppendChild(classNode);
                    }
                    else
                    {
                        DebugConsole.Debug($"{className} 已存在于项目中,跳过。");
                    }
                }
                else
                {
                    var autoClass = code.GetSubName(code.AutoName);
                    var xpath     = $"ns:Compile[@Include='{autoClass}']";
                    var csNode    = node?.SelectSingleNode(xpath, xnsm);
                    if (csNode == null)
                    {
                        var autoClassNode = xmlDoc.CreateElement("Compile", node.NamespaceURI);
                        autoClassNode.SetAttribute("Include", autoClass);
                        var uponNode = xmlDoc.CreateElement("DependentUpon", node.NamespaceURI);
                        uponNode.InnerText = $"{code.Name}";
                        autoClassNode.AppendChild(uponNode);
                        var classNode = xmlDoc.CreateElement("Compile", node.NamespaceURI);
                        classNode.SetAttribute("Include", code.GetSubName(code.Name));

                        node.AppendChild(autoClassNode);
                        node.AppendChild(classNode);
                    }
                    else
                    {
                        DebugConsole.Debug($"{autoClass} 已存在于项目中,跳过。");
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public SessionData getSessionData(string sessionVal)
        {
            try
            {
                string sessionValue = GetValue(sessionVal);
                object deserialized = serializer.Deserialize(sessionValue, typeof(SessionData));
                return((SessionData)deserialized);
            }
            catch (Exception e)
            {
                DebugConsole.Debug(this, "Error getting registry", e.Message);
            }


            return(null);
        }
Ejemplo n.º 4
0
        public bool putSession(String sessionVal, SessionData sessionData)
        {
            try
            {
                string jsonString = StringUtil.serializeCustomModel(sessionData);
                SetValue(sessionVal, jsonString);
                return(true);
            }
            catch (Exception e)
            {
                DebugConsole.Debug(this, "Error Updating registry", e.Message);
            }


            return(false);
        }
Ejemplo n.º 5
0
        public user GetUserByUsernameAndPassword(string Username, string Password)
        {
            DebugConsole.Debug(this, "DB ENTITIES IS NULL: " + (dbEntities == null));
            dbEntities = new mpi_dbEntities();
            if (dbEntities == null || Username == null || Password == null)
            {
                return(null);
            }

            DebugConsole.Debug(this, dbEntities.users.ToString());
            user User = (from u in dbEntities.users
                         where u.username.Equals(Username) && u.password.Equals(Password)
                         select u).SingleOrDefault();

            if (User != null)
            {
                return(User);
            }
            return(null);
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            DebugConsole.Debug(this, "Valid State: " + ModelState.IsValid);
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            //    var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);

            var  result = SignInStatus.Failure;
            user User   = UserService.GetUser(model.Username, model.Password);

            DebugConsole.Debug(this, "User: "******"loggedUser"] = User;
                UserValid();
            }

            switch (result)
            {
            case SignInStatus.Success:
                // return RedirectToLocal(returnUrl);
                return(RedirectToAction("Index", "Admin"));

            case SignInStatus.LockedOut:
                return(View("Lockout"));

            case SignInStatus.RequiresVerification:
                return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }));

            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }
        }
 void Debug(string message)
 {
     DebugConsole.Debug(this, message);
 }