Example #1
0
        static void Main(string[] args)
        {
            /*  char id = Console.ReadKey().KeyChar;
             * HttpWebRequest request =
             *   (HttpWebRequest)WebRequest.Create(string.Format("http://kodaday.intita.com/api/task/{0}", id));
             * request.Headers.Add("X-API-KEY: S95Xczjx");
             *
             * WebResponse response = request.GetResponse();
             * Console.WriteLine(((HttpWebResponse)response).StatusDescription);
             * Stream dataStream = response.GetResponseStream();
             * StreamReader reader = new StreamReader(dataStream);
             * string responseFromServer = reader.ReadToEnd();
             * reader.Close();
             * response.Close();*/



            Sourse json = new Sourse();
            // json = JsonConvert.DeserializeObject<Sourse>(responseFromServer);



            Answer answer = new Answer(json);
            Holder holder = new Holder(json);

            holder.distrib_Priorities();

            Sort sort = new Sort();

            sort.SortFunc(holder.Type0);
            sort.SortFunc(holder.Type1);
            sort.SortFunc(holder.Type2);


            sort.SortFunc(holder.ProcList);
            sort.GetAnswer(holder.ProcList, json, answer);
            answer.Print();
            Console.WriteLine(holder.ProcList[0].load);

            /*HttpWebRequest request2 =
             * (HttpWebRequest)WebRequest.Create(string.Format("http://kodaday.intita.com/api/task/{0}", id));
             * request2.Headers.Add("X-API-KEY: S95Xczjx");
             * request2.Method = "POST";
             * var stream = request2.GetRequestStream();
             * var writer = new StreamWriter(stream);
             * writer.Write(JsonConvert.SerializeObject(answer.answerMass));
             * writer.Flush();
             * writer.Close();
             * stream.Close();
             * WebResponse response2 = request2.GetResponse();
             * Console.WriteLine(response2);
             */
            Console.ReadKey();
        }
Example #2
0
        public void GetAnswer(List <Processor> List, Sourse json, Answer answer)
        {
            int length = List.Count();

            for (int i = 0; i < length; i++)
            {
                int lengthOftasks = List[i].indexTask.Count();
                for (int j = 0; j < lengthOftasks; j++)
                {
                    answer.answerMass[List[i].indexTask[j].index] = List[i].index;
                }
            }
        }
Example #3
0
        public Holder(Sourse json)
        {
            int lenght = json.processors.Length;

            for (int i = 0; i < lenght; i++)
            {
                switch (json.processors[i])
                {
                case 0:
                {
                    Processor a = new Processor(0, i);
                    ProcList.Add(a);
                    Type0.Add(a);
                }
                break;

                case 1:
                {
                    Processor a = new Processor(1, i);
                    ProcList.Add(a);
                    Type1.Add(a);
                }
                break;

                case 2:
                {
                    Processor a = new Processor(2, i);
                    ProcList.Add(a);
                    Type2.Add(a);
                }
                break;
                }
            }
            lenght = json.tasks.Length;
            for (int i = 0; i < lenght; i++)
            {
                TaskList.Add(new Task(json.tasks[i], i));
            }
        }
Example #4
0
 public Answer(Sourse json)
 {
     answerMass = new int[json.tasks.Length];
 }