Esempio n. 1
0
        public void userForm()
        {
            List <List <string> > arr = new List <List <string> >();
            List <string>         str = new List <string>();

            while (true)
            {
                Thread.Sleep(75);
                str = objSQL.getInfoUser(localId.ToString());
                post.sendMes(str[0]);
                Thread.Sleep(40);
                post.sendMes(objSQL.getUserInformationAboutYourself("0")[0]);
                Thread.Sleep(40);
                post.sendMes(objSQL.getUserInformationAboutYourself(localId.ToString())[0]);


                message = post.recvMes();
                if (message == "end" && localId != -1)
                {
                    post.deliteLocalId(localId);
                    localId = -1;
                    break;
                }
                else if (message == "redaction")
                {
                    //Редактирование от лица пользователя
                    str = objSQL.getInfoUser(localId.ToString());
                    post.sendMes(str[0]);
                    message = post.recvMes();
                    if (message == "end")
                    {
                        continue;
                    }
                    else
                    {
                        string[] buffer      = message.Split(',');
                        string   login       = "******" + buffer[0] + "'";
                        string   pass        = "******" + buffer[1] + "'";
                        string   name        = "Фио = '" + buffer[2] + "'";
                        string   zp          = "ЗП = '" + buffer[5] + "'";
                        string   position    = "Должность = '" + buffer[4] + "'";
                        string   phoneNumber = "Телефон = '" + buffer[3] + "'";
                        objSQL.redactionInfoUser(login, localId.ToString());
                        objSQL.redactionInfoUser(pass, localId.ToString());
                        objSQL.redactionInfoUser(name, localId.ToString());
                        objSQL.redactionInfoUser(zp, localId.ToString());
                        objSQL.redactionInfoUser(position, localId.ToString());
                        objSQL.redactionInfoUser(phoneNumber, localId.ToString());
                    }
                    continue;
                }
                else if (message == "aboutYou")
                {
                    message = post.recvMes();
                    objSQL.updateInformationAboutYourself(message, localId.ToString());
                    continue;
                }
            }
        }
Esempio n. 2
0
        public void startAdmin()
        {
            List <List <string> > arr = new List <List <string> >();
            List <string>         str = new List <string>();

            while (true)
            {
                post.clearStream();
                str = objSQL.getFinance();
                Thread.Sleep(20);

                for (int i = 0; i < str.Count; i++)
                {
                    str[i] += '|';
                    post.sendMes(str[i]);
                }

                Thread.Sleep(40);
                message = post.recvMes();
                if (message == "end")
                {
                    return;
                }
                else if (message == "userTable")
                {
                    int sort = 0;
                    while (true)
                    {
                        if (sort != 1)
                        {
                            int sizeMess = objSQL.returnSizeBD();
                            post.clearStream();
                            Thread.Sleep(60);
                            post.sendMes(sizeMess.ToString());
                            str = objSQL.getAllInfoUser();

                            str = objT.makeTable(str, sizeMess);

                            message = "|id|Логин                    |Пароль                   |ФИО                      |Зарплата                 |Должность                |Телефон                  |\n";
                            Thread.Sleep(100);
                            post.sendMes(message);
                            int x = 0;
                            while (true)
                            {
                                str[x] += "\n";
                                post.sendMes(str[x]);
                                Thread.Sleep(40);
                                if (x == sizeMess - 1)
                                {
                                    break;
                                }
                                x++;
                            }
                        }
                        sort = 0;
                        //Ожидание новых комманд
                        Thread.Sleep(40);

                        message = post.recvMes();
                        if (message == "end")
                        {
                            break;
                        }
                        else
                        if (message == "serch")
                        {
                            while (true)
                            {
                                message = post.recvMes();
                                if (message == "end")
                                {
                                    break;
                                }
                                else
                                {
                                    str = serchForm();
                                    if (str[0] == "Не было ни одного совпадения")
                                    {
                                        post.sendMes(str[0]);
                                        continue;
                                    }
                                    str     = objT.makeTable(str, str.Count);
                                    message = "|id|Логин                    |Пароль                   |ФИО                      |Зарплата                 |Должность                |Телефон                  |\n";
                                    post.clearStream();
                                    Thread.Sleep(100);
                                    post.sendMes(message);
                                    int k = 0;
                                    while (true)
                                    {
                                        if (k == str.Count)
                                        {
                                            break;
                                        }
                                        post.sendMes(str[k]);
                                        k++;
                                    }
                                }
                            }
                        }
                        else                 //Сделать сортировку
                        if (message == "sorting")
                        {
                            objT.sort(post.returnTcp());
                            post.clearStream();
                            sort = 1;
                            continue;
                        }
                        else
                        if (message == "goIn")
                        {
                            post.clearStream();
                            message = post.recvMes();
                            str     = serchForm();
                            post.clearStream();
                            if (str[0] == "Не было ни одного совпадения")
                            {
                                Thread.Sleep(40);
                                post.sendMes(str[0]);
                                continue;
                            }

                            string[]  words   = str[0].Split('|');
                            int       id      = Int32.Parse(words[0]);
                            ClassUser obgUser = new ClassUser(client);
                            obgUser.setLocalId(id);
                            obgUser.userForm();
                            continue;
                        }
                        else
                        if (message == "delete")
                        {
                            message = post.recvMes();
                            str     = objSQL.returnAllId();
                            int delete = 0;
                            for (int i = 0; i < str.Count; i++)
                            {
                                if (message == str[i])
                                {
                                    objSQL.deleteUser(message);
                                    message = "Пользователь удален";
                                    post.sendMes(message);
                                    delete = 1;
                                    break;
                                }
                            }
                            if (delete == 0)
                            {
                                message = "Нету такого пользователя";
                                post.sendMes(message);
                            }

                            continue;
                        }
                        else
                        if (message == "alert")
                        {
                            message = post.recvMes();
                            string buffId = message;
                            string buff2;
                            str = objSQL.getUserInformationAboutYourself(buffId);
                            Thread.Sleep(40);
                            post.sendMes(str[0]);
                            message = post.recvMes();
                            buff2   = post.recvMes();
                            if (message == "end")
                            {
                                continue;
                            }
                            else
                            {
                                objSQL.updateInformationAboutYourself(buff2, message);
                            }
                            continue;
                        }
                    }
                }
                else if (message == "providers")
                {
                    while (true)
                    {
                        message = post.recvMes();
                        if (message == "end")
                        {
                            break;
                        }
                        else if (message == "continue")
                        {
                            post.clearStream();
                            Thread.Sleep(30);
                            message = post.recvMes();
                            post.clearStream();
                            if (message == "end")
                            {
                                continue;
                            }
                            else
                            {
                                int numberOfExperts = int.Parse(message);
                                int scaleSize       = int.Parse(post.recvMes());
                                message = post.recvMes();
                                string   lenghP    = message;
                                string[] providers = message.Split('\n');
                                int      sizeMart  = providers.Length;
                                string[] matr      = objT.makeStrForExpeert(scaleSize, sizeMart);

                                double[,] assessments = new double[numberOfExperts, sizeMart];

                                Thread.Sleep(70);
                                post.sendMes(numberOfExperts.ToString());
                                post.clearStream();
                                Thread.Sleep(70);
                                post.sendMes(matr.Length.ToString());
                                post.clearStream();



                                for (int i = 0; i < numberOfExperts; i++)
                                {
                                    Thread.Sleep(70);
                                    post.sendMes(lenghP);
                                    post.clearStream();
                                    Thread.Sleep(20);
                                    for (int j = 0; j < sizeMart; j++)
                                    {
                                        post.sendMes(matr[j]);
                                    }
                                    post.clearStream();
                                    message = post.recvMes();
                                    post.clearStream();
                                    if (message == "end")
                                    {
                                        break;
                                    }
                                    else
                                    {
                                        int      k    = 0;
                                        string[] buff = message.Split('\n');
                                        //строки
                                        for (int h = 0; h < sizeMart; h++)
                                        {
                                            string[] buff2 = buff[h].Split('|');
                                            //символы
                                            for (int l = 0; l < sizeMart; l++)
                                            {
                                                if (buff2[l] != "-")
                                                {
                                                    string[] buff3 = buff2[l].Split('/');
                                                    assessments[i, k] += double.Parse(buff3[0]) / scaleSize;
                                                }
                                            }
                                            k++;
                                        }
                                        continue;
                                    }
                                }
                                List <double> buf  = new List <double>();
                                double        buf2 = 0;
                                for (int x = 0; x < sizeMart; x++)
                                {
                                    for (int x1 = 0; x1 < numberOfExperts; x1++)
                                    {
                                        assessments[x1, x] = assessments[x1, x] / (sizeMart * (sizeMart - 1));
                                        buf2 += assessments[x1, x];
                                    }
                                    buf.Add(buf2);
                                    Console.WriteLine(buf[x]);
                                    buf2 = 0;
                                }
                                Thread.Sleep(20);
                                post.sendMes(sizeMart.ToString());
                                Thread.Sleep(50);
                                for (int x3 = 0; x3 < sizeMart; x3++)
                                {
                                    providers[x3] += "=" + buf[x3] + "\n";
                                    post.sendMes(providers[x3]);
                                }
                            }
                        }
                    }
                }
                else if (message == "option Chart")
                {
                    while (true)
                    {
                        str = objSQL.getFinance();
                        for (int i = 0; i < str.Count; i++)
                        {
                            str[i] += '|';
                            post.sendMes(str[i]);
                        }

                        message = post.recvMes();
                        if (message == "end")
                        {
                            break;
                        }
                        else if (message == "set")
                        {
                            string month = post.recvMes();
                            string money = post.recvMes();
                            objSQL.updateFinance(month, money);
                            continue;
                        }
                    }
                }
            }
        }