Пример #1
0
        private void ExportToTag(string filePath, MSDS_Specification model)
        {
            Tag_ExportModel tag = new Tag_ExportModel();

            tag.SheetName_Big    = "大标签";
            tag.SheetName_Small  = "小标签";
            tag.templateFilePath = filePath;
            tag.ProductName      = model.CN_Name ?? model.Product_Name;

            #region 危险组分
            tag.HS = "组分:";
            if (model.HazardousSubstance != null && model.HazardousSubstance.Count > 0)
            {
                int i = 1;
                foreach (MSDS_HazardousSubstances hs in model.HazardousSubstance)
                {
                    if (i > 1)
                    {
                        tag.HS += "/n";
                    }
                    tag.HS += hs.HS_Name + hs.HS_MinPercent + "-" + hs.HS_MaxPercent + "%";
                    i++;
                }
            }
            else
            {
                tag.HS = "";
            }
            #endregion

            #region 危险图标
            List <string> imgPathList = new List <string>();
            string        strRootPath = Server.MapPath("~/Content/Images/");
            if (model.IsExplosive)
            {
                imgPathList.Add(strRootPath + "Explosive.png");
            }
            if (model.IsFlammable)
            {
                imgPathList.Add(strRootPath + "Flammable.png");
            }
            if (model.IsCorrosive)
            {
                imgPathList.Add(strRootPath + "Corrosive.png");
            }
            if (model.IsHealthHazard)
            {
                imgPathList.Add(strRootPath + "HealthHazard.png");
            }
            if (model.IsToxic)
            {
                imgPathList.Add(strRootPath + "Toxic.png");
            }
            if (model.IsOxidizing)
            {
                imgPathList.Add(strRootPath + "Oxidizing.png");
            }
            if (model.IsGasUnderPressure)
            {
                imgPathList.Add(strRootPath + "GasUnderPressure.png");
            }
            if (model.IsIrritant)
            {
                imgPathList.Add(strRootPath + "Irritant.png");
            }
            if (model.IsDangerousToEnvironment)
            {
                imgPathList.Add(strRootPath + "DangerousToEnvironment.png");
            }
            tag.WarningPicPaths = imgPathList;
            tag.BlankPicPath    = strRootPath + "blank.png";
            #endregion

            #region 危害警示
            tag.WarningContent = model.GHS_Warning;
            #endregion

            char[] sp = new char[1] {
                ','
            };
            #region 危害简述
            tag.HazardousDescription = "";
            if (!string.IsNullOrEmpty(model.GHS_HazardouDes_Values))
            {
                string[] names = model.GHS_HazardouDes_Values.Split(sp, StringSplitOptions.RemoveEmptyEntries);
                IList <MSDS_H_Statement> h_statments = _h_StatementService.GetListByNames(names);
                foreach (MSDS_H_Statement item in h_statments)
                {
                    tag.HazardousDescription += "" + item.Description + ",";
                }
                tag.HazardousDescription = tag.HazardousDescription.Substring(0, tag.HazardousDescription.Length - 1);
            }
            else
            {
                tag.HazardousDescription = model.GHS_HazardouDes_Append;
            }
            #endregion

            #region 预防措施
            tag.DefenceDes = "";
            if (!string.IsNullOrEmpty(model.GHS_DefenceDes_Values))
            {
                string[] names = model.GHS_DefenceDes_Values.Split(sp, StringSplitOptions.RemoveEmptyEntries);
                IList <MSDS_P_Statement> statements = _p_StatementService.GetListByNames(names);
                int i = 1;
                foreach (MSDS_P_Statement item in statements)
                {
                    tag.DefenceDes += "● " + item.Description + "\r\n";
                    i++;
                    if (i > 3)
                    {
                        break;
                    }
                }
            }
            else
            {
                tag.DefenceDes = model.GHS_DefenceDes_Append;
            }
            #endregion

            #region 事故响应
            tag.DealDES = "";
            if (!string.IsNullOrEmpty(model.GHS_DealDES_Values))
            {
                string[] names = model.GHS_DealDES_Values.Split(sp, StringSplitOptions.RemoveEmptyEntries);
                IList <MSDS_P_Statement> statements = _p_StatementService.GetListByNames(names);
                int i = 1;
                foreach (MSDS_P_Statement item in statements)
                {
                    tag.DealDES += "● " + item.Description + "\r\n";
                    i++;
                    if (i > 7)
                    {
                        break;
                    }
                }
            }
            else
            {
                tag.DealDES = model.GHS_DealDES_Append;
            }
            #endregion

            #region 安全储存
            //tag.StoreDes = "";
            //if (!string.IsNullOrEmpty(model.GHS_StoreDes_Values))
            //{
            //    string[] names = model.GHS_StoreDes_Values.Split(sp, StringSplitOptions.RemoveEmptyEntries);
            //    IList<MSDS_P_Statement> statements = _p_StatementService.GetListByNames(names);
            //    int i = 1;
            //    foreach (MSDS_P_Statement item in statements)
            //    {
            //        tag.StoreDes += item.Description + ";";
            //        i++;
            //        if (i > 3) break;
            //    }
            //}
            //else
            //{
            //    tag.StoreDes = model.GHS_StoreDes_Append;
            //}

            //if (tag.StoreDes?.Length > 34)
            //{
            //    tag.StoreDes = tag.StoreDes.Substring(0, 34);
            //}
            tag.StoreDes = "存储化学品必须遵照国家法律、法规和其他有关的规定,化学品应有明显的标志。一般情况下,应避免阳光直射,保持通风良好,储存区域内严禁吸烟和使用明火。";
            #endregion

            #region 废弃处置
            //if (model.Product_WasteHanding?.Length > 95)
            //{
            //    tag.WasteHanding = model.Product_WasteHanding.Substring(0,95);
            //}
            //else
            //{
            //    tag.WasteHanding = model.Product_WasteHanding;
            //}
            tag.WasteHanding = "请遵从当地环保法规要求";
            #endregion

            #region 供应商信息
            tag.Supplier_Big = string.Format(@"供应商:{0}
地址:{1}
电话:{2}
                                 应急电话:{3}",
                                             model.Supplier_Name,
                                             model.Supplier_Address,
                                             model.Supplier_Phone,
                                             model.Supplier_UrgencyCall);

            tag.Supplier_Small = string.Format(@"供应商:{0}
地址:{1}
电话:{2}",
                                               model.Supplier_Name,
                                               model.Supplier_Address,
                                               model.Supplier_Phone);
            #endregion

            _importExportService.ExportTagWithTemplate(tag);
        }