public void FillData(BinaryReader binred, uint dataOffset, int dataSize, uint nameOffset, uint fileId)
        {
            binred.BaseStream.Position = nameOffset;
            fileName = Tools.ReadCharTillNull(binred);
            binred.BaseStream.Position = dataOffset;
            this.fileId = fileId;

            startPos = binred.BaseStream.Position;

            idk                 = binred.ReadUInt32();
            fileSize            = binred.ReadUInt32();
            idk2                = binred.ReadUInt32();
            idRangeCount        = binred.ReadUInt32();
            stringOffsetCount   = binred.ReadUInt32();
            idk3                = binred.ReadUInt32();
            stringOffsetsOffset = binred.ReadInt64();
            idk4                = binred.ReadUInt32();
            idk5                = binred.ReadUInt32();

            idRangesList = new List <FmgIdRange>();
            for (int i = 0; i < idRangeCount; i++)
            {
                FmgIdRange fid = new FmgIdRange();
                fid.offsetIndex = binred.ReadUInt32();
                fid.firstId     = binred.ReadUInt32();
                fid.lastId      = binred.ReadUInt32();
                fid.idk         = binred.ReadUInt32();
                fid.idCount     = fid.lastId - fid.firstId + 1;
                idRangesList.Add(fid);
            }

            binred.BaseStream.Position = startPos + stringOffsetsOffset;
            stringOffsetsArray         = new long[stringOffsetCount];
            for (int i = 0; i < stringOffsetCount; i++)
            {
                stringOffsetsArray[i] = binred.ReadInt64();
            }

            linesList = new List <FmgString>();
            foreach (FmgIdRange idRange in idRangesList)
            {
                for (int i = 0; i < idRange.idCount; i++)
                {
                    binred.BaseStream.Position = startPos + stringOffsetsArray[idRange.offsetIndex + i];
                    FmgString line = new FmgString();
                    line.id          = (uint)(idRange.firstId + i);
                    line.str         = Tools.ReadCharTillNull(binred);
                    line.firstorLast = 0;
                    if (i == 0)
                    {
                        line.firstorLast = 1;
                    }
                    else if (i == idRange.idCount - 1)
                    {
                        line.firstorLast = -1;
                    }
                    linesList.Add(line);
                }
            }
        }
示例#2
0
        public void Create(FmgFile[] fmgArray, string where)
        {
            ExcelPackage   pck = new ExcelPackage(File.Open(where, FileMode.Create));
            ExcelWorksheet ws  = pck.Workbook.Worksheets.Add("Satirlar");

            ws.Cells["A1"].Value = "Orjinal Satır";
            ws.Cells["B1"].Value = "Türkçe Satır";
            ws.Cells["C1"].Value = "ID";
            ws.Cells["D1"].Value = "FOL";
            ws.Cells["E1"].Value = "File";
            ws.Cells["F1"].Value = "FileID";
            ws.Cells["A1:F1"].Style.Font.Bold = true;

            int col = 2;

            foreach (FmgFile fmg in fmgArray)
            {
                for (int i = 0; i < fmg.linesList.Count; i++)
                {
                    FmgString str             = fmg.linesList[i];
                    string    removedSpecials = str.str.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\\t");
                    ws.Cells["A" + col].Value = removedSpecials;
                    ws.Cells["C" + col].Value = str.id;
                    ws.Cells["D" + col].Value = str.firstorLast;
                    ws.Cells["E" + col].Value = fmg.fileName;
                    ws.Cells["F" + col].Value = fmg.fileId;
                    col++;
                }
            }

            Console.Write(".");
            pck.Save();
            pck.Dispose();
        }
示例#3
0
        public void Parse()
        {
            string[] allLines = File.ReadAllLines(filePath);

            TextBlock curBlock;
            int       i = 0;

            while (i < allLines.Length)
            {
                if (allLines[i].Contains(@"N:\FDP\"))
                {
                    curBlock = new TextBlock();
                    int idComaPos = allLines[i].IndexOf(",");
                    curBlock.fileId   = int.Parse(allLines[i].Substring(0, idComaPos));
                    curBlock.pathName = allLines[i].Substring(idComaPos + 1) + "\0";
                    i++;
                    while (i < allLines.Length && allLines[i] != "")
                    {
                        string    lin         = allLines[i];
                        int       idPos       = lin.IndexOf(',');
                        int       foLPos      = lin.IndexOf(',', idPos + 1);
                        int       id          = int.Parse(lin.Substring(0, idPos));
                        int       firstOrLast = int.Parse(lin.Substring(idPos + 1, foLPos - idPos - 1));
                        string    str         = lin.Substring(foLPos + 1);
                        FmgString fmgstr      = new FmgString();
                        fmgstr.id          = (uint)id;
                        fmgstr.str         = str.Replace("\\n", "\n").Replace("\\r", "\r").Replace("\\t", "\t") + "\0";
                        fmgstr.firstorLast = firstOrLast;
                        curBlock.lines.Add(fmgstr);
                        i++;
                    }
                    blocks.Add(curBlock);
                    FmgIdRange idrange = new FmgIdRange();
                    int        k       = 0;
                    while (k < curBlock.lines.Count)
                    {
                        if (curBlock.lines[k].firstorLast == 1)
                        {
                            idrange             = new FmgIdRange();
                            idrange.firstId     = curBlock.lines[k].id;
                            idrange.offsetIndex = (uint)k;
                            while (k + 1 < curBlock.lines.Count && curBlock.lines[k + 1].firstorLast < 1)
                            {
                                k++;
                            }
                            idrange.lastId = curBlock.lines[k].id;
                            curBlock.idRanges.Add(idrange);
                        }
                        k++;
                    }
                }
                i++;
            }
        }
示例#4
0
        public void Create(FmgFile[] fmgArray)
        {
            //yazdır
            StringBuilder allLines = new StringBuilder();

            foreach (FmgFile fmg in fmgArray)
            {
                allLines.AppendLine(fmg.fileId + "," + fmg.fileName);
                for (int i = 0; i < fmg.linesList.Count; i++)
                {
                    FmgString str             = fmg.linesList[i];
                    string    removedSpecials = str.str.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\\t");
                    allLines.AppendLine(str.id + "," + str.firstorLast + "," + removedSpecials);
                }
                allLines.AppendLine();
                allLines.AppendLine();
            }

            File.WriteAllText(filePath + ".txt", allLines.ToString());
        }
示例#5
0
        public void Read(string where)
        {
            excelPath = where;
            ExcelPackage   pck = new ExcelPackage(File.Open(where, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
            ExcelWorksheet ws  = pck.Workbook.Worksheets["Satirlar"];

            Dictionary <string, FmgFile> fmgDic = new Dictionary <string, FmgFile>();

            for (int col = 2; col < ws.Dimension.Rows; col++)
            {
                string orgStr   = Tools.HandleCellValue(ws.Cells["A" + col].Value);
                string trStr    = Tools.HandleCellValue(ws.Cells["B" + col].Value);
                uint   id       = uint.Parse(ws.Cells["C" + col].Value.ToString());
                int    fol      = int.Parse(ws.Cells["D" + col].Value.ToString());
                string fileName = ws.Cells["E" + col].Value.ToString();
                uint   fileId   = uint.Parse(ws.Cells["F" + col].Value.ToString());


                if (!fmgDic.ContainsKey(fileName))
                {
                    FmgFile fmgFile = new FmgFile();
                    fmgFile.fileName = fileName + "\0";
                    fmgFile.fileId   = fileId;
                    fmgDic.Add(fileName, fmgFile);
                }

                FmgString fmgStr      = new FmgString();
                string    selectedStr = trStr;
                if (trStr == null || trStr == "")
                {
                    selectedStr = orgStr;
                }

                selectedStr        = selectedStr.Replace("\\n", "\n").Replace("\\r", "\r").Replace("\\t", "\t") + "\0";
                fmgStr.str         = selectedStr;
                fmgStr.id          = id;
                fmgStr.firstorLast = fol;
                fmgDic[fileName].linesList.Add(fmgStr);
            }
            fmgBlocks = fmgDic.Values.ToList();

            foreach (var fmg in fmgBlocks)
            {
                FmgIdRange idrange;
                for (int i = 0; i < fmg.linesList.Count; i++)
                {
                    FmgString fstr = fmg.linesList[i];
                    if (fstr.firstorLast == 1)
                    {
                        idrange             = new FmgIdRange();
                        idrange.firstId     = fstr.id;
                        idrange.offsetIndex = (uint)i;
                        idrange.lastId      = fstr.id;
                        fmg.idRangesList.Add(idrange);
                    }
                    else if (fstr.firstorLast == -1)
                    {
                        fmg.idRangesList.Last().lastId = fstr.id;
                    }
                }
            }

            Console.Write(".");
        }