Answer the question
In order to leave comments, you need to log in
How to debug Windows services in C sharp?
In general there are 2 functions:
public static void tolog(string text)
{
File.AppendAllText("N:\\logs\\test.txt", text);
}
public static string GetUID()
{
// read registry
RegistryKey currentUserKey = Registry.LocalMachine;
RegistryKey UidKey = currentUserKey.OpenSubKey("defined path");
string result = (string)UidKey.GetValue("Value");
UidKey.Close();
tolog(result);
return result;
}
why is the file log not created?
there is a directory, the service is started on behalf of the system (which is natural),
there are no restrictions on rights, you
need to track how it gets the value from the registry and write it to the log, but something is wrong
Answer the question
In order to leave comments, you need to log in
Build the service under debug. Then you can connect to it through the debugger when it is running as a service.
From VS running as system administrator, which is important.
Once you have connected, you only need to trigger the above logic. Well, set breakpoints in advance, of course.
You have an M:N (many-to-many) relationship between the ITEMS and ATTR tables, so it is most logical to choose from the ATTR_ITEMS auxiliary table and link other tables to it.
That is, the main body of the request (before the WHERE clause) will be something like
SELECT *
FROM `attr_items` ai
inner join `items` i on ai.id_item = i.id
inner join `attr` a on ai.id_attr = a.id
SELECT *
FROM `attr_items` ai
inner join `items` i on ai.id_item = i.id
inner join `attr` a on ai.id_attr = a.id
WHERE
/* условие для категории */
(a.category_id = i.category and i.category = 2) and
/* условие для марки автомобиля */
(a.name = 'Марка' and ai.val = 'Audi') and
/* условие для модели автомобиля*/
(a.name = 'Модель' and ai.val = 'Audi А8')
SELECT *
FROM `attr_items` ai
inner join `items` i on ai.id_item = i.id
inner join `attr` a on ai.id_attr = a.id
WHERE
/* условие для категории */
(a.category_id = i.category and i.category = 2) and
/* условие для марки автомобиля */
(a.name = 'Марка' and ai.val = 'Audi') and
/* условие для года выбуска автомобиля*/
(a.name = 'Годвыпуска' and ai.val BETWEEN 2005 and 2015)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question