コード例 #1
0
        //打开一个网口,成功则返回一个可用Socket,失败返回null。Port一般指定为9100
        public static Socket CMNCT_OpenLan(String ipAddress, int Port)
        {
            Regex rx = new Regex(@"((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))");

            if (!rx.IsMatch(ipAddress))
            {
                MessageBox.Show("非法IP。请注意格式形如xxx.xxx.xxx.xxx的字符串才是有效ip地址");
                return(null);
            }
            IPAddress  ipPrinter      = IPAddress.Parse(ipAddress);
            IPEndPoint ipPrinterPoint = new IPEndPoint(ipPrinter, Port);

            if (CmnctSk == null)
            {
                CmnctSk = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                try
                {
                    CmnctSk.Connect(ipPrinterPoint);
                    if (!CmnctSk.Connected)
                    {
                        throw new Exception("连接失败!");
                    }
                    //载入Init资源
                    //TEXTANDPIC.TAC_Init();
                }
                catch (Exception Mistake)
                {
                    MessageBox.Show(Mistake.ToString());
                    CMNCT_CloseLan();
                }
            }
            return(CmnctSk);
        }
コード例 #2
0
 //下面就要发送数据。将二进制字节数组发送到已打开的端口
 public static Boolean CMNCT_Send(byte[] bArrayCommand)
 {
     try
     {
         if (CmnctSk != null)
         {
             CmnctSk.Send(bArrayCommand);
         }
         else if (CmnctSp != null)
         {
             CmnctSp.Write(bArrayCommand, 0, bArrayCommand.Length);
         }
         else if (CmnctUc != null)
         {
             CmnctUc.Write(bArrayCommand);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception Mistake)
     {
         MessageBox.Show(Mistake.ToString());
         return(false);
     }
     return(true);
 }
コード例 #3
0
        public IEnumerable <Source> GetMistakeSources(Mistake mistake)
        {
            var mistakesSources = _repository.Find(r => r.MistakeId == mistake.Id);

            List <int> sourceIds = mistakesSources.Select(x => x.SourceId).ToList();

            var sources = _sourceRepository.Find(x => sourceIds.Contains(x.Id));

            return(sources.ToList());
        }
コード例 #4
0
        public IActionResult Index()
        {
            var Mistake = new Mistake
            {
                MistaceOrigin = null,
                MistaceChange = null
            };

            return(View(Mistake));
        }
コード例 #5
0
        public void Delete(int id)
        {
            Mistake t = _context.Mistakes.Find(id);

            if (t != null)
            {
                _context.GeneralCritereaImpacts.RemoveRange(_context.GeneralCritereaImpacts.Where(x => x.MistakeID == id));
                _context.Mistakes.Remove(t);
                _context.SaveChanges();
            }
        }
コード例 #6
0
        public Mistake Create(Mistake newObject)
        {
            if (_context.Anwsers.Find(newObject.AnwserID) == null)
            {
                throw new AppException("Parrent anwser " + newObject.AnwserID + " does not exist");
            }

            _context.Mistakes.Add(newObject);
            _context.SaveChanges();

            return(_context.Mistakes.Last(x => x.AnwserID == newObject.AnwserID));
        }
コード例 #7
0
        public async Task <IActionResult> Details([FromForm] MistakeViewModel mistakeVM)
        {
            if (RouteData != null)
            {
                _tenant = (Tenant)RouteData.Values.SingleOrDefault(r => r.Key == "tenant").Value;
            }
            if (ModelState.IsValid)
            {
                var existing = _mistakeRepository.GetMistakeById(mistakeVM.MistakeId);

                var mistake = new Mistake();
                mistake.MistakeId         = mistakeVM.MistakeId;
                mistake.Description       = mistakeVM.Description;
                mistake.ManualType        = mistakeVM.ManualType;
                mistake.Name              = mistakeVM.Name;
                mistake.Status            = mistakeVM.Status;
                mistake.MistakeCategoryID = mistakeVM.SelectedMistakeCategoryId;

                if (mistakeVM.Image != null && mistakeVM.Image.Length != 0)
                {
                    if (existing.ImageUrl != mistakeVM.Image.GetFilename())
                    {
                        if (existing.ImageUrl != null)
                        {
                            var existingImagePath = Path.Combine(
                                Directory.GetCurrentDirectory(), "wwwroot\\ErrorImages" + "\\" + _tenant?.HostName, existing.ImageUrl);
                            Remove(existingImagePath);
                        }
                        var path = Path.Combine(
                            Directory.GetCurrentDirectory(), "wwwroot\\ErrorImages" + "\\" + _tenant?.HostName, mistakeVM.Image.GetFilename());

                        using (var stream = new FileStream(path, FileMode.Create))
                        {
                            await mistakeVM.Image.CopyToAsync(stream);
                        }

                        mistake.ImageUrl = mistakeVM.Image.GetFilename();
                    }
                    else
                    {
                        mistake.ImageUrl = mistakeVM.ImageUrl;
                    }
                }
                _mistakeRepository.UpdateMistake(mistake);
                mistakeVM.DateRegister = existing.DateRegister;
                mistakeVM.ImageUrl     = mistake.ImageUrl;
                ViewBag.message        = "Success";
                return(RedirectToAction("Index"));
            }

            ViewBag.Current = "MistakeList";
            return(View(mistakeVM));
        }
コード例 #8
0
        public void CreateMistake(Mistake mistake)
        {
            var existingmistake = _appDbContext.Mistakes.FirstOrDefault(x => x.Name == mistake.Name);

            if (existingmistake == null)
            {
                mistake.DateRegister = DateTime.Now;

                _appDbContext.Mistakes.Add(mistake);

                _appDbContext.SaveChanges();
            }
        }
コード例 #9
0
 //异步发送
 public static Boolean CMNCT_SendByNewThread(byte[] bArrayCommand)
 {
     try
     {
         System.Threading.Thread trWrite = new Thread(new ParameterizedThreadStart(CMNCT_TRStart));
         trWrite.Start(bArrayCommand);
         return(true);
     }
     catch (Exception Mistake)
     {
         MessageBox.Show(Mistake.ToString());
         return(false);
     }
 }
コード例 #10
0
 //可以是绝对路径或相对路径
 public static Boolean CMNCT_Send(String sBinaryFilePath)
 {
     try
     {
         if (CmnctSk != null)
         {
             CmnctSk.SendFile(sBinaryFilePath);
         }
         else if (CmnctSp != null)
         {
             System.IO.FileStream fileStream = new System.IO.FileStream(sBinaryFilePath, System.IO.FileMode.Open);
             byte[] dataToSend = new byte[fileStream.Length];
             if (dataToSend.Length > Int32.MaxValue)
             {
                 MessageBox.Show("数据超长");
                 fileStream.Close();
                 return(false);
             }
             fileStream.Read(dataToSend, 0, (int)fileStream.Length);
             CmnctSp.Write(dataToSend, 0, dataToSend.Length);
             fileStream.Close();
         }
         else if (CmnctUc != null)
         {
             System.IO.FileStream fileStream = new System.IO.FileStream(sBinaryFilePath, System.IO.FileMode.Open);
             byte[] dataToSend = new byte[fileStream.Length];
             if (dataToSend.Length > Int32.MaxValue)
             {
                 MessageBox.Show("数据超长");
                 fileStream.Close();
                 return(false);
             }
             fileStream.Read(dataToSend, 0, (int)fileStream.Length);
             CmnctUc.Write(dataToSend);
             fileStream.Close();
         }
         else
         {
             return(false);
         }
     }
     catch (Exception Mistake)
     {
         MessageBox.Show(Mistake.ToString());
         return(false);
     }
     return(true);
 }
コード例 #11
0
        public async Task <IActionResult> Create([FromForm] MistakeViewModel mistakeVM)
        {
            if (RouteData != null)
            {
                _tenant = (Tenant)RouteData.Values.SingleOrDefault(r => r.Key == "tenant").Value;
            }

            if (ModelState.IsValid)
            {
                var mistake = new Mistake();
                mistake.Description       = mistakeVM.Description;
                mistake.ManualType        = mistakeVM.ManualType;
                mistake.Name              = mistakeVM.Name;
                mistake.Status            = mistakeVM.Status;
                mistake.MistakeCategoryID = mistakeVM.SelectedMistakeCategoryId;

                if (mistakeVM.Image != null && mistakeVM.Image.Length != 0)
                {
                    var path = Path.Combine(
                        Directory.GetCurrentDirectory(), "wwwroot\\ErrorImages" + "\\" + _tenant?.HostName, mistakeVM.Image.GetFilename());

                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        await mistakeVM.Image.CopyToAsync(stream);
                    }

                    try
                    {
                        var image = new Bitmap(System.Drawing.Image.FromFile(path));
                        mistake.ImageUrl   = mistakeVM.Image.GetFilename();
                        mistakeVM.ImageUrl = mistakeVM.Image.GetFilename();
                    }
                    catch (Exception ex)
                    {
                        var e = ex;
                        Remove(path);
                        ModelState.AddModelError("", "Please update picture with *.jpg or *.png");
                        return(View(mistakeVM));
                    }
                }

                _mistakeRepository.CreateMistake(mistake);
                ViewBag.message = "Success";
                return(RedirectToAction("Index"));
            }
            return(View(mistakeVM));
        }
コード例 #12
0
        public Mistake Update(Mistake updatedObject)
        {
            Mistake t = _context.Mistakes.Find(updatedObject.ID);

            if (t == null)
            {
                throw new AppException("Mistake " + updatedObject.ID + " not found");
            }

            /*copy properties here*/
            t.AdjustedWeight = updatedObject.AdjustedWeight;

            _context.Mistakes.Update(t);
            _context.SaveChanges();

            return(t);
        }
コード例 #13
0
        public void UpdateMistake(Mistake mistake)
        {
            var existing = _appDbContext.Mistakes.FirstOrDefault(x => x.MistakeId == mistake.MistakeId);

            if (existing != null)
            {
                existing.Description       = mistake.Description;
                existing.ManualType        = mistake.ManualType;
                existing.Name              = mistake.Name;
                existing.Status            = mistake.Status;
                existing.ImageUrl          = mistake.ImageUrl == null ? existing.ImageUrl : mistake.ImageUrl;
                existing.MistakeCategoryID = mistake.MistakeCategoryID;

                _appDbContext.Mistakes.Update(existing);
                _appDbContext.SaveChanges();
            }
        }
コード例 #14
0
ファイル: TEXTANDPIC.cs プロジェクト: aircross/vs-projects
        //当前窗口上指定相对坐标,指定范围,转为点阵数据。
        public static byte[][] TAC_TurnAreaToPixData(Form fmImaNoScreen, int nPositionX, int nPositionY, int nAreaWidth, int nAreaHeight)
        {
            byte[][] tempDesData = new byte[nAreaHeight][];
            for (int i = 0; i < nAreaHeight; i++)
            {
                tempDesData[i] = new byte[nAreaWidth];
            }
            try
            {
                Bitmap bmpForm = new Bitmap(fmImaNoScreen.Width, fmImaNoScreen.Height);
                fmImaNoScreen.DrawToBitmap(bmpForm, new Rectangle(0, 0, bmpForm.Width, bmpForm.Height));
                Bitmap    bmpDes   = new Bitmap(nAreaWidth, nAreaHeight);
                Graphics  grpForm  = Graphics.FromImage(bmpDes);
                int       Border   = (fmImaNoScreen.Width - fmImaNoScreen.ClientSize.Width) / 2;
                Rectangle destRect = new Rectangle(nPositionX + Border,
                                                   nPositionY + fmImaNoScreen.Height - fmImaNoScreen.ClientSize.Height - Border,
                                                   nAreaWidth, nAreaHeight);
                Rectangle srcRect = new Rectangle(0, 0, nAreaWidth, nAreaHeight);
                grpForm.DrawImage(bmpForm, srcRect, destRect, GraphicsUnit.Pixel);

                System.Drawing.Imaging.BitmapData tempBitmapData = bmpDes.LockBits(srcRect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

                fmImaNoScreen.Enabled = false;
                unsafe
                {
                    byte *tempPixelData = (byte *)tempBitmapData.Scan0.ToPointer();
                    int   jump          = tempBitmapData.Stride - nAreaWidth * 3;
                    for (int i = 0; i < nAreaHeight; i++)
                    {
                        for (int j = 0; j < nAreaWidth; j++)
                        {
                            tempDesData[i][j] = TAC_IsBlack(*tempPixelData ^ 0xff, *(tempPixelData + 1) ^ 0xff, *(tempPixelData + 2) ^ 0xff, 1);
                            tempPixelData    += 3;
                        }
                        tempPixelData += jump;
                    }
                }
                fmImaNoScreen.Enabled = true;
            }
            catch (Exception Mistake)
            {
                MessageBox.Show(Mistake.ToString());
                return(null);
            }
            return(tempDesData);
        }
コード例 #15
0
        public IActionResult Create([FromBody] MistakeCreateDto mistakeDto)
        {
            // map dto to entity and set id
            Mistake c = _mapper.Map <Mistake>(mistakeDto);

            try
            {
                // save
                c = _mistakeService.Create(c);
                return(Ok(_mapper.Map <MistakeDto>(c)));
            }
            catch (AppException ex)
            {
                // return error message if there was an exception
                return(BadRequest(ex.Message));
            }
        }
コード例 #16
0
 //打开一个串口
 public static SerialPort CMNCT_OpenCom(String sComName, int nBaudrate, int nDataBits, float nStopBits, int nParity)
 {
     try
     {
         StopBits[] intToStopBits = { StopBits.One, StopBits.OnePointFive, StopBits.Two };
         Parity[]   intToParity   = { Parity.None, Parity.Odd, Parity.Even };
         CmnctSp = new SerialPort(sComName, nBaudrate, intToParity[nParity], nDataBits, intToStopBits[(int)(nStopBits * 2 - 2)]);
         CmnctSp.Open();
         //载入Init资源
         //TEXTANDPIC.TAC_Init();
     }
     catch (Exception Mistake)
     {
         MessageBox.Show(Mistake.ToString());
         CMNCT_CloseCom();
     }
     return(CmnctSp);
 }
コード例 #17
0
        public GeneralCritereaImpact Create(GeneralCritereaImpact newObject)
        {
            if (newObject.MistakeID < 0)
            {
                Mistake m = _context.Mistakes.First(x => x.AnwserID == newObject.AnwserID && x.ArgumentID == (newObject.MistakeID * -1));
                if (m == null)
                {
                    throw new AppException("When inserting general criteria the realted mistake was not found");
                }
                newObject.MistakeID = m.ID;
            }


            _context.GeneralCritereaImpacts.Add(newObject);
            _context.SaveChanges();

            return(_context.GeneralCritereaImpacts.Last());
        }
コード例 #18
0
 private static void FixSubmission(Tuple <ProgramNode, Models.Transformation> transformationTuple, int experiementId, int questionId,
                                   Tuple <Submission, State> submission)
 {
     try
     {
         if (!submission.Item1.IsFixed)
         {
             var manager = new TestManager();
             var mistake = new Mistake();
             mistake.before = submission.Item1.Code;
             var fixer     = new SubmissionFixer();
             var unparser  = new Unparser();
             var fixedCode = fixer.TryFix(manager.GetTests(questionId), transformationTuple.Item1, submission.Item2, unparser);
             if (fixedCode != null)
             {
                 var refazerDb2 = new RefazerDbContext();
                 submission.Item1.IsFixed = true;
                 var updatedSub = refazerDb2.Submissions.SingleOrDefault(e => e.ID == submission.Item1.ID);
                 if (updatedSub != null)
                 {
                     updatedSub.IsFixed = true;
                 }
                 var trans = refazerDb2.Transformations.First(x => x.ID == transformationTuple.Item2.ID);
                 var fix   = new Fix()
                 {
                     FixedCode      = fixedCode,
                     SessionId      = experiementId,
                     SubmissionId   = submission.Item1.SubmissionId,
                     QuestionId     = questionId,
                     Transformation = trans
                 };
                 refazerDb2.Fixes.Add(fix);
                 refazerDb2.SaveChanges();
                 Trace.TraceWarning(string.Format("Submission fixed: {0}, Session: {1}, Transformation: {2}, Time: {3}",
                                                  submission.Item1.SubmissionId, transformationTuple.Item2.SessionId, transformationTuple.Item2.ID, DateTime.Now));
             }
         }
     }
     catch (Exception e)
     {
         Trace.TraceError("Exception was thrown when applying fixes.");
         Trace.TraceError(e.Message);
     }
 }
コード例 #19
0
ファイル: TEXTANDPIC.cs プロジェクト: aircross/vs-projects
        //将图片转成点阵数据
        public static byte[][] TAC_TurnPicToPixData(String sFilePath)
        {
            try
            {
                Bitmap    bmp       = new Bitmap(sFilePath);
                int       widthPix  = bmp.Width;
                int       heightPix = bmp.Height;
                Rectangle rct       = new Rectangle(0, 0, widthPix, heightPix);
                System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(rct, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppRgb);

                //先将像素复制出来
                byte[][] bmpBitData = new byte[heightPix][];
                unsafe
                {
                    byte * pBmpData = (byte *)bmpData.Scan0;
                    double gray     = 0;

                    for (int i = 0; i < heightPix; i++)
                    {
                        bmpBitData[i] = new byte[widthPix];
                        for (int j = 0; j < widthPix; j++)
                        {
                            gray = *(pBmpData + 1) * 0.3 + *(pBmpData + 2) * 0.59 + *(pBmpData + 3) * 0.11;
                            if (gray < 128)
                            {
                                bmpBitData[i][j] = 0xfe;
                            }
                            else
                            {
                                bmpBitData[i][j] = 0x00;
                            }
                            pBmpData += 4;
                        }
                        pBmpData += bmpData.Stride - bmpData.Width * 4;
                    }
                }
                return(bmpBitData);
            }
            catch (Exception Mistake)
            {
                MessageBox.Show(Mistake.ToString());
                return(null);
            }
        }
コード例 #20
0
        private static int index = 1;                              //线程序号
        private static void CMNCT_TRStart(Object obArrayCommand)
        {
            int nWatashiNoIndex = index++; //只要start了,index就要+1

            boIsComplete[0] = true;        //如果是第一个线程,那么就将添加0号线程为已完成
            try
            {
                while (true)
                {
                    if (boIsComplete[nWatashiNoIndex - 1])
                    {
                        byte[] bArrayCommand = (byte[])obArrayCommand;
                        if (CmnctSk != null)
                        {
                            CmnctSk.Send(bArrayCommand);
                            boIsComplete[nWatashiNoIndex] = true;
                            return;
                        }
                        else if (CmnctSp != null)
                        {
                            CmnctSp.Write(bArrayCommand, 0, bArrayCommand.Length);
                            boIsComplete[nWatashiNoIndex] = true;
                            return;
                        }
                        else
                        {
                            throw (new Exception("未将对象设置引用到对象实例?"));
                        }
                    }
                }
            }
            catch (Exception Mistake)
            {
                MessageBox.Show(Mistake.ToString());
                boIsComplete[nWatashiNoIndex] = true;
            }
        }
コード例 #21
0
ファイル: Pos.cs プロジェクト: aircross/vs-projects
        /* 将位图转换为256色光栅位图流数据 */
        /* byte[height][width] */
        public static byte[][] POS_BitmapToStream(Bitmap orgBitmap)
        {
            try
            {
                int       widthPix  = orgBitmap.Width;
                int       heightPix = orgBitmap.Height;
                Rectangle rct       = new Rectangle(0, 0, widthPix, heightPix);
                System.Drawing.Imaging.BitmapData bmpData = orgBitmap.LockBits(rct, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppRgb);

                //先将像素复制出来
                byte[][] bmpBitData = new byte[heightPix][];
                unsafe
                {
                    byte * pBmpData = (byte *)bmpData.Scan0;
                    double gray     = 0;

                    for (int i = 0; i < heightPix; i++)
                    {
                        bmpBitData[i] = new byte[widthPix];
                        for (int j = 0; j < widthPix; j++)
                        {
                            gray             = *(pBmpData + 1) * 0.3 + *(pBmpData + 2) * 0.59 + *(pBmpData + 3) * 0.11;
                            bmpBitData[i][j] = (byte)gray;
                            pBmpData        += 4;
                        }
                        pBmpData += bmpData.Stride - bmpData.Width * 4;
                    }
                }
                orgBitmap.UnlockBits(bmpData);
                return(bmpBitData);
            }
            catch (Exception Mistake)
            {
                lasterror = Mistake.ToString();
                return(null);
            }
        }
コード例 #22
0
        public Anwser Update(Anwser updatedObject)
        {
            Anwser t = _context.Anwsers.Find(updatedObject.ID);

            if (t == null)
            {
                throw new AppException("Anwser " + updatedObject.ID + " not found");
            }

            _context.Mistakes.RemoveRange(_context.Mistakes.Where(x => x.AnwserID == updatedObject.ID));
            _context.GeneralCritereaImpacts.RemoveRange(_context.GeneralCritereaImpacts.Where(x => x.AnwserID == updatedObject.ID && x.MistakeID != null));
            _context.SaveChanges();

            /*copy properties here*/
            Question q   = _context.Questions.Find(t.QuestionID);
            float    max = (float)q.Max;

            //List<Mistake> list = _context.Mistakes.Where(x => x.AnwserID == t.ID).ToList();
            t.Adjustment = updatedObject.Adjustment;
            t.Total      = max;


            foreach (Mistake item in updatedObject.Mistakes)
            {
                Mistake temp = new Mistake()
                {
                    AnwserID = t.ID, ArgumentID = item.ArgumentID, AdjustedWeight = item.AdjustedWeight
                };
                _context.Mistakes.Add(temp);
                _context.SaveChanges();
                temp = _context.Mistakes.Last(x => x.AnwserID == t.ID);

                foreach (ArgumentCriterea ac in _context.ArgumentCritereas.Where(x => x.ArgumentID == item.ArgumentID))
                {
                    GeneralCritereaImpact tempgc = new GeneralCritereaImpact()
                    {
                        ExamAttemptID = t.ExamAttemptID, AnwserID = t.ID, MistakeID = temp.ID, ExamCritereaID = ac.ExamCritereaID, Weight = ac.Severity
                    };
                    _context.GeneralCritereaImpacts.Add(tempgc);
                }

                t.Total += item.AdjustedWeight;
                _context.SaveChanges();
            }

            if (t.Total + t.Adjustment > max)
            {
                t.Adjustment = max - t.Total;
                t.Total      = max;
            }
            else
            {
                t.Total += (float)t.Adjustment;
            }

            t.FinalTotal     = updatedObject.FinalTotal;
            t.CensorshipDate = DateTime.Now;
            t.Note           = updatedObject.Note;

            t.Completion = updatedObject.Completion;

            _context.Anwsers.Update(t);
            _context.SaveChanges();

            return(t);
        }
コード例 #23
0
        public IActionResult Index(Text texts)
        {
            ////////////////////////////////////////////////////////ORIGINAL

            List <TextRow>  _items     = new List <TextRow>();
            List <TextWord> _itemsWord = new List <TextWord>();

            List <TextRow>  _itemsCH     = new List <TextRow>();
            List <TextWord> _itemsWordCH = new List <TextWord>();


            string[] stringSeparators = new string[] { "\r\n", " " };

            string[] textsOneRow = texts.stringOne.Split(new string[] { stringSeparators[0] }, StringSplitOptions.None);
            string[] textsTwoRow = texts.stringTwo.Split(new string[] { stringSeparators[0] }, StringSplitOptions.None);

            //string[,] text1 = new string[,]
            //{
            //    {"რომელმან შექმნა სამყარო ძალითა მით ძლიერითა," },
            //    {"ზეგარდმოთ არსნი სულითა ყვნა ზეცით მონაბერითა," },
            //    {"ჩვენ, კაცთა, მოგვცა ქვეყანა, გვაქვს უთვალავი ფერითა," },
            //    {"მისგან არს ყოვლი ხელმწიფე სახითა მის მიერითა" }

            //};

            //string[,,] text1Split = new string[,,]
            //{
            //    {{"რომელმან" }, {"შექმნა" },{"სამყარო" },{"მით" },{"ძლიერითა" },{"მით" },{"ჩამატებული" }},
            //    {{"ზეგარდმოთ" }, {"არსნი" },{"სულითა" },{"ყვნა" },{"ზეცით" },{"მონაბერითა" },{"ჩამატებული" }},
            //    {{"ჩვენ" },{"კაცთა" },{"მოგვცა" },{"ქვეყანა" },{"გვაქვს" },{"უთვალავი" },{"ფერითა"}},
            //    {{"მისგან" }, {"არს" },{"ყოვლი" },{"ხელმწიფე" },{"სახითა" },{"მის" },{"მიერითა" }}

            //};
            //string[][] jaggedArray3 =
            //{
            //    new string[]{  "რომელმან შექმნა სამყარო ძალითა მით ძლიერითა,",  "რომელმან", "შექმნა", "სამყარო", "ძალითა", "მით", "ძლიერითა" },
            //    new string[]{  "ზეგარდმოთ არსნი სულითა ყვნა ზეცით მონაბერითა," , "ზეგარდმოთ" , "არსნი" ,"სულითა" ,"ყვნა" ,"ზეცით" ,"მონაბერითა" },
            //    new string[]{  "ჩვენ, კაცთა, მოგვცა ქვეყანა, გვაქვს უთვალავი ფერითა," ,  "ჩვენ" ,  "კაცთა" ,  "მოგვცა" , "ქვეყანა" ,  "გვაქვს" ,  "უთვალავი" ,  "ფერითა"  },
            //    new string[]{  "მისგან არს ყოვლი ხელმწიფე სახითა მის მიერითა" , "მისგან" ,  "არს" ,  "ყოვლი" ,  "ხელმწიფე" ,  "სახითა" ,  "მის" ,  "მიერითა"  }

            //};
            //string[,] jaggedText = new string[,] { };

            //for (int i = 0; i < textsOneRow.Length; i++)
            //{
            //    string[] SplitRowW = textsOneRow[i].Split(stringSeparators, StringSplitOptions.None);
            //    for (int j = 0; j < SplitRowW.Length; j++)
            //    {
            //        string[,] jaggedText1 =   new string[,] {{ textsOneRow[i], SplitRowW[j] } };
            //        jaggedText[i, 0] = textsOneRow[i];
            //        jaggedText += jaggedText1;



            //    }
            //}


            //List<Result> _result = new List<Result>();

            //try
            //{
            //for (int i = 0; i < 50; i++)
            //{
            //    string[] SplitRow = new string[] { };
            //    string[] SplitRowCH = new string[] { };
            //_items.Add(new TextRow { RowId = i, RowText = textsOneRow[i] });
            //if (textsOneRow[i].Count() < textsTwoRow[i].Count())
            //{

            //    SplitRowCH = textsTwoRow[i].Split(stringSeparators, StringSplitOptions.None);
            //    Array.Resize(ref textsOneRow, textsOneRow.Length + 1);
            //    textsOneRow[textsOneRow.Length - 1] = "new string new string new string new string new string new string new string";

            //}
            //else
            //{
            //SplitRow = textsOneRow[i].Split(stringSeparators, StringSplitOptions.None);
            //SplitRowCH = textsTwoRow[i].Split(stringSeparators, StringSplitOptions.None);

            //}

            //for (int j = 0; j < 50; j++)
            //{

            //if (SplitRow.Count() < SplitRowCH.Count())
            //{
            //    _result.Add(new Result
            //    {
            //        RowId = i,
            //        RowTextOr = textsOneRow[i].Length > 0 ? textsOneRow[i] : "jj",
            //        RowTextCh = textsTwoRow[i],
            //        WordId = j,
            //        WordOr = textsOneRow[i].Length > j ? SplitRow[j] : "<<WordOr",
            //        WordCh = textsTwoRow[i].Length > j ? SplitRowCH[j] : "<<WordCh",
            //        Status = "wrong",
            //    });
            //    k++;
            //}
            //else if (SplitRow.Count() > SplitRowCH.Count())
            //{

            //    _result.Add(new Result
            //    {
            //        RowId = i,
            //        RowTextOr = textsOneRow[i].Length > 0 ? textsOneRow[i] : "jj",
            //        RowTextCh = textsTwoRow[i],
            //        WordId = j,
            //        WordOr = textsOneRow[i].Length > j ? SplitRow[j] : "WordOr>>",
            //        WordCh = textsTwoRow[i].Length > j ? SplitRowCH[j] : "WordCh>>",
            //        Status = "wrong",
            //    });


            //}
            //else {

            //_result.Add(new Result
            //    {
            //        RowId = i,
            //        RowTextOr = textsOneRow[i].Length > 0 ? textsOneRow[i] : "jj",
            //        RowTextCh = textsTwoRow[i],
            //        WordId = j,
            //        WordOr = textsOneRow[i].Length > j ? SplitRow[j] : "jj",
            //        WordCh = SplitRowCH[j],
            //        Status = SplitRowCH[j] == SplitRow[j] ? "correct" : "wrong",
            //    });


            //}
            //}
            //}

            //}
            //catch (System.IndexOutOfRangeException ex)
            //{
            //    string input1 = "";
            //}
            //gansazgvre udidesi
            //for (int i = 0; i < textsTwoRow.Length; i++)
            //{
            //    _itemsCH.Add(new TextRow { RowId = i, RowText = textsTwoRow[i] });
            //    string[] SplitRowCH = textsTwoRow[i].Split(stringSeparators, StringSplitOptions.None);
            //    for (int j = 0; j < SplitRowCH.Length; j++)
            //    {
            //        _itemsWordCH.Add(new TextWord { WordId = j, RowText = SplitRowCH[j], RowIdFR = i });
            //    }
            //}
            //for (int i = 0; i < _itemsCH.Count(); i++)
            //{

            //    string[] split = _itemsCH[i].RowText.Split(stringSeparators, StringSplitOptions.None);
            //    for (int j = 0; j < split.Length; j++)
            //    {

            //        _result.Add(new Result
            //        {
            //            RowId = i,
            //            RowTextOr = _items[i].RowText,
            //            RowTextCh = _itemsCH[i].RowText,
            //            WordId = j,
            //            WordOr = _itemsWord[j].RowText,
            //            WordCh = _itemsWordCH[j].RowText,
            //            Status = _itemsWord[j].RowText == _itemsWordCH[j].RowText ? "correct" : "wrong",
            //        });
            //    }

            //}
            ////////////////////////////////////////////////////////////////////////////
            //var query =
            //           from itemRow in _items
            //           join itemword in _itemsWord on itemRow.RowId equals itemword.RowIdFR
            //           //where post.ID == id
            //           select new {
            //                       RowId =itemRow.RowId,
            //                       RowText = itemRow.RowText,
            //                       WordId = itemword.WordId,
            //                       Word = itemword.RowText
            //                      };
            ////////////////////////////////////////////////////////CHANGE
            List <TextWord> _textOr    = new List <TextWord>();
            List <TextWord> _textCh    = new List <TextWord>();
            List <TextWord> mistakeOr  = new List <TextWord>();
            List <TextWord> mistakeCh  = new List <TextWord>();
            List <TextWord> SmistakeOr = new List <TextWord>();
            List <TextWord> SmistakeCh = new List <TextWord>();
            List <TextWord> group      = new List <TextWord>();
            //List<List<TextWord>> diss = new List<List<TextWord>>();
            //var settings = new List<string[]>();
            //List<List<String[]>> _SecLocations = new List<List<String[]>>{

            //    new List<String[]> { new string[]{"Item1", "Item2", "Item3", "Item4"}},
            //    new List<String[]> {  new string[]{"Item1", "Item2", "Item3", "Item4"}},

            //};
            List <string> dis = new List <string>();

            for (int i = 0; i < textsOneRow.Length; i++)
            {
                string[] split = textsOneRow[i].Split(stringSeparators, StringSplitOptions.None);
                for (int j = 0; j < split.Length; j++)
                {
                    _textOr.Add(new TextWord
                    {
                        RowIdFR = i,
                        Text    = textsOneRow[i],
                        WordId  = j,
                        RowText = split[j]
                    });
                    //dis.Add(_textOr.ToString());
                    //diss.Add(_textOr);
                }
            }
            for (int i = 0; i < textsTwoRow.Length; i++)
            {
                string[] split = textsTwoRow[i].Split(stringSeparators, StringSplitOptions.None);
                for (int j = 0; j < split.Length; j++)
                {
                    _textCh.Add(new TextWord
                    {
                        RowIdFR = i,
                        Text    = textsTwoRow[i],
                        WordId  = j,
                        RowText = split[j]
                    });
                }
            }


            int minRow = _textOr.Count < _textCh.Count ? _textOr.Count : _textCh.Count;

            for (int i = 0; i < minRow; i++)
            {
                if (!_textOr.Exists(x => x.RowIdFR == _textCh[i].RowIdFR))
                {
                    mistakeOr.Add(_textOr[i]);
                    mistakeCh.Add(_textCh[i]);
                }

                else
                {
                    if (!_textOr[i].RowText.Contains(_textCh[i].RowText))
                    {
                        mistakeOr.Add(_textOr[i]);
                        mistakeCh.Add(_textCh[i]);
                    }
                }
            }
            if (textsOneRow.Length > textsTwoRow.Length)
            {
                for (int i = 0; i < _textOr.Count; i++)
                {
                    if (_textOr[i].RowIdFR >= mistakeOr[mistakeOr.Count - 1].RowIdFR)
                    {
                        mistakeOr.Add(_textOr[i]);
                    }
                }
            }
            if (textsOneRow.Length < textsTwoRow.Length)
            {
                for (int i = 0; i < _textCh.Count; i++)
                {
                    if (_textCh[i].RowIdFR >= mistakeCh[mistakeCh.Count - 1].RowIdFR)
                    {
                        mistakeCh.Add(_textCh[i]);
                    }
                }
            }


            //var groupedCustomerList = mistakeOr
            //                        .GroupBy(u => u.RowIdFR)
            //                        .Select(grp => grp.ToList())
            //                        .ToList();

            //for (int i = 0; i < groupedCustomerList.Count; i++)
            //{
            //    for (int j = 0; j < groupedCustomerList[i].Count; j++)
            //    {
            //        if (groupedCustomerList[i].Count== groupedCustomerList[i][j].Text.Split(stringSeparators, StringSplitOptions.None).Length)
            //        {
            //            group.Add(groupedCustomerList[i][j]);
            //        }
            //    }
            //}
            //var groupFullMistakeRow = group
            //                        .GroupBy(u => u.RowIdFR)
            //                        .Select(grp => grp.ToList())
            //                        .ToList();

            //var gr_textCh =  _textCh
            //                .GroupBy(u => u.RowIdFR)
            //                .Select(grp => grp.ToList())
            //                .ToList();

            //for (int i = 0; i < groupFullMistakeRow.Count; i++)
            //{
            //    for (int j = 0; j < gr_textCh[i].Count; j++)
            //    {

            //        if (groupFullMistakeRow[i][i].RowIdFR==gr_textCh[j][j].RowIdFR)
            //        {
            //            for (int k = 0; k < gr_textCh[j].Count; k++)
            //            {
            //                for (int p = gr_textCh[j][k].RowIdFR; p < gr_textCh[j].Count-1; p++)
            //                {

            //                    if (groupFullMistakeRow[i][k].RowText.Contains(gr_textCh[p][k].RowText))
            //                    {
            //                        SmistakeOr.Add(gr_textCh[p][k]);
            //                        //SmistakeCh.Add(_textCh[i]);
            //                    }
            //                }
            //            }
            //        }
            //    }
            //}

            Console.WriteLine(mistakeOr);
            Console.WriteLine(mistakeCh);
            Console.WriteLine(SmistakeOr);
            Console.WriteLine(SmistakeCh);
            // Console.WriteLine(groupedCustomerList);
            Console.WriteLine(group);
            var Mistake = new Mistake
            {
                MistaceOrigin = mistakeOr,
                MistaceChange = mistakeCh
            };


            //try
            //{
            //    for (int i = 0; i < _textCh.Count; i++)
            //    {
            //        //var groupedCustomerList = mistake.GroupBy(u => u.RowIdFR).Select(grp => grp.ToList()).ToList();



            //        var l = textsOneRow[i].Count();
            //        if (mistake[i].RowIdFR != _textOr[i+l].RowIdFR)
            //        {

            //            if (!_textOr[i].RowText.Contains(_textCh[i].RowText))
            //            {
            //                mistake1.Add(_textCh[i]);
            //            }

            //        }
            //    }
            //}
            //catch (System.ArgumentOutOfRangeException ex)
            //{
            //    string input1 = "";
            //}



            ////////////////////////////////////////////////////////////////////////////////
            //var queryCH =
            //           from itemRow in _itemsCH
            //           join itemword in _itemsWordCH on itemRow.RowId equals itemword.RowIdFR
            //           //where post.ID == id
            //           select new
            //           {
            //               RowId = itemRow.RowId,
            //               RowText = itemRow.RowText,
            //               WordId = itemword.WordId,
            //               Word = itemword.RowText
            //           };
            ///////////////////////////////////////////////////////////////////////////


            //_itemsCH.AddRange(_itemsWordCH);
            //var result =
            //                from original in query
            //                from change in queryCH
            //                where original.RowId == change.RowId && original.WordId == change.WordId
            //                select new
            //                {
            //                    RowId = original.RowId,
            //                    RowText = original.RowText,
            //                    RowTextCH = change.RowText,
            //                    WordId = original.WordId,
            //                    Word = original.Word,
            //                    WordCH = change.Word,
            //                    status = original.Word == change.Word ? "correct" : "wrong",
            //                    //status = "correct"
            //                };


            // var list = query.Select().Concat(queryCH.Where(x => true));



            // Console.WriteLine(_result);



            //ViewData["Result"] = result.ToList();

            ViewData["requestForm"] = "index";

            return(View(Mistake));
        }