I
I
Ivan Vyrov2017-09-18 12:24:59
C++ / C#
Ivan Vyrov, 2017-09-18 12:24:59

Where to look for data loss?

Hello Dear!
Please find mysticism in ("3 pines") code.

There is a WCF service with the Updates(<CurrentFileVersion>, <FileName.extension>, <FileKey>) method
public Updates Updates(long version, string fileName, string key_service)
        {
            Updates update = new Updates();
            try
            {
                if (key_service == "КлючьКФайлу")
                {
                    byte[] buffer;  //Временная переменная
                    List<Files> listDll = Hepler.List(path_dll, new List<string> { "*.dll", "*.exe" });
                    List<Files> selectFile = listDll.FindAll(delegate (Files teach) { return teach.name.StartsWith(fileName); });
                    if (selectFile.Count > 0)
                    {
                        long ver = long.Parse(selectFile[0].version.Replace(".", ""));
                        if (ver > version)
                        {
                            //На сервере есть обновления
                            FileStream fs = new FileStream(selectFile[0].fullName, FileMode.Open);
                            buffer = new byte[fs.Length];
                            int len = (int)fs.Length;
                            fs.Read(buffer, 0, len);
                            fs.Close();
                            update.file = buffer;
                            update.node = "Доступна новая версия";
                        }
                    }
                    else
                    {
                        update.node = "Неизвестный файл";
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            return update;
        }


The question is:
If when calling Updates(<CurrentFileVersion>, "Filename.extension", "FileKey") you specify the version of the current file 201709131, then the method will work and give us the updated file, but if you specify the file version 2017091318 (additional 8 at the end), then the method will not work and will return the class with null.
Screenshots
6e8c8a45cf6a49fcbdd83b654b4a350c.png82329bba70c747d198a558e9b7288234.png

What could be wrong? As I understand it, he does not like the size of the version (length). The service logs are clean and there are no errors during operation.
Initially, <CurrentFileVersion> was int, the situation has not changed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Vyrov, 2017-09-18
@ProKiLL

"An empty head - does not give rest to the legs"
The whole error was in the version of the file on the
server if (ver > version). we send version 2017091318 and the server has version 201709181
Conclusion: I fixed the file version on the server to 2017091801 and the problem was solved.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question