private void frmCyberTrack_Load(object sender, EventArgs e)
        {
            if (Directory.Exists(Path.GetTempPath() + @"\CyberApp\CyberTrack"))
            {
                string[] files = Directory.GetFiles(Path.GetTempPath() + @"\CyberApp\CyberTrack");

                foreach (var file in files)
                {
                    FileInfo fileInfo = new FileInfo(file);
                    if (fileInfo.Extension.Equals(".json"))
                    {
                        var item = Objeto.FromJson(File.ReadAllText(file));
                        if (Regex.Match(item.Codigo, @"^[A-Z]{2}[\d]{9}[A-Z]{2}$").Success)
                        {
                            uiItem uiItem = new uiItem();
                            uiItem.ItemTitle          = Path.GetFileNameWithoutExtension(fileInfo.FullName);
                            uiItem.ItemCodigoRastreio = item.Codigo;
                            uiItem.ItemImage          = Properties.Resources.correios;
                            uiItem.Click                += UiItem_Click;
                            uiItem.Tag                   = Path.GetFileNameWithoutExtension(fileInfo.FullName);
                            uiItem.LabelTitle.Click     += UiItem_Click;
                            uiItem.LabelTitle.Tag        = Path.GetFileNameWithoutExtension(fileInfo.FullName);
                            uiItem.LabelCompany.Click   += UiItem_Click;
                            uiItem.LabelCompany.Tag      = Path.GetFileNameWithoutExtension(fileInfo.FullName);
                            uiItem.PictureCompany.Click += UiItem_Click;
                            uiItem.PictureCompany.Tag    = Path.GetFileNameWithoutExtension(fileInfo.FullName);
                            uiFlowEncomendas.Controls.Add(uiItem);
                        }
                    }
                }
            }
        }
        private void UiItem_Click(object sender, EventArgs e)
        {
            var eventJson = string.Empty;

            if (sender is Panel)
            {
                Panel panel = sender as Panel;
                eventJson = File.ReadAllText(Path.GetTempPath() + String.Format(@"\CyberApp\CyberTrack\{0}.json", panel.Tag));
            }
            else if (sender is Label)
            {
                Label label = sender as Label;
                eventJson = File.ReadAllText(Path.GetTempPath() + String.Format(@"\CyberApp\CyberTrack\{0}.json", label.Tag));
            }
            else if (sender is PictureBox)
            {
                PictureBox pictureBox = sender as PictureBox;
                eventJson = File.ReadAllText(Path.GetTempPath() + String.Format(@"\CyberApp\CyberTrack\{0}.json", pictureBox.Tag));
            }
            else if (sender is uiItem)
            {
                uiItem item = sender as uiItem;
                eventJson = File.ReadAllText(Path.GetTempPath() + String.Format(@"\CyberApp\CyberTrack\{0}.json", item.Tag));
            }

            CreateBoxEvent(Objeto.FromJson(eventJson));
        }
Beispiel #3
0
    public static Objeto GetObjeto(string id)
    {
        var data = HttpUtil.GetRequest("api/objeto/" + id);

        return(Objeto.FromJson(data));
    }