コード例 #1
0
ファイル: AccountModel.cs プロジェクト: HDJN/SlickSafe
        /// <summary>
        /// get user account
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        internal UserAccountEntity GetUserAccount(LoginUser user)
        {
            var url                   = string.Format("{0}/Account/QueryUserByName", WebApiApplication.WebAPIHostUrl);
            var clientHelper          = HttpClientHelper.CreateHelper(url);
            var response              = clientHelper.Post <LoginUser, ResponseResult <UserAccountEntity> >(user);
            UserAccountEntity account = response.Entity;

            return(account);
        }
コード例 #2
0
ファイル: AccountModel.cs プロジェクト: HDJN/SlickSafe
        /// <summary>
        /// get user permission list
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        internal List <UserPermissionEntity> GetUserPermissionList(int userID, string ticket)
        {
            var url = string.Format("{0}/PermissionData/GetUserPermissionList/{1}",
                                    WebApiApplication.WebAPIHostUrl, userID);
            var clientHelper = HttpClientHelper.CreateHelper(url, ticket);

            var permissionList = clientHelper.Get <List <UserPermissionEntity> >();

            return(permissionList);
        }
コード例 #3
0
ファイル: AccountModel.cs プロジェクト: HDJN/SlickSafe
        /// <summary>
        /// change user password
        /// </summary>
        /// <param name="password"></param>
        /// <param name="ticket"></param>
        /// <returns></returns>
        internal Boolean ChangePassword(UserPassword password, string ticket)
        {
            var isOk         = false;
            var url          = string.Format("{0}/Account/ChangePassword", WebApiApplication.WebAPIHostUrl);
            var clientHelper = HttpClientHelper.CreateHelper(url, ticket);

            var response = clientHelper.Post <UserPassword, ResponseResult>(password);

            if (response.Status == 1)
            {
                isOk = true;
            }
            return(isOk);
        }
コード例 #4
0
        /// <summary>
        /// login record
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="loginName"></param>
        /// <param name="sessionGUID"></param>
        /// <param name="context"></param>
        internal void WriteLoginInfo(int userID, string loginName, string sessionGUID, string ipaddress)
        {
            var logInfo = new UserLogEntity
            {
                UserID      = userID,
                LoginName   = loginName,
                SessionGUID = sessionGUID,
                IPAddress   = ipaddress
            };
            var url          = string.Format("{0}/LogData/Login", WebApiApplication.WebAPIHostUrl);
            var clientHelper = HttpClientHelper.CreateHelper(url);

            clientHelper.Post <UserLogEntity, ResponseResult <UserLogEntity> >(logInfo);
        }
コード例 #5
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("begin to test...");
            var baseUrl = "http://localhost/soweb/api/helloworld";

            for (var i = 0; i < 10; i++)
            {
                var clientHelper = HttpClientHelper.CreateHelper(string.Format("{0}/get/{1}", baseUrl, i.ToString()));
                var message      = clientHelper.Get();

                Console.WriteLine(string.Format("the result is: {0} ", message));
            }


            System.Console.ReadLine();
        }
コード例 #6
0
        private ResponseResult PublishProductOrderCreateMessage(ProductOrderEntity entity)
        {
            var topic     = "Slickflow/ERP/OrderSystem/WorkflowService/ProductOrderSynced";
            var appRunner = new WfAppRunner();

            appRunner.MessageTopic    = topic;
            appRunner.AppName         = entity.ProductName;
            appRunner.AppInstanceID   = entity.ID.ToString();
            appRunner.AppInstanceCode = entity.OrderCode;

            //var mqService = new MessageQueueService();
            //await mqService.Publish(topic, JsonConvert.SerializeObject(appRunner));
            var httpclient = HttpClientHelper.CreateHelper("http://localhost/sfa2/api/MessageQueue/InvokeProcess");
            var result     = httpclient.Post(appRunner);

            return(result);
        }
コード例 #7
0
 /// <summary>
 /// 执行外部方法
 /// </summary>
 /// <param name="service">Action实体</param>
 /// <param name="delegateService">委托服务</param>
 private static void ExecuteWebApiMethod(ServiceEntity service, IDelegateService delegateService)
 {
     try
     {
         object result = null;
         if (service.SubMethod == SubMethodEnum.HttpGet)
         {
             var jsonGetValue  = delegateService.GetVariableThroughly(service.Arguments);
             var url           = string.Format("{0}/{1}", service.Expression, jsonGetValue);
             var httpGetClient = HttpClientHelper.CreateHelper(url);
             result = httpGetClient.Get();
         }
         else if (service.SubMethod == SubMethodEnum.HttpPost)
         {
             string url = service.Expression;
             var    httpClientHelper = HttpClientHelper.CreateHelper(url);
             var    jsonValue        = CompositeJsonValue(service.Arguments, delegateService);
             var    httpPostClient   = HttpClientHelper.CreateHelper(url);
             result = httpClientHelper.Post(jsonValue);
         }
         else if (service.SubMethod == SubMethodEnum.HttpPut)
         {
             string url = service.Expression;
             var    httpClientHelper = HttpClientHelper.CreateHelper(url);
             var    jsonValue        = CompositeJsonValue(service.Arguments, delegateService);
             var    httpPostClient   = HttpClientHelper.CreateHelper(url);
             result = httpClientHelper.Put(jsonValue);
         }
         else if (service.SubMethod == SubMethodEnum.HttpDelete)
         {
             var jsonGetValue  = delegateService.GetVariableThroughly(service.Arguments);
             var url           = string.Format("{0}/{1}", service.Expression, jsonGetValue);
             var httpGetClient = HttpClientHelper.CreateHelper(url);
             result = httpGetClient.Delete();
         }
     }
     catch (System.Exception ex)
     {
         throw new WorkflowException(LocalizeHelper.GetEngineMessage("actionexecutor.ExecuteWebApi.exception", ex.Message));
     }
 }
コード例 #8
0
        /// <summary>
        /// 打样
        /// </summary>
        /// <param name="entity"></param>
        public WfAppResult Sample(ProductOrderEntity entity)
        {
            var appResult = WfAppResult.Default();
            var wfas      = new WfAppInteropService();
            var session   = SessionFactory.CreateSession();

            try
            {
                session.BeginTrans();

                //流程运行
                var result = wfas.RunProcess(session, WfAppRunner, WfAppRunner.Conditions);
                if (result.Status == WfExecutedStatus.Success)
                {
                    //写步骤记录表
                    Write(session, WfAppRunner, "打样", entity.ID.ToString(), entity.OrderCode, "完成打样");

                    //业务数据处理部分,此处是简单示例...
                    short status = GetProductOrderStatusByActivityCode(WfAppRunner.ProcessGUID, WfAppRunner.Version,
                                                                       WfAppRunner.NextActivityPerformers.Keys.ElementAt <string>(0));
                    UpdateStatus(entity.ID, status, session);

                    session.Commit();
                    appResult = WfAppResult.Success();

                    try
                    {
                        //调用工厂作业流程节点:
                        //流程节点:OrderFactoryMessageCaught
                        //流程ProcessGUID:0f5829c7-17df-43eb-bfe5-1f2870fb2a0e Version:1
                        var invokeAppRunner = new WfAppRunner();
                        invokeAppRunner.UserID          = WfAppRunner.UserID;
                        invokeAppRunner.UserName        = WfAppRunner.UserName;
                        invokeAppRunner.ProcessGUID     = "0f5829c7-17df-43eb-bfe5-1f2870fb2a0e";
                        invokeAppRunner.Version         = "1";
                        invokeAppRunner.AppName         = WfAppRunner.AppName;
                        invokeAppRunner.AppInstanceID   = WfAppRunner.AppInstanceID;
                        invokeAppRunner.AppInstanceCode = WfAppRunner.AppInstanceCode;
                        invokeAppRunner.DynamicVariables["ActivityCode"] = "OrderFactoryMessageCaught";

                        var httpClient   = HttpClientHelper.CreateHelper("http://localhost/sfsweb2/api/wfservice/invokejob");
                        var invokeResult = httpClient.Post(invokeAppRunner);
                    }
                    catch (System.Exception ex)
                    {
                        //记录异常日志
                        ;
                    }
                }
                else
                {
                    session.Rollback();
                    appResult = WfAppResult.Error(result.Message);
                }
            }
            catch (System.Exception ex)
            {
                session.Rollback();
                appResult = WfAppResult.Error(ex.Message);
            }
            finally
            {
                session.Dispose();
            }
            return(appResult);
        }