예제 #1
0
        public JObject InstallPage()
        {
            try
            {
                var request = _httpContextProxy.GetRequestBody <JObject>();
                if (request == null)
                {
                    return(_responseBuilder.BadRequest());
                }
                var id         = request[CommonConst.CommonField.DISPLAY_ID].ToString();
                var moduleName = request[CommonConst.CommonField.MODULE_NAME].ToString();
                var path       = request[CommonConst.CommonField.FILE_PATH].ToString();

                var data = request[CommonConst.CommonField.DATA].ToString();

                string cleanupWWWRootFilter = "{ " + CommonConst.CommonField.MODULE_NAME + ":'" + moduleName + "', " + CommonConst.CommonField.FILE_PATH + ": '" + path + "'}";
                foreach (var item in _dbService.Get(CommonConst.Collection.STATIC_CONTECT, new RawQuery(cleanupWWWRootFilter)))
                {
                    _keyValueStorage.Delete(CommonConst.Collection.STATIC_CONTECT, item[CommonConst.CommonField.DISPLAY_ID].ToString());
                }

                _keyValueStorage.Put <string>(CommonConst.Collection.STATIC_CONTECT, id, data);
                request.Remove(CommonConst.CommonField.DATA);
                WriteToDB(request, moduleName, CommonConst.Collection.STATIC_CONTECT, CommonConst.CommonField.FILE_PATH);
                return(_responseBuilder.Success());
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message, ex);
                return(_responseBuilder.ServerError());
            }
        }
예제 #2
0
        public IActionResult SaveKeyValues([FromBody] KeyValueModel[] data)
        {
            var model = data.Select(itm => new KeyValuePair <string, string>(itm.Key, itm.Value)).ToArray();

            _keyValueStorage.Put(model);

            return(Ok(new { result = "OK" }));
        }
예제 #3
0
        private void InstallDlls(ModuleInstallRequest request)
        {
            var dllFilter = @"{name: /^lib\/netstandard2.0/, " + CommonConst.CommonField.MODULE_NAME + ": '" + request.Name + "', " + CommonConst.CommonField.VERSION + ": '" + request.Version + "'}";

            foreach (var item in _dbService.Get(CommonConst.Collection.MODULE_FILE_UPLOAD_CACHE, new RawQuery(dllFilter)))
            {
                var fileSourceId = item[CommonConst.CommonField.DISPLAY_ID].ToString();
                var fileName     = item[CommonConst.CommonField.NAME].ToString();
                var fileSize     = int.Parse(item[CommonConst.CommonField.FILE_SIZE].ToString());
                var contentType  = Mime.GetMimeType(fileName);
                var fileData     = JObjectHelper.GetJObjectDbDataFromFile(fileName, contentType, "lib/netstandard2.0/", request.Name, fileSize);
                fileData[CommonConst.CommonField.VERSION] = request.Version;
                var id       = fileData[CommonConst.CommonField.DISPLAY_ID].ToString();
                var data     = _keyValueStorage.Get <string>(CommonConst.Collection.MODULE_FILE_UPLOAD_CACHE, fileSourceId);
                var assembly = Assembly.Load(Convert.FromBase64String(data));
                fileData[CommonConst.CommonField.NAME] = assembly.FullName;
                WriteToDB(fileData, request.Name, CommonConst.Collection.DLLS, CommonConst.CommonField.FILE_PATH);
                InstallRoutes(request, assembly);
                _keyValueStorage.Put <string>(CommonConst.Collection.DLLS, id, data);
            }
        }
예제 #4
0
        public static void ProcessImage(JObject fileData, Bitmap image, IKeyValueStorage keyValueStorage, RotateFlipType rotate = RotateFlipType.RotateNoneFlipNone)
        {
            Size           imageSize = new Size();
            ImageThumbnail it        = new ImageThumbnail();
            var            fileHash  = fileData[ImageProcessor.FILE_HASH].ToString();

            keyValueStorage.Put <string>(ImageProcessor.IMAGE_KEY_VALUE_BUCKET, ImageProcessor.GetFileKey(ImageProcessor.IMAGE_S_BASE64, fileHash), it.CompressImage(image, 100, 75, out imageSize, 70, rotate));

            //fileData[ImageProcessor.IMAGE_S_BASE64] = it.CompressImage(image, 100, 75, out imageSize, 70, rotate);
            AddSize(fileData, imageSize, ImageProcessor.IMAGE_S_SIZE);

            keyValueStorage.Put <string>(ImageProcessor.IMAGE_KEY_VALUE_BUCKET, ImageProcessor.GetFileKey(ImageProcessor.IMAGE_M_BASE64, fileHash), it.CompressImage(image, 240, 180, out imageSize, 90, rotate));

            //fileData[ImageProcessor.IMAGE_M_BASE64] = it.CompressImage(image, 240, 180, out imageSize,90, rotate);
            AddSize(fileData, imageSize, ImageProcessor.IMAGE_M_SIZE);

            keyValueStorage.Put <string>(ImageProcessor.IMAGE_KEY_VALUE_BUCKET, ImageProcessor.GetFileKey(ImageProcessor.IMAGE_L_BASE64, fileHash), it.CompressImage(image, 1024, 768, out imageSize, 90, rotate));

            //fileData[ImageProcessor.IMAGE_L_BASE64] = it.CompressImage(image, 1024, 768, out imageSize,90, rotate);
            AddSize(fileData, imageSize, ImageProcessor.IMAGE_L_SIZE);
            fileData[ImageProcessor.CHANGESET_NO] = 0;
        }