Пример #1
0
 public PSLinkConnection(LinkConnection linkConnection)
 {
     this.SourceDatabase = linkConnection?.SourceDatabase != null ? new PSLinkConnectionSourceDatabase(linkConnection?.SourceDatabase) : null;
     this.TargetDatabase = linkConnection?.TargetDatabase != null ? new PSLinkConnectionTargetDatabase(linkConnection?.TargetDatabase) : null;
     this.LandingZone    = linkConnection?.LandingZone != null ? new PSLinkConnectionLandingZone(linkConnection?.LandingZone) : null;
     this.Compute        = linkConnection?.Compute != null ? new PSLinkConnectionCompute(linkConnection?.Compute) : null;
 }
Пример #2
0
        private async Task Run()
        {
            PortConnection portConn = new PortConnection(ip.ipAddress);
            Port           port     = Task.Run(() => portConn.GetNextPort(previousPortNumber)).Result;

            if (port == null)
            {
                addLog(true, ip.ipAddress, null, "not found next port!");
                return;
            }

            loadPort(port.portNumber);
            if (port.links != null && port.links.Count > 0)
            {
                loadLink(port.portNumber, 0);
            }

            //Set để chạy port kế tiếp khi làm xong
            previousPortNumber = port.portNumber;
            //Chạy port
            string ipAddress = ip.ipAddress, portNumber = port.portNumber;

            addLog(true, ipAddress, portNumber, "run port!");

            if (!port.active || !port.data || !port.die || !port.port)
            {
                addLog(true, ipAddress, portNumber, "port not active!");
                return;
            }

            //Lay link dau tien cua port
            LinkConnection linkConn = new LinkConnection(ipAddress, portNumber);
            Link           link     = Task.Run(() => linkConn.GetFirstElement()).Result;

            addLog(true, ipAddress, portNumber, "run link: " + link.link);
            addLog(true, ipAddress, portNumber, "\tdelete link on database!");

            //Xoa link
            await linkConn.Delete(link.key);

            //Update port
            link = Task.Run(() => linkConn.GetFirstElement()).Result;
            if (link == null)
            {
                port        = Task.Run(() => portConn.GetWithKey(portNumber)).Result;
                port.data   = false;
                port.active = false;
                //update port
                await portConn.Update(port);
            }

            //Thit
            //.....
            addLog(true, ipAddress, portNumber, "\tstep 1!");
            addLog(true, ipAddress, portNumber, "\tstep 2!");
            addLog(true, ipAddress, portNumber, "\tstep ...!");
            addLog(true, ipAddress, portNumber, "\tstep n!");
        }
Пример #3
0
        public FormEditLink(string ipAddress, string portNumber, string key)
        {
            this.ipAddress  = ipAddress;
            this.portNumber = portNumber;
            this.key        = key;
            linkConn        = new LinkConnection(ipAddress.Replace(".", "_"), portNumber);
            link            = Task.Run(() => linkConn.GetWithKey(key)).Result;

            InitializeComponent();
        }
Пример #4
0
        private void loadLink()
        {
            bool success = false;
            int  loop    = 0;

            do
            {
                if (loop == 10)
                {
                    break;
                }
                try
                {
                    lv_link.Items.Clear();
                    if (IPSelected == null || PortSelected == null)
                    {
                        return;
                    }

                    LinkConnection            linkConn = new LinkConnection(IPSelected.ipAddress, PortSelected.portNumber);
                    Dictionary <string, Link> lst      = new Dictionary <string, Link>();
                    lst = Task.Run(() => linkConn.GetAll()).Result;

                    foreach (Link link in lst.Values)
                    {
                        ListViewItem item = new ListViewItem(PortSelected.portNumber);
                        item.SubItems.Add(link.key == null ? "" : link.key);
                        item.SubItems.Add(link.link == null ? "" : link.link);
                        item.SubItems.Add(link.linkThumbnail == null ? "" : link.linkThumbnail);
                        item.SubItems.Add(link.title == null ? "" : link.title);
                        item.SubItems.Add(link.tag == null ? "" : link.tag);
                        item.SubItems.Add(link.description == null ? "" : link.description);
                        item.SubItems.Add(link.linkAff == null ? "" : link.linkAff);
                        item.SubItems.Add(link.type + "");

                        lv_link.Items.Add(item);
                    }
                    success = true;
                }
                catch
                {
                    loop++;
                    Thread.Sleep(1000);
                }
            } while (!success);

            if (!success)
            {
                MessageBox.Show("Đã thử load " + loop + " lần mà *** đc :))");
            }
        }
Пример #5
0
        private void loadLink(string portNumber, int index)
        {
            lv_link.Items.Clear();
            PortConnection portConn     = new PortConnection(ip.ipAddress);
            Port           PortSelected = Task.Run(() => portConn.GetWithKey(portNumber)).Result;

            if (ip == null || PortSelected == null)
            {
                return;
            }

            LinkConnection            linkConn = new LinkConnection(ip.ipAddress, PortSelected.portNumber);
            Dictionary <string, Link> lst      = new Dictionary <string, Link>();

            lst = Task.Run(() => linkConn.GetAll()).Result;

            int i = 0;

            foreach (Link link in lst.Values)
            {
                ListViewItem item = new ListViewItem(PortSelected.portNumber);
                item.SubItems.Add(link.key == null ? "" : link.key);
                item.SubItems.Add(link.link == null ? "" : link.link);
                item.SubItems.Add(link.linkThumbnail == null ? "" : link.linkThumbnail);
                item.SubItems.Add(link.title == null ? "" : link.title);
                item.SubItems.Add(link.description == null ? "" : link.description);
                item.SubItems.Add(link.type == null ? "" : link.type + "");

                if (index != -1 && index == i)
                {
                    item.BackColor = Color.Blue;
                }
                i++;
                lv_link.Items.Add(item);
            }
        }
Пример #6
0
 public OutputConfiguration(LinkConnection linkConnection)
 {
     LinkConnection = linkConnection;
 }
Пример #7
0
 public LinkConnectionViewModel(LinkConnection linkConnection)
 {
     LinkConnectionData = linkConnection;
 }
Пример #8
0
        private async void btn_addLink_Click(object sender, EventArgs e)
        {
            if (PortSelected == null)
            {
                MessageBox.Show("Chua chon Port!");
                return;
            }

            this.Enabled = false;
            bool success = false;
            int  loop    = 0;

            do
            {
                if (loop == 10)
                {
                    break;
                }
                try
                {
                    Link link = new Link();
                    link.link          = txt_link.Text;
                    link.linkThumbnail = txt_linkThumbnail.Text;
                    link.title         = txt_title.Text;
                    link.tag           = txt_tag.Text;
                    link.description   = txt_description.Text;
                    link.linkAff       = txt_linkAff.Text;
                    link.type          = Int32.Parse(txt_type.Text);

                    LinkConnection linkConn = new LinkConnection(IPSelected.ipAddress, PortSelected.portNumber);
                    await linkConn.Insert(link);

                    //Update port.data
                    PortConnection portConn = new PortConnection(IPSelected.ipAddress);
                    PortSelected = Task.Run(() => portConn.GetWithKey(PortSelected.portNumber)).Result;
                    if (PortSelected.links != null && PortSelected.links.Count > 0 && !PortSelected.data)
                    {
                        PortSelected.data = true;
                        await portConn.Delete(PortSelected.portNumber);

                        await portConn.Insert(PortSelected);

                        loadPort();
                    }

                    success = true;

                    loadLinkWithWaitForm();
                    resetInputLink();
                }
                catch
                {
                    loop++;
                    Thread.Sleep(2000);
                }
            } while (!success);

            if (!success)
            {
                MessageBox.Show("Đã thử " + loop + " lần mà *** đc :))");
                this.Enabled = true;
            }
            this.Enabled = true;
        }