Beispiel #1
0
        public void BuildingBlock(string[] massline, ProductMenager workFile, ParserSetup parser, AccountHandler Notify)
        {
            string[,] mainmass = new string[countLine, countColumns];
            int LineNumber   = 0;
            int ColumnNumber = 0;

            try
            {
                if (massline.Any(x => x == null) == true)
                {
                    return;
                }
                for (int i = 0; i < massline.Length; i++)
                {
                    if (ColumnNumber != Convert.ToInt32(countColumns))
                    {
                        StringConversion(massline[i], LineNumber, ColumnNumber, mainmass);
                        if (LineNumber == Convert.ToInt32(countLine) - 1)
                        {
                            LineNumber = 0;
                            ColumnNumber++;
                        }
                        else
                        {
                            LineNumber++;
                        }
                    }
                    else
                    {
                        LineNumber   = 0;
                        ColumnNumber = 0;
                    }
                }

                string[] finmass = new string[mainmass.GetLength(0)];
                for (int j = 0; j < mainmass.GetLength(0); j++)
                {
                    for (int z = 0; z < mainmass.GetLength(1); z++)
                    {
                        finmass[j] += mainmass[j, z];
                        if (mainmass.GetLength(1) - 1 != z)
                        {
                            finmass[j] += "|";
                        }
                        finmass[j] += "   ";
                    }
                }
                lock (lockerW)
                {
                    workFile.WriteTitle();
                    workFile.WriteLineMass(finmass);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.StackTrace);
                Notify?.Invoke();
            }
        }
Beispiel #2
0
        private void ProductCreationB_Click(object sender, RoutedEventArgs e)
        {
            if (DataChecking() == false)
            {
                return;
            }
            string[]       info    = new string[] { ProductTypeT.Text, NumberLinesT.Text, MainColumnsT.Text, PathRezT.Text, TitleT.Text, FormattingT.Text, Convert.ToString(PresenceHeaders.IsChecked), PackT.Text, NumberLengthT.Text };
            ProductType    product = new ProductType();
            ProductMenager work    = new ProductMenager();

            product.infowrite(info);
            work.ProductRecord(product);
        }
Beispiel #3
0
        private void ProductRemovingB_Click(object sender, RoutedEventArgs e)
        {
            ProductMenager work = new ProductMenager();

            ProductType[] mass = work.ReadingProduct();
            for (int i = 0; i < mass.Length; i++)
            {
                if (mass[i].NameProduct == ProductTypeT.Text)
                {
                    mass = mass.Where(val => val.NameProduct != ProductTypeT.Text).ToArray();
                    work.rewriting(mass);
                }
            }
        }
Beispiel #4
0
        public void RumWork()
        {
            int tempnum = 0;

            if (RunDataChecks() == true)
            {
                return;
            }
            ProductMenager workFile = new ProductMenager(settings.Title, settings.Pack, GetNumberBlocks());

            Task[] masstask = new Task[3]; // Ссколько будет использоваться потоков, пока синхронизиции нет 3
            try
            {
                workFile.OpenFilePathR(settings.Path);
                workFile.OpenFilePathW(settings.PathRez);
                WorkString[] massstring = new WorkString[masstask.Length];
                int          i          = 0;
                int          j          = 0;
                while (true)
                {
                    massstring[i] = new WorkString(settings.Formatting, settings.CountLine, settings.CountColumns);
                    string[] line = workFile.ReadBlok(settings.CountLine * settings.CountColumns, settings.TitleBlok);
                    if (line[0] == null || error == "stop")
                    {
                        break;
                    }
                    masstask[i] = new Task(() => massstring[i].BuildingBlock(line, workFile, settings.Parser, Notify));
                    masstask[i].Start();
                    if (masstask.Any(x => x == null) == false)
                    {
                        while (true)
                        {
                            if (j == masstask.Length)
                            {
                                j = 0;
                            }
                            if (masstask[j].Status == TaskStatus.RanToCompletion)
                            {
                                i = j;
                                break;
                            }
                            j++;
                        }
                    }
                    else
                    {
                        i++;
                    }
                    if (tempnum == 50)
                    {
                        settings.Parser.Dispatcher.BeginInvoke((Action)(() => settings.Parser.UpdateProgressBar((settings.CountLine * settings.CountColumns) * 50)));
                        tempnum = 0;
                    }
                    else
                    {
                        tempnum++;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Task.WaitAll(masstask);
                workFile.CloseFilePathR();
                workFile.CloseFilePathW();
            }
        }