示例#1
0
        private IEnumerable <List <string> > ParsExportLinks(List <string> path)
        {
            message.MessageTriger("Чтение файла експорт линков...");
            NeededColumnNameInfo neededColumnNameInfo = null;
            var headerInitialize = false;

            HashSet <string> allSKUInPD = GetSKUFromPD();

            foreach (string filePath in path)
            {
                var dataFromFile = GetLineFromFile(filePath);

                foreach (var line in dataFromFile)
                {
                    if (!headerInitialize)
                    {
                        neededColumnNameInfo = GetNeededColumnNamesInfo(line);
                        headerInitialize     = true;
                        var headers = neededColumnNameInfo.HeaderNames;
                        headers.Add("Brand+SKU");
                        yield return(headers);

                        continue;
                    }

                    if (line[2] == "")
                    {
                        continue;
                    }

                    var dataLine = new List <string>();

                    for (int i = 0; i < neededColumnNameInfo.ColumnNumbers.Count; i++)
                    {
                        for (int x = 0; x < line.Length; x++)
                        {
                            if (neededColumnNameInfo.ColumnNumbers[i] == x)
                            {
                                dataLine.Add(line[x]);
                                break;
                            }
                        }
                    }

                    GetExportLinksInfo(dataLine);
                    if (skuFromPDCheck && !allSKUInPD.Contains(dataLine[dataLine.Count - 1]))
                    {
                        continue;
                    }

                    yield return(dataLine);
                }
            }
        }
示例#2
0
        private NeededColumnNameInfo GetNeededColumnNamesInfo(string[] headers)
        {
            NeededColumnNameInfo columnNameInfo = new NeededColumnNameInfo();

            columnNameInfo.ColumnNumbers = new List <int>();
            columnNameInfo.HeaderNames   = new List <string>();

            string[] neededColumNames = { "Product ID", "Brand", "SKU", "Product Name", "Child Title", "Images", "MMY", "Make", "Manufacturer ID", "Model", "Template", "Years", "linkwww" };

            for (int i = 0; i < neededColumNames.Length; i++)
            {
                for (int x = 0; x < headers.Length; x++)
                {
                    if (neededColumNames[i] == headers[x])
                    {
                        columnNameInfo.ColumnNumbers.Add(x);

                        columnNameInfo.HeaderNames.Add(headers[x]);
                        break;
                    }
                }
            }
            return(columnNameInfo);
        }