Пример #1
0
        public void Calc()
        {
            List <CZakaz> simpleZakazes  = new List <CZakaz>();
            List <CZakaz> newZakazes     = new List <CZakaz>();
            List <CZakaz> resolveZakazes = new List <CZakaz>();

            UpdateZakazsList(resolveZakazes, newZakazes, simpleZakazes);

            CSmartArray calcArray = new CSmartArray();

            LoadZakazListToSmartArray(calcArray, simpleZakazes);

            CProductCalc productCalc = new CProductCalc();

            productCalc.SetArray(calcArray);
            productCalc.SetAlreadyHave(m_alreadyHave.Copy());
            productCalc.Calc(5);

            Worksheet pTotalSheet = m_pBook.Worksheets.Add();

            pTotalSheet.Name = GetUniqueSheetName("MainTotal");
            ExportToExcel(pTotalSheet, productCalc.GetFactoryList(), productCalc.GetArray());
            {
                Worksheet pOneTableSheet = m_pBook.Worksheets.Add();
                pOneTableSheet.Name = GetUniqueSheetName("OneTableTotal");
                Kernal.CAllFactoryOneTable allFactoryOneTable = new Kernal.CAllFactoryOneTable(productCalc.GetFactoryList(), pOneTableSheet);
                Kernal.CAllSourceWrite     AllSourceWrite     = new Kernal.CAllSourceWrite(pOneTableSheet, productCalc.GetArray());
            }

            if (newZakazes.Count > 0)
            {
                CProductCalc productCalc2 = GetProductCalcSimpleAndSecond(simpleZakazes, newZakazes);
                {
                    Worksheet pTotalSheet2 = m_pBook.Worksheets.Add();
                    pTotalSheet2.Name = GetUniqueSheetName("OtherTotal");
                    ExportToExcel(pTotalSheet2, productCalc2.GetFactoryList(), productCalc2.GetArray());
                }
                productCalc2.ExcludeWhatHave(productCalc);
                Worksheet pSimpleSheet = m_pBook.Worksheets.Add();
                pSimpleSheet.Name = GetUniqueSheetName("SimpleTotal");
                new CSimpleFactoryExport(pSimpleSheet, productCalc2.GetFactoryList(), productCalc2.GetArray());
            }
            if (resolveZakazes.Count > 0)
            {
                CProductCalc productCalc2   = GetProductCalcSimpleAndSecond(simpleZakazes, resolveZakazes);
                CSmartArray  newAlreadyHave = productCalc.GetAlreadyHave();

                //вывести на другой лист значение newAlreadyHave
            }
        }
Пример #2
0
 public void ExcludeWhatHave(CProductCalc pCalc)
 {
     for (int i = 0; i < m_factArray.Count; i++)
     {
         List <CFactory> pList = pCalc.GetFactoryList();
         m_factArray[i].ExcludeWhatHave(pList[i]);
     }
     m_array.ExcludeWhatHave(pCalc.m_array);
 }
Пример #3
0
        public void WriteInfoAboutSourceToExcel()
        {
            CProductCalc    productCalc  = new CProductCalc();
            List <CFactory> factList     = productCalc.GetFactoryList();
            Worksheet       pSourceSheet = m_pBook.Worksheets.Add();

            pSourceSheet.Name = GetUniqueSheetName("FullSource");
            int currentRow = 1 + 1;

            for (int factNo = 0; factNo < factList.Count; factNo++)
            {
                Kernal.CFactory          factory  = factList[factNo];
                List <Kernal.ProductTag> tagInput = factory.GetInputArray();
                for (int i = 0; i < tagInput.Count; i++)
                {
                    Kernal.CSmartArray array = new Kernal.CSmartArray();
                    array.Add(tagInput[i], 1);
                    factory.SetInput(array);
                    factory.Calc();
                    Kernal.CSmartArray result = new Kernal.CSmartArray();
                    factory.UpdateResult(result);
                    Dictionary <ProductTag, int> map = result.GetMap();
                    int count = map.Count;
                    var en    = map.Keys.GetEnumerator();
                    en.MoveNext();
                    for (int j = 0; j < count; j++)
                    {
                        ProductTag pTag = en.Current;
                        en.MoveNext();
                        int TagCount = result.GetTagCount(pTag);
                        Kernal.Utils.UpdateCell(pSourceSheet, currentRow, 1, m_Spisok.GetName(tagInput[i]), 20);
                        Kernal.Utils.UpdateCell(pSourceSheet, currentRow, 2, m_Spisok.GetName(pTag), 10);
                        Kernal.Utils.UpdateCell(pSourceSheet, currentRow, 3, TagCount.ToString());
                        currentRow++;
                    }
                }
            }
        }
Пример #4
0
 private void button1_Click(object sender, EventArgs e)
 {
     Kernal.CSmartArray array = GetAllZakazArray();
     array.Merge(GetAllTrainArray());
     array.Merge(GetAllPlaneArray());
     array.ExcludeWhatHave(m_AlreadyHave.Copy());
     Kernal.CProductCalc calc = new Kernal.CProductCalc();
     calc.SetArray(array);
     calc.SetAlreadyHave(m_AlreadyHave.Copy());
     for (int i = 0; i < CalcCount; i++)
     {
         calc.Calc();
     }
     ShowResultForm(calc.Print());
     Kernal.CExportAllFactoryHelper helper = new Kernal.CExportAllFactoryHelper(calc.GetFactoryList());
 }
Пример #5
0
        public void WriteInfoAboutFactroryToExcel()
        {
            List <ProductSourceInfo> PSInfo      = new List <ProductSourceInfo>();
            CProductCalc             productCalc = new CProductCalc();
            List <CFactory>          factList    = productCalc.GetFactoryList();

            //Worksheet pSourceSheet = m_pBook.Worksheets.Add();
            //pSourceSheet.Name = GetUniqueSheetName("FullSource");
            for (int factNo = 0; factNo < factList.Count; factNo++)
            {
                Kernal.CFactory          factory  = factList[factNo];
                List <Kernal.ProductTag> tagInput = factory.GetInputArray();
                for (int i = 0; i < tagInput.Count; i++)
                {
                    Kernal.CSmartArray array = new Kernal.CSmartArray();
                    array.Add(tagInput[i], 1);
                    factory.SetInput(array);
                    factory.Calc();
                    Kernal.CSmartArray result = new Kernal.CSmartArray();
                    factory.UpdateResult(result);
                    Dictionary <ProductTag, int> map = result.GetMap();
                    int count = map.Count;
                    var en    = map.Keys.GetEnumerator();
                    en.MoveNext();
                    for (int j = 0; j < count; j++)
                    {
                        ProductTag pTag = en.Current;
                        en.MoveNext();
                        int TagCount = result.GetTagCount(pTag);
                        PSInfo.Add(new ProductSourceInfo(tagInput[i], pTag, TagCount));
                    }
                }
            }

            Dictionary <ProductTag, List <ProductInfo> > InfoArray = new Dictionary <ProductTag, List <ProductInfo> >();

            for (int i = 0; i < PSInfo.Count; i++)
            {
                ProductSourceInfo info = PSInfo[i];
                if (!InfoArray.ContainsKey(info.m_SourceTag))
                {
                    InfoArray[info.m_SourceTag] = new List <ProductInfo>();
                }
                InfoArray[info.m_SourceTag].Add(new ProductInfo(info.m_ProductTag, info.m_Value));
            }

            int FactCount = Enum.GetNames(typeof(FactoryType)).Length;

            for (int FactNo = 0; FactNo < FactCount; FactNo++)
            {
                CFactory pFact = CreateFactory((FactoryType)FactNo);
                string   FactName;
                if (pFact == null)
                {
                    if ((FactoryType)FactNo == FactoryType.ftField)
                    {
                        FactName = "поля";
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    FactName = pFact.GetFactName();
                }

                Worksheet pSourceSheet = m_pBook.Worksheets.Add();
                pSourceSheet.Name = GetUniqueSheetName(FactName);
                int CurrentColumn = 1;
                var e             = InfoArray.Keys.GetEnumerator();
                for (int i = 0; i < InfoArray.Count; i++)
                {
                    e.MoveNext();
                    ProductTag tag = e.Current;

                    if (m_Spisok.GetFactoryType(tag) == (FactoryType)FactNo)
                    {
                        List <ProductInfo> list = InfoArray[tag];
                        Kernal.Utils.UpdateCell(pSourceSheet, 1, CurrentColumn, m_Spisok.GetName(tag), 20);
                        Range pTitleRange = Utils.GetRange(pSourceSheet, 1, CurrentColumn, 1, CurrentColumn + 1);
                        pTitleRange.Merge();
                        for (int ProductNo = 0; ProductNo < list.Count; ProductNo++)
                        {
                            ProductInfo info = list[ProductNo];
                            Kernal.Utils.UpdateCell(pSourceSheet, ProductNo + 2, CurrentColumn, m_Spisok.GetName(info.m_SourceTag), 20);
                            Kernal.Utils.UpdateCell(pSourceSheet, ProductNo + 2, CurrentColumn + 1, info.m_Value.ToString(), 4);
                        }
                        Range pRange = Utils.GetRange(pSourceSheet, 1, CurrentColumn, list.Count + 1, CurrentColumn + 1);
                        for (int borderNo = (int)XlBordersIndex.xlEdgeLeft; borderNo <= (int)XlBordersIndex.xlInsideHorizontal; borderNo++)
                        {
                            pRange.Borders[(XlBordersIndex)borderNo].LineStyle = XlLineStyle.xlContinuous;
                        }
                        CurrentColumn += 2;
                    }
                }
            }
        }