public void TestRevokeWorkflow()
        {
            var appEntity = new AppInfoModel
            {
                ActivityState = "Submit",
                AppId         = "007",
                AppName       = "TestApp",
                WorkflowName  = "TestStateWorkFlow",
                UserId        = "007",
                CurrentState  = "Common"
            };
            var result = WfServiceInstance.NewWorkFlow(appEntity);

            Assert.AreEqual(result, "Manage");

            var commonEntity = new AppInfoModel
            {
                ActivityState = "Revoke",
                AppId         = "007",
                AppName       = "TestApp",
                WorkflowName  = "TestStateWorkFlow",
                UserId        = "007",
                CurrentState  = "Common"
            };
            var revokeResult = WfServiceInstance.Execute(commonEntity);

            Assert.AreEqual(revokeResult, "Common");
        }
        public void TestManageRejectWorkFlow()
        {
            var appEntity = new AppInfoModel
            {
                ActivityState = "Submit",
                AppId         = "004",
                AppName       = "TestApp",
                WorkflowName  = "TestStateWorkFlow",
                UserId        = "004",
                CurrentState  = "Common"
            };
            var result = WfServiceInstance.NewWorkFlow(appEntity);

            Assert.AreEqual(result, "Manage");

            var manageEntity = new AppInfoModel
            {
                ActivityState = "Reject",
                AppId         = "004",
                AppName       = "TestApp",
                WorkflowName  = "TestStateWorkFlow",
                UserId        = "005",
                CurrentState  = "Manage"
            };
            var manageResult = WfServiceInstance.Execute(manageEntity);

            Assert.AreEqual(manageResult, "Refuse");
        }
Esempio n. 3
0
        public void setAppInfo(string appInfo)
        {
            AppInfoModel model = JsonConvert.DeserializeObject <AppInfoModel>(appInfo);

            if (model == null)
            {
                MessageBox.Show("未获取到app信息!", "提示");
                return;
            }

            this.AppNameBox.Text        = model.name;
            this.AppPkgNameBox.Text     = model.pkg;
            this.AppVersionBox.Text     = model.appVersion;
            this.SignHashMd5Box.Text    = model.signHashMd5;
            this.SignByteArrayBox.Text  = model.signByteArray;
            this.SignHashBox.Text       = model.signHash;
            this.SignCharStringBox.Text = model.signCharString;
            this.PermissionsList.Text   = model.permissions;
            byte[]       bytes = Convert.FromBase64String(model.icon);
            MemoryStream ms    = new MemoryStream(bytes);

            ms.Position = 0;
            Image img = Image.FromStream(ms);

            ms.Close();
            this.icon.Image = img;
        }
Esempio n. 4
0
        public async Task <IHttpActionResult> GetAppInfo(GetAppInfoParameter param)
        {
            var outputModel = new AppInfoModel();

            var info = new AppInfo();

            if (param != null && param.ClientOS != null)
            {
                using (AuthRepository _repo = new AuthRepository())
                {
                    info = _repo.GetAppInfo(param.ClientOS);
                }
            }
            else
            {
                info = null;
            }

            if (info != null)
            {
                outputModel.Id          = info.Id;
                outputModel.ClientOS    = info.ClientOS;
                outputModel.Version     = info.Version;
                outputModel.AppStoreURL = info.AppStoreURL;
                outputModel.ForceUpdate = info.ForceUpdate.ToString();
                outputModel.Remark      = info.Remark;

                return(Ok(outputModel));
            }

            return(NotFound());
        }
        public IActionResult AppInfoSave(AppInfoModel model)
        {
            if (string.IsNullOrWhiteSpace(model.app_id))
            {
                return(Content("app_id Empty"));
            }
            var res = MongoDbHelper.InsertAppInfo(model);

            return(Content(res ? "OK" : "ERROR"));
        }
Esempio n. 6
0
        private static IOptions <LCMessagingSettingsModel> SetLCMessagingSettingsModelOptions()
        {
            var dir = AppContext.BaseDirectory;
            //
            var config = new ConfigurationBuilder().SetBasePath(dir).AddJsonFile("appsettings.json").AddEnvironmentVariables().AddUserSecrets("ac948920-353d-45bc-8520-906312b08889").Build();

            AppInfoModel.Init(config, config.GetSection(LifeCouple.Server.Startup.aDB2CCONFIGSECTION)?.GetChildren()?.Count() > 0, config.GetSection(LifeCouple.Server.Startup.cOSMOSDBSECTION)?.GetChildren()?.Count() > 0);
            var settings = config.GetSection(LCMessagingSettingsModel.SettingsSection).Get <LCMessagingSettingsModel>();

            return(Options.Create <LCMessagingSettingsModel>(settings));
        }
        public IActionResult AppInfoEdit(string appid = "")
        {
            AppInfoModel model = new AppInfoModel();

            model.events = new List <EventInfoModel>();

            if (!string.IsNullOrWhiteSpace(appid))
            {
                var list = MongoDbHelper.SearchAppInfoList(appid);
                model = list.First();
            }

            return(View(model));
        }
        public void TestSaveWorkflow()
        {
            var appEntity = new AppInfoModel
            {
                ActivityState = "Save",
                AppId         = "006",
                AppName       = "TestApp",
                WorkflowName  = "TestStateWorkFlow",
                UserId        = "006",
                CurrentState  = "Common"
            };
            var result = WfServiceInstance.NewWorkFlow(appEntity);

            Assert.AreEqual(result, "Common");
        }
Esempio n. 9
0
        public static bool InsertAppInfo(AppInfoModel model)
        {
            try
            {
                var coll = MongodbWrite.GetCollection <AppInfoModel>("AppInfo");
                coll.InsertOneAsync(model);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(false);
            }

            return(true);
        }
        public IHttpActionResult Post([FromBody] dynamic data)
        {
            try
            {
                AppInfoModel coordinates = new AppInfoModel();
                coordinates.Latitude  = data.lat;
                coordinates.Longitude = data.longt;
                coordinates.UserId    = data.userId;
                _context.Coordinates.Add(coordinates);
                _context.SaveChanges();


                return(Ok(new { response = "Data saved! " + data.lat + " and " + data.longt })); //galima grazinti tik man suprantama koda, butu logiskiau.
            }
            catch (Exception)
            {
                return(Ok(new { response = "error in saving!" }));
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Uses the OpenAPI/Swagger middlewares.
        /// </summary>
        /// <param name="builder">The application builder.</param>
        /// <param name="appInfo">The application information.</param>
        public static void UseOpenApiMiddlewares(this IApplicationBuilder builder, AppInfoModel appInfo)
        {
            Ensure.ArgumentNotNull(builder, nameof(builder));
            Ensure.ArgumentNotNull(appInfo, nameof(appInfo));

            // https://github.com/RSuter/NSwag/wiki/Assembly-loading#net-core
            builder.UseReDoc(options =>
            {
                options.Path         = "/redoc";
                options.DocumentPath = "/specification.json";
            });

            // Serves the Swagger UI 3 web ui to view the OpenAPI/Swagger documents by default on `/swagger`
            builder.UseSwaggerUi3(options =>
            {
                options.Path = "/swagger";
                options.SwaggerRoutes.Add(new SwaggerUi3Route($"v{appInfo.AppVersion}", "/specification.json"));
            });
        }
Esempio n. 12
0
        public static IEnumerable <AppInfoModel> ToModel(this IEnumerable <AppInfo> src)
        {
            var dst = new List <AppInfoModel>();

            foreach (var item in src)
            {
                if (!item.IsEmpty)
                {
                    var d = new AppInfoModel(
                        path: item.Path,
                        name: item.Name,
                        image: GetImage(item.Path)
                        );
                    dst.Add(d);
                }
            }

            return(dst);
        }
Esempio n. 13
0
        public string Execute(AppInfoModel entity)
        {
            var activityEntity       = WorkFlowActivityDAL.Current.QueryByAppId(entity.AppId);
            var currentWorkFlowState =
                WfeInstance.Execute(entity.WorkflowName, entity.CurrentState,
                                    entity.ActivityState);

            activityEntity.ForeWorkflowState    = activityEntity.CurrentWorkflowState;
            activityEntity.CurrentWorkflowState = currentWorkFlowState;
            activityEntity.OperatorUserId       = entity.UserId;
            activityEntity.OperatorUserList    += entity.UserId + WFConstants.SplitCharacterTag;
            activityEntity.LastUpdateDateTime   = DateTime.Now;
            activityEntity.ApplicationState     = GetApplicationStateByWorkFlowActivityEntity(activityEntity).ToString();
            activityEntity.OperatorActivity     = entity.ActivityState;
            activityEntity.WorkflowName         = entity.WorkflowName;
            if (!string.IsNullOrEmpty(entity.AppName))
            {
                activityEntity.AppName = entity.AppName;
            }
            DataOperationBLL.Current.Modify(activityEntity);
            CheckApplicationState(activityEntity);
            return(currentWorkFlowState);
        }
        public void TestWorkflowAppState()
        {
            var appEntity = new AppInfoModel
            {
                ActivityState = "Submit",
                AppId         = "009",
                AppName       = "TestApp",
                WorkflowName  = "TestStateWorkFlow",
                UserId        = "009",
                CurrentState  = "Common"
            };

            var firstState = WfServiceInstance.GetApplicationStateByAppId(appEntity.AppId);

            Assert.AreEqual(firstState, ApplicationState.Draft);
            var result = WfServiceInstance.NewWorkFlow(appEntity);

            Assert.AreEqual(result, "Manage");
            var secondState = WfServiceInstance.GetApplicationStateByAppId(appEntity.AppId);

            Assert.AreEqual(secondState, ApplicationState.InProgress);
            var commonEntity = new AppInfoModel
            {
                ActivityState = "Approve",
                AppId         = "009",
                AppName       = "TestApp",
                WorkflowName  = "TestStateWorkFlow",
                UserId        = "009",
                CurrentState  = "Manage"
            };
            var approveResult = WfServiceInstance.Execute(commonEntity);

            Assert.AreEqual(approveResult, "Done");
            var thirdState = WfServiceInstance.GetApplicationStateByAppId(appEntity.AppId);

            Assert.AreEqual(thirdState, ApplicationState.Complete);
        }
Esempio n. 15
0
        public string NewWorkFlow(AppInfoModel entity)
        {
            var activityEntity = new WorkFlowActivityModel
            {
                ForeWorkflowState  = entity.CurrentState,
                OperatorActivity   = entity.ActivityState,
                LastUpdateDateTime = DateTime.Now,
                AppId            = entity.AppId,
                CreateDateTime   = DateTime.Now,
                CreateUserId     = entity.UserId,
                OperatorUserId   = entity.UserId,
                WorkflowName     = entity.WorkflowName,
                AppName          = entity.AppName,
                OperatorUserList = entity.UserId + WFConstants.SplitCharacterTag,
            };

            WfeInstance.InitWorkflowState(entity.WorkflowName);
            var currentWorkFlowState = WfeInstance.Execute(entity.WorkflowName, string.Empty, entity.ActivityState);

            activityEntity.CurrentWorkflowState = currentWorkFlowState;
            activityEntity.ApplicationState     = currentWorkFlowState;
            DataOperationBLL.Current.Insert(activityEntity);
            return(currentWorkFlowState);
        }
Esempio n. 16
0
 public Startup(IConfiguration config, IHostingEnvironment env)
 {
     _config = config;
     _env    = env;
     AppInfoModel.Init(config, _config.GetSection(aDB2CCONFIGSECTION)?.GetChildren()?.Count() > 0, _config.GetSection(cOSMOSDBSECTION)?.GetChildren()?.Count() > 0);
 }
Esempio n. 17
0
 public string NewWorkFlow(AppInfoModel entity)
 {
     return(WorkFlowEngineInstance.NewWorkFlow(entity));
 }
Esempio n. 18
0
        /// <summary>
        /// 得到一个店铺的权限列表
        /// </summary>
        /// <param name="accid"></param>
        /// <returns></returns>
        public static AppList GetAccountAppList(int accid)
        {
            var appModel = new AppList();

            appModel.Data = t_App_AuBLL.GetListByAccId(accid);

            var appList = new Dictionary <int, string>();

            appList.Add(1, "手机橱窗");
            appList.Add(2, "优惠券");
            appList.Add(3, "销售挂单");
            appList.Add(4, "百姓网");
            appList.Add(5, "分店功能");
            appList.Add(6, "多计次卡");
            appList.Add(7, "商品自定义属性");
            appList.Add(9, "工资计算");
            appList.Add(10, "支付宝收款");
            appList.Add(17, "专家版");
            appList.Add(18, "明细模板");
            appList.Add(19, "微信营销");
            appList.Add(21, "手机串号");
            //信息处理
            if (appModel.Rows > 0)
            {
                var iList = new List <int>();
                foreach (var item in appModel.Data)
                {
                    iList.Add(item.AppKey);
                    if (item.AppKey == 1 || item.AppKey == 2)
                    {
                        if (item.Status == 1)
                        {
                            item.DisplayStatus = "付费版本";
                            item.ActiveStatus  = 2;
                        }
                        else
                        {
                            item.DisplayStatus = "试用版本";
                            item.ActiveStatus  = 1;
                        }
                    }
                    else
                    {
                        item.DisplayStatus = "正常使用";
                        item.ActiveStatus  = 2;
                    }

                    if (item.ActiveStatus == 2)
                    {
                        TimeSpan ts = item.EndDate - DateTime.Now;
                        if (ts.Days > 0)
                        {
                            item.LastDays = ts.Days;
                        }
                        else
                        {
                            item.LastDays      = ts.Days;
                            item.DisplayStatus = "版本到期";
                            item.ActiveStatus  = -1;
                        }
                    }
                }

                foreach (var item in appList)
                {
                    if (!iList.Contains(item.Key))
                    {
                        var model = new AppInfoModel();
                        model.AppKey        = item.Key;
                        model.AppName       = item.Value;
                        model.DisplayStatus = "未开通";
                        model.ShortUrl      = "";
                        model.ActiveStatus  = 0;
                        model.Remark        = "";
                        appModel.Data.Add(model);
                    }
                }
            }
            else
            {
                var newModels = new List <AppInfoModel>();
                foreach (var item in appList)
                {
                    var model = new AppInfoModel();
                    model.AppKey        = item.Key;
                    model.AppName       = item.Value;
                    model.DisplayStatus = "未开通";
                    model.ShortUrl      = "";
                    model.ActiveStatus  = 0;
                    model.Remark        = "";
                    newModels.Add(model);
                }
                appModel.Data = newModels;
            }



            return(appModel);
        }
Esempio n. 19
0
 public string Execute(AppInfoModel entity)
 {
     return(WorkFlowEngineInstance.Execute(entity));
 }
Esempio n. 20
0
        /// <summary>
        /// Adds services required for OpenAPI 3.0 generation (change document settings to generate Swagger 2.0).
        /// </summary>
        /// <param name="services">The service collection.</param>
        /// <param name="appInfo">The information about the application.</param>
        public static void AddCustomOpenApiDocument(this IServiceCollection services, AppInfoModel appInfo)
        {
            Ensure.ArgumentNotNull(services, nameof(services));
            Ensure.ArgumentNotNull(appInfo, nameof(appInfo));

            // Customise the Swagger specification
            var openApiSecurityScheme = new OpenApiSecurityScheme
            {
                Type        = OpenApiSecuritySchemeType.ApiKey,
                Name        = "Authorization",
                In          = OpenApiSecurityApiKeyLocation.Header,
                Description = "Type into the textbox: Bearer {your JWT token}."
            };

            services.AddOpenApiDocument(document =>
            {
                document.Title        = "AMI API";
                document.Version      = appInfo.AppVersion;
                document.DocumentName = "default";
                document.AddSecurity("JWT", Enumerable.Empty <string>(), openApiSecurityScheme);
                document.OperationProcessors.Add(new AspNetCoreOperationSecurityScopeProcessor("JWT"));
                document.Description = @"REST service for [Animated Medical Imaging](https://github.com/niklr/animated-medical-imaging) (AMI)

## Introduction
Integrating this Application Programming Interface (API) is the easiest way to submit data to AMI. 
The following documentation will help you to get full advantage of the API by understanding and implementing all endpoints. 
With AMI API you will be able to upload files and submit tasks containing information needed for processing and receive the processed results. 
Requests with a body are sent in JavaScript Object Notation (JSON) format over HTTP(S), using the PUT or POST method.

Please, feel free to ask any questions, report bugs, suggest new features, and more on [GitHub](https://github.com/niklr/animated-medical-imaging/issues)

## Authentication
Authentication of requests is accomplished by using JSON Web Tokens (JWT). Tokens can be obtained by providing your credentials to the tokens API endpoint.
If you don't have a registered account, you still can obtain tokens with the special API endpoint for anonymous users. 
The response of the tokens API endpoint contains 3 different tokens: 

- **Access Token**: An authorization credential that can be used by the application to access the API.
- **ID Token**: Contains user profile information (such as the user's name and email) which is represented in the form of claims.
- **Refresh Token**: Contains the information required to obtain a new Access Token or ID Token.

For each API request you need to include the encoded JWT Access Token with a ""Bearer"" prefix.

## Requests, Responses, and Errors
Status codes are issued by the API in response to a client's request made to the API.

> A **successful** completion of a request returns one of three possible status codes.

Status code | Name | Description
---- | ---- | ----
200 | OK | The default status code for successful requests.
201 | Created | Returned on successful POST requests when one or more new entities have been created.
204 | No Content | Returned on successful DELETE requests.

> An **unsuccessful** completion of a request returns one of the following status codes.

Status code | Name | Description
---- | ---- | ----
400 | Bad Request | The format of the URL and/or of values in the parameter list is not valid.
401 | Unauthorized | Usually caused by using a wrong/expired access token or by not using one at all.
403 | Forbidden | The request was valid, but insufficient permissions for the resource.
404 | Not Found | The requested entity does not (or no longer) exist.
409 | Conflict | Indicates a mismatch in the current state of the resource.
429 | Too Many Requests | Indicates that the rate limit has been reached.
500 | Internal Server Error | An exception occurred that has no adequate handling.

## HTTP method definitions
The Hypertext Transfer Protocol (HTTP) defines a set of request methods to indicate the desired action to be performed for a given resource/endpoint. 
Although they can also be nouns, these request methods are sometimes referred as HTTP verbs.
An idempotent HTTP method can be called many times without different outcomes.
AMI API makes use of the following HTTP methods:

Method | Description
---- | ----
GET | Getting a resource. (e.g. GET *https://localhost/objects/23* without body)
POST | Creating a resource. (e.g. POST *https://localhost/tasks* with a body containing JSON data)
PUT | Updating a resource. (e.g. PUT *https://localhost/tasks/7* with a body containing JSON data)
DELETE | Deleting a resource. (e.g. DELETE *https://localhost/objects/23* without body)

## Rate Limits
Requests are limited on a 60 seconds basis to provide equal access to the API for everyone.
The rate limit information is indicated in the header of the response e.g.

- X-Rate-Limit-Limit: 1m
- X-Rate-Limit-Remaining: 56
- X-Rate-Limit-Reset: 2019-07-25T09:44:13.4658862Z

## Pagination
All endpoints returning a list of entities are paginated by default.
Returning a limited amount of entities is easier to handle, instead of hundreds or thousands.

Option | Description
---- | ---- 
limit | Defines the limit to constrain the number of items. (Allowed values: 10, 25, 50)
page | Defines the current page number. (Allowed values: 0, 1, 2, ...)

## Date format
All dates are in UTC (Universal Time Coordinated) and represented in ISO 8601 format (International Organization for Standardization).

> 2019-04-17T07:52:41.4700000Z

## Webhooks
After we process and complete your request you will be notified via webhook depending on the type of request.
Dedicated resources enable you to specify new webhooks, get missed webhooks and clear missed webhooks.
For testing purposes you can use a service like [hookbin.com](https://hookbin.com/).

";
            });
        }