Beispiel #1
0
        private Image RetrieveImage(string path)
        {
            #region Folder Structure For Storage

            var stationKey = (ServiceProvider.Instance().GetStationInfoService().GetStationInfos() ?? new List <StationInfo>())[0].StationKey;
            var username   = Utils.CurrentUser.UserName;
            var year       = DateTime.Now.Year.ToString(CultureInfo.InvariantCulture);
            //var username = "******";


            #endregion

            const string imgName  = "636549040395366983";
            const string fileName = imgName + ".jpeg";
            //var fileName = imgName;
            //TODO:Resourse path
            string folderPath   = "/Station-" + stationKey + "/" + username + "/" + year + "/" + "/Image/";
            var    imageResPath = folderPath + fileName;
            var    dir          = InternetCon.GetBasePath() + ConfigurationManager.AppSettings["BioResource"];
            var    imagePath    = Path.GetFullPath(dir + imageResPath);

            var img = Image.FromFile(path);
            return(img);
            //var img = Image.FromFile(imagePath);
            //using (var img = Image.FromFile(imagePath))
            //{
            //    picImage.Image = new Bitmap(img);
            //}
        }
Beispiel #2
0
        private void SaveImage(byte[] imageByteArray)
        {
            var imgName  = DateTime.Now.Ticks;
            var fileName = imgName + ".jpeg";
            //TODO:Resourse path
            const string folderPath   = "/Image/";
            var          imageResPath = folderPath + fileName;
            var          dir          = InternetCon.GetBasePath() + ConfigurationManager.AppSettings["BiometricResource"];
            var          imagePath    = Path.GetFullPath(dir + imageResPath);

            if (!Directory.Exists(@dir + @folderPath))
            {
                try
                {
                    Directory.CreateDirectory(@dir + @folderPath);
                }
                catch (Exception ex)
                {
                }
            }
            while (File.Exists(imagePath))
            {
                fileName     = DateTime.Now.Ticks + ".jpeg";
                imageResPath = folderPath + fileName;
                imagePath    = Path.GetFullPath(dir + imageResPath);
            }

            File.WriteAllBytes(@imagePath, imageByteArray);
        }
Beispiel #3
0
        private void SetFileAccess()
        {
            var basePath = InternetCon.GetBasePath() + "\\AppFiles";

            //var resourceFiles = InternetCon.GetFromResources(basePath + "\\AppFiles");

            CustomHelper.AccessControl(basePath);
        }
Beispiel #4
0
        public static string SaveImageLocally(Image image, string stationKey, string username, out string msg)
        {
            try
            {
                #region Folder Structure For Storage

                //var stationKey = (ServiceProvider.Instance().GetStationInfoService().GetStationInfos() ?? new List<StationInfo>())[0].StationKey;
                //var username = Utils.CurrentUser.UserName;
                var year = DateTime.Now.Year.ToString(CultureInfo.InvariantCulture);

                var imgName  = DateTime.Now.Ticks;
                var fileName = imgName + ".jpeg";
                //var fileName = imgName;
                //TODO:Resourse path
                string folderPath   = "/Station-" + stationKey + "/" + username + "/" + year + "/" + "/Image/";
                var    imageResPath = folderPath + fileName;
                var    dir          = InternetCon.GetBasePath() + ConfigurationManager.AppSettings["BioResource"];
                var    imagePath    = Path.GetFullPath(dir + imageResPath);
                if (!Directory.Exists(@dir + @folderPath))
                {
                    try
                    {
                        Directory.CreateDirectory(@dir + @folderPath);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                        msg = ex.Message;
                        return(null);
                    }
                }
                while (File.Exists(imagePath))
                {
                    fileName     = DateTime.Now.Ticks + ".jpeg";
                    imageResPath = folderPath + fileName;
                    imagePath    = Path.GetFullPath(dir + imageResPath);
                }


                #endregion

                image.Save(imagePath, ImageFormat.Jpeg);
                msg = "";
                return(imagePath);
                //File.WriteAllBytes(@imagePath, imageByteArray);
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                msg = "Processing Error Occurred! " + ex.Message;
                return(null);
            }
        }
Beispiel #5
0
        void btnSaveImage_Click(object sender, EventArgs e)
        {
            #region Save Image

            //var bioStoreDir = InternetCon.GetBasePath() + ConfigurationManager.AppSettings["BiometricResource"];
            var bioStoreDir = InternetCon.GetBasePath();
            var mainFolder  = ConfigurationManager.AppSettings["BiometricResource"];
            bioStoreDir = bioStoreDir + mainFolder;
            //var imgImage = new Bitmap(picImage.Image);    //Create an object of Bitmap class/
            var imgName = DateTime.Now.Ticks;
            //picImage.Image.Save(bioStoreDir + "\\" + imgName + "\\" + 1 + ".jpg");


            //using (var fs = picImage.Image)
            //{
            //    byte[] bytes = Convert.FromBase64String(fs);
            //    File.WriteAllBytes(@imagePath, bytes);
            //}

            if (picImage.Image != null)
            {
                SaveImage(picImage.Image);
            }


            //using (var mStream = new MemoryStream())
            //{
            //    if (picImage.Image != null)
            //    {
            //        //using MemoryStream:
            //        picImage.Image.Save(mStream, ImageFormat.Jpeg);
            //        //var photoAray = new byte[mStream.Length];
            //        var photoAray = mStream.ToArray();
            //        SaveImage(photoAray);
            //        //File.WriteAllBytes(bioStoreDir + "\\" + imgName, photoAray);
            //    }
            //}

            #endregion
        }
Beispiel #6
0
        private void SaveImage(Image image)
        {
            #region Folder Structure For Storage

            var stationKey = (ServiceProvider.Instance().GetStationInfoService().GetStationInfos() ?? new List <StationInfo>())[0].StationKey;
            var username   = Utils.CurrentUser.UserName;
            var year       = DateTime.Now.Year.ToString(CultureInfo.InvariantCulture);

            #endregion

            var imgName  = DateTime.Now.Ticks;
            var fileName = imgName + ".jpeg";
            //var fileName = imgName;
            //TODO:Resourse path
            string folderPath   = "/Station-" + stationKey + "/" + username + "/" + year + "/" + "/Image/";
            var    imageResPath = folderPath + fileName;
            var    dir          = InternetCon.GetBasePath() + ConfigurationManager.AppSettings["BioResource"];
            var    imagePath    = Path.GetFullPath(dir + imageResPath);
            if (!Directory.Exists(@dir + @folderPath))
            {
                try
                {
                    Directory.CreateDirectory(@dir + @folderPath);
                }
                catch (Exception ex)
                {
                }
            }
            while (File.Exists(imagePath))
            {
                fileName     = DateTime.Now.Ticks + ".jpeg";
                imageResPath = folderPath + fileName;
                imagePath    = Path.GetFullPath(dir + imageResPath);
            }

            image.Save(imagePath, ImageFormat.Jpeg);
            //File.WriteAllBytes(@imagePath, imageByteArray);
        }
Beispiel #7
0
 public void ProcessLookUpFromFiles(BioEnumeratorEntities context)
 {
     try
     {
         var basePath = InternetCon.GetBasePath();
         if (string.IsNullOrEmpty(basePath))
         {
             return;
         }
         if (!context.LocalAreas.Any())
         {
             var stateLgas = InternetCon.GetFromResources(basePath + "\\SqlFiles\\lga_lookups.sql");
             if (!string.IsNullOrEmpty(stateLgas))
             {
                 context.Database.ExecuteSqlCommand(stateLgas);
             }
         }
     }
     catch (Exception ex)
     {
         ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
     }
 }
Beispiel #8
0
 public BioEnumeratorEntities()
     : base(InternetCon.GetConnString(_path), true)
 {
     Configuration.ProxyCreationEnabled = false;
 }
Beispiel #9
0
        private void SetFileAccess()
        {
            var basePath = InternetCon.GetBasePath() + "\\AppFiles";

            CustomHelper.AccessControl(basePath);
        }
Beispiel #10
0
        private void Intialiazer()
        {
            try
            {
                var beneficiaryBiometrics = new BeneficiaryRepository().GetBeneficiarys();
                if (!beneficiaryBiometrics.Any())
                {
                }


                //var beneficiary = new BeneficiaryRepository().GetBeneficiary(1);
                //if (beneficiary == null || beneficiary.BeneficiaryId < 1)
                //{

                //}


                var pathString = ConfigurationManager.AppSettings["BioResource"];
                var appDir     = InternetCon.GetBasePath();
                var root       = Path.GetPathRoot(pathString);
                var imagePath  = Path.GetFullPath(appDir + pathString);


                #region Verification
                #endregion



                var bioMetricInfo = new BeneficiaryRepository().GetBeneficiaryBiometric(1);

                var companyInfo = new CorporateInfoService().GetCompanyInfos();
                if (companyInfo.Any())
                {
                    MessageBox.Show(@"Database Initializer", @"Configuration");
                }

                var userList = new UserService().GetUsers();
                if (userList.Any())
                {
                    MessageBox.Show(@"Database Initializer", @"Configuration");
                }


                var station = new StationInfoService().GetStationInfos();
                if (station.Any())
                {
                    MessageBox.Show(@"Database Initializer", @"Configuration");
                }

                //var dir = InternetCon.GetBasePath() + ConfigurationManager.AppSettings["BiometricResource"];


                var userProfiles = new UserProfileRepository().GetUserProfiles();
                if (userProfiles.Any())
                {
                    MessageBox.Show(@"Database Initializer", @"Configuration");
                }

                var localAreas = new LocalAreaRepository().GetLocalAreas();
                if (localAreas.Any())
                {
                    MessageBox.Show(@"Database Initializer", @"Configuration");
                }



                _apiHelper = new WebAPIHelper(_api);
                List <RegisteredUserReportObj> users = null;
                string reply = null;


                #region POST Request - Add User Details

                var roleList = new List <NameAndValueObject>
                {
                    new NameAndValueObject {
                        Id = 1, Name = "My Admin"
                    }
                };

                var resp = new UserRegResponse();

                var selRoles = new[] { "1" }.ToList();
                var roleIds = new[] { 1 };

                var helper = new UserRegistrationObj
                {
                    ConfirmPassword    = "******",
                    Email              = "*****@*****.**",
                    Othernames         = "Adesoji",
                    Surname            = "Ilesanmi",
                    MobileNumber       = "08036975694",
                    MyRoleIds          = roleIds,
                    MyRoles            = selRoles.ToArray(),
                    Username           = "******",
                    Password           = "******",
                    SelectedRoles      = string.Join(";", selRoles),
                    Sex                = 1,
                    RegisteredByUserId = 1,
                };

                if (_apiHelper.AddStationUser(helper, ref reply, ref resp))
                {
                    if (resp == null || resp.UserId < 1)
                    {
                        return;
                    }
                }

                #endregion


                //var userList = Controller.DownLoadStationUsers();



                if (_apiHelper.GetStationUsers(ref reply, ref users))
                {
                    if (users == null || !users.Any())
                    {
                        return;
                    }
                    var total = users.Count();
                }

                //var context = new BioEnumeratorEntities();
                //InternetCon.ProcessLookUpFromFiles(context);

                string msg;

                var delState = new StateRepository().DeleteState(37);
                if (delState.IsSuccessful)
                {
                    MessageBox.Show(@"State Deleted Successfully", @"Record Deletion");
                }

                //var intit = eDataAdminLite.API.MigrationAssistance.Migrate(out msg);
                //if (intit)
                //{
                //    MessageBox.Show(@"Database Initializer", @"Configuration");
                //}

                //var st = new StateRepository().GetState(37);
                //if (st != null && st.StateId > 0)
                //{
                //    st.Name = "Epay Plus Limited";
                //}

                //var updateState = new StateRepository().UpdateState(st);
                //if (updateState.IsSuccessful)
                //{
                //    MessageBox.Show(@"Database Initializer", @"State Update successfully");
                //}


                //var state = new State
                //{
                //    Name = "Epay Plus",
                //};
                //var retVal = new StateRepository().AddState(state);
                //if (retVal.IsSuccessful)
                //{
                //    MessageBox.Show(@"Database Initializer", @"Configuration");
                //}

                var states = new StateRepository().GetStates();
                if (states.Any())
                {
                    MessageBox.Show(@"Database Initializer", @"Configuration");
                }

                var roles = new RoleRepository().GetRoles();
                if (roles.Any())
                {
                    MessageBox.Show(@"Database Initializer", @"Configuration");
                }



                //var retVal = eDataAdminLite.API.UserManager.AddRole(role);
                //if (retVal.IsSuccessful)
                //{
                //    MessageBox.Show(@"Database Initializer", @"Configuration");
                //}

                //var roles = eDataAdminLite.API.UserManager.GetRoles();
                //if (!roles.Any())
                //{
                //    MessageBox.Show(@"Database Initializer", @"Configuration");
                //}
            }
            catch (Exception)
            {
                throw;
            }
        }