예제 #1
0
        void PushViewController(CompanyLogo companyLogo)
        {
            var imageViewController = UIStoryboard.FromName("Main", NSBundle.MainBundle).InstantiateViewController("ImageViewControllerId") as ImageViewController;

            imageViewController.CompanyLogo = companyLogo;
            NavigationController.PushViewController(imageViewController, true);
        }
예제 #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            if (CompanyLogo == null)
            {
                InputCompany.CompanyLogo = "";
            }
            else
            {
                var filename = Guid.NewGuid().ToString() + Path.GetExtension(CompanyLogo.FileName);
                var file     = Path.Combine(_environment.ContentRootPath, "wwwroot", "icons", filename);
                using (var fileStream = new FileStream(file, FileMode.Create))
                {
                    await CompanyLogo.CopyToAsync(fileStream);
                }
                InputCompany.CompanyLogo = filename;
            }
            _context.Company.Add(InputCompany);
            BaseUser user = new BaseUser {
                UserName = InputCompany.CompanyId, Email = InputCompany.CompanyId, Role = "Company"
            };
            var result = await _userManager.CreateAsync(user, Password);

            await _context.SaveChangesAsync();

            BaseUser currentUser = await _userManager.FindByNameAsync(InputCompany.CompanyId);

            await _signInManager.SignInAsync(currentUser, isPersistent : false);

            return(RedirectToPage("/Index"));
        }
예제 #3
0
        public void Update(CompanyLogo CompanyLogoDAObj)
        {
            var CompanyLogoExist = NewCompanyLogoDA.GetByUsername(CompanyLogoDAObj.Username);

            CompanyLogoExist.Logo = CompanyLogoDAObj.Logo;
            CompanyLogoExist.Flag = CompanyLogoDAObj.Flag;
            NewCompanyLogoDA.Update(CompanyLogoExist);
        }
예제 #4
0
    public async Task <IActionResult> getCompanyLogo(string name, int size = 40, bool greyscale = false)
    {
        using (var httpClient = new HttpClient()) {
            if (name.Contains("."))
            {
                LogoByDomain logoByDomain = null;
                try {
                    String url = "https://logo.clearbit.com/" + name + "?size=" + size + "&greyscale=" + greyscale;

                    var response = await httpClient.GetAsync(new Uri(url)).ConfigureAwait(false);

                    response.EnsureSuccessStatusCode();
                    var stringResult = await response.Content.ReadAsStringAsync();

                    // var rawData = JsonConvert.DeserializeObject<LogoByDomain>(stringResult);
                    logoByDomain = new LogoByDomain {
                        url = url
                    };
                    return(Ok(logoByDomain));
                }
                catch (HttpRequestException httpRequestException) {
                    return(BadRequest($"Error getting data: {httpRequestException.Message}"));
                }
            }
            else
            {
                CompanyLogo companyLogo = null;
                try {
                    if (name.Contains("The Washington Post"))
                    {
                        name = name.Split("The")[1].Trim();
                    }
                    String url = "https://company.clearbit.com/v1/domains/find?name=" + name;
                    httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic",
                                                                                                                           Convert.ToBase64String(Encoding.ASCII.GetBytes(API_KEY + ":")));
                    var response = await httpClient.GetAsync(new Uri(url)).ConfigureAwait(false);

                    response.EnsureSuccessStatusCode();
                    var stringResult = await response.Content.ReadAsStringAsync();

                    var rawData = JsonConvert.DeserializeObject <CompanyLogo>(stringResult);
                    companyLogo = new CompanyLogo {
                        Name   = rawData.Name,
                        Domain = rawData.Domain,
                        Logo   = rawData.Logo
                    };
                    return(Ok(companyLogo));
                }
                catch (HttpRequestException httpRequestException) {
                    return(BadRequest($"Error getting data: {httpRequestException.Message}"));
                }
            }
        }
    }
예제 #5
0
        public async Task ChangeYearAsync(int id, int?year, string userId)
        {
            CompanyLogo logo = await _context.CompanyLogos.Where(l => l.Id == id).FirstOrDefaultAsync();

            if (logo is null)
            {
                return;
            }

            logo.Year = year;
            await _context.SaveChangesWithUserAsync(userId);
        }
예제 #6
0
        private void SizingPicture(CompanyLogo logo, Picture picture)
        {
            var m_sngLogoWidth  = picture.Width;
            var m_sngLogoHeight = picture.Height;
            //ロゴの設定
            var    ms  = new MemoryStream(logo.Logo);
            Bitmap bmp = new Bitmap(ms);

            picture.Image = bmp;
            if (picture.Image == null)
            {
                return;
            }
            picture.Visible = true;

            var   intImageHeight = picture.Image.Height;
            var   intImageWidth  = picture.Image.Width;
            float sngSavWidth    = 0;
            float sngSavHeight   = 0;

            if (intImageWidth > intImageHeight)
            {
                //横長なら横固定で縦で調整
                picture.Width  = m_sngLogoWidth;
                picture.Height = Convert.ToSingle(m_sngLogoWidth * intImageHeight / intImageWidth);

                ////縦がオーバーするなら縦横比率はそのままでイメージの大きさを調整
                if (picture.Height > m_sngLogoHeight)
                {
                    sngSavWidth  = Convert.ToSingle(picture.Width * m_sngLogoHeight / picture.Height);
                    sngSavHeight = Convert.ToSingle(picture.Height * m_sngLogoHeight / picture.Height);
                }
            }
            else
            {
                //縦長なら縦固定で横で調整
                picture.Width  = Convert.ToSingle(m_sngLogoHeight * intImageWidth / intImageHeight);
                picture.Height = m_sngLogoHeight;

                //横がオーバーするなら縦横比率はそのままでイメージの大きさを調整
                if (picture.Width > m_sngLogoWidth)
                {
                    sngSavWidth  = Convert.ToSingle(picture.Width * m_sngLogoWidth / picture.Width);
                    sngSavHeight = Convert.ToSingle(picture.Height * m_sngLogoWidth / picture.Width);
                }
            }
            if (sngSavWidth > 0)
            {
                picture.Width  = sngSavWidth;
                picture.Height = sngSavHeight;
            }
        }
예제 #7
0
        /// <summary>
        /// 获取推荐品牌公司logo路径(有线路区域)
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        protected string GetCompanyLogo(object obj)
        {
            CompanyLogo companylogo = (CompanyLogo)obj;

            if (companylogo != null)
            {
                return(Utils.GetNewImgUrl(companylogo.ImagePath, 2));
            }
            else
            {
                return(Utils.GetNewImgUrl("", 2));
            }
        }
예제 #8
0
 public async Task <CompanyLogoResult> SaveLogoAsync(string SessionKey, CompanyLogo CompanyLogo)
 {
     return(await authorizationProcessor.DoAuthorizeAsync(SessionKey, async token =>
     {
         var result = (await companyLogoProcessor.SaveAsync(new[] { CompanyLogo }, token)).First();
         return new CompanyLogoResult
         {
             ProcessResult = new ProcessResult {
                 Result = true
             },
             CompanyLogo = result
         };
     }, logger));
 }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CompanyLogo companyLogo = db.CompanyLogos.Find(id);

            if (companyLogo == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CompanyProfileID = new SelectList(db.CompanyProfiles, "CompanyProfileID", "UserID", companyLogo.CompanyProfileID);
            return(View(companyLogo));
        }
예제 #10
0
        public async Task <int> CreateAsync(int companyId, Guid guid, int?year, string userId)
        {
            var logo = new CompanyLogo
            {
                Guid      = guid,
                Year      = year,
                CompanyId = companyId
            };

            await _context.CompanyLogos.AddAsync(logo);

            await _context.SaveChangesWithUserAsync(userId);

            return(logo.Id);
        }
예제 #11
0
        public ActionResult SalesReceipt(string TNo)
        {
            string GetUserOnce = "Y";

            Model.User           UserReceipt          = new Model.User();
            CompanyLogo          CompanyLogoReceipt   = new CompanyLogo();
            List <Sales>         SalesReceipt         = new List <Sales>();
            List <CompanyDetail> CompanyDetailReceipt = new List <CompanyDetail>();
            List <PaymentDetail> PaymentDetailReceipt = new List <PaymentDetail>();

            //try
            //{
            //    ViewBag.UserId = Session["Username"].ToString();
            //}
            //catch
            //{
            //    Session["ConfirmLogin"] = "******";
            //    return RedirectToAction("Login", new { Area = "Security", Controller = "Access" });
            //}
            if (Session["FinalTransNo"] != null)
            {
                SalesReceipt         = salesBs.GetByTransactionNo(Session["FinalTransNo"].ToString()).ToList();
                CompanyDetailReceipt = companyDetailBs.ListAll().ToList();
                PaymentDetailReceipt = paymentDetailBs.GetByPaymentNo(Session["FinalTransNo"].ToString()).ToList();
                CompanyLogoReceipt   = companyLogoBs.GetCompanyLogo();

                if (GetUserOnce == "Y")
                {
                    foreach (var item in SalesReceipt)
                    {
                        UserReceipt = userBs.GetByUsername(item.CreatedBy);
                    }
                    GetUserOnce = "N";
                }

                receipt.SalesReceipt         = SalesReceipt;
                receipt.CompanyDetailReceipt = CompanyDetailReceipt;
                receipt.UserReceipt          = UserReceipt;
                receipt.PaymentDetailReceipt = PaymentDetailReceipt;
                receipt.CompanyLogoReceipt   = CompanyLogoReceipt;
                //receipt.CustomerReceipt = CustomerReceipt;
                return(View(receipt));
            }
            return(View());
        }
        public ActionResult Create([Bind(Include = "CompanyProfileID,PhotoName,PhotoContent")] CompanyLogo companyLogo, HttpPostedFileBase upload)
        {
            if (ModelState.IsValid)
            {
                if (upload != null && upload.ContentLength > 0)
                {
                    companyLogo.PhotoName = System.IO.Path.GetFileName(upload.FileName);
                    byte[] data = new byte[upload.ContentLength];
                    upload.InputStream.Read(data, 0, upload.ContentLength);

                    companyLogo.PhotoContent = data;
                }
                db.CompanyLogos.Add(companyLogo);
                db.SaveChanges();
                return(RedirectToAction("Index", "CompanyDashboard"));
            }
            return(View(companyLogo));
        }
        public ActionResult Edit([Bind(Include = "CompanyProfileID,PhotoName,PhotoContent")] CompanyLogo companyLogo, HttpPostedFileBase upload)
        {
            if (ModelState.IsValid)
            {
                if (upload != null && upload.ContentLength > 0)
                {
                    companyLogo.PhotoName = System.IO.Path.GetFileName(upload.FileName);
                    byte[] data = new byte[upload.ContentLength];
                    upload.InputStream.Read(data, 0, upload.ContentLength);

                    companyLogo.PhotoContent = data;
                }
                db.Entry(companyLogo).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", "CompanyDashboard"));
            }
            ViewBag.CompanyProfileID = new SelectList(db.CompanyProfiles, "CompanyProfileID", "UserID", companyLogo.CompanyProfileID);
            return(View(companyLogo));
        }
예제 #14
0
        public Task <CompanyLogo> SaveAsync(CompanyLogo CompanyLogo, CancellationToken token = default(CancellationToken))
        {
            #region merge query
            var query = @"
MERGE INTO CompanyLogo AS target 
USING ( 
    SELECT 
        @CompanyId [CompanyId]
       ,@LogoType  [LogoType]
) AS source 
ON  ( 
        target.CompanyId = source.CompanyId 
    AND target.LogoType  = source.LogoType
    )
WHEN MATCHED THEN 
    UPDATE SET 
        Logo = @Logo
        ,UpdateBy = @UpdateBy
        ,UpdateAt = @UpdateAt
WHEN NOT MATCHED THEN 
    INSERT (
         CompanyId
        ,Logo
        ,CreateBy
        ,CreateAt
        ,UpdateBy
        ,UpdateAt
        ,LogoType
        )
    VALUES
    (@CompanyId
    ,@Logo
    ,@CreateBy
    ,GETDATE()
    ,@UpdateBy
    ,GETDATE()
    ,@LogoType)
OUTPUT inserted.*; ";
            #endregion
            return(dbHelper.ExecuteAsync <CompanyLogo>(query, CompanyLogo, token));
        }
예제 #15
0
        public async Task Save(ZipArchive iArchive)
        {
            if (CompanyLogo != null)
            {
                ZipArchiveEntry pZAELogo = iArchive.CreateEntry("logo.jpg", CompressionLevel.Optimal);
                using (Stream pStmLogo = pZAELogo.Open())
                {
                    await CompanyLogo.ToStreamMaxJPEGAsync(pStmLogo);

                    await pStmLogo.FlushAsync();
                }
            }

            if (BackgroundImage != null)
            {
                ZipArchiveEntry pZAEBackground = iArchive.CreateEntry("background.jpg", CompressionLevel.Optimal);
                using (Stream pStmBackgroundImage = pZAEBackground.Open())
                {
                    await BackgroundImage.ToStreamMaxJPEGAsync(pStmBackgroundImage);

                    await pStmBackgroundImage.FlushAsync();
                }
            }
        }
예제 #16
0
        public async Task DeleteAsync(int id, string userId)
        {
            CompanyLogo logo = await _context.CompanyLogos.Where(l => l.Id == id).FirstOrDefaultAsync();

            if (logo is null)
            {
                return;
            }

            _context.CompanyLogos.Remove(logo);
            await _context.SaveChangesWithUserAsync(userId);

            if (File.Exists(Path.Combine(_webRootPath, "assets/logos", logo.Guid + ".svg")))
            {
                File.Delete(Path.Combine(_webRootPath, "assets/logos", logo.Guid + ".svg"));
            }

            if (File.Exists(Path.Combine(_webRootPath, "assets/logos/webp/1x", logo.Guid + ".webp")))
            {
                File.Delete(Path.Combine(_webRootPath, "assets/logos/webp/1x", logo.Guid + ".webp"));
            }

            if (File.Exists(Path.Combine(_webRootPath, "assets/logos/webp/2x", logo.Guid + ".webp")))
            {
                File.Delete(Path.Combine(_webRootPath, "assets/logos/webp/2x", logo.Guid + ".webp"));
            }

            if (File.Exists(Path.Combine(_webRootPath, "assets/logos/webp/3x", logo.Guid + ".webp")))
            {
                File.Delete(Path.Combine(_webRootPath, "assets/logos/webp/3x", logo.Guid + ".webp"));
            }

            if (File.Exists(Path.Combine(_webRootPath, "assets/logos/png/1x", logo.Guid + ".png")))
            {
                File.Delete(Path.Combine(_webRootPath, "assets/logos/png/1x", logo.Guid + ".png"));
            }

            if (File.Exists(Path.Combine(_webRootPath, "assets/logos/png/2x", logo.Guid + ".png")))
            {
                File.Delete(Path.Combine(_webRootPath, "assets/logos/png/2x", logo.Guid + ".png"));
            }

            if (File.Exists(Path.Combine(_webRootPath, "assets/logos/png/3x", logo.Guid + ".png")))
            {
                File.Delete(Path.Combine(_webRootPath, "assets/logos/png/3x", logo.Guid + ".png"));
            }

            if (File.Exists(Path.Combine(_webRootPath, "assets/logos/thumbs/webp/1x", logo.Guid + ".webp")))
            {
                File.Delete(Path.Combine(_webRootPath, "assets/logos/thumbs/webp/1x", logo.Guid + ".webp"));
            }

            if (File.Exists(Path.Combine(_webRootPath, "assets/logos/thumbs/webp/2x", logo.Guid + ".webp")))
            {
                File.Delete(Path.Combine(_webRootPath, "assets/logos/thumbs/webp/2x", logo.Guid + ".webp"));
            }

            if (File.Exists(Path.Combine(_webRootPath, "assets/logos/thumbs/webp/3x", logo.Guid + ".webp")))
            {
                File.Delete(Path.Combine(_webRootPath, "assets/logos/thumbs/webp/3x", logo.Guid + ".webp"));
            }

            if (File.Exists(Path.Combine(_webRootPath, "assets/logos/thumbs/png/1x", logo.Guid + ".png")))
            {
                File.Delete(Path.Combine(_webRootPath, "assets/logos/thumbs/png/1x", logo.Guid + ".png"));
            }

            if (File.Exists(Path.Combine(_webRootPath, "assets/logos/thumbs/png/2x", logo.Guid + ".png")))
            {
                File.Delete(Path.Combine(_webRootPath, "assets/logos/thumbs/png/2x", logo.Guid + ".png"));
            }

            if (File.Exists(Path.Combine(_webRootPath, "assets/logos/thumbs/png/3x", logo.Guid + ".png")))
            {
                File.Delete(Path.Combine(_webRootPath, "assets/logos/thumbs/png/3x", logo.Guid + ".png"));
            }
        }
예제 #17
0
 public void Update(CompanyLogo CompanyLogoDAObj)
 {
     context.Entry(CompanyLogoDAObj).State = EntityState.Modified;
     context.SaveChanges();
 }
예제 #18
0
 public void Insert(CompanyLogo CompanyLogoDAObj)
 {
     NewCompanyLogoDA.Insert(CompanyLogoDAObj);
 }
예제 #19
0
        private void PrepareLogos()
        {
            if (SaveLogos.Any())
            {
                SaveLogos.Clear();
            }
            if (DeleteLogos.Any())
            {
                DeleteLogos.Clear();
            }

            foreach (int logoType in Enum.GetValues(typeof(CompanyLogoType)))
            {
                var pictureBox = new PictureBox();
                if (logoType == (int)CompanyLogoType.Logo)
                {
                    pictureBox = picLogo;
                }
                else if (logoType == (int)CompanyLogoType.SquareSeal)
                {
                    pictureBox = picSquareSeal;
                }
                else if (logoType == (int)CompanyLogoType.RoundSeal)
                {
                    pictureBox = picRoundSeal;
                }

                if (CompanyLogos != null &&
                    CompanyLogos.Any(x => x.LogoType == logoType) &&
                    pictureBox.Image == null)
                {
                    //削除対象
                    var deleteLogo = CompanyLogos.FirstOrDefault(x => x.LogoType == logoType);
                    DeleteLogos.Add(deleteLogo);
                    continue;
                }

                var hasLogo     = true;
                var companyLogo = new CompanyLogo();
                companyLogo.Logo = new byte[0];
                var filePath = pictureBox.ImageLocation;

                if (!string.IsNullOrEmpty(filePath))
                {
                    companyLogo.Logo     = ChangeImageToBinary(filePath);
                    companyLogo.UpdateAt = DateTime.Now;
                }
                else if (pictureBox.Image != null)
                {
                    var currentLogo = CompanyLogos.Where(x => x.LogoType == logoType).FirstOrDefault();
                    companyLogo.Logo     = currentLogo.Logo;
                    companyLogo.UpdateAt = currentLogo.UpdateAt;
                }
                else
                {
                    hasLogo = false;
                }

                if (hasLogo)
                {
                    companyLogo.CompanyId = Company.Id;
                    companyLogo.CreateBy  = Login.UserId;
                    companyLogo.UpdateBy  = Login.UserId;
                    companyLogo.LogoType  = logoType;
                    SaveLogos.Add(companyLogo);
                }
            }
        }
예제 #20
0
 public void Insert(CompanyLogo CompanyLogoDAObj)
 {
     context.CompanyLogos.Add(CompanyLogoDAObj);
     context.SaveChanges();
 }
예제 #21
0
    private Company SaveCompanyData()
    {
        if (string.IsNullOrEmpty(txtCompanyName.Text))
        {
            string message = ResourceManager.GetString("messageComNameMustNotBeEmpty");
            string script = "<script type=\"text/javascript\">";
            script += " alert(\"" + message + "\")";
            script += " </script>";

            if (!ClientScript.IsClientScriptBlockRegistered("redirectUser"))
                ClientScript.RegisterStartupScript(this.GetType(), "redirectUser", script);
            return null;
        }
        bool isNew = false;
        //Save Company
        Company currentCompany = new Company();
        if (SessionManager.CurrentCompany != null)
        {
            currentCompany = SessionManager.CurrentCompany;
        }
        else
        {
            isNew = true;
            currentCompany = new Company();
        }

        //header
        currentCompany.CompanyName = txtCompanyName.Text.Trim();
        currentCompany.WebLink = txtWebsite.Text.Trim();
        if (!string.IsNullOrEmpty(ddlNeosResp.SelectedValue))
            currentCompany.Responsible = ddlNeosResp.SelectedValue;
        else
            currentCompany.Responsible = null;
        //tab contact info
        currentCompany.Address = txtCompanyAddress.Text.Trim();
        currentCompany.ZipCode = txtCompanyZipCode.Text.Trim();
        currentCompany.City = txtCompanyCity.Text.Trim();
        currentCompany.Email = txtCompanyEmail.Text.Trim();
        currentCompany.TelephoneZone = txtCompanyPhoneArea.Text.Trim();
        currentCompany.Group = txtCompanyGroup.Text.Trim();
        currentCompany.Telephone = txtCompanyPhone.Text.Trim();
        currentCompany.Fax = txtCompanyFax.Text.Trim();
        currentCompany.NVAT = txtCompanyVAT.Text.Trim();
        if (!string.IsNullOrEmpty(ddlCompanyLegalForm.SelectedValue))
            currentCompany.LegalForm = ddlCompanyLegalForm.SelectedValue;
        else
            currentCompany.LegalForm = null;

        if (!string.IsNullOrEmpty(ddlParamClientStatus.SelectedValue))
            currentCompany.Status = int.Parse(ddlParamClientStatus.SelectedValue);
        else
            currentCompany.Status = null;

        //tab client info
        currentCompany.Activity = txtActivity.Text.Trim();
        currentCompany.Remark = txtRemark.Text.Trim();
        currentCompany.CreatedDate = datCreatedDate.SelectedDate;
        if (!string.IsNullOrEmpty(ddlUnit.SelectedValue))
            currentCompany.UnitCode = ddlUnit.SelectedValue;
        else
            currentCompany.UnitCode = null;
        currentCompany.SponsorArea = chkSponsor.Checked;

        CompanyRepository repo = new CompanyRepository();
        if (isNew)
        {
            currentCompany.CreatedDate = DateTime.Now;
            repo.Insert(currentCompany);
        }
        else
            repo.Update(currentCompany);
        //insert company logo
        if (chkRemoveLogo.Checked)
        {
            CompanyLogoRepository companyLogoRepo = new CompanyLogoRepository();
            companyLogoRepo.Delete(new CompanyLogo(currentCompany.CompanyID));
        }
        else
        {
            if (fileCompanyLogo.HasFile)
            {
                string fileName = string.Format("{0}_{1}", currentCompany.CompanyID, System.IO.Path.GetFileName(fileCompanyLogo.PostedFile.FileName.ToString()));//fileCompanyLogo.PostedFile.FileName
                CompanyLogoRepository companyLogoRepo = new CompanyLogoRepository();
                CompanyLogo logo = companyLogoRepo.FindOne(new CompanyLogo(currentCompany.CompanyID));
                if (logo != null)
                {
                    logo.LogoPath = WebConfig.UserImagePath + fileName;
                    companyLogoRepo.Update(logo);
                }
                else
                {
                    logo = new CompanyLogo();
                    logo.CompanyID = currentCompany.CompanyID;
                    logo.LogoPath = WebConfig.UserImagePath + fileName;
                    companyLogoRepo.Insert(logo);
                }
                fileCompanyLogo.SaveAs(WebConfig.UserImages + fileName);
            }
        }
        currentCompany = repo.FindOne(currentCompany);
        SessionManager.CurrentCompany = currentCompany;
        SaveLastViewCompaniesToCookie(currentCompany);
        if (isNew)
        {
            string script1 = "<script type='text/javascript'>";
            script1 += "onSaveOrLoadCompanyProfilePage();";
            script1 += "</script>";
            if (!ClientScript.IsClientScriptBlockRegistered("onSaveOrLoadCompanyProfilePage"))
                ClientScript.RegisterStartupScript(this.GetType(), "onSaveOrLoadCompanyProfilePage", script1);
        }

        //Save company contact
        SaveCompanyContact(currentCompany);

        return currentCompany;
    }