Пример #1
0
        public IHttpActionResult GetTaskReminders()
        {
            TaskCountModel result = new TaskCountModel();

            result.TaskCount     = TaskWork.GetUseableTaskWork().Count(c => c.ReceiverAccount == ClientCookie.UserCode && c.Status == TaskWorkStatus.UnFinish);
            result.ReminderCount = Remind.Count(c => c.ReceiverAccount == ClientCookie.UserCode &&
                                                !c.IsReaded);
            result.NoticeCount = Notification.Count(ClientCookie.UserCode);
            //获取PMT任务数量
            string encryptUserCode = Cryptography.Encrypt(ClientCookie.UserCode, DateTime.Now.ToString("yyyyMMdd"), "oms");
            string redirectUrl     = string.Format(Constants.AM_To_PMT_RedirectUrl, "&eid=" + encryptUserCode);
            string callPMTTaskUrl  = string.Format(Constants.Get_PMT_TaskUrl, encryptUserCode);

            if (Constants.GetPMTTask)
            {
                var pmtTaskResult = ApiProxy.Call <PMTTaskCountModel>(callPMTTaskUrl);
                if (pmtTaskResult != null)
                {
                    result.PMT_ApproveCount = pmtTaskResult.ApproveCount;
                    result.PMT_DealCount    = pmtTaskResult.DealCount;
                    result.PMT_NotifyCount  = pmtTaskResult.NotifyCount;
                    result.PMT_RemindCount  = pmtTaskResult.RemindCount;
                    result.PMT_Total        = pmtTaskResult.Total;
                }
            }
            result.PMT_URL = redirectUrl;
            return(Ok(result));
        }
Пример #2
0
        public static UserInfo Authenticate(string userId)
        {
            UserInfo userInfo = null;
            var      context  = HttpContext.Current;

            if (context.Session[SessionToken] != null)
            {
                userInfo = context.Session[SessionToken] as UserInfo;
            }
            else
            {
                string url = string.Format("{0}api/user/auth?userId={1}", ConfigurationManager.AppSettings["Fx.ServiceUri"], userId);
                userInfo = ApiProxy.Call <UserInfo>(url, "GET", null, null);
                context.Session[SessionToken] = userInfo;
                context.Session.Timeout       = 24 * 60;
            }

            HttpCookie cookieUser = new HttpCookie(CookieUserToken);

            cookieUser["Code"]      = userInfo.Code;
            cookieUser["NameZHCN"]  = HttpUtility.UrlEncode(userInfo.NameZHCN);
            cookieUser["NameENUS"]  = HttpUtility.UrlEncode(userInfo.NameENUS);
            cookieUser["TitleENUS"] = userInfo.TitleENUS;
            cookieUser.Expires      = DateTime.Now.AddMinutes(24 * 60);

            context.Response.Cookies.Add(cookieUser);
            return(userInfo);
        }
Пример #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            if (!string.IsNullOrEmpty(context.Request.ContentType))
            {
                context.Response.ContentType = context.Request.ContentType;
            }
            string url = context.Request.QueryString["url"];

            using (MemoryStream ms = new MemoryStream())
            {
                HttpContext.Current.Request.InputStream.CopyTo(ms);
                HttpContext.Current.Response.Write(ApiProxy.Call(url, HttpContext.Current.Request.HttpMethod, HttpContext.Current.Request.QueryString, ms.ToArray()));
            }
        }
Пример #4
0
        public void TestFlowCompleted()
        {
            string url = apiHost + @"api/k2callback/flowcompleted";

            //url = @"http://172.24.130.43:10083/api/flow/topnav";

            NameValueCollection _queryStrings = new NameValueCollection();

            _queryStrings.Add("procInstID", "644");
            _queryStrings.Add("flowStatus", "0");



            string _result = ApiProxy.Call(url, "GET", _queryStrings, null);


            if (!string.IsNullOrEmpty(_result))
            {
                // Formatting JSON String
                _result = _result.Trim('"').Replace("\\\"", "\"");
            }

            string _cd = "{\"ReturnData\":\"truefdsf\"}";

            Console.WriteLine("Result 1: {0}", _cd);
            Console.WriteLine("Result 2: {0}", _result);
            //MCDAMReturnObject _returnAMObject = JsonConvert.DeserializeObject<MCDAMReturnObject>(_cd);

            MCDAMReturnObject _returnAMObject = JsonConvert.DeserializeObject <MCDAMReturnObject>(_result);

            //Assert.AreEqual(_cd, _result);
            Console.WriteLine("Result: {0}", JsonConvert.SerializeObject(_result));

            /*
             * string _result = ApiProxy.Call(url, "GET", _queryStrings, null);
             * Console.WriteLine("Result: {0}", _result);
             *
             * MCDAMReturnObject _returnAMObject = JsonConvert.DeserializeObject<MCDAMReturnObject>(_result);
             *
             * Console.WriteLine("MCDAMReturnObject: {0}", JsonConvert.SerializeObject(_returnAMObject));*/
        }
Пример #5
0
        public ActionResult Login(string eid)
        {
            //获取用户信息
            if (string.IsNullOrEmpty(eid) || string.IsNullOrWhiteSpace(eid))
            {
                return(Redirect("~/Error/LoginError.html"));
            }
            var    userId   = eid;
            var    context  = System.Web.HttpContext.Current;
            string url      = string.Format("{0}api/user/login?userId={1}", ConfigurationManager.AppSettings["Fx.ServiceUri"], userId);
            var    userInfo = ApiProxy.Call <UserInfo>(url, "GET", null, null);

            context.Session[SessionToken] = userInfo;
            context.Session.Timeout       = 24 * 60;
            HttpCookie cookieUser = new HttpCookie(CookieUserToken);

            cookieUser["Code"]      = userInfo.Code;
            cookieUser["NameZHCN"]  = HttpUtility.UrlEncode(userInfo.NameZHCN);
            cookieUser["NameENUS"]  = HttpUtility.UrlEncode(userInfo.NameENUS);
            cookieUser["TitleENUS"] = userInfo.TitleENUS;
            cookieUser.Expires      = DateTime.Now.AddMinutes(24 * 60);
            context.Response.Cookies.Add(cookieUser);
            return(RedirectToAction("Index", "Home"));
        }