Ejemplo n.º 1
0
 public static void SendGrams(Form parent, ContractItem senderItem, OwnerItem destItem)
 {
     if (senderItem != null && destItem != null)
     {
         if (destItem != null)
         {
             using (SendGramForm form = new SendGramForm(senderItem.Contract, destItem.Owner))
             {
                 if (form.ShowDialog(parent) == DialogResult.OK)
                 {
                     if (Constants.LinuxMode && form.Grams > 0)
                     {
                         senderItem.StartWait();
                         destItem.StartWait();
                         ThreadStack.Run(delegate(object[] param)
                         {
                             Contract src = param[0] as Contract;
                             Owner dst    = param[1] as Owner;
                             src.SendGram(dst.Address, (double)(decimal)param[2]);
                             if (dst is Contract)
                             {
                                 (dst as Contract).WaitGramsChanged();
                             }
                         }, senderItem.Contract, destItem.Owner, form.Grams);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        private void removeContractMenuItem_Click(object sender, EventArgs e)
        {
            ContractItem manageritem = this.managersListView.SelectedItem;

            if (manageritem != null)
            {
                ManagerContract manager = manageritem.Contract as ManagerContract;
                ContractItem    item    = this.contractListView.SelectedItem;
                if (item != null)
                {
                    if (Constants.LinuxMode)
                    {
                        item.StartWait();
                        manageritem.StartWait();
                        ThreadStack.Run(delegate(object[] param)
                        {
                            ManagerContract mc  = param[0] as ManagerContract;
                            ContractItem ctitem = param[1] as ContractItem;
                            if (mc.RemoveContact(ctitem.Contract))
                            {
                                mc.Contracts.Remove(ctitem.Contract);
                                Utils.Invoke(this, delegate
                                {
                                    this.contractListView.Items.Remove(ctitem);
                                });
                                mc.WaitGramsChangedLoop();
                            }
                        }, manager, item);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 private static void GetGrams(Contract contract)
 {
     if (Constants.LinuxMode)
     {
         ThreadStack.Run(delegate(object[] param)
         {
             (param[0] as Contract).GetGrams();
         }, contract);
     }
 }
Ejemplo n.º 4
0
 public void SendMessage(Owner dest, Message message)
 {
     if (Constants.LinuxMode)
     {
         ThreadStack.Run(delegate(object[] param)
         {
             ClientExecutor.Instance.SendMessage(param[0] as Contract, param[1] as Owner, param[2] as Message);
         }, this, dest, message);
     }
 }
Ejemplo n.º 5
0
 public void ChangeOwner(bool wait)
 {
     if (Constants.LinuxMode)
     {
         ThreadStack.Run(delegate(object[] param)
         {
             ClientExecutor.Instance.ChangeOwner(param[0] as Contract, (bool)param[1]);
         }, this, wait);
     }
 }
Ejemplo n.º 6
0
 public void ChangeCode()
 {
     if (Constants.LinuxMode)
     {
         ThreadStack.Run(delegate(object[] param)
         {
             ClientExecutor.Instance.ChangeCode(param[0] as Contract);
         }, this);
     }
 }
Ejemplo n.º 7
0
 private void findButton_Click(object sender, EventArgs e)
 {
     if (Constants.LinuxMode)
     {
         this.findButton.Enabled = false;
         ThreadStack.Run(delegate(object[] param)
         {
             this.member = ClientExecutor.Instance.GetMember(param[0] as string);
             Utils.Invoke(this, this.UpdateMember);
         }, this.textBox1.Text);
     }
 }
Ejemplo n.º 8
0
        public void LoadManagers(Form form)
        {
            if (this.managers.Count == 0)
            {
                ThreadStack.Run(delegate(object[] param)
                {
                    if (Constants.LinuxMode)
                    {
                        ClientExecutor.Instance.Start();
                    }
                    foreach (string file in Directory.GetFiles(Constants.ContractsDirectory, "*.ct"))
                    {
                        using (StreamReader reader = new StreamReader(file))
                        {
                            ManagerContract manager = new ManagerContract(reader);
                            this.managers.Add(manager);
                            if (Constants.LinuxMode)
                            {
                                Owner owner = ClientExecutor.Instance.GetOwner(manager.Address);
                                if (owner != null)
                                {
                                    manager.Update(owner);
                                    manager.LoadContracts();
                                }
                            }
                            else
                            {
                                MessengerContract contract = new MessengerContract("Александр Гордиенко", MessagerType.Private);
                                contract.Update("0", null, null, ContractState.Online);
                                contract.Members.Add(new Member("Вася", "1", ContractState.Online, MessagerType.Private));
                                contract.Members.Add(new Member("Петя", "2", ContractState.Offline, MessagerType.Private));
                                manager.Contracts.Add(contract);

                                contract = new MessengerContract("Вася", MessagerType.Public);
                                contract.Update("1", null, null, ContractState.Online);
                                contract.Members.Add(new Member("Андрей", "3", ContractState.Online, MessagerType.Public));
                                contract.Members.Add(new Member("Сергей", "4", ContractState.Offline, MessagerType.Private));
                                manager.Contracts.Add(contract);

                                contract = new MessengerContract("Андрей", MessagerType.Public);
                                contract.Update("3", null, null, ContractState.Online);
                                contract.Members.Add(new Member("Алексей", "5", ContractState.Offline, MessagerType.Public));
                                contract.Members.Add(new Member("Михаил", "6", ContractState.Online, MessagerType.Public));
                                manager.Contracts.Add(contract);
                            }
                        }
                    }

                    Utils.Invoke(form, this.StartLoaded);
                });
            }
        }
Ejemplo n.º 9
0
 private void createManagerButton_Click(object sender, EventArgs e)
 {
     using (CreateManagerForm form = new CreateManagerForm(Utils.GetNext("Manager", managers)))
     {
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             ManagerContract manager = new ManagerContract(form.ContractName, 0);
             this.Add(manager);
             if (Constants.LinuxMode)
             {
                 ThreadStack.Run(delegate(object[] param)
                 {
                     ClientExecutor.Instance.CreateContract(param[0] as Contract, param[1] as string);
                 }, manager, form.WorkchainID);
             }
         }
     }
 }
Ejemplo n.º 10
0
        private void createContractButton_Click(object sender, EventArgs e)
        {
            ContractItem manageritem = this.managersListView.SelectedItem;

            if (manageritem != null)
            {
                ManagerContract manager = manageritem.Contract as ManagerContract;

                using (CreateContractForm form = new CreateContractForm(Utils.GetNext("Messenger", this.contractListView.Items)))
                {
                    if (form.ShowDialog(this) == DialogResult.OK)
                    {
                        Contract     contract = Contract.Create(form.ContractName, form.ContractType, form.OwnerType);
                        ContractItem item     = new ContractItem(contract);
                        this.contractListView.Items.Add(item);
                        this.contractListView.SelectedItem = item;
                        item.StartWait();
                        manageritem.StartWait();
                        if (Constants.LinuxMode)
                        {
                            ThreadStack.Run(delegate(object[] param)
                            {
                                ManagerContract mgr = param[0] as ManagerContract;
                                Contract ct         = param[1] as Contract;
                                ClientExecutor.Instance.CreateContract(ct, param[2] as string);
                                if (!item.IsWaitState)
                                {
                                    item.StartWait();
                                }
                                mgr.Contracts.Add(contract);
                                ClientExecutor.Instance.InitContract(mgr, ct, (double)param[3]);
                                manageritem.StartWait();
                                mgr.AddContract(ct);
                                Utils.Invoke(this, this.OnManagersLoaded);
                            }, manager, contract, form.WorkchainID, (double)form.Grams);
                        }
                    }
                }
            }
        }
Ejemplo n.º 11
0
 private void WaitTimerChanged(object state)
 {
     ThreadStack.Run(this.WaitGramsChanged);
 }