Check if already exists in list/table

  • Автор темы Автор темы awzse00
  • Дата начала Дата начала

awzse00

Client
Регистрация
16.03.2013
Сообщения
238
Реакции
36
Баллы
28
Hi guys i'm trying to figure out how this snippet works, is it still up to date? Because i'm trying for the last 2 hours to get it running.
Basically i need to check if a Dealer is in my list already or not. If it's there, stop the action ,if it isn't continue with the template.

Код:
Развернуть Свернуть Копировать
// take search text from variable
var textContains = project.Variables["DealerName"].Value;
// get a list or search
var sourceList = project.Lists["Dealeri"];
// search in each line of list
lock(SyncObjects.ListSyncer)
{
    for(int i=0; i < sourceList.Count; i++)
    {
        // get line from list
        var str = sourceList[i];
        // check if line contains text, if there are matches return "yes"
        if (str.Contains(textContains))
            return "yes";
    }
}
// ifnothing found return "no"
return "no";
 
It can be obvious, but did you uncheck do not return a value option on C# module window?
 
Код:
Развернуть Свернуть Копировать
project.Variables["isContain"].Value = project.Lists["Dealeri"].Any(x => x.IndexOf(project.Variables["DealerName"].Value) != -1).ToString();
or
Код:
Развернуть Свернуть Копировать
if (project.Lists["Dealeri"].Any(x => x.IndexOf(project.Variables["DealerName"].Value) != -1))
    throw new Exception();
 
Последнее редактирование:

Кто просматривает тему: (Всего: 0, Пользователи: 0, Гости: 0)