示例#1
0
        public Order[] GetOrders(DateTime startDate, DateTime endDate, string filter)
        {
            CheckHelper.ArgumentWithinCondition(startDate <= endDate, "startDate <= endDate");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            return(APIClientHelper <DocumentAPIClient> .Call(c => c.GetOrders(startDate, endDate, filter)));
        }
示例#2
0
        public OrderItem[] GetOrderItems(Order order)
        {
            CheckHelper.ArgumentNotNull(order, "order");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            return(APIClientHelper <DocumentAPIClient> .Call(c => c.GetOrderItems(order)));
        }
示例#3
0
        public SubCategory[] GetSubCategories(string filter, Category category)
        {
            CheckHelper.ArgumentNotNull(category, "category");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            return(APIClientHelper <DictionaryAPIClient> .Call(c => c.GetSubCategoriesByCategory(category, filter)));
        }
示例#4
0
        public string Login(string login, string password)
        {
            if (string.IsNullOrWhiteSpace(login) && string.IsNullOrWhiteSpace(password))
            {
                return(@"Не заданы ""Логин"" и ""Пароль""");
            }

            if (string.IsNullOrWhiteSpace(login))
            {
                return(@"Не задан ""Логин""");
            }

            if (string.IsNullOrWhiteSpace(password))
            {
                return(@"Не задан ""Пароль""");
            }

            var securityData =
                new SecurityData
            {
                Login    = login,
                Password = password
            };

            var errorMessage = APIClientHelper <SecurityAPIClient> .Call(c => c.LogIn(securityData));

            if (string.IsNullOrEmpty(errorMessage))
            {
                _securityData = securityData;
            }

            return(errorMessage);
        }
示例#5
0
        public Order[] GetOrders(Parcel parcel, string filter)
        {
            CheckHelper.ArgumentNotNull(parcel, "parcel");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            return(APIClientHelper <DocumentAPIClient> .Call(c => c.GetOrdersByParcel(parcel, filter)));
        }
示例#6
0
        public ProductSize[] GetProductSizes(DTO.Product product, string filter)
        {
            CheckHelper.ArgumentNotNull(product, "product");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in.");

            return(APIClientHelper <ProductAPIClient> .Call(c => c.GetProductSizesByProduct(product, filter)));
        }
示例#7
0
        public Size[] GetSizes(string filter, SubCategory subCategory, Brand brand)
        {
            CheckHelper.ArgumentNotNull(subCategory, "subCategory");
            CheckHelper.ArgumentNotNull(brand, "brand");

            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            return(APIClientHelper <DictionaryAPIClient> .Call(c => c.GetSizesBySubCategoryAndBrand(subCategory, brand, filter)));
        }
示例#8
0
        public void DeletePicture(Picture picture)
        {
            CheckHelper.ArgumentNotNull(picture, "picture");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            IoC.Container.Get <IValidateService>().CheckIsValid(picture);

            APIClientHelper <ImageAPIClient> .Call(c => c.DeletePicture(picture));
        }
示例#9
0
        public string ResetPassword(User user)
        {
            CheckHelper.ArgumentNotNull(user, "user");
            CheckHelper.ArgumentWithinCondition(user.Id > 0, "user.Id > 0");
            CheckHelper.WithinCondition(IsLoggedIn, "IsLoggedIn");

            if (_currentUser.Id == user.Id)
            {
                return("Пользователь не может сбросить себе пароль.");
            }

            return(APIClientHelper <SecurityAPIClient> .Call(c => c.ResetPassword(user)));
        }
示例#10
0
        public string UpdateDistributorTransfer(DistributorTransfer distributorTransfer)
        {
            CheckHelper.ArgumentNotNull(distributorTransfer, "distributorTransfer");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(distributorTransfer);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            return(APIClientHelper <DocumentAPIClient> .Call(c => c.UpdateDistributorTransfer(distributorTransfer)));
        }
示例#11
0
        public string UpdateBrand(Brand brand)
        {
            CheckHelper.ArgumentNotNull(brand, "brand");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(brand);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            return(APIClientHelper <DictionaryAPIClient> .Call(c => c.UpdateBrand(brand)));
        }
示例#12
0
        public string UpdateParcel(Parcel parcel)
        {
            CheckHelper.ArgumentNotNull(parcel, "parcel");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(parcel);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            return(APIClientHelper <DocumentAPIClient> .Call(c => c.UpdateParcel(parcel)));
        }
示例#13
0
        public string UpdateSubCategory(SubCategory subCategory)
        {
            CheckHelper.ArgumentNotNull(subCategory, "subCategory");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(subCategory);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            return(APIClientHelper <DictionaryAPIClient> .Call(c => c.UpdateSubCategory(subCategory)));
        }
示例#14
0
        public string UpdateProduct(DTO.Product product)
        {
            CheckHelper.ArgumentNotNull(product, "product");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in.");

            var errors = IoC.Container.Get <IValidateService>().Validate(product);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            return(APIClientHelper <ProductAPIClient> .Call(c => c.UpdateProduct(product)));
        }
示例#15
0
        public Picture UploadPicture(string path)
        {
            CheckHelper.ArgumentNotNullAndNotWhiteSpace(path, "path");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            CheckHelper.WithinCondition(File.Exists(path), string.Format("File {0} does not exist.", path));

            var fileExtension = Path.GetExtension(path);

            CheckHelper.WithinCondition(fileExtension != null && fileExtension.ToUpper() == ".JPG",
                                        string.Format("File {0} is not jpg file.", path));

            var picture = File.ReadAllBytes(path);

            var resizedPicture = ResizePicture(picture);

            return(APIClientHelper <ImageAPIClient> .Call(c => c.UploadPicture(resizedPicture)));
        }
示例#16
0
        /// <summary>
        /// Initializes the CTSManager and Parses the Query Params
        /// </summary>
        protected override void Init()
        {
            base.Init();

            ParsedReqUrlParams = new NciUrl(true, true, true);  //We need this to be lowercase and collapse duplicate params. (Or not use an NCI URL)
            ParsedReqUrlParams.SetUrl(this.Request.Url.Query);

            //////////////////////////////
            // Create an instance of a BasicCTSManager.
            ClinicalTrialsAPIClient apiClient = APIClientHelper.GetV1ClientInstance();

            CTSManager = new BasicCTSManager(apiClient);

            /////////////////////////////
            // Parse the Query to get the search params.
            try
            {
                // Get mapping file names from configuration
                TrialTermLookupConfig mappingConfig = new TrialTermLookupConfig();
                mappingConfig.MappingFiles.AddRange(Config.MappingFiles.Select(fp => HttpContext.Current.Server.MapPath(fp)));

                CTSSearchParamFactory factory = new CTSSearchParamFactory(new TrialTermLookupService(mappingConfig, apiClient), new ZipCodeGeoLookup());
                SearchParams = factory.Create(ParsedReqUrlParams);
            }
            catch (Exception ex)
            {
                log.Error("could not parse the CTS search parameters", ex);
                throw ex;
            }

            ///////////////////////////
            // Parse the page specific parameters
            if (IsInUrl(ParsedReqUrlParams, "pn"))
            {
                this._pageNum = ParsedReqUrlParams.CTSParamAsInt("pn", 1);
            }

            _itemsPerPage = Config.DefaultItemsPerPage;
            if (IsInUrl(ParsedReqUrlParams, "ni"))
            {
                this._itemsPerPage = ParsedReqUrlParams.CTSParamAsInt("ni", _itemsPerPage);
            }
        }
示例#17
0
        public string CreateUser(User user)
        {
            CheckHelper.ArgumentNotNull(user, "user");
            CheckHelper.WithinCondition(IsLoggedIn, "IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(user);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            var createdUser = (User)user.Clone();

            var errorMessage = APIClientHelper <SecurityAPIClient> .Call(c => c.CreateUser(ref createdUser));

            user.Id = createdUser.Id;

            return(errorMessage);
        }
示例#18
0
        public string CreateProductSize(ProductSize productSize)
        {
            CheckHelper.ArgumentNotNull(productSize, "productSize");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in.");

            var errors = IoC.Container.Get <IValidateService>().Validate(productSize);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            var createdProductSize = (ProductSize)productSize.Clone();

            var errorMessage = APIClientHelper <ProductAPIClient> .Call(c => c.CreateProductSize(ref createdProductSize));

            productSize.Id = createdProductSize.Id;

            return(errorMessage);
        }
示例#19
0
        public string CreateOrder(Order order)
        {
            CheckHelper.ArgumentNotNull(order, "order");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(order);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            var createdOrder = (Order)order.Clone();

            var errorMessage = APIClientHelper <DocumentAPIClient> .Call(c => c.CreateOrder(ref createdOrder));

            order.Id = createdOrder.Id;

            return(errorMessage);
        }
示例#20
0
        public string CreateSize(Size size)
        {
            CheckHelper.ArgumentNotNull(size, "size");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(size);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            var createdSize = (Size)size.Clone();

            var errorMessage = APIClientHelper <DictionaryAPIClient> .Call(c => c.CreateSize(ref createdSize));

            size.Id = createdSize.Id;

            return(errorMessage);
        }
示例#21
0
        public string CreateBrand(Brand brand)
        {
            CheckHelper.ArgumentNotNull(brand, "brand");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(brand);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            var createdBrand = (Brand)brand.Clone();

            var errorMessage = APIClientHelper <DictionaryAPIClient> .Call(c => c.CreateBrand(ref createdBrand));

            brand.Id = createdBrand.Id;

            return(errorMessage);
        }
示例#22
0
        public string CreateParcel(Parcel parcel)
        {
            CheckHelper.ArgumentNotNull(parcel, "parcel");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(parcel);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            var createdParcel = (Parcel)parcel.Clone();

            var errorMessage = APIClientHelper <DocumentAPIClient> .Call(c => c.CreateParcel(ref createdParcel));

            parcel.Id = createdParcel.Id;

            return(errorMessage);
        }
示例#23
0
        public string CreateCategory(Category category)
        {
            CheckHelper.ArgumentNotNull(category, "category");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(category);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            var createdCategory = (Category)category.Clone();

            var errorMessage = APIClientHelper <DictionaryAPIClient> .Call(c => c.CreateCategory(ref createdCategory));

            category.Id = createdCategory.Id;

            return(errorMessage);
        }
        protected sealed override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            this.LoadConfig();

            //This is referenced by the listing page templates.  Those templates
            //should be updated to reference the Page Number directly.
            this.SearchParams = new VelocitySearchParams(this);

            //Set our default items per page based on the config
            _itemsPerPage = this.GetItemsPerPage();

            //Using NciUrl for handling parameters instead of raw URL query
            //This is mainly for pagination
            ParsedReqUrlParams = new NciUrl(true, true, true);  //We need this to be lowercase and collapse duplicate params. (Or not use an NCI URL)
            ParsedReqUrlParams.SetUrl(this.Request.Url.Query);

            _basicCTSManager = new BasicCTSManager(APIClientHelper.GetV1ClientInstance());
        }
示例#25
0
        public string UpdateSettings(Settings settings)
        {
            CheckHelper.ArgumentNotNull(settings, "settings");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(settings);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            var errorMessage = APIClientHelper <AdministrationAPIClient> .Call(c => c.UpdateSettings(settings));

            if (errorMessage == null)
            {
                _settings = null;
            }

            return(errorMessage);
        }
示例#26
0
        public string UpdateUser(User user)
        {
            CheckHelper.ArgumentNotNull(user, "user");
            CheckHelper.WithinCondition(IsLoggedIn, "IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(user);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            var errorMessage = APIClientHelper <SecurityAPIClient> .Call(c => c.UpdateUser(user));

            if (errorMessage == null && _currentUser.Id == user.Id)
            {
                _securityData.Login = user.Login;
                _currentUser        = null;
            }

            return(errorMessage);
        }
示例#27
0
        public string ChangePassword(string newPassword, string passwordConfirmation)
        {
            CheckHelper.WithinCondition(IsLoggedIn, "IsLoggedIn");

            if (string.IsNullOrWhiteSpace(newPassword) && string.IsNullOrWhiteSpace(passwordConfirmation))
            {
                return(@"Не заданы ""Новый пароль"" и ""Подтверждение пароля""");
            }

            if (string.IsNullOrWhiteSpace(newPassword))
            {
                return(@"Не задан ""Новый пароль""");
            }

            if (string.IsNullOrWhiteSpace(passwordConfirmation))
            {
                return(@"Не задано ""Подтверждение пароля""");
            }

            if (newPassword != passwordConfirmation)
            {
                return(@"""Новый пароль"" и ""Подтверждение пароля"" не совпадают");
            }

            if (!StringValidator.ValidatePassword(newPassword))
            {
                return("Пароль должен иметь длину от 5 до 50 символов.");
            }

            var errorMessage = APIClientHelper <SecurityAPIClient> .Call(c => c.ChangePassword(newPassword));

            if (string.IsNullOrEmpty(errorMessage))
            {
                _securityData.Password = newPassword;
            }

            return(errorMessage);
        }
示例#28
0
        private void GeneratePrintCacheAndRedirect(HttpContext context, CTSPrintManager manager)
        {
            HttpRequest  request  = context.Request;
            HttpResponse response = context.Response;

            NciUrl parsedReqUrlParams = new NciUrl(true, true, true);  //We need this to be lowercase and collapse duplicate params. (Or not use an NCI URL)

            parsedReqUrlParams.SetUrl(request.Url.Query);


            ClinicalTrialsAPIClient apiClient = APIClientHelper.GetV1ClientInstance();

            CTSSearchParams searchParams = null;

            try
            {
                // Get mapping file names from configuration
                TrialTermLookupConfig mappingConfig = new TrialTermLookupConfig();
                mappingConfig.MappingFiles.AddRange(_config.MappingFiles.Select(fp => HttpContext.Current.Server.MapPath(fp)));

                CTSSearchParamFactory factory = new CTSSearchParamFactory(new TrialTermLookupService(mappingConfig, apiClient), new ZipCodeGeoLookup());
                searchParams = factory.Create(parsedReqUrlParams);
            }
            catch (Exception ex)
            {
                ErrorPageDisplayer.RaisePageByCode(this.GetType().ToString(), 400); //Anything here is just a bad request.
            }

            //Set our output to be JSON
            response.ContentType     = "application/json";
            response.ContentEncoding = Encoding.UTF8;

            //Try and get the request.
            Request req = null;

            try
            {
                req = GetRequestAndValidate(context);
            }
            catch (Exception)
            {
                ErrorPageDisplayer.RaisePageByCode(this.GetType().ToString(), 400); //Anything here is just a bad request.
                return;
            }

            // Store the cached print content
            Guid printCacheID = manager.StorePrintContent(req.TrialIDs, DateTime.Now, searchParams);

            //Add in debugging helper param to make debugging templates easier.
            //TODO: Refactor so get content and render is a single function.
            if (parsedReqUrlParams.QueryParameters.ContainsKey("debug") && parsedReqUrlParams.QueryParameters["debug"] == "true")
            {
                response.ContentType     = "text/HTML";
                response.ContentEncoding = Encoding.UTF8;
                // If there is no error, send the printID to the manager to retrieve the cached print content
                string printContent = manager.GetPrintContent(printCacheID);

                printContent = printContent.Replace("${generatePrintURL}", GetEmailUrl(printCacheID));

                response.Write(printContent);
                response.End();
            }
            else
            {
                // Format our return as JSON
                var resp = JsonConvert.SerializeObject(new
                {
                    printID = printCacheID
                });

                response.Write(resp);
                response.End();
            }
        }
示例#29
0
        public ProductSize[] GetProductSizes(string filter)
        {
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in.");

            return(APIClientHelper <ProductAPIClient> .Call(c => c.GetProductSizes(filter)));
        }
示例#30
0
        public DTO.Product[] GetProducts(DateTime startDate, DateTime endDate, string filter)
        {
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in.");

            return(APIClientHelper <ProductAPIClient> .Call(c => c.GetProductsByDate(startDate, endDate, filter)));
        }