예제 #1
0
    void ShowScore()
    {
        if (score > finalScore)
        {
            finalScore = score;
        }
        if (finalScore > PlayerPrefs.GetFloat("MemoryScore"))
        {
            PlayerPrefs.SetFloat("MemoryScore", finalScore);
        }
        else
        {
            finalScore = PlayerPrefs.GetFloat("MemoryScore");
        }

        lives = 5;
        UI.SetActive(false);
        Capsules.SetActive(false);
        Spheres.GetComponent <Randomsphere>().Getclonei().SetActive(false);
        Spheres.GetComponent <Randomsphere>().Getclonej().SetActive(false);
        Spheres.GetComponent <Randomsphere>().Getclonek().SetActive(false);
        scoreBoard.SetActive(true);
        scoreBoard.transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z + 35);
        Username.GetComponent <TMPro.TextMeshPro>().text = FacebookManager.Instance.ProfileName + ": " + score.ToString();
        if (FacebookManager.Instance.ProfilePic != null)
        {
            ProfilePic.GetComponent <Image>().sprite = FacebookManager.Instance.ProfilePic;
        }
    }
        public async Task <IActionResult> SaveProfilePic([FromBody] SaveProfilePicViewModel vm)
        {
            var user = await getUser();

            if (vm != null && !string.IsNullOrEmpty(vm.imgdata))
            {
                var pp = _context.ProfilePics.FirstOrDefault(x => x.userId == user.Id);
                if (pp != null)
                {
                    pp.imgData = vm.imgdata;
                    _context.ProfilePics.Update(pp);
                }
                else
                {
                    pp = new ProfilePic()
                    {
                        userId  = user.Id,
                        imgData = vm.imgdata
                    };
                    _context.ProfilePics.Add(pp);
                }

                var purl = this.url + "/account/profilepic/" + pp.guid;
                if (user.photoUrl != purl)
                {
                    user.photoUrl = purl;
                    _context.Users.Update(user);
                }

                await _context.SaveChangesAsync();
            }

            return(Ok());
        }
예제 #3
0
        public ProfilePic GetProPicById(int id)
        {
            ProfilePic profilePic = null;

            command             = new SqlCommand("spGetImageById", conn);
            command.CommandType = CommandType.StoredProcedure;

            SqlParameter paramId = new SqlParameter()
            {
                ParameterName = "@Id",
                Value         = id
            };

            command.Parameters.Add(paramId);

            conn.Open();
            SqlDataReader reader = command.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    profilePic           = new ProfilePic();
                    profilePic.Id        = Convert.ToInt32(reader["Id"]);
                    profilePic.Name      = reader["Name"].ToString();
                    profilePic.Size      = Convert.ToInt32(reader["Size"]);
                    profilePic.ImageData = (byte[])reader["ImageData"];
                    profilePic.UserId    = Convert.ToInt32(reader["UserId"]);
                }
            }
            conn.Close();
            return(profilePic);
        }
예제 #4
0
        public string AddEmpWithImage(UIEmp uiEmp)
        {
            HttpPostedFileBase imgFile = Request.Files["ProfilePic"];
            BinaryReader       br      = new BinaryReader(imgFile.InputStream);

            byte[] bytes = br.ReadBytes(Convert.ToInt32(imgFile.ContentLength));
            uiEmp.ProfilePic = new UIProfilePic();
            uiEmp.ProfilePic.ProfileImage = bytes;
            Employee employee = new Employee();

            employee.FirstName = uiEmp.FirstName;
            employee.LastName  = uiEmp.LastName;
            employee.GenderId  = uiEmp.Gender.GenderId;
            employee.MobileNo  = uiEmp.MobileNo;
            employee.EmailId   = uiEmp.EmailId;
            employee.CountryId = uiEmp.Country.CountryId;
            employee.StateId   = uiEmp.State.StateId;
            employee.Address   = uiEmp.Address;
            employee.ZipCode   = uiEmp.ZipCode;
            mvcDemoEntities.Employees.Add(employee);
            int status = mvcDemoEntities.SaveChanges();
            int empId  = employee.EmployeeId;

            if (status > 0)
            {
                ProfilePic profilePic = new ProfilePic();
                profilePic.ProfileImage = uiEmp.ProfilePic.ProfileImage;
                profilePic.EmployeeId   = empId;
                mvcDemoEntities.ProfilePics.Add(profilePic);
                int res = mvcDemoEntities.SaveChanges();
            }

            return("");
        }
예제 #5
0
    void ShowScore()
    {
        fin = true;
        if (score > finalScore)
        {
            finalScore = score;
        }
        if (finalScore > PlayerPrefs.GetFloat("CGampScore"))
        {
            PlayerPrefs.SetFloat("CGampScore", finalScore);
        }
        else
        {
            finalScore = PlayerPrefs.GetFloat("CGampScore");
        }

        UI.SetActive(false);
        scoreBoard.SetActive(true);
        CGAMPspawnSystem.GetComponent <SpawnCGamp>().enabled = false;
        StingspawnSystem.GetComponent <SpawnSting>().enabled = false;
        scoreBoard.transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z + 1);
        lives = 3;
        Username.GetComponent <TMPro.TextMeshPro>().text = FacebookManager.Instance.ProfileName + ": " + score.ToString();
        if (FacebookManager.Instance.ProfilePic != null)
        {
            ProfilePic.GetComponent <Image>().sprite = FacebookManager.Instance.ProfilePic;
        }
    }
예제 #6
0
        public JsonStandardResponse SaveFile(ProfilePic pp)
        {
            string error = string.Empty;
            string URL   = string.Empty;

            byte[] imagebytes = null;
            JsonStandardResponse objJsonReturn = null;

            try
            {
                objJsonReturn = new JsonStandardResponse();

                try
                {
                    imagebytes = Convert.FromBase64String(pp.profileimage);
                    Image image;
                    using (MemoryStream ms = new MemoryStream(imagebytes))
                    {
                        image = Image.FromStream(ms);
                    }
                    Bitmap newBitmap = new Bitmap(image);
                    //Saving Image to folder
                    Random objRandom = new Random();
                    int    RandomNo  = objRandom.Next(10000000, 99999999); // creates a 8 digit random no.
                    //string path = @"C:\FileManager\";
                    string path     = HttpContext.Current.Server.MapPath("~/ProfilePicture/");
                    string datetime = DateTime.Now.ToString("yyyy-MM-ddTHH-mm-ss");
                    string fileName = RandomNo + datetime + ".jpg";
                    string fullpath = path + fileName;
                    // System.Drawing.Image imageIn = base64.ToString();
                    newBitmap.Save(fullpath);
                    error = string.Empty;
                    if (File.Exists(fullpath))
                    {
                        new DataAccessController().UpdateUserProfilePic("https://stg-smtshjapp.shj.ae/ProfilePicture/" + fileName, pp.userName);
                    }
                    objJsonReturn.status = "success";
                    objJsonReturn.data   = "https://stg-smtshjapp.shj.ae/ProfilePicture/" + RandomNo + datetime + ".jpg";
                }
                catch (Exception ex)
                {
                    objJsonReturn.status  = "error";
                    objJsonReturn.message = ex.Message;
                    objJsonReturn.data    = string.Empty;

                    new BusinessLogic().CreateLog(1, ex.Message, ex.HResult.ToString(), "FileManager/SaveFile");
                }
            }
            catch (Exception e)
            {
                objJsonReturn.status  = "error";
                objJsonReturn.message = e.Message;
                objJsonReturn.data    = string.Empty;
                new BusinessLogic().CreateLog(1, e.Message, e.HResult.ToString(), "FileManager/SaveFile");
            }
            return(objJsonReturn);
        }
예제 #7
0
    //google has been removed as we cannot get the picture without authenticating ourselves first.

    public static void GetProfilePicture(Action <Texture2D> callback, PlatformID platformID, string platformUserID)
    {
        GameObject profilePicPacket = new GameObject("ProfilePicPacket");

        ProfilePic pic = profilePicPacket.AddComponent <ProfilePic>();

        pic.callback = callback;

        pic.GetProfilePicture(platformID, platformUserID);
    }
        void ReleaseDesignerOutlets()
        {
            if (CartButton != null)
            {
                CartButton.Dispose();
                CartButton = null;
            }

            if (ChatButton != null)
            {
                ChatButton.Dispose();
                ChatButton = null;
            }

            if (MyLibraryButton != null)
            {
                MyLibraryButton.Dispose();
                MyLibraryButton = null;
            }

            if (NotificationsButton != null)
            {
                NotificationsButton.Dispose();
                NotificationsButton = null;
            }

            if (ProfileButton != null)
            {
                ProfileButton.Dispose();
                ProfileButton = null;
            }

            if (ProfileButton2 != null)
            {
                ProfileButton2.Dispose();
                ProfileButton2 = null;
            }

            if (ProfilePic != null)
            {
                ProfilePic.Dispose();
                ProfilePic = null;
            }

            if (ProfilePicButton != null)
            {
                ProfilePicButton.Dispose();
                ProfilePicButton = null;
            }
        }
예제 #9
0
    public void ShowProfileForTag(string tag)
    {
        ProfilePic profileToShow = new ProfilePic();

        foreach (ProfilePic profile in Profiles)
        {
            if (profile.tag.Equals(tag))
            {
                profileToShow = profile;
            }
        }
        GetComponent <ArrayAnimatorScript>().Stop();
        GetComponent <SpriteRenderer>().sprite = profileToShow.sprites[0];
        GetComponent <ArrayAnimatorScript>().AnimationArray = profileToShow.sprites;
    }
예제 #10
0
        public int SaveProfilePic(ProfilePic profilePic)
        {
            command             = new SqlCommand("spSaveImage", conn);
            command.CommandType = CommandType.StoredProcedure;

            SqlParameter nameparamName = new SqlParameter()
            {
                ParameterName = "@Name",
                Value         = profilePic.Name
            };

            command.Parameters.Add(nameparamName);
            SqlParameter nameparamSize = new SqlParameter()
            {
                ParameterName = "@Size",
                Value         = profilePic.Size
            };

            command.Parameters.Add(nameparamSize);
            SqlParameter nameparamImageData = new SqlParameter()
            {
                ParameterName = "@ImageData",
                Value         = profilePic.ImageData
            };

            command.Parameters.Add(nameparamImageData);
            SqlParameter nameparamUserId = new SqlParameter()
            {
                ParameterName = "@UserId",
                Value         = profilePic.UserId
            };

            command.Parameters.Add(nameparamUserId);
            SqlParameter nameparamNewId = new SqlParameter()
            {
                ParameterName = "@NewId",
                Value         = -1,
                Direction     = ParameterDirection.Output
            };

            command.Parameters.Add(nameparamNewId);

            conn.Open();
            command.ExecuteNonQuery();
            conn.Close();

            return(Convert.ToInt32(command.Parameters["@NewId"].Value));
        }
        public ActionResult OpenPersonalPic(string app_user_id)
        {
            PersonalAccount p_acc = db.personalaccounts.ToList().Where(x => x.AppUserId == app_user_id).FirstOrDefault();
            ProfilePic      ppic  = db.profilepics.ToList().Where(x => x.UserId == p_acc.ID).FirstOrDefault();


            if (ppic != null)
            {
                var pic = db.Files.OrderByDescending(x => x.ProfilePicID == ppic.ID).FirstOrDefault();
                return(File(pic.Content, pic.ContentType));
            }
            else
            {
                return(File("/Content/default.jpg", "image/jpeg"));
            }
        }
        public string UploadFile(ProfilePic picupload)
        {
            string ext = System.IO.Path.GetExtension(picupload.FormFile.FileName);



            if (picupload.FormFile != null && (ext == ".jpeg" || ext == ".jpg" || ext == ".gif" || ext == ".png"))
            {
                string filepath = $"{_env.WebRootPath}/images/{ picupload.FormFile.FileName}";


                var stream = System.IO.File.Create(filepath);
                picupload.FormFile.CopyTo(stream);
            }
            else
            {
                return("Only Images of type .jpg,.gif,.png or .jpeg is accepted");
            }
            return("PROFILE PIC UPLOAD SUCCESSFUL");
        }
        private void LoadProPic(int userId)
        {
            User profileUser = userManager.GetUserById(userId);

            if (profileUser.ProPicId != 0)
            {
                ProfilePic propic = profilePicManager.GetProPicById(profileUser.ProPicId);
                var        base64 = Convert.ToBase64String(propic.ImageData);
                var        imgSrc = String.Format("data:image/jpg;base64,{0}", base64);
                proPicImage.Attributes.Add("src", imgSrc);
                proPicImage.Attributes.Add("height", "225px");
                proPicImage.Attributes.Add("width", "100%");
            }
            else
            {
                proPicImage.Attributes.Add("src", "../Images/pollen.jpg");
                proPicImage.Attributes.Add("width", "100%");
                proPicImage.Attributes.Add("height", "225px");
            }
        }
예제 #14
0
 private void button1_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         FileDialog fldlg = new OpenFileDialog();
         fldlg.InitialDirectory = Environment.SpecialFolder.MyPictures.ToString();
         fldlg.Filter           = "Image File (*.jpg;*.bmp;*.gif)|*.jpg;*.bmp;*.gif";
         fldlg.ShowDialog();
         {
             strName   = fldlg.SafeFileName;
             imageName = fldlg.FileName;
             ImageSourceConverter isc = new ImageSourceConverter();
             ProfilePic.SetValue(Image.SourceProperty, isc.ConvertFromString(imageName));
         }
         fldlg = null;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
     }
 }
        protected void uploadButton_Click(object sender, EventArgs e)
        {
            HttpPostedFile postedFile = profilePicImg.PostedFile;

            ProfilePic profilePic = new ProfilePic();

            profilePic.Name = Path.GetFileName(postedFile.FileName);
            profilePic.Size = postedFile.ContentLength;
            Stream       stream = postedFile.InputStream;
            BinaryReader br     = new BinaryReader(stream);

            profilePic.ImageData = br.ReadBytes((int)stream.Length);
            profilePic.UserId    = loggedInUser.Id;

            int proPicId = profilePicManager.SaveProfilePic(profilePic);

            User user = new User();

            user.ProPicId = proPicId;
            user.Id       = loggedInUser.Id;
            userManager.UpdateUserWithPic(user);
            LoadProPic(user.Id);
        }
 public int SaveProfilePic(ProfilePic profilePic)
 {
     return(profilePicGateway.SaveProfilePic(profilePic));
 }
예제 #17
0
        public async Task <ActionResult> EditImage(ProfilePic profilePic)
        {
            string imagesFolder = Path.Combine(Directory.GetCurrentDirectory(), "images");
            string tempImage    = imagesFolder + "\\" + profilePic.Image;


            //Scale
            Bitmap   scaledBitmap = new Bitmap(profilePic.Width, profilePic.Height);
            Graphics graph        = Graphics.FromImage(scaledBitmap);

            using (Bitmap tempBitmap = new Bitmap(tempImage))
            {
                graph.DrawImage(tempBitmap, 0, 0, profilePic.Width, profilePic.Height);
            }

            // Delete the temp image
            System.IO.File.Delete(tempImage);



            //Crop
            Bitmap croppedBitmap = new Bitmap(300, 300);

            for (int i = 0; i < 300; i++)
            {
                for (int y = 0; y < 300; y++)
                {
                    Color pxlclr = scaledBitmap.GetPixel(profilePic.CropLeft + i, profilePic.CropTop + y);
                    croppedBitmap.SetPixel(i, y, pxlclr);
                }
            }


            //Create the new image
            string imageName = Guid.NewGuid().ToString("N") + ".png";
            string newImage  = Path.Combine(imagesFolder, imageName);

            croppedBitmap.Save(newImage, ImageFormat.Png);


            //Get the customer associated with this profile pic
            string   customerId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            Customer customer   = await unitOfWork.Customers.Get(x => x.Id == customerId);


            //Update the customer's profile picture
            customer.Image = imageName;
            unitOfWork.Customers.Update(customer);

            //Save
            await unitOfWork.Save();


            // Send an email
            if (customer.EmailPrefProfilePicChange == true)
            {
                emailService.AddToQueue(EmailType.ProfilePicChange, "Updated profile picture", new Recipient
                {
                    FirstName = customer.FirstName,
                    LastName  = customer.LastName,
                    Email     = customer.Email
                }, new EmailProperties {
                    Host = GetHost()
                });
            }



            return(Ok(imageName));
        }
        public ActionResult AddEmp1(UIEmp uiEmp)
        {
            string statusMsg = string.Empty;

            try
            {
                int empId  = uiEmp.EmployeeId;
                int status = 0;
                HttpPostedFileBase imgFile = Request.Files["ProfilePic"];
                BinaryReader       br      = new BinaryReader(imgFile.InputStream);
                byte[]             bytes   = br.ReadBytes(Convert.ToInt32(imgFile.ContentLength));
                uiEmp.ProfilePic = new UIProfilePic();
                uiEmp.ProfilePic.ProfileImage = bytes;

                if (empId == 0)
                {
                    Employee employee = new Employee();
                    employee.FirstName    = uiEmp.FirstName;
                    employee.LastName     = uiEmp.LastName;
                    employee.MobileNo     = uiEmp.MobileNo;
                    employee.EmailId      = uiEmp.EmailId;
                    employee.Address      = uiEmp.Address;
                    employee.ZipCode      = uiEmp.ZipCode;
                    employee.GenderId     = uiEmp.Gender.GenderId;
                    employee.CountryId    = uiEmp.Country.CountryId;
                    employee.StateId      = uiEmp.State.StateId;
                    employee.StatusTypeId = 1;
                    mvcDemoEntities.Employees.Add(employee);
                    status = mvcDemoEntities.SaveChanges();
                    int id = employee.EmployeeId;
                    if (status > 0)
                    {
                        if (imgFile.ContentLength != 0)
                        {
                            ProfilePic profilePic = new ProfilePic();
                            profilePic.ProfileImage = uiEmp.ProfilePic.ProfileImage;
                            profilePic.EmployeeId   = id;
                            mvcDemoEntities.ProfilePics.Add(profilePic);
                            int res = mvcDemoEntities.SaveChanges();
                        }
                        statusMsg = "Add";
                    }
                }
                else
                {
                    var lstEmp = mvcDemoEntities.Employees.Find(empId);
                    lstEmp.FirstName = uiEmp.FirstName;
                    lstEmp.LastName  = uiEmp.LastName;
                    lstEmp.MobileNo  = uiEmp.MobileNo;
                    lstEmp.EmailId   = uiEmp.EmailId;
                    lstEmp.Address   = uiEmp.Address;
                    lstEmp.ZipCode   = uiEmp.ZipCode;
                    lstEmp.GenderId  = uiEmp.Gender.GenderId;
                    lstEmp.CountryId = uiEmp.Country.CountryId;
                    lstEmp.StateId   = uiEmp.State.StateId;
                    mvcDemoEntities.Entry(lstEmp).State = EntityState.Modified;
                    status = mvcDemoEntities.SaveChanges();
                    if (status > 0)
                    {
                        if (mvcDemoEntities.ProfilePics.Any(o => o.EmployeeId == empId))
                        {
                            if (imgFile.ContentLength != 0)
                            {
                                var obj = mvcDemoEntities.ProfilePics.FirstOrDefault(o => o.EmployeeId == empId);
                                mvcDemoEntities.ProfilePics.Remove(obj);
                                mvcDemoEntities.Entry(obj).State = EntityState.Deleted;
                                int i = mvcDemoEntities.SaveChanges();

                                ProfilePic profilePic = new ProfilePic();
                                profilePic.ProfileImage = uiEmp.ProfilePic.ProfileImage;
                                profilePic.EmployeeId   = empId;
                                mvcDemoEntities.ProfilePics.Add(profilePic);
                                int res = mvcDemoEntities.SaveChanges();
                                obj.ProfileImage = uiEmp.ProfilePic.ProfileImage;
                                status           = mvcDemoEntities.SaveChanges();
                            }
                        }
                        else
                        {
                            ProfilePic profilePic = new ProfilePic();
                            profilePic.ProfileImage = uiEmp.ProfilePic.ProfileImage;
                            profilePic.EmployeeId   = empId;
                            mvcDemoEntities.ProfilePics.Add(profilePic);
                            int res = mvcDemoEntities.SaveChanges();
                        }
                        statusMsg = "Update";
                    }
                }
            }
            catch (Exception ex)
            {
                statusMsg = "Error";
            }

            //return RedirectToAction("jqEmpsList");
            return(Redirect("jqEmpsList?status=" + statusMsg));
        }