Пример #1
0
        public static Response Process_Index(Request request)
        {
            var pre_Ei = request.Simple_Preprocess(Constants.C_Dyn_0);

            if (pre_Ei.HasLeft)
            {
                return(pre_Ei.Left);
            }
            var req_body = request.Body_Get <Req_User>(Constants.C_Dyn_0);

            req_body.DoWhen(b => !string.IsNullOrEmpty(b.u_idfa), fu => DataAccess.User_Ifda_Insert(fu.u_idfa));
            req_body.DoWhen(b => b.u_id > 0 && !string.IsNullOrWhiteSpace(b.u_clientID), fu => DataAccess.User_ClientID_Insert(fu.u_id, fu.u_clientID));

            var user_Mb = req_body.Where(u => !string.IsNullOrEmpty(u.u_name))
                          .Select(u => DataAccess.User_FromName_Select(u.u_name).ToMaybe());        // get user according to the user name


            var token = user_Mb.HasValue        // generate a token value
                ? new Token(pre_Ei.Right, user_Mb.Value.u_id.ToString(), user_Mb.Value.u_name).Compose(t => Cipher_Md5.Md5_16(t)).Induce()
                : new Token(pre_Ei.Right).Compose(t => Cipher_Md5.Md5_16(t)).Induce();

            var head = new Response_Head().ToJson();
            var body = Resp_Index.Resp_Indices.First().SetToken(token).ToJson();

            var response = new Response(head.ToEncryption(EncryptType.PT | EncryptType.ResetKey), body.ToEncryption(EncryptType.AES));//.ToJson();

            return(response);
        }
Пример #2
0
        public static LogError Create_LogError(Exception e)
        {
            var log = new LogError();

            log.err_referrer = WebOperationContext.Current.IncomingRequest.UserAgent ?? string.Empty;
            log.err_source   = e.Source;
            log.err_time     = DateTime.Now;
            log.err_stack    = e.StackTrace;
            log.err_type     = "error log";
            log.err_url      = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.RequestUri.OriginalString;
            log.err_ip       = Util.Get_RemoteIp();
            log.err_message  = e.Message;
            var es = e as ExceptionServer;

            log.err_guid = $"{DateTime.Now.ToString("yyyyMMdd")}-{Cipher_Md5.Md5_16(Guid.NewGuid().ToString())}";
            if (es != null)
            {
                log.err_user = es.u_id;
            }
            else
            {
                log.err_user = "";
            }
            return(log);
        }
Пример #3
0
        public static LogError Create_TestLog(string input, string input2, string userid)
        {
            var log = new LogError();

            log.err_stack    = input;
            log.err_referrer = WebOperationContext.Current.IncomingRequest.UserAgent ?? string.Empty;
            log.err_source   = "";
            log.err_time     = DateTime.Now;
            log.err_type     = "error log";
            log.err_url      = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.RequestUri.OriginalString;
            log.err_ip       = Util.Get_RemoteIp();
            log.err_message  = input2 ?? "";

            log.err_user = userid;
            log.err_guid = $"{DateTime.Now.ToString("yyyyMMdd")}-{Cipher_Md5.Md5_16(Guid.NewGuid().ToString())}";
            return(log);
        }