//[HttpGet]
        //public HttpResponseMessage Get(int id, int convertType = 0) // convertType = 0 : cm / 1 : inch
        //{
        //    try
        //    {
        //        PatternBO objPattern = new PatternBO();
        //        objPattern.ID = id;
        //        objPattern.GetObject();

        //        WebServicePattern objWebServicePattern = new WebServicePattern(true);
        //        string filePath = objWebServicePattern.GeneratePDF(objPattern, false, convertType.ToString(), GetCompressionImagePhysicalPath(objPattern));

        //        var stream = new MemoryStream();

        //        using (FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.Read))
        //        {
        //            byte[] bytes = new byte[file.Length];
        //            file.Read(bytes, 0, (int)file.Length);
        //            stream.Write(bytes, 0, (int)file.Length);
        //        }

        //        var result = new HttpResponseMessage(HttpStatusCode.OK)
        //        {
        //            Content = new ByteArrayContent(stream.GetBuffer())
        //        };
        //        result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
        //        {
        //            FileName = objPattern.Number + ".pdf"
        //        };
        //        result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");

        //        return result;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw;
        //    }
        //}

        private string TemplateImagePath(List <PatternTemplateImageBO> lstOtherImages, bool isHero = false)
        {
            string imageFilePath = string.Empty;

            if (lstOtherImages.Any() && lstOtherImages.First().ID > 0)
            {
                PatternTemplateImageBO objPTI = isHero ? lstOtherImages.Last() : lstOtherImages.First();
                imageFilePath = File.Exists(IndicoConfiguration.AppConfiguration.PathToDataFolder + "/PatternTemplates/" + objPTI.Pattern + "/" + objPTI.Filename + objPTI.Extension) ?
                                IndicoConfiguration.AppConfiguration.SiteHostAddress + IndicoConfiguration.AppConfiguration.DataFolderName + "/PatternTemplates/" + objPTI.Pattern + "/" + objPTI.Filename + objPTI.Extension :
                                string.Empty; //IndicoConfiguration.AppConfiguration.DataFolderName + "/noimage-png-350px-350px.png";
            }
            else
            {
                imageFilePath = string.Empty; // IndicoConfiguration.AppConfiguration.DataFolderName + "/noimage-png-350px-350px.png";
            }
            return(imageFilePath.ToLower());
        }
예제 #2
0
        public string GeneratePDF(PatternBO objPattern, bool isWebService, string convertType, string compressionImagePath = "", bool isAllSizes = false)
        {
            string createpdfPath = string.Empty;
            string imagepath     = string.Empty;

            try
            {
                if (isWebService)
                {
                    imagepath = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServiceImages/" + objPattern.Number.ToString() + "/" + objPattern.Number + ".jpg";
                }
                else
                {
                    List <PatternTemplateImageBO> listPTIs = objPattern.PatternTemplateImagesWhereThisIsPattern.Where(o => o.IsHero).ToList();

                    if (listPTIs.Any())
                    {
                        PatternTemplateImageBO objPatternTemplateImage = listPTIs.Last();
                        imagepath = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/PatternTemplates/" + objPattern.ID.ToString() + "/" + objPatternTemplateImage.Filename + objPatternTemplateImage.Extension;
                    }
                }

                imagepath = (File.Exists(imagepath)) ? imagepath : IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServiceImages/gspec-missing.jpg";

                createpdfPath = (isWebService) ? IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServicePDF/" + objPattern.Number.ToString() + ".pdf" : IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "\\temp\\" + "GS_" + objPattern.Number.ToString() + ".pdf";;

                //Document document = new Document();
                using (var document = new Document())
                    using (var writer = PdfWriter.GetInstance(document, new FileStream(createpdfPath, FileMode.Create)))
                    {
                        document.AddKeywords("paper airplanes");

                        float marginBottom = 12;
                        float lineHeight   = 14;
                        float pageMargin   = 20;
                        float pageHeight   = iTextSharp.text.PageSize.A4.Width;
                        float pageWidth    = iTextSharp.text.PageSize.A4.Height;

                        document.SetPageSize(new iTextSharp.text.Rectangle(pageWidth, pageHeight));
                        document.SetMargins(0, 0, 0, 0);

                        // Open the document for writing content
                        document.Open();
                        // Get the top layer and write some text
                        contentByte = writer.DirectContent;

                        contentByte.BeginText();
                        string content = string.Empty;

                        // Header
                        contentByte.SetFontAndSize(this.PDFFont, 24);
                        content = "GARMENT SPECIFICATION";
                        contentByte.ShowTextAligned(PdfContentByte.ALIGN_LEFT, content, pageMargin, (pageHeight - pageMargin - lineHeight), 0);

                        // Title
                        contentByte.SetFontAndSize(this.PDFFont, 9);
                        content = "Pattern " + objPattern.Number + " - " + objPattern.NickName;
                        contentByte.ShowTextAligned(PdfContentByte.ALIGN_LEFT, content, pageMargin, (pageHeight - pageMargin - lineHeight - marginBottom), 0);

                        content = objPattern.ModifiedDate.ToLongDateString();
                        contentByte.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, content, (pageWidth - pageMargin), (pageHeight - pageMargin - lineHeight - marginBottom), 0);

                        // Footer
                        contentByte.SetFontAndSize(this.PDFFont, 8);
                        content = "© Copyright " + DateTime.Now.Year.ToString() + ", All rights reserved.";
                        contentByte.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, content, (pageWidth - pageMargin), pageMargin, 0);

                        contentByte.EndText();

                        // Top Line
                        contentByte.SetLineWidth(0.5f);
                        contentByte.SetColorStroke(BaseColor.BLACK);
                        contentByte.MoveTo(pageMargin, (pageHeight - pageMargin - lineHeight - marginBottom - 4));
                        contentByte.LineTo((pageWidth - pageMargin), (pageHeight - pageMargin - lineHeight - marginBottom - 4));
                        contentByte.Stroke();

                        // Bottom Line
                        contentByte.SetLineWidth(0.5f);
                        contentByte.SetColorStroke(BaseColor.BLACK);
                        contentByte.MoveTo(pageMargin, pageMargin + marginBottom);
                        contentByte.LineTo((pageWidth - pageMargin), pageMargin + marginBottom);
                        contentByte.Stroke();

                        if (string.IsNullOrWhiteSpace(compressionImagePath) && objPattern.PatternCompressionImage != 0 && objPattern.objPatternCompressionImage != null)
                        {
                            var fileName  = objPattern.objPatternCompressionImage.Filename;
                            var extension = objPattern.objPatternCompressionImage.Extension;

                            var physicalFolderPath = IndicoConfiguration.AppConfiguration.PathToDataFolder + "\\PatternCompressionImages\\" + objPattern.ID + "\\";

                            if (File.Exists(physicalFolderPath + fileName + extension))
                            {
                                var dataFolderPath = Path.Combine(IndicoConfiguration.AppConfiguration.PathToProjectFolder, IndicoConfiguration.AppConfiguration.DataFolderName);
                                compressionImagePath = Path.Combine(dataFolderPath, "PatternCompressionImages", objPattern.ID.ToString(), fileName + extension);
                            }
                        }
                        if ((objPattern.PatternCompressionImage ?? 0) > 0 && !string.IsNullOrWhiteSpace(compressionImagePath))
                        {
                            var specImage = iTextSharp.text.Image.GetInstance(compressionImagePath);
                            specImage.ScaleToFit(pageWidth - (pageMargin * 2), 230f);
                            specImage.SetAbsolutePosition(((pageWidth - specImage.ScaledWidth) / 2), (pageHeight - (pageMargin * 2) - lineHeight - marginBottom - specImage.ScaledHeight));
                            document.Add(specImage);
                        }
                        else
                        {
                            // Draw Hero Image
                            var heroImage = iTextSharp.text.Image.GetInstance(imagepath);
                            heroImage.ScaleToFit(pageWidth - (pageMargin * 2), 270f);
                            heroImage.SetAbsolutePosition(((pageWidth - heroImage.ScaledWidth) / 2), (pageHeight - (pageMargin * 2) - lineHeight - marginBottom - heroImage.ScaledHeight));
                            document.Add(heroImage);

                            var htmlText   = CreateHtml(objPattern, convertType, isAllSizes);
                            var htmlWorker = new HTMLWorker(document);
                            htmlWorker.Parse(new StringReader(htmlText));
                        }

                        document.Close();
                        writer.Close();
                    }
                // PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(createpdfPath, FileMode.Create));
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(createpdfPath);
        }
        // GET api/PatternDetails
        public PatternDetailModel Get(string number)
        {
            PatternDetailModel objModel = new PatternDetailModel();

            try
            {
                PatternBO objPattern = new PatternBO();
                objPattern.IsActiveWS = true;
                objPattern.IsActive   = true;
                objPattern.Number     = number;
                objPattern            = objPattern.SearchObjects().SingleOrDefault();

                if (objPattern != null && objPattern.Creator > 0)
                {
                    objModel.Pattern     = objPattern.ID;
                    objModel.Number      = objPattern.Number;
                    objModel.Remarks     = objPattern.Remarks;
                    objModel.Gender      = objPattern.objGender.Name;
                    objModel.Description = objPattern.Description;

                    if ((objPattern.PatternCompressionImage ?? 0) > 0)
                    {
                        objModel.GarmentSpecChartImagePath = PopulatePatternCompressionImage(objPattern);
                    }
                    else
                    {
                        List <MeasurementLocation> lstMLocations = new List <MeasurementLocation>();

                        SizeChartBO objSChart = new SizeChartBO();
                        objSChart.Pattern = objPattern.ID;
                        List <SizeChartBO> lstSizeCharts = objSChart.SearchObjects().Where(o => o.objMeasurementLocation.IsSend == true && o.Val > 0).ToList();

                        List <MeasurementLocationBO> lstLocations = lstSizeCharts.Select(m => m.objMeasurementLocation).Distinct().ToList();

                        IEnumerable <IGrouping <string, MeasurementLocationBO> > lst = lstLocations.GroupBy(m => m.Name);

                        foreach (IGrouping <string, MeasurementLocationBO> objML in lst)
                        {
                            MeasurementLocation location = new MeasurementLocation();
                            location.Name = objML.Key;

                            List <SizeChartBO> lstMSizes = lstSizeCharts.Where(m => m.MeasurementLocation == objML.ElementAtOrDefault(0).ID).ToList();

                            foreach (SizeChartBO objSize in lstMSizes)
                            {
                                location.ListSizes.Add(new Size {
                                    name = objSize.objSize.SizeName, Value = objSize.Val.ToString()
                                });
                            }

                            lstMLocations.Add(location);
                        }

                        objModel.ListMeasurementLocations = lstMLocations;
                    }

                    //Populate Images
                    PatternTemplateImageBO objOtherImage = new PatternTemplateImageBO();
                    objOtherImage.Pattern = objPattern.ID;
                    List <PatternTemplateImageBO> lstOtherImages = objOtherImage.SearchObjects();

                    List <PatternTemplateImageBO> lstOtherImages1 = lstOtherImages.Where(o => o.ImageOrder == 1).ToList();
                    List <PatternTemplateImageBO> lstOtherImages2 = lstOtherImages.Where(o => o.ImageOrder == 2).ToList();
                    List <PatternTemplateImageBO> lstOtherImages3 = lstOtherImages.Where(o => o.ImageOrder == 3).ToList();

                    objModel.GarmentImagePath1    = TemplateImagePath(lstOtherImages1);
                    objModel.GarmentImagePath2    = TemplateImagePath(lstOtherImages2);
                    objModel.GarmentImagePath3    = TemplateImagePath(lstOtherImages3);
                    objModel.GarmentSpecImagePath = TemplateImagePath(lstOtherImages.Where(o => o.IsHero).ToList(), true);
                }
            }
            catch (Exception ex)
            {
                objModel.Ex = ex;
            }

            return(objModel);
        }
예제 #4
0
        protected void RadGridCostSheet_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                var item = e.Item as GridDataItem;

                if (item.ItemIndex > -1 && item.DataItem is CostSheetDetailsView)
                {
                    CostSheetDetailsView objCostSheet = (CostSheetDetailsView)item.DataItem;

                    Label lblCostSheet = (Label)item.FindControl("lblCostSheet");
                    lblCostSheet.Text = (objCostSheet.CostSheet).ToString();

                    TextBox txtQuotedCIF = (TextBox)item.FindControl("txtQuotedCIF");
                    txtQuotedCIF.Text = (objCostSheet.QuotedCIF).ToString("0.00");

                    TextBox txtFOBCost = (TextBox)item.FindControl("txtFOBCost");
                    txtFOBCost.Text = (objCostSheet.QuotedFOBCost).ToString("0.00");

                    TextBox txtExchangeRate = (TextBox)item.FindControl("txtExchangeRate");
                    txtExchangeRate.Text = (objCostSheet.ExchangeRate).ToString("0.00");

                    TextBox txtDutyRate = (TextBox)item.FindControl("txtDutyRate");
                    txtDutyRate.Text = (objCostSheet.DutyRate).ToString("0.00");

                    TextBox txtSMVRate = (TextBox)item.FindControl("txtSMVRate");
                    txtSMVRate.Text = (objCostSheet.SMVRate).ToString("0.000");

                    HyperLink linkEdit = (HyperLink)item.FindControl("linkEdit");
                    linkEdit.NavigateUrl = "/AddEditFactoryCostSheet.aspx?id=" + objCostSheet.CostSheet.ToString();

                    LinkButton btnPrintJkCostSheet = (LinkButton)item.FindControl("btnPrintJkCostSheet");
                    btnPrintJkCostSheet.Attributes.Add("id", objCostSheet.CostSheet.ToString());

                    LinkButton btnIndimanCostSheet = (LinkButton)item.FindControl("btnIndimanCostSheet");
                    btnIndimanCostSheet.Attributes.Add("id", objCostSheet.CostSheet.ToString());
                    btnIndimanCostSheet.Visible = (this.LoggedUserRoleName == UserRole.IndimanAdministrator) ? true : false;

                    var linkDelete = (HyperLink)item.FindControl("linkDelete");
                    var hasProduct = ValidateField2(0, "VisualLayout", "FabricCode", objCostSheet.FabricID.ToString(), "Pattern", objCostSheet.PatternID.ToString()) < 1;
                    if (hasProduct)
                    {
                        linkDelete.Visible = false;
                    }


                    linkDelete.Attributes.Add("qid", objCostSheet.CostSheet.ToString());

                    //VisualLayoutBO objVL = new VisualLayoutBO();
                    //objVL.Pattern = objCostSheet.patt

                    HyperLink linkClone = (HyperLink)item.FindControl("linkClone");
                    linkClone.NavigateUrl = "AddEditFactoryCostSheet.aspx?cloneid=" + objCostSheet.CostSheet.ToString();

                    LinkButton btnShowToIndico = (LinkButton)item.FindControl("btnShowToIndico");
                    btnShowToIndico.Attributes.Add("id", objCostSheet.CostSheet.ToString());
                    btnShowToIndico.Text = ((bool)objCostSheet.ShowToIndico) ? "Hide from Indico" : "Show to Indico";

                    btnShowToIndico.Visible = !(this.LoggedUserRoleName == UserRole.FactoryAdministrator || this.LoggedUserRoleName == UserRole.FactoryCoordinator);

                    /*  // Column show to indico
                     * Label lblShowToIndico = (Label)item.FindControl("lblShowToIndico");
                     * lblShowToIndico.Attributes.Add("id", objCostSheet.CostSheet.ToString());
                     * if((bool)objCostSheet.ShowToIndico)
                     * {
                     *    lblShowToIndico.Text = "Yes";
                     * ;                   }
                     * else if ((bool)objCostSheet.ShowToIndico == false)
                     * {
                     *    lblShowToIndico.Text = "No";
                     * } */

                    Label lblShowToIndico = (Label)item.FindControl("lblShowToIndico");
                    if ((bool)objCostSheet.ShowToIndico)
                    {
                        lblShowToIndico.Text = @"<span class='badge badge-success '\>&nbsp;</span>";
                    }
                    else if ((bool)objCostSheet.ShowToIndico == false)
                    {
                        lblShowToIndico.Text = @"<span class='badge badge-important'\>&nbsp;</span>";
                    }

                    //Displaying pattern images
                    string imagePath_1    = IndicoConfiguration.AppConfiguration.DataFolderName + "/noimage-png-350px-350px.png";
                    string imagePath_2    = IndicoConfiguration.AppConfiguration.DataFolderName + "/noimage-png-350px-350px.png";
                    string imagePath_3    = IndicoConfiguration.AppConfiguration.DataFolderName + "/noimage-png-350px-350px.png";
                    string imagePath_hero = IndicoConfiguration.AppConfiguration.DataFolderName + "/noimage-png-350px-350px.png";
                    int    count          = 0;

                    int patternID = objCostSheet.PatternID;
                    PatternTemplateImageBO objPatternTemplateImage = new PatternTemplateImageBO();
                    objPatternTemplateImage.Pattern = patternID;

                    List <PatternTemplateImageBO> lstPatternTemplateImageNotHero = objPatternTemplateImage.SearchObjects().Where(m => m.IsHero == false).ToList();
                    count = lstPatternTemplateImageNotHero.Count;

                    foreach (PatternTemplateImageBO patImage in lstPatternTemplateImageNotHero)
                    {
                        if (patImage.ImageOrder == 1)
                        {
                            string imagePath1 = IndicoConfiguration.AppConfiguration.DataFolderName + "/PatternTemplates/" + "/" + patImage.Pattern + "/" + patImage.Filename + lstPatternTemplateImageNotHero[0].Extension;

                            if (File.Exists(Server.MapPath(imagePath1)))
                            {
                                imagePath_1 = imagePath1;
                            }

                            continue;
                        }

                        if (patImage.ImageOrder == 2)
                        {
                            string imagepPath2 = IndicoConfiguration.AppConfiguration.DataFolderName + "/PatternTemplates/" + "/" + patImage.Pattern + "/" + patImage.Filename + lstPatternTemplateImageNotHero[0].Extension;

                            if (File.Exists(Server.MapPath(imagepPath2)))
                            {
                                imagePath_2 = imagepPath2;
                            }

                            continue;
                        }

                        if (patImage.ImageOrder == 3)
                        {
                            string imagePath3 = IndicoConfiguration.AppConfiguration.DataFolderName + "/PatternTemplates/" + "/" + patImage.Pattern + "/" + patImage.Filename + lstPatternTemplateImageNotHero[0].Extension;

                            if (File.Exists(Server.MapPath(imagePath3)))
                            {
                                imagePath_3 = imagePath3;
                            }

                            continue;
                        }
                    }

                    HtmlAnchor         ancTemplateImage = (HtmlAnchor)item.FindControl("ancTemplateImage");
                    HtmlGenericControl iimageView       = (HtmlGenericControl)item.FindControl("iimageView");

                    List <PatternTemplateImageBO> lstPatternTemplateImageHero = objPatternTemplateImage.SearchObjects().Where(m => m.IsHero == true).ToList();

                    if (lstPatternTemplateImageHero.Count > 0)
                    {
                        string imagePathHero = IndicoConfiguration.AppConfiguration.DataFolderName + "/PatternTemplates/" + patternID.ToString() + "/" + lstPatternTemplateImageHero.First().Filename + lstPatternTemplateImageHero.First().Extension;
                        if (File.Exists(Server.MapPath(imagePathHero)))
                        {
                            imagePath_hero = imagePathHero;
                        }

                        if (File.Exists(Server.MapPath(imagePathHero)))
                        {
                            ancTemplateImage.Attributes.Add("class", "btn-link preview");
                            iimageView.Attributes.Add("class", "icon-eye-open");

                            System.Drawing.Image VLOrigImage = System.Drawing.Image.FromFile(Server.MapPath(imagePathHero));
                            SizeF origImageSize = VLOrigImage.PhysicalDimension;
                            VLOrigImage.Dispose();

                            System.Drawing.Image VLImage_1 = System.Drawing.Image.FromFile(Server.MapPath(imagePath_1));
                            SizeF image_1Size = VLImage_1.PhysicalDimension;
                            VLImage_1.Dispose();

                            System.Drawing.Image VLImage_2 = System.Drawing.Image.FromFile(Server.MapPath(imagePath_2));
                            SizeF image_2Size = VLImage_2.PhysicalDimension;
                            VLImage_2.Dispose();

                            System.Drawing.Image VLImage_3 = System.Drawing.Image.FromFile(Server.MapPath(imagePath_3));
                            SizeF image_3Size = VLImage_3.PhysicalDimension;
                            VLImage_3.Dispose();

                            List <float> lstVLImageDimensions = (new ImageProcess()).GetResizedImageDimension(Convert.ToInt32(Math.Abs(origImageSize.Width)), Convert.ToInt32(Math.Abs(origImageSize.Height)), 380, 380);
                            List <float> lstVLImageDimensionsForPhotographyImage_1 = (new ImageProcess()).GetResizedImageDimension(Convert.ToInt32(Math.Abs(image_1Size.Width)), Convert.ToInt32(Math.Abs(image_1Size.Height)), 128, 128);
                            List <float> lstVLImageDimensionsForPhotographyImage_2 = (new ImageProcess()).GetResizedImageDimension(Convert.ToInt32(Math.Abs(image_2Size.Width)), Convert.ToInt32(Math.Abs(image_2Size.Height)), 128, 128);
                            List <float> lstVLImageDimensionsForPhotographyImage_3 = (new ImageProcess()).GetResizedImageDimension(Convert.ToInt32(Math.Abs(image_3Size.Width)), Convert.ToInt32(Math.Abs(image_3Size.Height)), 128, 128);

                            string htmlPreview = "<div id='dvPatternTemplate' class=\"ihero\"  target='_blank'>" +
                                                 "<div class=\"ihero-image\">" +
                                                 "<img src=\"" + imagePathHero + "\" alt=\"Hero Image\" height=\"" + lstVLImageDimensions[0].ToString() + "\" width=\"" + lstVLImageDimensions[1].ToString() + "\" />" +
                                                 "</div>" +
                                                 "<div class=\"ihero-details\">" +
                                                 "<img src=\"" + imagePath_1 + "\" alt=\"Thumbnail\" height=\"" + lstVLImageDimensionsForPhotographyImage_1[0].ToString() + "\" width=\"" + lstVLImageDimensionsForPhotographyImage_1[1].ToString() + "\" />" +
                                                 "<img src=\"" + imagePath_2 + "\" alt=\"Thumbnail\" height=\"" + lstVLImageDimensionsForPhotographyImage_2[0].ToString() + "\" width=\"" + lstVLImageDimensionsForPhotographyImage_2[1].ToString() + "\" />" +
                                                 "<img src=\"" + imagePath_3 + "\" alt=\"Thumbnail\" height=\"" + lstVLImageDimensionsForPhotographyImage_3[0].ToString() + "\" width=\"" + lstVLImageDimensionsForPhotographyImage_3[1].ToString() + "\" />" +
                                                 "</div>" +
                                                 "</div>";

                            HtmlContainerControl previewTemplate = (HtmlContainerControl)item.FindControl("previewTemplate");
                            previewTemplate.InnerHtml = htmlPreview;

                            HtmlAnchor ancFullImage = (HtmlAnchor)item.FindControl("ancFullImage");
                            ancFullImage.HRef    = imagePathHero;
                            ancFullImage.Visible = true;

                            ancTemplateImage.HRef = "#" + previewTemplate.ClientID;
                            // ancTemplateImage.Title = "Pattern Images";

                            //ancTemplateImage.Attributes.Add("target", "_blank");
                            //ancTemplateImage.Attributes.Add("onclick", "Javascript:populateDiv(this);return false;");
                            //ancTemplateImage.Attributes.Add("style", "pointer-events:none;");

                            ancTemplateImage.Attributes.Add("hero", imagePathHero);
                            ancTemplateImage.Attributes.Add("nohero_1", imagePath_1);
                            ancTemplateImage.Attributes.Add("nohero_2", imagePath_2);
                            ancTemplateImage.Attributes.Add("nohero_3", imagePath_3);
                        }
                        else
                        {
                            ancTemplateImage.Title = "Pattern Images Not Found";
                            //ancTemplateImage.Attributes.Add("class", "btn-link iremove");
                            iimageView.Attributes.Add("class", "icon-eye-close");
                        }
                    }
                    else
                    {
                        ancTemplateImage.Title = "Pattern Images Not Found";
                        //ancTemplateImage.Attributes.Add("class", "btn-link iremove");
                        iimageView.Attributes.Add("class", "icon-eye-close");
                    }
                }
            }
        }
예제 #5
0
        protected void rptGarmentSpecs_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            RepeaterItem item = e.Item;

            if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
            {
                PatternBO objItem = (PatternBO)(item.DataItem);

                HtmlAnchor linkPattern = (HtmlAnchor)(item.FindControl("linkPattern"));

                //#if DEBUG
                //                linkPattern.HRef = "javascript:void(parent.window.location.href='http://www.bmizzle.com.au/sizing-spec-details/?" +
                //                                   objItem.Number.ToString() + "');";
                //#else
                //                linkPattern.HRef = "javascript:void(parent.window.location.href='http://www.blackchrome.com.au/our-products/garment-sizing-specification-details/?" +
                //                                   objItem.Number.ToString() + "');";
                //#endif

#if DEBUG
                linkPattern.HRef = "javascript:void(window.open('http://local-indico.com/SizingSpecDetails.aspx?id=" + objItem.Number.ToString() + "','_blank'))";
#else
                linkPattern.HRef = "javascript:void(window.open('http://gw.indiman.net/SizingSpecDetails.aspx?id=" + objItem.Number.ToString() + "','_blank'))";
#endif

                string imgLocation = string.Empty;
                PatternTemplateImageBO objPatternTemplateImage = new PatternTemplateImageBO();
                objPatternTemplateImage.Pattern = objItem.ID;

                List <PatternTemplateImageBO> lstPTImages = objPatternTemplateImage.SearchObjects().Where(m => m.ImageOrder == 1).ToList();

                if (lstPTImages.Any())
                {
                    objPatternTemplateImage = lstPTImages.First();

                    if (objPatternTemplateImage != null)
                    {
                        imgLocation = IndicoConfiguration.AppConfiguration.DataFolderName + "/PatternTemplates/" + objItem.ID.ToString() + "/" + objPatternTemplateImage.Filename + objPatternTemplateImage.Extension;
                        if (!File.Exists(IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + imgLocation))
                        {
                            imgLocation = IndicoConfiguration.AppConfiguration.DataFolderName + "/noimage-png-350px-350px.png";
                        }
                    }
                }
                else
                {
                    imgLocation = IndicoConfiguration.AppConfiguration.DataFolderName + "/noimage-png-350px-350px.png";
                }

                Image imgItem = (Image)(item.FindControl("imgItem"));
                imgItem.ImageUrl = imgLocation;

                HtmlGenericControl lblDescription = (HtmlGenericControl)(item.FindControl("lblDescription"));
                lblDescription.InnerText = objItem.Number + " - " + objItem.NickName;
                //lblDescription.InnerText = objItem.Remarks;

                HtmlGenericControl lblAgeGroupGender = (HtmlGenericControl)(item.FindControl("lblAgeGroupGender"));
                HtmlGenericControl lblSizeSet        = (HtmlGenericControl)(item.FindControl("lblSizeSet"));

                string        sizes    = string.Empty;
                List <SizeBO> lstSizes = objItem.objSizeSet.SizesWhereThisIsSizeSet.Where(o => o.IsDefault == true).ToList();
                if (lstSizes.Any())
                {
                    sizes = (lstSizes.Count > 1) ? lstSizes.First().SizeName + " - " + lstSizes.Last().SizeName : lstSizes.First().SizeName;
                }

                lblAgeGroupGender.InnerText = objItem.objGender.Name + ((objItem.AgeGroup.HasValue && objItem.AgeGroup > 0) ? " - " + objItem.objAgeGroup.Name : "");
                lblSizeSet.InnerText        = sizes;
            }
        }
        private void PopulateControls()
        {
            if (string.IsNullOrEmpty(this.QueryNumber))
            {
                //#if DEBUG
                //                Response.Redirect("http://www.bmizzle.com.au/sizing-specs/");
                //#else
                //                Response.Redirect("http://www.blackchrome.com.au/garment-sizing-specifications/");
                //#endif
                Response.Redirect("http://www.blackchrome.com.au/");
            }
            else
            {
                PatternBO objPattern = new PatternBO();
                objPattern.IsActiveWS = true;
                objPattern.IsActive   = true;
                objPattern.Number     = this.QueryNumber;
                objPattern            = objPattern.SearchObjects().SingleOrDefault();

                if (objPattern != null && objPattern.Creator > 0)
                {
                    WebServicePattern obj = new WebServicePattern();

                    if ((objPattern.PatternCompressionImage ?? 0) > 0)
                    {
                        this.imgSpec.ImageUrl = PopulatePatternCompressionImage(objPattern);
                        this.imgSpec.Visible  = true;
                    }
                    else
                    {
                        this.litSpecBody.Text    = obj.CreateHtml(objPattern, "0", true);
                        this.litSpecBody.Visible = this.dvUnits.Visible = true;
                    }

                    //Populate Images
                    PatternTemplateImageBO objOtherImage = new PatternTemplateImageBO();
                    objOtherImage.Pattern = objPattern.ID;
                    List <PatternTemplateImageBO> lstOtherImages = objOtherImage.SearchObjects();

                    List <PatternTemplateImageBO> lstOtherImages1 = lstOtherImages.Where(o => o.ImageOrder == 1).ToList();
                    List <PatternTemplateImageBO> lstOtherImages2 = lstOtherImages.Where(o => o.ImageOrder == 2).ToList();
                    List <PatternTemplateImageBO> lstOtherImages3 = lstOtherImages.Where(o => o.ImageOrder == 3).ToList();

                    this.imgOther1.Src = this.TemplateImagePath(lstOtherImages1);
                    this.lnkImage1.Attributes.Add("data-image", "../" + this.imgOther1.Src);
                    this.lnkImage1.Attributes.Add("data-zoom-image", "../" + this.imgOther1.Src);
                    this.lnkImage1.Visible = !string.IsNullOrEmpty(this.imgOther1.Src);

                    this.imgOther2.Src = TemplateImagePath(lstOtherImages2);
                    this.lnkImage2.Attributes.Add("data-image", "../" + this.imgOther2.Src);
                    this.lnkImage2.Attributes.Add("data-zoom-image", "../" + this.imgOther2.Src);
                    this.lnkImage2.Visible = !string.IsNullOrEmpty(this.imgOther2.Src);

                    this.imgOther3.Src = TemplateImagePath(lstOtherImages3);
                    this.lnkImage3.Attributes.Add("data-image", "../" + this.imgOther3.Src);
                    this.lnkImage3.Attributes.Add("data-zoom-image", "../" + this.imgOther3.Src);
                    this.lnkImage3.Visible = !string.IsNullOrEmpty(this.imgOther3.Src);

                    //PatternTemplateImageBO objGamentSpec = new PatternTemplateImageBO();
                    //if (lstOtherImages.Where(o => o.IsHero).Any())
                    //{
                    //    objGamentSpec = lstOtherImages.Where(o => o.IsHero).Last();
                    this.imgGamentSpec.Src = TemplateImagePath(lstOtherImages.Where(o => o.IsHero).ToList(), true);
                    // }

                    this.lblNumber.InnerText      = objPattern.Number;
                    this.lblRemarks.InnerText     = objPattern.Remarks;
                    this.lblGender.InnerText      = objPattern.objGender.Name;
                    this.lblDescription.InnerText = objPattern.Description;

                    this.imgHero.Src = (this.lnkImage3.Visible) ? this.imgOther3.Src :
                                       (this.lnkImage1.Visible) ? this.imgOther1.Src : IndicoConfiguration.AppConfiguration.DataFolderName + "/noimage-png-350px-350px.png";
                }
                else
                {
                    //#if DEBUG
                    //                    Response.Redirect("http://www.bmizzle.com.au/sizing-specs/");
                    //#else
                    //                    Response.Redirect("http://www.blackchrome.com.au/garment-sizing-specifications/");
                    //#endif
                    Response.Redirect("http://www.blackchrome.com.au/");
                }
            }
        }