Esempio n. 1
0
  public override IMessage Invoke (IMessage msg) {
    Console.WriteLine ("Invoke: ");
    Console.WriteLine (msg.GetType());

    IMethodCallMessage mcall = msg as IMethodCallMessage;

    IMethodReturnMessage ret = new ReturnMessage (null, null, 0,
						  mcall.LogicalCallContext,
						  mcall);
    Console.WriteLine ("Finish");
    return ret;
  }
Esempio n. 2
0
        public JsonResult CheckMemberIsTeacher()
        {
            var result = new ReturnMessage(false)
            {
                Message = "检查失败!"
            };

            try
            {
                if (LoginUser == null)
                {
                    result.IsSuccess = true;
                    result.Code      = -1;
                    result.Message   = "请先登陆";
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                var teacherlist = TeacherBLL.Instance.GetList(new TeacherEntity()
                {
                    Mobile = LoginUser.Mobile
                });
                if (teacherlist.Count > 0)
                {
                    result.IsSuccess = true;
                    result.Code      = 1;
                    result.Message   = "会员是教练";
                }
                else
                {
                    result.IsSuccess = true;
                    result.Code      = 0;
                    result.Message   = "不是教练是会员";
                }
            }
            catch (Exception ex)
            {
                ex.Data["Method"] = "TrainingCarController>>CheckMemberIsTeacher";
                new ExceptionHelper().LogException(ex);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public JsonResult SetUp(string status, string altertype)
        {
            var result = new ReturnMessage(false)
            {
                Message = "操作失败!"
            };

            try
            {
                MessageSetUpEntity entity = new MessageSetUpEntity();
                var setlist = MessageSetUpBLL.Instance.GetList(new MessageSetUpEntity()
                {
                    AccountId = LoginUser.UserId, AlterType = int.Parse(altertype)
                });
                if (setlist != null && setlist.Count() > 0)
                {
                    //修改
                    entity        = setlist.FirstOrDefault() as MessageSetUpEntity;
                    entity.Status = int.Parse(status);
                    MessageSetUpBLL.Instance.Update(entity);
                }
                else
                {
                    //新增
                    entity.MessageSetUpId = Util.NewUpperGuid();
                    entity.AlterType      = int.Parse(altertype);
                    entity.AccountId      = LoginUser.UserId;
                    entity.Status         = int.Parse(status);
                    MessageSetUpBLL.Instance.Add(entity);
                }
                result.IsSuccess = true;
                result.Message   = "设置成功";
            }
            catch (Exception ex)
            {
                ex.Data["Method"] = "MessageController>>SetUp";
                new ExceptionHelper().LogException(ex);
            }
            return(Json(result));
        }
Esempio n. 4
0
        public JsonResult CreateOwner(string data)
        {
            var result = new ReturnMessage(false)
            {
                Message = "创建车主信息失败!"
            };

            try
            {
                var entity = JsonConvert.DeserializeObject <OwnerEntity>(data);
                if (entity == null)
                {
                    return(Json(result));
                }
                var list = OwnerBLL.Instance.GetList(new OwnerEntity()
                {
                    MemberMobile = entity.MemberMobile
                });

                if (list.Count > 0)
                {
                    entity.OwnerId = list.FirstOrDefault().OwnerId;
                    OwnerBLL.Instance.Update(entity);
                }
                else
                {
                    entity.OwnerId    = Util.NewUpperGuid();
                    entity.CreateTime = DateTime.Now;
                    OwnerBLL.Instance.Add(entity);
                }
                result.IsSuccess = true;
                result.Message   = "创建成功";
            }
            catch (Exception ex)
            {
                ex.Data["Method"] = "OwnerController>>CreateOwner";
                new ExceptionHelper().LogException(ex);
            }
            return(Json(result));
        }
Esempio n. 5
0
        public ActionResult getPaymentType()
        {
            ReturnMessage rm = new ReturnMessage();

            try
            {
                int  memberId = int.Parse(User.Claims.FirstOrDefault(p => p.Type == "jti").Value);
                Guid tenantId = Guid.Parse(User.Claims.FirstOrDefault(p => p.Type == "tenantId").Value);

                List <ShopCartPrd> items = DataManager.shopCartDao.getItemsByMember(memberId);

                List <String> methods = new List <String>();
                foreach (ShopCartPrd item in items)
                {
                    if (item.paymentType.Contains(TenantSettingTAG.PaymentType_ATM))
                    {
                        methods.Add(TenantSettingType.PaymentType_ATM);
                    }

                    if (item.shipType.Contains(TenantSettingTAG.PaymentType_Face))
                    {
                        methods.Add(TenantSettingType.PaymentType_Face);
                    }
                }

                if (methods.Count == 0)
                {
                    methods.Add(TenantSettingType.PaymentType_Face);
                }

                rm.code = MessageCode.SUCCESS;
                rm.data = methods;
            }
            catch (Exception e)
            {
                rm.code = MessageCode.ERROR;
                rm.data = e.Message;
            }
            return(Ok(rm));
        }
Esempio n. 6
0
        public ActionResult getBankInfo()
        {
            ReturnMessage rm = new ReturnMessage();

            try
            {
                int  memberId = int.Parse(User.Claims.FirstOrDefault(p => p.Type == "jti").Value);
                Guid tenantId = Guid.Parse(User.Claims.FirstOrDefault(p => p.Type == "tenantId").Value);
                List <TenantSetting>        settings = DataManager.tenantDao.getAllTenantSetting(tenantId);
                Dictionary <string, string> type     = new Dictionary <string, string>();
                foreach (TenantSetting setting in settings)
                {
                    if (!string.IsNullOrEmpty(setting.content))
                    {
                        type.Add(TenantSettingMapping.getType(setting.title), setting.content);
                    }
                }
                var data = new
                {
                    bank = new
                    {
                        bankTitle   = type.GetValueOrDefault("bankTitle"),
                        bankCode    = type.GetValueOrDefault("bankCode"),
                        bankAccount = type.GetValueOrDefault("bankAccount"),
                        bankName    = type.GetValueOrDefault("bankName"),
                        subBankName = type.GetValueOrDefault("subBankName")
                    }
                };


                rm.code = MessageCode.SUCCESS;
                rm.data = data;
            }
            catch (Exception e)
            {
                rm.code = MessageCode.ERROR;
                rm.data = e.Message;
            }
            return(Ok(rm));
        }
        public ActionResult Create(UserEntity collection, string IsContinue)
        {
            ReturnMessage RM = new ReturnMessage(false);

            try
            {
                if (collection.UserPwd == "" || string.IsNullOrEmpty(collection.UserPwd))
                {
                    ///默认密码MD5加密
                    collection.UserPwd = Md5.Encode("123456");
                }
                ///根据登录名称查询是否已经存在,
                var query = BusinessContext.User.GetModel(collection.LoginName);
                if (query != null)
                {
                    RM.Message = "登录名已被占用";
                }
                else
                {
                    RM.IsSuccess = BusinessContext.User.Add(collection);
                    if (RM.IsSuccess)
                    {
                        if (IsContinue == "1")
                        {
                            RM.IsContinue = true;
                        }
                        else
                        {
                            RM.IsContinue = false;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                RM.Message = ex.Message;
            }

            return(Json(RM));
        }
        public virtual IMessage     SyncProcessMessage(IMessage reqMsg)
        {
            Object[] args     = new Object[] { null, null };
            IMessage replyMsg = null;

            try
            {
                Message.DebugOut("\n::::::::::::::::::::::::: CrossContext Channel: Sync call starting");
                IMessage errMsg = ValidateMessage(reqMsg);
                if (errMsg != null)
                {
                    return(errMsg);
                }

                ServerIdentity srvID = GetServerIdentity(reqMsg);
                Message.DebugOut("Got Server identity \n");
                BCLDebug.Assert(null != srvID, "null != srvID");


                BCLDebug.Assert(null != srvID.ServerContext, "null != srvID.ServerContext");

                args[0]  = reqMsg;
                args[1]  = srvID.ServerContext;
                replyMsg = (IMessage)Thread.CurrentThread.InternalCrossContextCallback(srvID.ServerContext, s_xctxDel, args);
            }
            catch (Exception e)
            {
                Message.DebugOut("Arrgh.. XCTXSink::throwing exception " + e + "\n");
                replyMsg = new ReturnMessage(e, (IMethodCallMessage)reqMsg);
                if (reqMsg != null)
                {
                    ((ReturnMessage)replyMsg).SetLogicalCallContext(
                        (LogicalCallContext)
                        reqMsg.Properties[Message.CallContextKey]);
                }
            }

            Message.DebugOut("::::::::::::::::::::::::::: CrossContext Channel: Sync call returning!!\n");
            return(replyMsg);
        }
Esempio n. 9
0
        public void TestLocationForward()
        {
            IiopChannel chan = new IiopChannel(8090);

            ChannelServices.RegisterChannel(chan, false);
            // publish location fwd target
            TestService target       = new TestService();
            string      fwdTargetUri = "testuriFwd";

            RemotingServices.Marshal(target, fwdTargetUri);

            // request msg the reply is for
            MethodInfo methodToCall = typeof(TestService).GetMethod("Add");

            object[]    args       = new object[] { ((Int32)1), ((Int32)2) };
            string      origUrl    = "iiop://localhost:8090/testuri"; // Giop 1.2 will be used because no version spec in uri
            TestMessage requestMsg = new TestMessage(methodToCall, args, origUrl);
            // prepare connection desc
            GiopClientConnectionDesc conDesc = new GiopClientConnectionDesc(null, null, new GiopRequestNumberGenerator(), null);

            try {
                Stream locFwdStream = PrepareLocationFwdStream("localhost", 8090,
                                                               target);
                IMessage resultMsg =
                    (IMessage)m_handler.ParseIncomingReplyMessage(locFwdStream, requestMsg, conDesc);
                MarshalByRefObject fwdToTarget;
                bool isFwd = GiopMessageHandler.IsLocationForward(resultMsg, out fwdToTarget);
                Assert.IsTrue(isFwd, "is a forward?");
                Assert.NotNull(fwdToTarget, "new target reference null?");
                ReturnMessage result = (ReturnMessage)
                                       m_handler.ForwardRequest(requestMsg, fwdToTarget);
                Assert.AreEqual(3, result.ReturnValue);
                Assert.AreEqual(0, result.OutArgCount);
            } finally {
                // unpublish target + channel
                RemotingServices.Disconnect(target);
                chan.StopListening(null);
                ChannelServices.UnregisterChannel(chan);
            }
        }
Esempio n. 10
0
        public JsonResult GetWeekDateJson(string objectid)
        {
            var result = new ReturnMessage(false)
            {
                Message = "获取设置失败!"
            };

            try
            {
                //var list = GetCurrentWeekWithDrivingFreeDateList(objectid);
                //if (list != null && list.Count() > 0)
                //{
                //    result.IsSuccess = true;
                //    result.Code = 100;
                //    result.Message = "获取设置成功";
                //    result.ResultData["List"] = list;

                //}
                //else
                //{
                //这里初始化应该是服务自动执行,这里方便测试用 手动模式添加数据
                WithDrivingFreeTimeBLL.Instance.AddInitFreeTime(objectid);
                //查询数据
                var list = GetCurrentWeekWithDrivingFreeDateList(objectid);
                if (list != null && list.Count() > 0)
                {
                    result.IsSuccess          = true;
                    result.Code               = 100;
                    result.Message            = "获取设置成功";
                    result.ResultData["List"] = list;
                }
            }
            //}
            catch (Exception ex)
            {
                ex.Data["Method"] = "WithDrivingFreeTimeController>>GetWeekDateJson";
                new ExceptionHelper().LogException(ex);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 11
0
        //Attribute olarak eklenen metot çağırıldığında çalışacak olan metotdur.
        public override IMessage Invoke(IMessage msg)
        {
            var           methodCallMessage = msg as IMethodCallMessage;
            ReturnMessage returnMessage     = null;

            object[]      interceptions = null;
            InterceptArgs e             = CreateEventArgs(methodCallMessage);

            try
            {
                interceptions = GetInterceptions(methodCallMessage);

                // PreInterceptionlarımız çalıştırıyoruz, cache tarzı geriye donen attribute varsa bunlardan donen sonucu alıyoruz
                PreInterceptArgs preArg = new PreInterceptArgs(e);
                object           result = OnPreIntercept(interceptions, preArg);

                // OverrideReturnValue true ise esas metodu çalıştırmamıza gerek yok
                if (preArg.OverrideReturnValue)
                {
                    returnMessage = new ReturnMessage(result, null, 0, methodCallMessage.LogicalCallContext, methodCallMessage);
                }
                else
                {
                    // boş resultımız olduğuna göre ilgili metodu çalıştırabiliriz
                    result        = methodCallMessage.MethodBase.Invoke(new T(), methodCallMessage.InArgs);
                    returnMessage = new ReturnMessage(result, null, 0, methodCallMessage.LogicalCallContext, methodCallMessage);
                }

                OnPostIntercept(interceptions, new PostInterceptArgs(e, result));

                // PostInterceptionlarımız çalıştırdıktan sonra artık geriye çıktıyı dönebiliriz.
                return(returnMessage);
            }
            catch (System.Exception ex)
            {
                var exArg = new ExceptionInterceptArgs(e, ex);
                OnErrorIntercept(interceptions, exArg);
                return(new ReturnMessage(exArg.Ex, methodCallMessage));
            }
        }
Esempio n. 12
0
        /// <summary>
        /// 开启读取器连接
        /// </summary>
        /// <returns></returns>
        public ReturnMessage OpenReaderConnection()
        {
            ReturnMessage returnMsg = new ReturnMessage();

            if (m_RFIDReader == null)
            {
                IsAllowStartRead      = false;
                returnMsg.CallMessage = "读取器开启失败 : 读取器对象为空.";
                returnMsg.CallStatus  = false;
            }

            try
            {
                if (!m_RFIDReader.IsConnected)
                {
                    if (m_UsedInfrared)
                    {
                        //增加GPIO设备响应事件
                        m_GPIEventHandler              = new GPIO_EventHandlerAdv(BRIReaderEventHandler_GPITrigger);
                        m_RFIDReader.EventHandlerGPIO += m_GPIEventHandler;
                    }
                    //m_RFIDReader.SetAutoPollTriggerEvents(false);
                    m_RFIDReader.AutoPollTriggerEvents = false;
                    SetReaderAttributes();
                    SetTriggers();

                    IsAllowStartRead      = true;
                    returnMsg.CallMessage = "读取器开启成功.";
                    returnMsg.CallStatus  = true;
                }
            }
            catch (BasicReaderException brex)
            {
                IsAllowStartRead      = false;
                returnMsg.CallMessage = "读取器属性设置失败 : 异常信息 === " + brex.Message;
                returnMsg.CallStatus  = false;
            }

            return(returnMsg);
        }
Esempio n. 13
0
        public IMessage SyncProcessMessage(IMessage msg)
        {
                        #if !DISABLE_REMOTING
            ServerIdentity identity = (ServerIdentity)RemotingServices.GetMessageTargetIdentity(msg);

            Context  oldContext = null;
            IMessage response;

            if (Threading.Thread.CurrentContext != identity.Context)
            {
                oldContext = Context.SwitchToContext(identity.Context);
            }

            try
            {
                Context.NotifyGlobalDynamicSinks(true, msg, false, false);
                Thread.CurrentContext.NotifyDynamicSinks(true, msg, false, false);

                response = identity.Context.GetServerContextSinkChain().SyncProcessMessage(msg);

                Context.NotifyGlobalDynamicSinks(false, msg, false, false);
                Thread.CurrentContext.NotifyDynamicSinks(false, msg, false, false);
            }
            catch (Exception ex)
            {
                response = new ReturnMessage(ex, (IMethodCallMessage)msg);
            }
            finally
            {
                if (oldContext != null)
                {
                    Context.SwitchToContext(oldContext);
                }
            }

            return(response);
                        #else
            return(null);
                        #endif
        }
Esempio n. 14
0
        /// <summary>
        /// 消息拦截
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public override IMessage Invoke(IMessage msg)
        {
            IMethodCallMessage callMsg = msg as IMethodCallMessage;

            object[]               args = callMsg.Args;
            IMessage               message;
            MethodInfo             useMethod         = null;
            List <VoidDoAttribute> lstVoidDoAttribue = new List <VoidDoAttribute>();
            MethodCallContext      thisContext       = new AOPSuite.MethodCallContext();

            thisContext.ThisMethod       = callMsg.MethodBase;
            thisContext.InputParameterns = callMsg.Args;
            try
            {
                useMethod = FindMethod(callMsg);
                Utility.GetVoidAttribute(useMethod, ref lstVoidDoAttribue);

                foreach (var oneAttribute in lstVoidDoAttribue)
                {
                    oneAttribute.DoBeforeMethod(thisContext);
                }

                object o = callMsg.MethodBase.Invoke(m_Tag, args);
                message = new ReturnMessage(o, args, args.Length - callMsg.InArgCount, callMsg.LogicalCallContext, callMsg);

                thisContext.RetrunValue  = o;
                thisContext.IfReturnVoid = (callMsg.MethodBase as MethodInfo).ReturnType == typeof(void);

                for (int indexOfAttribute = lstVoidDoAttribue.Count - 1; indexOfAttribute >= 0; indexOfAttribute--)
                {
                    lstVoidDoAttribue[indexOfAttribute].DoAfterMethod(thisContext);
                }
            }
            catch (Exception e)
            {
                message = new ReturnMessage(e, callMsg);
            }

            return(message);
        }
Esempio n. 15
0
        public override IMessage Invoke(IMessage msg)
        {
            T t;

            if (this.callBack != null)
            {
                t = DuplexChannelFactoryCreator.Create <T>(this.callBack, this.configurationPath, this.endpointName).CreateChannel();
            }
            else
            {
                t = DuplexChannelFactoryCreator.Create <T>(Activator.CreateInstance(typeof(TCallBack)), this.configurationPath, this.endpointName).CreateChannel();
            }
            IMethodCallMessage   methodCallMessage = (IMethodCallMessage)msg;
            IMethodReturnMessage result            = null;

            object[] array = Array.CreateInstance(typeof(object), methodCallMessage.Args.Length) as object[];
            methodCallMessage.Args.CopyTo(array, 0);
            this.GetParameters(methodCallMessage);
            ServiceProxyFactory.GetEndpointAddress <T>(this.configurationPath, this.endpointName);
            try
            {
                result = new ReturnMessage(methodCallMessage.MethodBase.Invoke(t, array), array, array.Length, methodCallMessage.LogicalCallContext, methodCallMessage);
            }
            catch (CommunicationException e)
            {
                (t as ICommunicationObject).Abort();
                result = new ReturnMessage(e, methodCallMessage);
            }
            catch (TimeoutException e2)
            {
                (t as ICommunicationObject).Abort();
                result = new ReturnMessage(e2, methodCallMessage);
            }
            catch (System.Exception e3)
            {
                (t as ICommunicationObject).Abort();
                result = new ReturnMessage(e3, methodCallMessage);
            }
            return(result);
        }
Esempio n. 16
0
        public ActionResult Edit(ServiceEntity collection)
        {
            ReturnMessage RM = new ReturnMessage(false);

            try
            {
                List <string> inList  = new List <string>();
                List <string> outList = new List <string>();
                string        inStr   = Request["inAddr"];
                if (!string.IsNullOrWhiteSpace(inStr))
                {
                    inList = inStr.Split(',').ToList();
                }
                string outStr = Request["outAddr"];
                if (!string.IsNullOrWhiteSpace(outStr))
                {
                    outList = outStr.Split(',').ToList();
                }
                ServiceCfg cfg = new ServiceCfg();
                cfg.InAddr  = inList;
                cfg.OutAddr = outList;
                cfg.Remarks = collection.Remark;
                ServiceEntity model = BusinessContext.ServiceList.GetModel(Convert.ToInt32(Request["_id"]));
                model.ServiceName   = collection.ServiceName;
                model.SecondaryName = collection.SecondaryName;
                model.Host          = collection.Host;
                model.Version       = collection.Version;
                model.Remark        = collection.Remark;
                model.RegContent    = JsonConvert.SerializeObject(cfg);

                RM.IsSuccess = BusinessContext.ServiceList.Update(model);
            }
            catch (Exception ex)
            {
                RM.Message = "数据异常,请刷新重试";
                LogManager.Error(ex);
            }

            return(Json(RM, JsonRequestBehavior.AllowGet));
        }
Esempio n. 17
0
        public ActionResult SaveData()
        {
            ReturnMessage RM = new ReturnMessage();

            try
            {
                string paramData           = Request.Form["paramData"];
                int    RoleId              = Convert.ToInt32(Request.Form["RoleId"]);
                List <sys_role_right> list = Newtonsoft.Json.JsonConvert.DeserializeObject <List <sys_role_right> >(paramData);

                List <sys_role_right> oldlist =
                    BusinessContext.sys_role_right.GetList(Query <sys_role_right> .EQ(t => t.rf_Role_Id, RoleId));

                var newList = list.Except(oldlist).ToList(); //新增的权限
                var delList = oldlist.Except(list).ToList(); //删除的权限
                if (newList.Count == 0 && delList.Count == 0)
                {
                    RM.IsSuccess = true;
                    RM.Message   = "无权限变化";
                }
                else
                {
                    RM.IsSuccess = BusinessContext.sys_role_right.Delete(delList.Select(t => t.Rid).ToList());
                    RM.IsSuccess = RM.IsSuccess && BusinessContext.sys_role_right.Add(newList);
                    if (RM.IsSuccess)
                    {
                        foreach (sys_role_right item in list)
                        {
                            OperateLogHelper.Create <sys_role_right>(item);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                RM.IsSuccess = false;
                RM.Message   = ex.Message;
            }
            return(Json(RM, JsonRequestBehavior.AllowGet));
        }
Esempio n. 18
0
        public ActionResult Create(sys_role collection, string IsContinue = "0")
        {
            ReturnMessage RM = new ReturnMessage(false);

            if (ModelState.IsValid)
            {
                try
                {
                    var query =
                        BusinessContext.sys_role.GetList(Query <sys_role> .EQ(t => t.role_name, collection.role_name));
                    if (query.Count > 0)
                    {
                        RM.Message = "角色名称已被占用";
                    }
                    else
                    {
                        var res = BusinessContext.sys_role.Add(collection);
                        RM.IsSuccess = res;
                        if (RM.IsSuccess)
                        {
                            //collection.Rid = Rid;
                            OperateLogHelper.Create <sys_role>(collection);
                            if (IsContinue == "1")
                            {
                                RM.IsContinue = true;
                            }
                            else
                            {
                                RM.IsContinue = false;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    RM.Message = ex.Message;
                }
            }
            return(Json(RM));
        }
Esempio n. 19
0
        public JsonResult SendFindPwdVerifySms(string mobile)
        {
            var result = new ReturnMessage(false)
            {
                Message = "短信发送失败!"
            };

            if (string.IsNullOrWhiteSpace(mobile))
            {
                result.Message = "电话号码不能为空";
                return(Json(result));
            }
            try
            {
                if (!new System.Text.RegularExpressions.Regex("^1[0-9]{10}$").IsMatch(mobile))
                {
                    result.Message = "请输入正确的手机号!";
                    return(Json(result));
                }
                int count = MemberBLL.Instance.GetList(new MemberEntity()
                {
                    Mobile = mobile
                }).Count();
                if (count == 0)
                {
                    result.Message = "该账号未注册!";
                    return(Json(result));
                }

                result.IsSuccess = true;

                SmsVerifyHelper.SendMobileSms(mobile);
            }
            catch (Exception ex)
            {
                ex.Data["Method"] = "AccountController>>SendVerifySms";
                new ExceptionHelper().LogException(ex);
            }
            return(Json(result));
        }
Esempio n. 20
0
        public HttpResponseMessage AuditErrand(string token, string ccode)
        {
            string        errMsg = "";
            ReturnMessage msg    = new ReturnMessage();

            vouMag = (VoucherManager)HttpContext.Current.Application.Get(token);
            if (vouMag == null)
            {
                msg.Success = false;
                msg.Msg     = "参数token无效或已过期";
                msg.Code    = 500;
            }
            else
            {
                ErrandManager errandMag = new ErrandManager(vouMag.UFDataConnstringForNet);
                int           i         = errandMag.auditErrand(ccode, vouMag.cUserName, vouMag.cUserID, ref errMsg);
                if (i >= 2)
                {
                    msg.Success = true;
                    msg.Code    = 200;
                    dynamic c = new { code = ccode };
                    msg.Data = JsonConvert.SerializeObject(c);
                    msg.Msg  = "审核成功";
                }
                else
                {
                    msg.Success = false;
                    msg.Code    = 500;
                    msg.Msg     = "审核失败:" + errMsg;
                }
            }

            HttpContext.Current.Application.Remove(vouMag.GetGUID);
            string str = msg.ToJson();

            return(new HttpResponseMessage {
                Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json")
            });
        }
Esempio n. 21
0
        public async Task <Result> AddJob(Job newjob)
        {
            try
            {
                string results = await Service.InvokePost(Constants.addjobUrl, JsonConvert.SerializeObject(newjob));

                ReturnMessage rmessage = JsonConvert.DeserializeObject <ReturnMessage>(results);
                string        success  = string.Format("Job at location {0} was created", newjob.address);
                if (rmessage.message == success)
                {
                    return(Result.Success);
                }
                else
                {
                    return(Result.Exist);
                }
            }
            catch (HttpRequestException)
            {
                return(Result.Network);
            }
        }
Esempio n. 22
0
        public async Task <bool> Login(User user)
        {
            try
            {
                string results = await Service.InvokePost(Constants.loginUrl, JsonConvert.SerializeObject(user));

                ReturnMessage checkUser    = JsonConvert.DeserializeObject <ReturnMessage>(results);
                string        checkmessage = string.Format("Logged in as {0}", user.username);
                if (checkUser.message == checkmessage)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (HttpRequestException)
            {
                return(false);
            }
        }
Esempio n. 23
0
        public async Task <Result> RegisterNewUser(User user)
        {
            try
            {
                string results = await Service.InvokePost(Constants.registrationUrl, JsonConvert.SerializeObject(user));

                ReturnMessage rmessage = JsonConvert.DeserializeObject <ReturnMessage>(results);
                string        success  = string.Format("User {0} was created", user.username);
                if (rmessage.message == success)
                {
                    return(Result.Success);
                }
                else
                {
                    return(Result.Exist);
                }
            }
            catch (HttpRequestException)
            {
                return(Result.Network);
            }
        }
Esempio n. 24
0
        public ActionResult DeriveData()
        {
            ReturnMessage RM = new ReturnMessage();

            try
            {
                string        paramData = Request.Form["paramData"];
                StringBuilder strSql    = new StringBuilder("select  ButtonName '按钮名称 ', Remark as '备注'  from tblButtonName  where  1=1");
                if (string.IsNullOrEmpty(paramData))
                {
                    string keyword = Request.QueryString["keyword"];
                    if (!string.IsNullOrWhiteSpace(keyword))
                    {
                        strSql.Append(" and (ButtonName like '%" + keyword + "%')");
                    }
                    strSql.Append(" and " + whe);
                }
                else
                {
                    string[] RidArr = paramData.Split('*');
                    strSql.Append(" and  Rid in " + DBContext.DataDecision.AssemblyInCondition(RidArr.ToList()));
                }
                strSql.Append(" order by ButtonName");

                DataTable dt        = DBContext.DataDecision.GetDataTable(strSql.ToString());
                string    sheetName = "按钮名称";
                //返回路径
                string absoluFilePath = DoExport.ExportDataTableToExcel(dt, sheetName, "按钮名称");

                RM.IsSuccess = true;
                RM.Text      = HttpUtility.UrlEncode(absoluFilePath);
            }
            catch (Exception ex)
            {
                RM.IsSuccess = false;
                RM.Message   = ex.Message;
            }
            return(Json(RM, JsonRequestBehavior.AllowGet));
        }
Esempio n. 25
0
        private void backgroundWorkerLogin_DoWork(object sender, DoWorkEventArgs e)
        {
            ReturnMessage rm = new ReturnMessage();

            try
            {
                thread = Thread.CurrentThread;
                thread.IsBackground = true;
                rm._code            = Login((LoginInfo)e.Argument);
                if (rm._code < 0)
                {
                    rm._msg = "用户名或密码错误.";
                }
            }
            catch (Exception ex)
            {
                rm._code = -1;
                rm._msg  = ex.Message;
            }

            e.Result = rm;
        }
Esempio n. 26
0
        public ActionResult DeriveData()
        {
            ReturnMessage RM = new ReturnMessage();

            try
            {
                string        paramData = Request.Form["paramData"];
                StringBuilder strSql    = new StringBuilder("select  ProcessName as '流程名称',  NodeName as '节点名称',NoticeRole as '通知角色', Remark  as '备注'  from tblProcessNotice  where  1=1");
                if (string.IsNullOrEmpty(paramData))
                {
                    string ProcessName = Request.Form["ProcessName"];
                    if (!string.IsNullOrWhiteSpace(ProcessName))
                    {
                        strSql.Append(" and (ProcessName like '%" + ProcessName + "%')");
                    }
                    strSql.Append(" and " + wheres);
                }
                else
                {
                    string[] tblRcdidArr = paramData.Split('*');
                    strSql.Append(" and  TblRcdId in " + DBContext.DataDecision.AssemblyInCondition(tblRcdidArr.ToList()));
                }
                strSql.Append(" order by ProcessName");

                DataTable dt        = DBContext.DataDecision.GetDataTable(strSql.ToString());
                string    sheetName = "流程消息设置表";
                //返回路径
                string absoluFilePath = DoExport.ExportDataTableToExcel(dt, sheetName, "流程消息设置表");

                RM.IsSuccess = true;
                RM.Text      = HttpUtility.UrlEncode(absoluFilePath);
            }
            catch (Exception ex)
            {
                RM.IsSuccess = false;
                RM.Message   = ex.Message;
            }
            return(Json(RM, JsonRequestBehavior.AllowGet));
        }
Esempio n. 27
0
        public JsonResult GetExamList(string EnCode)
        {
            var result = new ReturnMessage(false)
            {
                Message = "获取失败!"
            };

            try
            {
                DataItemCache dataItemCache = new DataItemCache();
                var           data          = dataItemCache.GetDataItemList(EnCode);
                result.IsSuccess          = true;
                result.Message            = "获取成功!";
                result.ResultData["List"] = data;
            }
            catch (Exception ex)
            {
                ex.Data["Method"] = "ExamController>>GetExamList";
                new ExceptionHelper().LogException(ex);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 28
0
        /// <summary>
        /// </summary>
        /// <param name="context"></param>
        /// <exception cref="SignatureException"></exception>
        private bool validateRequestSignature(HttpContext context, out ReturnMessage returnMessage)
        {
            returnMessage = null;
            var verifySignature = context.Request.Headers["signature"];
            var requestBody     = GetRequestContent(context);

            _logger.LogDebug("接收到数据 {0}", requestBody);
            var validResult = BuildSignature(context, requestBody);

            _logger.LogDebug("接收到数据-服务器签名 {0},客户端提交签名{1}", validResult, verifySignature);
            if (validResult != verifySignature)
            {
                returnMessage = new ReturnMessage
                {
                    Code    = "-20",
                    Message = "sign fail."
                };
                return(false);
            }
            context.Items["signatureResult"] = true;
            return(true);
        }
Esempio n. 29
0
        public ActionResult Edit(tblPageDetail collection)
        {
            ReturnMessage RM = new ReturnMessage(false);

            if (ModelState.IsValid)
            {
                try
                {
                    tblPageDetail old = BusinessContext.tblPageDetail.GetModel(collection.Rid);
                    RM.IsSuccess = BusinessContext.tblPageDetail.Update(collection);
                    if (RM.IsSuccess)
                    {
                        OperateLogHelper.Edit <tblPageDetail>(collection, old);
                    }
                }
                catch (Exception ex)
                {
                    RM.Message = ex.Message;
                }
            }
            return(Json(RM));
        }
Esempio n. 30
0
 private void DealWelcomeMessage(ReturnMessage retMessage)
 {
     try
     {
         if (retMessage.ListData == null || retMessage.ListData.Count < 4)
         {
             CurrentApp.WriteLog("DealWelcome", string.Format("ListData is null or count invalid"));
             return;
         }
         //string strServerTime = retMessage.ListData[3];
         //DateTime dtServerTime;
         //if (DateTime.TryParse(strServerTime, out dtServerTime))
         //{
         //    DateTime now = DateTime.Now.ToUniversalTime();
         //    double timeDeviation = (now - dtServerTime).TotalSeconds;
         //}
     }
     catch (Exception ex)
     {
         CurrentApp.WriteLog("DealWelcome", string.Format("Fail.\t{0}", ex.Message));
     }
 }
Esempio n. 31
0
 public ReturnMessage <U> GetClient(string url, string token = null)
 {
     try
     {
         if (token != null)
         {
             Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
         }
         var respraw      = Client.GetAsync(url).Result;
         var responsecode = respraw.StatusCode;
         var response     = respraw.Content.ReadAsAsync <ReturnMessage <U> >().Result;
         return(response);
     }
     catch (Exception x)
     {
         var errorResp = new ReturnMessage <U>();
         errorResp.Code      = 500;
         errorResp.IsCatched = 1;
         errorResp.Message   = "Something wrong with server : " + x.Message;
         return(errorResp);
     }
 }
Esempio n. 32
0
        [System.Security.SecurityCritical]  // auto-generated
        public IMessage SyncProcessMessage(IMessage msg)
        {
            Contract.Assert( 
                Thread.CurrentContext.InternalContextID == _targetCtxID,
                "Transition message routed to wrong context"); 
 
            try
            { 
                LogicalCallContext oldcctx = Message.PropagateCallContextFromMessageToThread(msg);
                if (_delegate != null)
                {
                    _delegate(); 
                }
                else 
                { 
                    // This is the cross appdomain case, so we need to construct
                    //   the delegate and call on it. 
                    CallBackHelper cb = new CallBackHelper(
                                            _eeData,
                                            true /*fromEE*/,
                                            _targetDomainID); 
                    CrossContextDelegate ctxDel = new CrossContextDelegate(cb.Func);
                    ctxDel(); 
                } 
                Message.PropagateCallContextFromThreadToMessage(msg, oldcctx);
            } 

            catch (Exception e)
            {
                ReturnMessage retMsg = new ReturnMessage(e, new ErrorMessage()); 
                retMsg.SetLogicalCallContext(
                    (LogicalCallContext) msg.Properties[Message.CallContextKey]); 
                return retMsg; 
            }
 
            return this;
        }