Ejemplo n.º 1
0
        public void CkImage(string sid)
        {
            SVG_IMAGE img = new SVG_IMAGE();
            img.svgID = sid;
            IList<SVG_IMAGE> list = Services.BaseService.GetList<SVG_IMAGE>("SelectSVG_IMAGEBySvgID", img);
            for (int i = 0; i < list.Count; i++)
            {
                if (!System.IO.File.Exists(Application.StartupPath + "\\" + list[i].SUID + "." + list[i].col1))
                {
                    FileStream fs = new FileStream(Application.StartupPath + "\\" + list[i].SUID + "." + list[i].col1, FileMode.Create, FileAccess.Write, FileShare.None);
                    fs.Write(list[i].image, 0, list[i].image.Length);
                    fs.Close();
                }

            }
        }
Ejemplo n.º 2
0
        public void Delete()
        {
            if (tlVectorControl1.SVGDocument.CurrentElement != null && tlVectorControl1.SVGDocument.CurrentElement.ID != "svg") {
                frmMessageBox msg = new frmMessageBox();
                if (msg.ShowDialog() == DialogResult.OK) {
                    //if (msg.ck)
                    //{
                    // if(MessageBox.Show("确认删除么?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Information)==DialogResult.Yes){
                    for (int i = 0; i < tlVectorControl1.SVGDocument.SelectCollection.Count; i++) {
                        string larid = "";
                        larid = ((SvgElement)tlVectorControl1.SVGDocument.SelectCollection[i]).GetAttribute("layer");
                        if (!ChangeLayerList.Contains(larid)) {
                            ChangeLayerList.Add(larid);
                        }
                        if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Image") {
                            SVG_IMAGE s_img = new SVG_IMAGE();

                            s_img.SUID = tlVectorControl1.SVGDocument.SelectCollection[i].ID;
                            Services.BaseService.Delete<SVG_IMAGE>(s_img);
                        }
                        if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                            glebeProperty gle = new glebeProperty();
                            gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                            gle.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID;
                            Services.BaseService.Update("DeleteglebePropertyByEleID", gle);
                            SVG_ENTITY pro = new SVG_ENTITY();
                            pro.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID;
                            pro.svgID = tlVectorControl1.SVGDocument.SvgdataUid;
                            Services.BaseService.Update("DeleteSVG_ENTITYByEleID", pro);
                        }
                        if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polyline" || tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Line") {
                            LineInfo _line = new LineInfo();
                            _line.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                            _line.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID;
                            LineInfo temp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", _line);
                            if (temp != null) {
                                Services.BaseService.Update("DeleteLinePropertyByEleID", _line);

                                Services.BaseService.Update("DeleteLine_InfoByCode", temp.UID);
                            }
                            SVG_ENTITY pro = new SVG_ENTITY();
                            pro.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID;
                            pro.svgID = tlVectorControl1.SVGDocument.SvgdataUid;
                            Services.BaseService.Update("DeleteSVG_ENTITYByEleID", pro);
                        }
                        if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Use") {
                            string str_name = ((XmlElement)(tlVectorControl1.SVGDocument.SelectCollection[i])).GetAttribute("xlink:href");
                            if (str_name.Contains("Substation")) {
                                substation _sub = new substation();
                                _sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                _sub.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID;

                                substation temp = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", _sub);

                                if (temp != null) {
                                    Services.BaseService.Update("DeletesubstationByEleID", _sub);

                                    Services.BaseService.Update("DeleteSubstation_InfoByCode", temp.UID);
                                }
                                SVG_ENTITY pro = new SVG_ENTITY();
                                pro.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID;
                                pro.svgID = tlVectorControl1.SVGDocument.SvgdataUid;
                                Services.BaseService.Update("DeleteSVG_ENTITYByEleID", pro);

                                substation p = new substation();
                                p.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID;
                                p.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                Services.BaseService.Update("DeletesubstationByEleID", p);

                                PSP_SubstationSelect sel = new PSP_SubstationSelect();
                                sel.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID;
                                sel.SvgID = tlVectorControl1.SVGDocument.SvgdataUid;
                                Services.BaseService.Update("DeletePSP_SubstationByEleID", sel);
                            }
                        }
                        if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.ConnectLine") {
                            ConnectLine cline = (ConnectLine)tlVectorControl1.SVGDocument.SelectCollection[i];
                            if (cline.StartGraph != null) {
                                SvgElement ele = (SvgElement)cline.StartGraph;
                                if (!ele.GetAttribute("xlink:href").Contains("Substation")) {
                                    tlVectorControl1.SVGDocument.SelectCollection.Add(cline.StartGraph);
                                }
                            }
                            if (cline.EndGraph != null) {
                                tlVectorControl1.SVGDocument.SelectCollection.Add(cline.EndGraph);
                            }
                        }

                    }
                    //}
                    /* else
                     {
                         for (int i = 0; i < tlVectorControl1.SVGDocument.SelectCollection.Count; i++)
                         {
                             string larid = "";
                             larid = ((SvgElement)tlVectorControl1.SVGDocument.SelectCollection[i]).GetAttribute("layer");
                             if (!ChangeLayerList.Contains(larid))
                             {
                                 ChangeLayerList.Add(larid);
                             }
                             if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Image")
                             {
                                 SVG_IMAGE s_img = new SVG_IMAGE();

                                 s_img.SUID = tlVectorControl1.SVGDocument.SelectCollection[i].ID;
                                 Services.BaseService.Delete<SVG_IMAGE>(s_img);
                             }
                             if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polyline" || tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Line")
                             {
                                 LineInfo _line = new LineInfo();
                                 _line.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                 _line.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID;

                                 LineInfo linetemp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", _line);
                                 if (linetemp != null)
                                 {
                                     PowerProTypes temp = (PowerProTypes)Services.BaseService.GetObject("SelectPowerProTypesByCode", linetemp.UID);
                                     if (temp != null)
                                     {
                                         linetemp.EleID = "";
                                         Services.BaseService.Update<LineInfo>(linetemp);
                                     }
                                     else
                                     {
                                         Services.BaseService.Update("DeleteLineInfo", linetemp);
                                     }
                                 }

                             }
                             if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Use")
                             {
                                 string str_name = ((XmlElement)(tlVectorControl1.SVGDocument.SelectCollection[i])).GetAttribute("xlink:href");
                                 if (str_name.Contains("Substation"))
                                 {
                                     substation _sub = new substation();
                                     _sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                     _sub.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID;

                                     substation subtemp = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", _sub);
                                     if (subtemp != null)
                                     {
                                         PowerProTypes temp = (PowerProTypes)Services.BaseService.GetObject("SelectPowerProTypesByCode", subtemp.UID);
                                         if (temp != null)
                                         {
                                             subtemp.EleID = "";
                                             Services.BaseService.Update<substation>(subtemp);
                                         }
                                         else
                                         {
                                             Services.BaseService.Update("Deletesubstation", subtemp);
                                         }
                                     }
                                 }
                             }
                             if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.ConnectLine")
                             {
                                 ConnectLine cline = (ConnectLine)tlVectorControl1.SVGDocument.SelectCollection[i];
                                 if (cline.StartGraph != null)
                                 {
                                     SvgElement ele = (SvgElement)cline.StartGraph;
                                     if (!ele.GetAttribute("xlink:href").Contains("Substation"))
                                     {
                                         tlVectorControl1.SVGDocument.SelectCollection.Add(cline.StartGraph);
                                     }
                                 }
                                 if (cline.EndGraph != null)
                                 {
                                     tlVectorControl1.SVGDocument.SelectCollection.Add(cline.EndGraph);
                                 }
                             }
                         }

                     }*/

                    tlVectorControl1.Delete();
                }
            }
        }
Ejemplo n.º 3
0
        public void SaveAllLayer()
        {
            SaveAllItem();
            string txt = "";
            //Image

            XmlNodeList imglist = tlVectorControl1.SVGDocument.SelectNodes("svg/image");
            foreach (XmlNode node in imglist) {
                string tran = ((XmlElement)node).GetAttribute("xlink:href");
                if (tran.Substring(0, tran.Length - 4) != ((SvgElement)node).ID) {
                    string[] sp = tran.Split(".".ToCharArray());
                    FileStream fs = new FileStream(tran, FileMode.Open, FileAccess.Read);
                    byte[] img = new byte[fs.Length];
                    fs.Read(img, 0, (int)fs.Length);
                    fs.Close();
                    SVG_IMAGE svg_img = new SVG_IMAGE();
                    svg_img.SUID = ((SvgElement)node).ID;
                    svg_img.svgID = tlVectorControl1.SVGDocument.SvgdataUid;
                    svg_img.layerID = ((SvgElement)node).GetAttribute("layer");
                    svg_img.image = img;
                    svg_img.MDATE = System.DateTime.Now;
                    svg_img.col1 = sp[sp.Length - 1];
                    Services.BaseService.Create<SVG_IMAGE>(svg_img);
                    ((SvgElement)node).SetAttribute("xlink:href", ((SvgElement)node).ID + "." + sp[sp.Length - 1]);

                } else {
                    SVG_IMAGE svg_img = new SVG_IMAGE();
                    svg_img.SUID = ((SvgElement)node).ID;
                    svg_img.layerID = ((SvgElement)node).GetAttribute("layer");
                    svg_img.XML = ((SvgElement)node).GetAttribute("transform");
                    Services.BaseService.Update("UpdateSVG_IMAGEXML", svg_img);

                }
            }
            string tems_id = "";
            string[] stryearid = yearID.Split(",".ToCharArray());
            if (stryearid.Length > 1) {
                tems_id = stryearid[1].Replace("'", "");
                tems_id = tems_id.Replace("\"", "");
            }
            //layer
            ArrayList list = tlVectorControl1.SVGDocument.getLayerList();
            for (int i = 0; i < list.Count; i++) {
                txt = "";
                Layer lar = list[i] as Layer;
                bool IsSave = false;

                for (int m = 0; m < SaveID.Count; m++) {
                    if (lar.GetAttribute("ParentID") == SaveID[m].ToString()) {
                        IsSave = true;
                    }
                }
                //for (int j = 0; j<frmlar.NoSave.Count; j++)
                //{
                //    if (lar.ID == ((Layer)frmlar.NoSave[j]).ID)
                //    {
                //        IsSave = false;
                //    }
                //}
                for (int j = 0; j < ChangeLayerList.Count; j++) {
                    if (lar.ID == ChangeLayerList[j].ToString() && IsSave)
                    //if (IsSave)
                    {
                        XmlNodeList nn1 = tlVectorControl1.SVGDocument.SelectNodes("svg/* [@layer='" + lar.ID + "']");
                        foreach (XmlNode node in nn1) {
                            txt = txt + node.OuterXml;
                        }
                        SVG_LAYER _svg = new SVG_LAYER();
                        _svg.SUID = lar.ID;
                        _svg.svgID = SVGUID;
                        _svg = (SVG_LAYER)Services.BaseService.GetObject("SelectSVG_LAYERByKey", _svg);
                        int ny = 0;
                        try { ny = int.Parse(lar.Label.Substring(0, 4)); } catch { }
                        if (_svg != null) {
                            _svg.XML = txt;
                            _svg.NAME = lar.Label;
                            _svg.MDATE = System.DateTime.Now;
                            _svg.OrderID = ny * 100 + list.IndexOf(lar);
                            // _svg.YearID = lar.GetAttribute("ParentID");
                            _svg.IsChange = lar.GetAttribute("IsChange");
                            _svg.visibility = lar.GetAttribute("visibility");
                            _svg.layerType = lar.GetAttribute("layerType");
                            _svg.IsSelect = lar.GetAttribute("IsSelect");
                            Services.BaseService.Update<SVG_LAYER>(_svg);
                        } else {
                            _svg = new SVG_LAYER();
                            _svg.SUID = lar.ID;
                            _svg.NAME = lar.Label;
                            _svg.svgID = SVGUID;
                            _svg.XML = txt;
                            _svg.MDATE = System.DateTime.Now;
                            _svg.OrderID = ny * 100 + list.IndexOf(lar);
                            _svg.YearID = tems_id;// lar.GetAttribute("ParentID");
                            _svg.IsChange = lar.GetAttribute("IsChange");
                            _svg.visibility = lar.GetAttribute("visibility");
                            _svg.layerType = lar.GetAttribute("layerType");
                            _svg.IsSelect = lar.GetAttribute("IsSelect");
                            Services.BaseService.Create<SVG_LAYER>(_svg);
                        }
                        continue;
                    }
                }
            }
            //symbol
            XmlNodeList symlist = tlVectorControl1.SVGDocument.SelectNodes("svg/defs/symbol");
            foreach (XmlNode node in symlist) {
                SVG_SYMBOL _sym = new SVG_SYMBOL();
                _sym.EleID = ((XmlElement)node).GetAttribute("id");
                _sym.svgID = SVGUID;
                _sym = (SVG_SYMBOL)Services.BaseService.GetObject("SelectSVG_SYMBOLByEleID", _sym);
                if (_sym != null) {
                    _sym.XML = node.OuterXml;
                    _sym.MDATE = System.DateTime.Now;
                    Services.BaseService.Update<SVG_SYMBOL>(_sym);
                } else {
                    _sym = new SVG_SYMBOL();
                    _sym.SUID = Guid.NewGuid().ToString();
                    _sym.EleID = ((XmlElement)node).GetAttribute("id");
                    _sym.NAME = ((XmlElement)node).GetAttribute("label");
                    _sym.svgID = SVGUID;
                    _sym.XML = node.OuterXml;
                    _sym.MDATE = System.DateTime.Now;
                    Services.BaseService.Create<SVG_SYMBOL>(_sym);
                }
            }
        }