Dictionary<string, string> titleReplaces = new Dictionary<string, string>();
titleReplaces.Add("ID","_SKU_");
titleReplaces.Add("Артикул","_MODEL_");
titleReplaces.Add("Название","_NAME_");
titleReplaces.Add("Бренд","_MANUFACTURER");
titleReplaces.Add("Цена","_PRICE_");
titleReplaces.Add("Наличие, шт","_QUANTITY_");
titleReplaces.Add("Валюта","_EAN_");
lock(SyncObjects.TableSyncer)
{
var sourceTable = project.Tables["startTable"];
while(!titleReplaces.Keys.ToList().Any(sourceTable.GetRow(0).ToList().Contains)){
if(sourceTable.RowCount == 0){
throw new Exception("Таблица пустая");
}
sourceTable.DeleteRow(0);
}
foreach(string str in titleReplaces.Keys.ToArray()){
int col = sourceTable.GetRow(0).ToList().IndexOf(str);
sourceTable.SetCell(col, 0, sourceTable.GetCell(col, 0).Replace(str, titleReplaces.Single(x=>x.Key.Equals(str)).Value));
}
int k = sourceTable.GetRow(0).ToList().IndexOf("_SKU_");
if(k > -1){
for(int i = 1; i < sourceTable.RowCount; i++){
sourceTable.SetCell(k, i, "robots|" + sourceTable.GetCell(k, i));
}
}
k = sourceTable.GetRow(0).ToList().IndexOf("_EAN_");
if(k > -1){
for(int i = 1; i < sourceTable.RowCount; i++){
sourceTable.SetCell(k, i, sourceTable.GetCell(k, i).Replace("RUB", "EUR"));
}
}
}