Ejemplo n.º 1
0
 public FilesUploadContext(FilesUploadFeature feature, UploadLocation location, IRequest request, string fileName)
 {
     Feature  = feature;
     Location = location;
     Request  = request;
     FileName = fileName;
 }
Ejemplo n.º 2
0
        public string GetUniqueFilePath(UploadLocation location, string extension)
        {
            string filePath = "";

            do
            {
                filePath = location.GetAbsoluteFilePathForLocation($"{Path.GetRandomFileName()}.{extension}");
            } while (File.Exists(filePath) == true);
            return(filePath);
        }
Ejemplo n.º 3
0
        private string saveUploadFile(HttpPostedFileBase file, FileTypeEnum fileType)
        {
            var location = UploadLocation.Get(fileType);
            var extenson = Path.GetExtension(file.FileName).Replace(".", "");
            var filePath = GetUniqueFilePath(location, extenson);

            Directory.CreateDirectory(Path.GetDirectoryName(filePath));
            file.SaveAs(filePath);
            return(filePath);
        }
        protected override void OnLoad()
        {
            base.OnLoad();

            SiteSettings            siteSettings      = ConfigurationManager.GetInstance().GetSiteSettings();
            List <ExplorerLocation> explorerLocations = ConfigurationManager.GetInstance().GetExplorerLocations(ApplicationContext.Current.GetApplicationType());
            List <Folder>           folders           = ConfigurationManager.GetInstance().GetFoldersByExplorerLocations(explorerLocations, false);

            UploadLocation.InitializeForm(siteSettings, folders, true, null);
            this.OKButtonSelected += new EventHandler(UploadFilesForm_OKButtonSelected);
            this.SetUploadFilesText();
        }
Ejemplo n.º 5
0
        public void RemoveUploadFile(Flashcards.Entities.File file)
        {
            var absPath = UploadLocation.GetAbsoluteFilePathForLocation(file);

            if (File.Exists(absPath))
            {
                File.Delete(absPath);
            }

            fileRepository.Remove(file);
            fileRepository.SaveChanges();
        }
        public async Task <UploadLocation> UploadLocations(UploadLocation model, string Userid)
        {
            if (IsActiveProfile)
            {
                var locData     = ValidateModel(model);
                int?LocConfigID = GetLocationConfigByCompany(model.CompanyID);
                foreach (var loc in locData.ValidData.Locationdata)
                {
                    bool isActive = (loc.isActive.ToLower() == "yes" || loc.isActive.ToLower() == "y") ? true : false;
                    //Insert Location Data
                    var Locationadata = await context.Locations.FirstOrDefaultAsync(locCode => locCode.LocCode == loc.LocCode && locCode.CompanyID == model.CompanyID);

                    if (Locationadata == null)
                    {
                        Locationadata = new Location
                        {
                            LocCode    = loc.LocCode,
                            CompanyID  = model.CompanyID,
                            ModifiedBy = Userid,
                            ModifiedOn = DateTime.Now,
                            CreatedBy  = Userid,
                            CreatedOn  = DateTime.Now,
                            IsActive   = isActive,
                            IsDelete   = false
                        };
                        context.Locations.Add(Locationadata);
                        await context.SaveChangesAsync();

                        //Insert Location Meta data
                        await insertLocations(context, loc, LocConfigID, model.CompanyID, Userid, Locationadata.LocId, isActive);
                    }
                    else
                    {
                        //UpdateLocationMeta Locationmeta if Exists
                        var LocationMeta = Locationadata.LocationMetadatas.Where(x => x.LocId == Locationadata.LocId && x.CustomerID == model.CompanyID).ToList();
                        await UpdateLocationMeta(LocationMeta, Userid, loc, LocConfigID, model.CompanyID, Locationadata.LocId, isActive);
                    }
                }
                return(locData.UnValidData);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 7
0
        public async Task <StatusResult> UploadBulkLocations(UploadLocation model)
        {
            StatusResult c = new StatusResult();

            try
            {
                if (!ModelState.IsValid)
                {
                    c.Status = Status.BadRequest.ToString();
                    c.Result = BadRequest();
                    return(c);
                }
                if (User.IsInRole(Roles.SuperAdmin) || User.IsInRole(Roles.PortalAdmin) || User.IsInRole(Roles.AccountAdmin))
                {
                    LocationConfig locationConfig = new LocationConfig();
                    string         UserID         = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;
                    var            res            = await locationConfig.UploadLocations(model, UserID);

                    if (res != null)
                    {
                        c.Status = Status.Success.ToString();
                        c.Result = res.Locationdata;
                        return(c);
                    }
                    else
                    {
                        c.Status = Status.Fail.ToString();
                        c.Result = "Please upload standard file.";
                        return(c);
                    }
                }
                else
                {
                    c.Status = Status.NoAccess.ToString();
                    c.Result = "No Access";
                    return(c);
                }
            }
            catch (Exception ex)
            {
                c.Status = Status.InternalServerError.ToString();
                c.Result = ex.Message + "Please upload standard file.";
                return(c);
            }
        }
Ejemplo n.º 8
0
        public async Task <UploadLocation> UploadLocations(UploadLocation model, string Userid)
        {
            ILocationConfigService loc = new LocationConfigService(model.CompanyID);

            return(await loc.UploadLocations(model, Userid));
        }
        private LocationValidationData ValidateModel(UploadLocation model)
        {
            LocationValidationData data = new LocationValidationData();

            data.UnValidData              = new UploadLocation();
            data.ValidData                = new UploadLocation();
            data.ValidData.Locationdata   = new List <LocationData>();
            data.UnValidData.Locationdata = new List <LocationData>();

            List <LocationData> invalidLocationName = model.Locationdata.Where(x => string.IsNullOrEmpty(x.LocationName))
                                                      .Select(x => new LocationData
            {
                LocationName       = x.LocationName,
                LocCode            = x.LocCode,
                FirstContactEmail  = x.FirstContactEmail,
                FirstContactName   = x.FirstContactName,
                SecondContactEmail = x.SecondContactEmail,
                SecondContactName  = x.SecondContactName,
                isActive           = x.isActive,
                ThirdContactEmail  = x.ThirdContactEmail,
                ThirdContactName   = x.ThirdContactName,
                Tags    = x.Tags,
                Remarks = "Location Name is Empty"
            }).ToList();

            model.Locationdata.RemoveAll(x => invalidLocationName.Any(y => y.LocationName == x.LocationName));


            List <LocationData> invalidLocationCode = model.Locationdata.Where(x => string.IsNullOrEmpty(x.LocCode))
                                                      .Select(x => new LocationData
            {
                LocationName       = x.LocationName,
                LocCode            = x.LocCode,
                FirstContactEmail  = x.FirstContactEmail,
                FirstContactName   = x.FirstContactName,
                SecondContactEmail = x.SecondContactEmail,
                SecondContactName  = x.SecondContactName,
                isActive           = x.isActive,
                ThirdContactEmail  = x.ThirdContactEmail,
                ThirdContactName   = x.ThirdContactName,
                Tags    = x.Tags,
                Remarks = "Location Code is Empty"
            }).ToList();

            model.Locationdata.RemoveAll(x => invalidLocationCode.Any(y => y.LocCode == x.LocCode));

            List <LocationData> invalidFirstContactName = model.Locationdata.Where(x => string.IsNullOrEmpty(x.FirstContactName))
                                                          .Select(x => new LocationData
            {
                LocationName       = x.LocationName,
                LocCode            = x.LocCode,
                FirstContactEmail  = x.FirstContactEmail,
                FirstContactName   = x.FirstContactName,
                SecondContactEmail = x.SecondContactEmail,
                SecondContactName  = x.SecondContactName,
                isActive           = x.isActive,
                ThirdContactEmail  = x.ThirdContactEmail,
                ThirdContactName   = x.ThirdContactName,
                Tags    = x.Tags,
                Remarks = "FirstContact Name is Empty"
            }).ToList();

            model.Locationdata.RemoveAll(x => invalidFirstContactName.Any(y => y.FirstContactName == x.FirstContactName));

            List <LocationData> invalidFirstContactEmail = model.Locationdata.Where(x => !CommonFunctions.validateEmail(x.FirstContactEmail))
                                                           .Select(x => new LocationData
            {
                LocationName       = x.LocationName,
                LocCode            = x.LocCode,
                FirstContactEmail  = x.FirstContactEmail,
                FirstContactName   = x.FirstContactName,
                SecondContactEmail = x.SecondContactEmail,
                SecondContactName  = x.SecondContactName,
                isActive           = x.isActive,
                ThirdContactEmail  = x.ThirdContactEmail,
                ThirdContactName   = x.ThirdContactName,
                Tags    = x.Tags,
                Remarks = "FirstContact Email is Empty or Email format wrong"
            }).ToList();

            model.Locationdata.RemoveAll(x => invalidFirstContactEmail.Any(y => y.FirstContactEmail == x.FirstContactEmail));

            List <LocationData> invalidSecondContactEmail = model.Locationdata.Where(x => !CommonFunctions.validateSEmail(x.SecondContactEmail))
                                                            .Select(x => new LocationData
            {
                LocationName       = x.LocationName,
                LocCode            = x.LocCode,
                FirstContactEmail  = x.FirstContactEmail,
                FirstContactName   = x.FirstContactName,
                SecondContactEmail = x.SecondContactEmail,
                SecondContactName  = x.SecondContactName,
                isActive           = x.isActive,
                ThirdContactEmail  = x.ThirdContactEmail,
                ThirdContactName   = x.ThirdContactName,
                Tags    = x.Tags,
                Remarks = "SecondContact Email is Wrongformat"
            }).ToList();

            model.Locationdata.RemoveAll(x => invalidSecondContactEmail.Any(y => y.SecondContactEmail == x.SecondContactEmail));

            List <LocationData> invalidThirdContactEmail = model.Locationdata.Where(x => !CommonFunctions.validateSEmail(x.ThirdContactEmail))
                                                           .Select(x => new LocationData
            {
                LocationName       = x.LocationName,
                LocCode            = x.LocCode,
                FirstContactEmail  = x.FirstContactEmail,
                FirstContactName   = x.FirstContactName,
                SecondContactEmail = x.SecondContactEmail,
                SecondContactName  = x.SecondContactName,
                isActive           = x.isActive,
                ThirdContactEmail  = x.ThirdContactEmail,
                ThirdContactName   = x.ThirdContactName,
                Tags    = x.Tags,
                Remarks = "ThirdContact Email is Wrongformat"
            }).ToList();

            model.Locationdata.RemoveAll(x => invalidThirdContactEmail.Any(y => y.ThirdContactEmail == x.ThirdContactEmail));

            data.ValidData = model;
            data.UnValidData.Locationdata = invalidLocationName;
            data.UnValidData.Locationdata.AddRange(invalidLocationCode);
            data.UnValidData.Locationdata.AddRange(invalidFirstContactName); data.UnValidData.Locationdata.AddRange(invalidFirstContactEmail);
            data.UnValidData.Locationdata.AddRange(invalidSecondContactEmail); data.UnValidData.Locationdata.AddRange(invalidThirdContactEmail);
            return(data);
        }
 private void BeforeWebDriverSetupSetps()
 {
     downloadLocation = new Lazy <string>(() => DownloadLocation.CreateWebDriverDirectory(appConfigMember.Browser.ToString() + appConfigMember.ExecutionType.ToString(), appConfigMember.RootDownloadLocation));
     uploadLocation   = new Lazy <UploadLocation>(() => UploadLocation.Create(appConfigMember.Browser.ToString() + appConfigMember.ExecutionType.ToString(), true, appConfigMember.RootUploadLocation));
 }