Exemplo n.º 1
0
        public fReport(AiKEntities ctx, string imagesPath)
        {
            InitializeComponent();
            Mode = 0;

            _ctx        = ctx;
            _imagesPath = imagesPath;
        }
Exemplo n.º 2
0
        public Form1()
        {
            LoadConfig();
            InitializeComponent();
            SetConfig();

            _ctx = new AiKEntities();
            _ctx.Database.CommandTimeout = 600;

            InitArtGrid();
            InitCraftGrid();
            InitPicGrid();
            InitLinkGrid();

            LoadArts();
            LoadCrafts();
            LoadPics(true);

            tabControl1.SelectedIndex = 1;
        }
Exemplo n.º 3
0
        public void DoMakeLinks(AiKEntities ctx, Label lInfo, int ind)
        {
            if (!(MessageBox.Show("Load Links?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes))
            {
                return;
            }

            var ld = new List <string>();

            for (var i = 1; i <= 7; i++)
            {
                Recs[i] = new List <TRec>();
            }

            lInfo.Text = "Loading...";
            Application.DoEvents();

            var crafts = ctx.Crafts.Where(x => "1234567".Contains(x.Source)).ToList();

            foreach (var craft in crafts)
            {
                var r = new TRec(craft);
                Recs[r.isrc].Add(r);
            }

            var icnt = 0;
            var cnt  = Recs[1].Count +
                       Recs[2].Count +
                       Recs[3].Count +
                       Recs[4].Count +
                       Recs[5].Count +
                       Recs[6].Count +
                       Recs[7].Count;

            for (var i = 1; i <= 7; i++)
            {
                foreach (var r in Recs[i])
                {
                    icnt++;
                    lInfo.Text = $"{icnt} of {cnt}";
                    Application.DoEvents();

                    var craft = ctx.Crafts.Single(x => x.CraftId == r.id);
                    for (var k = 1; k <= 7; k++)
                    {
                        if ((ind == 0) || (ind == i) || (ind == k))
                        {
                            if (i == k)
                            {
                                craft.GetType().GetProperty($"s{k}").SetValue(craft, r.id);
                            }
                            else
                            {
                                craft.GetType().GetProperty($"s{k}").SetValue(craft, null);
                                var maxcmp = Int32.MinValue;
                                var maxyr  = 0;
                                var maxid  = 0;
                                ld.Clear();
                                foreach (var r1 in Recs[k])
                                {
                                    var m = CompareRecs(r, r1);
                                    if (m > Int32.MinValue)
                                    {
                                        if (m > maxcmp)
                                        {
                                            maxcmp = m;
                                            maxid  = r1.id;
                                            maxyr  = r1.iyear;
                                            ld.Clear();
                                        }
                                        else if (m == maxcmp)
                                        {
                                            ld.Add($"{r1.name} ({m})");
                                            if ((r1.iyear > 0) && ((maxyr > r1.iyear) || (maxyr == 0)))
                                            {
                                                maxcmp = m;
                                                maxid  = r1.id;
                                                maxyr  = r1.iyear;
                                                ld.Move(ld.Count - 1, 0);
                                            }
                                        }
                                    }
                                }
                                if (maxcmp > Int32.MinValue)
                                {
                                    craft.GetType().GetProperty($"s{k}").SetValue(craft, maxid);
                                }
                            }
                        }
                    }
                    ctx.SaveChanges();
                    Util.DetachAllEntities(ctx);
                }
            }

            lInfo.Text = "";
            MessageBox.Show("OK!");
        }
Exemplo n.º 4
0
        public void LoadOld(AiKEntities ctx, string _imagesPath, Label lInfo)
        {
            if (!(MessageBox.Show("Load 3-4?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes))
            {
                return;
            }

            ctx.Database.ExecuteSqlCommand("Delete from Pics where CraftId in (Select CraftId from Crafts where Source in ('3', '4'))");
            ctx.Database.ExecuteSqlCommand("Delete from Crafts where Source in ('3', '4')");

            var text3 = File.ReadAllText("E:\\Live\\Avia\\Text3.dat", Encoding.GetEncoding("windows-1251"));
            var text4 = File.ReadAllText("E:\\Live\\Avia\\Text4.dat", Encoding.GetEncoding("windows-1251"));

            var artId3 = ctx.Arts.Where(x => x.Mag == "Site3").Single().ArtId;
            var artId4 = ctx.Arts.Where(x => x.Mag == "Site4").Single().ArtId;

            var cnt    = 0;
            var crafts = ctx.CraftsOld.Where(x => x.Source == 3 || x.Source == 4).ToList();

            foreach (var craft in crafts)
            {
                lInfo.Text = (++cnt).ToString();
                Application.DoEvents();

                var newCraft = new Crafts()
                {
                    Construct = craft.Construct,
                    Name      = craft.Name,
                    Country   = craft.Country,
                    IYear     = craft.IYear,
                    Vert      = craft.Vert,
                    Uav       = craft.UAV,
                    Glider    = craft.Glider,
                    Source    = craft.Source.ToString(),
                    Type      = craft.Type
                };
                if ((craft.TxtBeg ?? 0) > 0)
                {
                    newCraft.CText = (craft.Source == 3 ? text3 : text4).Substring(craft.TxtBeg.Value, craft.TxtEnd.Value - craft.TxtBeg.Value);
                }
                ctx.Crafts.Add(newCraft);
                ctx.SaveChanges();

                var prms = ctx.ParamsOld.Where(x => x.CraftId == craft.ID).ToList();
                if (prms.Any())
                {
                    var s = "\n\n";
                    foreach (var prm in prms)
                    {
                        s += $"\n{prm.ParamName}\t{prm.ParamData}";
                    }
                    newCraft.CText += s;
                }

                var pics = ctx.PicsOld.Where(x => x.CraftID == craft.ID).ToList();
                foreach (var pic in pics)
                {
                    var newPic = new Pics()
                    {
                        ArtId   = craft.Source == 3 ? artId3 : artId4,
                        CraftId = newCraft.CraftId,
                        NNN     = pic.PictID,
                        Path    = pic.Picture
                    };
                    if ((pic.TxtBeg ?? 0) > 0)
                    {
                        newPic.Text = (craft.Source == 3 ? text3 : text4).Substring(pic.TxtBeg.Value, pic.TxtEnd.Value - pic.TxtBeg.Value);
                    }
                    ctx.Pics.Add(newPic);
                }
                ctx.SaveChanges();

                Util.DetachAllEntities(ctx);
            }

            lInfo.Text = "";
            MessageBox.Show("OK");
        }
Exemplo n.º 5
0
        public void Load5(AiKEntities ctx, string _imagesPath, Label lInfo)
        {
            _ctx       = ctx;
            imagesPath = _imagesPath;

            _lInfo = lInfo;
            if (!(MessageBox.Show("Load Aerofiles?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes))
            {
                return;
            }


            artId = ctx.Arts.Where(x => x.Name == "Aerofiles").Single().ArtId;

            ls = new List <string>();
            lp = new List <string>();

            ctx.Database.ExecuteSqlCommand("Delete From dbo.Pics From dbo.Pics p join dbo.Crafts c on c.CraftId = p.CraftId where c.Source = '5'");
            ctx.Database.ExecuteSqlCommand("Delete From dbo.Crafts where Source = '5'");
            ctx.Database.Connection.Close();
            ctx.Database.Connection.Open();

            using (var G = File.CreateText(_imagesPath + "Images5.lst"))
            {
                var files = Directory.GetFiles("E:\\download\\aerofiles.com", "_*.html");
                foreach (var file in files)
                {
                    _lInfo.Text = file;
                    Application.DoEvents();

                    for (q = 1; q < 3; q++)
                    {
                        s      = File.ReadAllText(file, Encoding.GetEncoding("UTF-8"));
                        GFile  = s.Split('\n').ToList();
                        GFileI = 0;

                        was_first = false;

                        sc = ""; cnt = 0;
                        var srName = Path.GetFileName(file);
                        if (srName.Length > 8)
                        {
                            s = FindString("<TITLE", true).Trim();
                            s = StrNoTags(s);
                            if (s != "")
                            {
                                if (s.Substring(1).StartsWith("merican airplanes"))
                                {
                                    s = s.Substring(19).Trim();
                                }
                                if (s.Length > 2 && s[s.Length - 2] == '-')
                                {
                                    s = s.Substring(0, s.Length - 4).Trim();
                                }
                                if (s.Length > 5 && s.Substring(s.Length - 5, 4) == " to ")
                                {
                                    s = s.Substring(0, s.Length - 7).Trim();
                                }
                                if (s.Length > 7 && s.Substring(s.Length - 7, 6) == " page ")
                                {
                                    s = s.Substring(0, s.Length - 7).Trim();
                                }
                            }
                            i = s.IndexOf("-hyphenates");
                            if (i >= 0)
                            {
                                s = s.Substring(0, i);
                            }
                            sc = s;
                        }
                        sc1 = s;

                        while (!Eof2())
                        {
                            s = ReadLn2();

                            su = s.ToUpper().Trim();
                            if (((s.IndexOf(".jpg") >= 0) && su.StartsWith("<A HREF")) || (s.IndexOf(" = ") >= 0))
                            {
                                break;
                            }

                            if (srName.Length <= 8)
                            {
                                if (FindFirm(su))
                                {
                                    ss = StrNoTags(s);
                                    if (!string.IsNullOrEmpty(ss))
                                    {
                                        sc        = ss;
                                        sc1       = sc;
                                        s         = ReadLn2();
                                        su        = s.ToUpper();
                                        was_first = false;
                                    }
                                }
                            }
                        }

                        ResetCraft();

                        while (!Eof2())
                        {
                            i = s.IndexOf(".jpg");
                            if (i < 0)
                            {
                                i = s.ToLower().IndexOf(".gif");
                                if (i >= 0 && s.ToLower().IndexOf("cleardot.gif") >= 0)
                                {
                                    i = -1;
                                }
                            }
                            while (i >= 0)
                            {
                                if (/*((q=2) or(Length(sr.Name) <= 8)) and*/ (bq == 0) && (stt != ""))
                                {
                                    SaveCraft();
                                }

                                ss = ExtName(s.Substring(0, i + 4));
                                if (ss.StartsWith("logo-"))
                                {
                                    SaveCraft();
                                    i = s.IndexOf("alt=");
                                    if (i < 0)
                                    {
                                        i  = ss.IndexOf(".");
                                        ss = ss.Substring(5, i - 6);
                                        var sb = new StringBuilder(ss);
                                        sb[0] = sb[0].ToString().ToUpper()[0];
                                        ss    = sb.ToString();
                                    }
                                    else
                                    {
                                        ss = s.Substring(i + 4);
                                        i  = ss.IndexOf("logo");
                                        if (i < 0)
                                        {
                                            i = ss.IndexOf("\"");
                                            if (i < 0)
                                            {
                                                ss = sc;
                                            }
                                            else
                                            {
                                                ss = ss.Substring(0, i - 1).Trim();
                                            }
                                        }
                                        else
                                        {
                                            ss = ss.Substring(0, i - 1).Trim();
                                        }
                                    }
                                    sc  = ss;
                                    sc1 = sc;
                                }

                                i = s.IndexOf(".jpg");
                                if (i < 0)
                                {
                                    i = s.ToLower().IndexOf(".gif");
                                    if (i >= 0 && s.ToLower().IndexOf("cleardot.gif") >= 0)
                                    {
                                        i = -1;
                                    }
                                }
                                ss = ExtName(s.Substring(0, i + 4));
                                lp.Add(ss);
                                G.WriteLine("http://www.aerofiles.com/" + ss);

                                ss = "";
                                st = StrNoTags(s);

                                s = ReadLn2();

                                su = s.ToUpper();
                                while ((s.IndexOf(".gif") < 0) && (su.IndexOf("<SPACER") < 0) &&
                                       (!FindFirm(su)) && (FindCraft(s) < 0) && !Eof2())
                                {
                                    st = StrNoTags(s);
                                    if (st != "")
                                    {
                                        ss = (ss + " " + st).Trim();
                                    }

                                    s  = ReadLn2();
                                    su = s.ToUpper();
                                }
                                ls.Add(ss);

                                i = s.IndexOf(".jpg");
                                if (i < 0)
                                {
                                    i = s.ToLower().IndexOf(".gif");
                                    if (i >= 0 && s.ToLower().IndexOf("cleardot.gif") >= 0)
                                    {
                                        i = -1;
                                    }
                                }
                            }

                            if (FindFirm(su))
                            {
                                ss = StrNoTags(s);
                                if ((ss != "") && (!ss.StartsWith("SEE")))
                                {
                                    ResetCraft();

                                    sc  = ss;
                                    sc1 = sc;

                                    s         = ReadLn2();
                                    su        = s.ToUpper();
                                    was_first = false;
                                }
                            }


                            st = StrNoTags(s);

                            ss        = st + " ";
                            i         = FindCraft(ss);
                            new_craft = false;
                            if (i >= 0)
                            {
                                if (/*{((q=2) or(Length(sr.Name) <= 8)) and}*/ (bq == 0) && (stt != ""))
                                {
                                    SaveCraft();
                                    ss = st + " ";
                                }

                                new_craft = true;
                                stt      += "\n\n\n";
                                for (j = 0; j < bq; j++)
                                {
                                    stt += ". . ";
                                }

                                if (iy == 0)
                                {
                                    was_first = true;
                                    was_year  = true;
                                    j         = i;
                                    while ((ss[j] == ' ') && (j > 3))
                                    {
                                        j--;
                                    }
                                    if (ss[j] == ')')
                                    {
                                        while ((ss[j] != '(') && (j > 3))
                                        {
                                            j--;
                                        }
                                        j--;
                                        while ((ss[j] == ' ') && (j > 3))
                                        {
                                            j--;
                                        }
                                    }
                                    if ((IsDigit(ss[j]) || (ss[j] == '?')) &&
                                        (IsDigit(ss[j - 1]) || (ss[j - 1] == '?')) &&
                                        (IsDigit(ss[j - 2]) || (ss[j - 2] == '?')) &&
                                        (IsDigit(ss[j - 3]) || (ss[j - 3] == '?')))
                                    {
                                        try
                                        {
                                            iy = int.Parse(ss.Substring(j - 3, 4));
                                        } catch { }

                                        if (sn == "")
                                        {
                                            ss = ss.Substring(0, j - 3).Trim();
                                            if (ss.EndsWith("c."))
                                            {
                                                ss = ss.Substring(0, ss.Length - 2).Trim();
                                            }
                                            sn = ss;
                                        }
                                    }
                                    else
                                    {
                                        sn = ss.Substring(0, i).Trim();
                                    }
                                    if (sn != "")
                                    {
                                        if (sn[0] == '-')
                                        {
                                            i = sn.IndexOf(" ");
                                            s = i > 0 ? sn.Substring(0, i) : sn;
                                            i = sc.IndexOf(s);
                                            if (i >= 0)
                                            {
                                                j = i;
                                                while ((j >= 0) && (sc[j] != ','))
                                                {
                                                    j--;
                                                }
                                                ss  = sc.Substring(j + 1, i - j - 1).Trim();
                                                sc1 = ss + s;
                                                sn  = ss + sn;
                                                st  = ss + st;
                                            }
                                            else
                                            {
                                                sc1 = sc + s;
                                                sn  = sc + sn;
                                                st  = sc + st;
                                            }
                                        }
                                    }
                                }
                            }

                            if (st != "")
                            {
                                if (stt == "")
                                {
                                    stt = st;
                                }
                                else if (new_craft)
                                {
                                    stt = stt + st;
                                }
                                else
                                {
                                    stt = stt + "\n" + st;
                                }
                            }

                            ss = su;
                            i  = ss.IndexOf("<BLOCKQUOTE");
                            while (i >= 0)
                            {
                                bq++;
                                ss = ss.Substring(i + 1);
                                i  = ss.IndexOf("<BLOCKQUOTE");
                            }

                            ss = su;
                            i  = ss.IndexOf("</BLOCKQUOTE");
                            while (i >= 0)
                            {
                                bq--;
                                ss = ss.Substring(i + 1);
                                i  = ss.IndexOf("</BLOCKQUOTE");
                            }

                            if ((!was_first) && (stt != ""))
                            {
                                ResetCraft();
                            }


                            if (su.IndexOf("<HR") >= 0)
                            {
                                SaveCraft();
                            }

                            s = ReadLn2();
                            if (s.IndexOf("home.html") >= 0)
                            {
                                SaveCraft();
                                break;
                            }
                            su = s.ToUpper();
                            if (FindFirm(su))
                            {
                                ss = StrNoTags(s);
                                if (ss != "")
                                {
                                    ResetCraft();

                                    sc        = ss;
                                    sc1       = sc;
                                    s         = ReadLn2();
                                    su        = s.ToUpper();
                                    was_first = false;
                                }
                            }
                        }
                        if (cnt > 0)
                        {
                            break;
                        }
                    }
                    SaveCraft();
                }
            }

            _lInfo.Text = "";
            MessageBox.Show("OK!");
        }
Exemplo n.º 6
0
        public void Load1(AiKEntities ctx, string _imagesPath, Label lInfo)
        {
            _lInfo = lInfo;
            if (!(MessageBox.Show("Load Airwar?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes))
            {
                return;
            }

            ctx.Database.ExecuteSqlCommand("Delete From dbo.WordLinks From dbo.WordLinks wl join dbo.Pics p on wl.PicId = p.PicId join dbo.Crafts c on c.CraftId = p.CraftId where c.Source = '1'");
            ctx.Database.ExecuteSqlCommand("Delete From dbo.WordLinks From dbo.WordLinks wl join dbo.Crafts c on c.CraftId = wl.CraftId where c.Source = '1'");
            ctx.Database.ExecuteSqlCommand("Delete From dbo.Pics From dbo.Pics p join dbo.Crafts c on c.CraftId = p.CraftId where c.Source = '1'");
            ctx.Database.ExecuteSqlCommand("Delete From dbo.Crafts where Source = '1'");
            ctx.Database.Connection.Close();
            ctx.Database.Connection.Open();

            var artId = ctx.Arts.Where(x => x.Name == "Airwar").Single().ArtId;

            using (var M = File.CreateText(_imagesPath + "Bads.txt"))
            {
                ls  = new List <string>();
                lc  = new List <string>();
                lcc = new List <string>();
                lct = new List <string>();
                string sName;
                int    i, j;

                var dirs = Directory.GetDirectories(_imagesPath + "Source1\\Pages\\enc", "*.");
                foreach (var dir in dirs)
                {
                    var files = Directory.GetFiles(dir, "*.html");
                    foreach (var file in files)
                    {
                        _lInfo.Text = file;
                        Application.DoEvents();
                        try
                        {
                            s = File.ReadAllText(file, Encoding.GetEncoding("KOI8-R"));
                            lc.Clear();
                            lcc.Clear();
                            lct.Clear();
                            su = s.ToUpper();
                            i  = s.IndexOf("flags_small");
                            if (i < 0)
                            {
                                M.WriteLine($"No flag_small: {file}");
                                continue;
                            }
                            TrimAll(i);
                            i = s.IndexOf(">");
                            TrimAll(i + 1);
                            i     = su.IndexOf("</TR");
                            sName = StrNoTags(s.Substring(0, i));
                            if (string.IsNullOrEmpty(sName))
                            {
                                M.WriteLine($"Bad name: {file}");
                                continue;
                            }
                            var craft = new Crafts()
                            {
                                Source = "1",
                                Name   = ClearString(sName)
                            };
                            var dirName = Path.GetFileName(dir).ToUpper();
                            if ((dirName.Length == 2 && dirName[1] == 'H') || dirName == "HELI")
                            {
                                craft.Vert = true;
                                //craft.Craft = False;
                            }
                            else
                            {
                                craft.Vert = false;
                                //craft.Craft = True;
                            }
                            if (dirName == "GLIDER")
                            {
                                craft.Uav    = false;
                                craft.Glider = true;
                                //craft.MM = False;
                            }
                            else if (dirName == "BPLA")
                            {
                                craft.Uav    = true;
                                craft.Glider = false;
                                //craft.MM = False;
                            }
                            else
                            {
                                craft.Uav    = false;
                                craft.Glider = false;
                                //craft.MM = True;
                            }

                            var k = su.IndexOf("<IMG SRC");
                            if (k < 0)
                            {
                                M.WriteLine($"Pic?: {file}");
                                ///!!!??? or continue???
                                continue;
                            }
                            var kk = su.IndexOf(".JPG", k);
                            var kl = su.IndexOf(".GIF", k);
                            if ((kk == 0) && (kl == 0))
                            {
                                M.WriteLine($"Pic??: {file}");
                                ///!!!??? or continue???
                                continue;
                            }
                            if ((kk > kl) || (kk < 0))
                            {
                                if (kl >= 0)
                                {
                                    kk = kl;
                                }
                            }
                            ss = s.Substring(k + 8, kk - k - 3);
                            ss = ss.Replace("\"", "");
                            k  = ss.ToUpper().IndexOf("/IMAGE/");
                            if (k < 0)
                            {
                                M.WriteLine($"Pic???: {file}");
                                ///!!!??? or continue???
                                continue;
                            }
                            ss = ss.Substring(k + 7);
                            ls.Add(ss);
                            lc.Add(ss);
                            lcc.Add("");
                            lct.Add("f");

                            i = s.IndexOf("Разработчик:");
                            if (i < 0)
                            {
                                M.WriteLine($"No construct: {file}");
                                continue;
                            }
                            TrimAll(i);
                            i = s.IndexOf("<");
                            TrimAll(i);
                            i     = su.IndexOf("</TR>");
                            sName = StrNoTags(s.Substring(0, i));
                            if (string.IsNullOrEmpty(sName))
                            {
                                M.WriteLine($"Bad construct: {file}");
                                continue;
                            }
                            craft.Construct = sName;
                            i = s.IndexOf("Страна:");
                            if (i < 0)
                            {
                                M.WriteLine($"No country: {file}");
                                continue;
                            }
                            TrimAll(i);
                            i = s.IndexOf("<");
                            TrimAll(i);
                            i     = su.IndexOf("</TR>");
                            sName = StrNoTags(s.Substring(0, i)).Trim();
                            if (string.IsNullOrEmpty(sName))
                            {
                                M.WriteLine($"Bad country: {file}");
                                continue;
                            }
                            if (sName.IndexOf(",") >= 0)
                            {
                                sName = "International";
                            }
                            if (sName.Length == 4)
                            {
                                if (sName[0] == sName[1] && sName[1] == sName[2])
                                {
                                    sName = "СССР";
                                }
                            }
                            if (sName.Length > 20)
                            {
                                M.WriteLine($"Too long country: {file}\n{sName}");
                                sName = sName.Substring(0, 20).Trim();
                            }
                            craft.Country = sName;
                            i             = s.IndexOf("Первый полет:");
                            if (i >= 0)
                            {
                                TrimAll(i);
                                i = s.IndexOf("<");
                                TrimAll(i);
                                i     = su.IndexOf("</TR>");
                                sName = StrNoTags(s.Substring(0, i));
                                if (!string.IsNullOrEmpty(sName))
                                {
                                    i = sName.IndexOf("?");
                                    if (i >= 0)
                                    {
                                        sName = sName.Substring(0, i);
                                        //FieldByName('YearBad').AsBoolean := True;
                                    }
                                    try
                                    {
                                        craft.IYear = int.Parse(sName);
                                    }
                                    catch { }
                                }
                            }
                            i = s.IndexOf("Тип:");
                            if (i < 0)
                            {
                                i = s.IndexOf("Type:");
                                if (i < 0)
                                {
                                    i = s.IndexOf("Тип :");
                                    if (i < 0)
                                    {
                                        i = s.IndexOf("Type :");
                                        if (i < 0)
                                        {
                                            M.WriteLine($"No type: {file}");
                                            //continue;
                                        }
                                    }
                                }
                            }
                            TrimAll(i);
                            i = s.IndexOf("<");
                            TrimAll(i);
                            i     = su.IndexOf("</TR>");
                            sName = StrNoTags(ClearString(s.Substring(0, i)));
                            if (string.IsNullOrEmpty(sName))
                            {
                                M.WriteLine($"Bad type: {file}");
                                //continue;
                            }
                            craft.Type = sName;
                            i          = su.IndexOf("<TABLE");
                            TrimAll(i);
                            i = su.IndexOf(">");
                            TrimAll(i + 1);
                            i = su.IndexOf("<TABLE");
                            TrimAll(i);
                            i = su.IndexOf(">");
                            TrimAll(i + 1);
                            i = su.IndexOf("<TABLE");
                            TrimAll(i);
                            i = su.IndexOf(">");
                            TrimAll(i + 1);
                            i = su.IndexOf("<TABLE");
                            if (i < 0)
                            {
                                M.WriteLine($"No text: {file}");
                                //continue;
                            }
                            text = DoWriteText(i);
                            while (true)
                            {
                                i     = su.IndexOf("<TABLE");
                                j     = su.IndexOf("</TABLE");
                                sName = su.Substring(0, j);
                                if (sName.IndexOf("TAB_CORNER_RIGHT.GIF") >= 0)
                                {
                                    break;
                                }
                                TrimAll(j);
                                i     = su.IndexOf("<TABLE");
                                text += DoWriteText(i);
                            }
                            while (i >= 0)
                            {
                                var finish = GetTable(0, M, file);
                                TrimAll(finish);
                                i = su.IndexOf("<TABLE", 0);
                            }
                            craft.CText = text;

                            ctx.Crafts.Add(craft);
                            ctx.SaveChanges();

                            for (i = 0; i < lc.Count; i++)
                            {
                                var pic = new Pics()
                                {
                                    //Source = "1"
                                    CraftId = craft.CraftId,
                                    ArtId   = artId,
                                    Path    = lc[i].Replace("/", "\\"),
                                    Type    = lct[i],
                                    NType   = Util.GetNType(lct[i])
                                };
                                ctx.Pics.Add(pic);
                                if (!string.IsNullOrEmpty(lcc[i]))
                                {
                                    pic.Text = WriteTextX(lcc[i]);
                                }
                                ctx.SaveChanges();
                            }
                            //MessageBox.Show("XXX!");
                            Util.DetachAllEntities(ctx);
                        }
                        catch (Exception e)
                        {
                            M.WriteLine($"Exception in {file}:\n{e.Message}");
                            //MessageBox.Show(file + "\n" + e.Message);
                        }
                    }
                }
            }
            _lInfo.Text = "";
            MessageBox.Show("OK!");
        }