Example #1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            using (StreamReader reader = File.OpenText(@"D:\Databases\find_logsV.json"))
            {
                string          json        = reader.ReadToEnd();
                int             counter     = 0;
                IList <dynamic> jsonObjects = JsonConvert.DeserializeObject <IList <dynamic> >(json);

                TimeCutoffModel cargotimeFlow = new TimeCutoffModel();

                var pushCargotimeFlow = new List <TimeCutoffModel>();

                foreach (var jsonObject in jsonObjects)
                {
                    cargotimeFlow = new TimeCutoffModel();

                    counter++;
                    cargotimeFlow.NodeNumber = counter;
                    cargotimeFlow.UserId     = jsonObject.uid;
                    cargotimeFlow.UserRole   = jsonObject.user.role.id;
                    cargotimeFlow.Method     = jsonObject.user.method;
                    cargotimeFlow.Status     = jsonObject.user.method;
                    cargotimeFlow.Status     = Checker.CheckAbbreviation(jsonObject.in_doc.work_list);

                    dynamic collection = jsonObject.in_doc.containers;
                    foreach (var container in collection)
                    {
                        Console.WriteLine();
                    }


                    pushCargotimeFlow.Add(cargotimeFlow);
                }

                dgCargosolView.DataSource = pushCargotimeFlow;
                dgCargosolView.Columns["NodeId"].DefaultCellStyle.Alignment         = DataGridViewContentAlignment.MiddleCenter;
                dgCargosolView.Columns["RegistryNumber"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                dgCargosolView.Columns[13].HeaderText = "Danger class";
                dgCargosolView.Columns[4].HeaderText  = "Bill lading time";
                dgCargosolView.Columns[0].SortMode    = DataGridViewColumnSortMode.Programmatic;

                for (int i = 0; i <= dgCargosolView.Columns.Count - 1; i++)
                {
                    dgCargosolView.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                }
            }
        }
        public static void GetFirstData()
        {
            using (StreamReader reader = File.OpenText(@"D:\Databases\find_logsV.json"))
            {
                string json = reader.ReadToEnd();

                TimeCutoffModel cargotimeFlow = new TimeCutoffModel();

                IList <dynamic> jsonObjects = JsonConvert.DeserializeObject <IList <dynamic> >(json);

                var pushCargotimeFlow = new List <TimeCutoffModel>();

                foreach (var jsonObject in jsonObjects)
                {
                    cargotimeFlow = new TimeCutoffModel();
                    //cargotimeFlow.UserId = jsonObject.uid;
                    cargotimeFlow.UserTime = jsonObject.time_stamp;
                    //cargotimeFlow.UserIdDoc = jsonObject.user.uid;
                    cargotimeFlow.UserLastLoginDoc = jsonObject.user.last_login;
                    cargotimeFlow.UserRoleDoc      = jsonObject.user.id;
                    cargotimeFlow.UserRoleDoc      = jsonObject.user.role.id;
                    //cargotimeFlow.DocId = jsonObject.in_doc.uid;
                    cargotimeFlow.DocTime       = jsonObject.in_doc.time_stamp;
                    cargotimeFlow.DocLastUpdate = jsonObject.in_doc.last_update;

                    string element         = jsonObject.in_doc.work_list;
                    string dangerClassItem = Checker.CheckAbbreviation(element);
                    cargotimeFlow.DocInnerDangerClassificationStatus = dangerClassItem;

                    for (int c = 0; c < jsonObject.in_doc.containers.Count; c++)
                    {
                        //cargotimeFlow.ContainerNumOrder = jsonObject.in_doc.containers[c].num_order;
                        //cargotimeFlow.ContainerNumRegistraion = jsonObject.in_doc.containers[c].registry_number;

                        try
                        {
                            cargotimeFlow.ContainerNavisTime = jsonObject.in_doc.containers[c].navis.time_stamp;
                        }
                        catch (Exception)
                        {
                            cargotimeFlow.ContainerNavisTime = null;
                        }

                        var checker = jsonObject.in_doc.containers[c].bills_of_lading;

                        if (checker != null)
                        {
                            cargotimeFlow.BillsOfLadingTimeStamp = jsonObject.in_doc.containers[c].bills_of_lading.time_stamp;
                        }
                    }

                    for (int s = 0; s < jsonObject.in_doc.scans.Count; s++)
                    {
                        cargotimeFlow.ScanTime = jsonObject.in_doc.scans[s].time_stamp;
                        //cargotimeFlow.OperatorId = jsonObject.in_doc.scans[s][email protected];
                        //cargotimeFlow.OperatorLastLogin = jsonObject.in_doc.scans[s][email protected]_login;
                        //cargotimeFlow.OperatorRole = jsonObject.in_doc.scans[s][email protected];
                    }

                    for (int i = 0; i < jsonObject.in_doc.protocols.Count; i++)
                    {
                        cargotimeFlow.ProtocolTime = jsonObject.in_doc.protocols[i].time_stamp;
                        //cargotimeFlow.ProtocolUserId = jsonObject.in_doc.protocols[i].user.uid;
                        //cargotimeFlow.UserLastLogin = jsonObject.in_doc.protocols[i].user.last_login;
                        //cargotimeFlow.UserProtocolRole = jsonObject.in_doc.protocols[i].user.role.id;
                        //cargotimeFlow.ProtocolStatus = jsonObject.in_doc.protocols[i].status;
                    }

                    pushCargotimeFlow.Add(cargotimeFlow);
                }

                List <TimeCutoffModel> SortedList = pushCargotimeFlow.OrderBy(o => o.ScanTime).ToList();

                int counter = 0;

                foreach (var item in SortedList)
                {
                    counter++;
                    item.NodeId = counter;
                }

                Printer.PrintFullModel(SortedList);
                Console.ReadLine();
            }
        }