Ejemplo n.º 1
0
        public List <InstrumentInfo> getInsrumetns(UserData _user)
        {
            List <InstrumentInfo> instrumentInfoList   = new List <InstrumentInfo>();
            LicenseServiceClient  licenseServiceClient = new LicenseServiceClient();

            foreach (InstrumentsContract instrumentsContract in ((IEnumerable <InstrumentsContract>)licenseServiceClient.getInstuments(new Trader()
            {
                Account = _user.User,
                Signature = _user.Signature
            })).Where <InstrumentsContract>((Func <InstrumentsContract, bool>)(inst => inst.Enabled)))
            {
                InstrumentInfo instrumentInfo = new InstrumentInfo()
                {
                    ID         = instrumentsContract.DisplayId,
                    Name       = instrumentsContract.Description,
                    Parameters = new string[2]
                    {
                        instrumentsContract.Parametr1,
                        instrumentsContract.Parametr2
                    },
                    Providerid = instrumentsContract.ProviderId
                };
                instrumentInfoList.Add(instrumentInfo);
            }
            return(instrumentInfoList);
        }
Ejemplo n.º 2
0
        private void button8_Click(object sender, EventArgs e)
        {
            this.panel2.Focus();
            LicenseServiceClient licenseServiceClient = new LicenseServiceClient();

            foreach (DataGridViewRow row in (IEnumerable)this.lwInstruments.Rows)
            {
                try
                {
                    string s = row.Cells["InstrumentId"].Value.ToString();
                    licenseServiceClient.setInstumentState(long.Parse(s), (bool)row.Cells["Active"].Value);
                }
                catch
                {
                }
            }
            licenseServiceClient.Close();
            SettingsProvider.Settings.LocalSetting.GetInstruments();
            if (!MainWindow.processes.ContainsKey("Lmax"))
            {
                return;
            }
            MainWindow.stopProcess("Lmax");
            MainWindow.startProcess("Lmax", "");
        }
Ejemplo n.º 3
0
        public void sendLogin()
        {
            LicenseServiceClient licenseServiceClient = new LicenseServiceClient();

            licenseServiceClient.sendLogin(new Trader()
            {
                Account   = this.User,
                Signature = this.Config
            });
            licenseServiceClient.Close();
        }
        private void bSubmit_Click(object sender, EventArgs e)
        {
            bool   flag = true;
            string text = "";

            if (this.tbInstrumentId.Text == "")
            {
                text += "Instrument id must be defined\n";
                flag  = false;
            }
            if (this.tbExchange.Text == "" && this.cbProvider.Text == "Rithmic")
            {
                text += "Exchange must be defined";
                flag  = false;
            }
            if (this.tbName.Text == "")
            {
                text += "Name  must be defined";
                flag  = false;
            }
            if (this.cbProvider.Text == "")
            {
                text += "Provider must be defined";
                flag  = false;
            }
            if (!flag)
            {
                Error2.showError(text);
            }
            else
            {
                LicenseServiceClient licenseServiceClient = new LicenseServiceClient();
                int num = licenseServiceClient.addInstrument(new InstrumentsContract()
                {
                    DisplayId   = this.tbInstrumentId.Text,
                    Description = this.tbName.Text,
                    Parametr1   = this.tbExchange.Text,
                    ProviderId  = this.providerDict[this.cbProvider.Text]
                });
                licenseServiceClient.Close();
                if (num == 0)
                {
                    Error2.showError("Instument already under revision");
                }
                else
                {
                    if (num != 1)
                    {
                        return;
                    }
                    Error2.showError("Your request has been added");
                }
            }
        }
Ejemplo n.º 5
0
        private void button8_Click(object sender, EventArgs e)
        {
            this.panel2.Focus();
            LicenseServiceClient licenseServiceClient = new LicenseServiceClient();

            foreach (DataGridViewRow row in (IEnumerable)this.lwInstruments.Rows)
            {
                licenseServiceClient.setInstumentState(long.Parse(row.Cells["InstrumentId"].Value.ToString()), (bool)row.Cells["Active"].Value);
            }
            licenseServiceClient.Close();
            SettingsProvider.Settings.LocalSetting.GetInstruments();
            MainWindow.stopProcess("Saxo");
            MainWindow.startProcess("Saxo", "");
        }
Ejemplo n.º 6
0
        public static bool checkLicense(string Account, string SKU)
        {
            LicenseServiceClient licenseServiceClient1 = new LicenseServiceClient();
            LicenseServiceClient licenseServiceClient2 = licenseServiceClient1;
            Trader _traderData = new Trader();

            _traderData.Account   = Account;
            _traderData.Signature = SettingsProvider.Security.CalcHash(Account);
            string SKU1 = SKU;
            int    num  = licenseServiceClient2.checkLicense(_traderData, SKU1) == 0 ? 1 : 0;

            licenseServiceClient1.Close();
            return(num == 0);
        }
Ejemplo n.º 7
0
        public static ICollection <InstrumentsContract> getInstuments(string Account, string SKU, string Product = "")
        {
            LicenseServiceClient licenseServiceClient1 = new LicenseServiceClient();
            LicenseServiceClient licenseServiceClient2 = licenseServiceClient1;
            Trader _traderData = new Trader();

            _traderData.Account   = Account;
            _traderData.Signature = SettingsProvider.Security.CalcHash(Account);
            string SKU1         = SKU;
            string ProviderName = Product;

            InstrumentsContract[] instumentsSku = licenseServiceClient2.getInstumentsSKU(_traderData, SKU1, ProviderName);
            licenseServiceClient1.Close();
            return((ICollection <InstrumentsContract>)instumentsSku);
        }
Ejemplo n.º 8
0
        public string addNewInstrument(string _InstrumentId, string _Name, string _Parametr1, int _Provider, string _Parametr2 = "")
        {
            bool   flag = true;
            string str1 = "";

            if (_InstrumentId == "")
            {
                str1 += "Instrument id must be defined\n";
                flag  = false;
            }
            if (_Parametr1 == "" && _Provider == 3)
            {
                str1 += "Exchange must be defined";
                flag  = false;
            }
            if (_Name == "")
            {
                str1 += "Name  must be defined";
                flag  = false;
            }
            if (!flag)
            {
                return(str1);
            }
            string str2 = "";
            LicenseServiceClient licenseServiceClient = new LicenseServiceClient();
            int num = licenseServiceClient.addInstrument(new InstrumentsContract()
            {
                DisplayId   = _InstrumentId,
                Description = _Name,
                Parametr1   = _Parametr1,
                Parametr2   = _Parametr2,
                ProviderId  = _Provider
            });

            licenseServiceClient.Close();
            switch (num)
            {
            case 0:
                str2 = "Instument already under revision";
                break;

            case 1:
                str2 = "Your request has been added";
                break;
            }
            return(str2);
        }
Ejemplo n.º 9
0
        public bool connectToServer()
        {
            bool flag = false;
            LicenseServiceClient licenseServiceClient = new LicenseServiceClient();

            if (licenseServiceClient.checkUser(new Trader()
            {
                Account = Settings.LocalSetting.User,
                Signature = Settings.LocalSetting.Config
            }) == 0)
            {
                flag = true;
            }
            licenseServiceClient.Close();
            return(true);
        }
Ejemplo n.º 10
0
 public void getProxySettings()
 {
     byte[] lmaxSettings = new LicenseServiceClient().getLmaxSettings(new Trader()
     {
         Account   = this.User,
         Signature = this.Config
     });
     if (lmaxSettings == null)
     {
         return;
     }
     string[] strArray = Encoding.ASCII.GetString(lmaxSettings).Split('!');
     this.lamxProxyUrl = strArray[0];
     Settings.LmaxSettings lmax = Settings.LocalSetting.Lmax;
     lmax.User     = strArray[1];
     lmax.Password = strArray[2];
     Settings.LocalSetting.Lmax = lmax;
 }
Ejemplo n.º 11
0
        public bool canUseFeed(UserData _user)
        {
            LicenseServiceClient licenseServiceClient = new LicenseServiceClient();
            bool flag;

            try
            {
                flag = (uint)licenseServiceClient.canUseFeed(new Trader()
                {
                    Account   = _user.User,
                    Signature = _user.Signature
                }) > 0U;
                licenseServiceClient.Close();
            }
            catch
            {
                flag = false;
            }
            return(true);
        }
Ejemplo n.º 12
0
        public bool Authorize(UserData _user)
        {
            LicenseServiceClient licenseServiceClient = new LicenseServiceClient();
            bool flag;

            try
            {
                flag = licenseServiceClient.checkUser(new Trader()
                {
                    Account   = _user.User,
                    Signature = _user.Signature
                }) == 0;
                licenseServiceClient.Close();
            }
            catch
            {
                flag = false;
            }
            return(true);
        }
        public NewInstrumentRequest()
        {
            this.InitializeComponent();
            this.providerDict = new Dictionary <string, int>();
            LicenseServiceClient licenseServiceClient = new LicenseServiceClient();

            ProviderContract[] providers = licenseServiceClient.getProviders(new Trader()
            {
                Account   = Settings.LocalSetting.User,
                Signature = Settings.LocalSetting.Config
            });
            if (providers != null)
            {
                foreach (ProviderContract providerContract in providers)
                {
                    this.providerDict.Add(providerContract.Name, providerContract.Id);
                    this.cbProvider.Items.Add((object)providerContract.Name);
                }
            }
            licenseServiceClient.Close();
        }
Ejemplo n.º 14
0
        public void getProxySettingsRithmic()
        {
            byte[] rithmicSettings = new LicenseServiceClient().getRithmicSettings(new Trader()
            {
                Account   = this.User,
                Signature = this.Config
            });
            if (rithmicSettings == null)
            {
                return;
            }
            string[] strArray = Encoding.ASCII.GetString(rithmicSettings).Split('!');
            this.lamxProxyUrl = strArray[0];
            this.RUser        = strArray[1];
            this.RPass        = strArray[2];
            WebProxy webProxy = new WebProxy(this.lamxProxyUrl, 9798);

            webProxy.BypassList = new List <string>((IEnumerable <string>)webProxy.BypassList)
            {
                this.lamxProxyUrl
            }.ToArray();
        }
 public LicenseDataService()
 {
     this._client = new LicenseServiceClient();
 }
Ejemplo n.º 16
0
        public void GetInstruments()
        {
            if (this.CQGInstruments != null)
            {
                this.CQGInstruments.Clear();
            }
            if (this.SaxoInstruments != null)
            {
                this.SaxoInstruments.Clear();
            }
            if (this.LmaxInstruments != null)
            {
                this.LmaxInstruments.Clear();
            }
            if (this.rithmicSubscriptions != null)
            {
                this.rithmicSubscriptions.Clear();
            }
            if (this.TWSInstruments != null)
            {
                this.TWSInstruments.Clear();
            }
            if (this.IQInstruments != null)
            {
                this.IQInstruments.Clear();
            }
            if (!new Security().connectToServer())
            {
                return;
            }
            LicenseServiceClient    licenseServiceClient = new LicenseServiceClient();
            List <ProviderContract> list1 = ((IEnumerable <ProviderContract>)licenseServiceClient.getProviders(new Trader()
            {
                Account = this.User,
                Signature = this.Config
            })).ToList <ProviderContract>();
            List <InstrumentsContract> list2 = ((IEnumerable <InstrumentsContract>)licenseServiceClient.getInstuments(new Trader()
            {
                Account = this.User,
                Signature = this.Config
            })).ToList <InstrumentsContract>();

            licenseServiceClient.Close();
            if (list1 != null && list2 != null)
            {
                foreach (InstrumentsContract instrumentsContract in list2)
                {
                    InstrumentsContract            p      = instrumentsContract;
                    IEnumerable <ProviderContract> source = list1.Where <ProviderContract>((Func <ProviderContract, bool>)(pr => pr.Id == p.ProviderId));
                    if (source != null && source.Count <ProviderContract>() == 1)
                    {
                        string name = source.First <ProviderContract>().Name;
                        if (!(name == "Lmax"))
                        {
                            if (!(name == "CQG"))
                            {
                                if (!(name == "Saxo"))
                                {
                                    if (!(name == "Rithmic"))
                                    {
                                        if (!(name == "TWS"))
                                        {
                                            if (name == "IQFeed")
                                            {
                                                this.IQInstruments.Add(new Settings.IQFeedInstruments()
                                                {
                                                    Id      = p.Id,
                                                    Symbol  = p.DisplayId,
                                                    Name    = p.Description,
                                                    Enabled = p.Enabled
                                                });
                                            }
                                        }
                                        else
                                        {
                                            string[] strArray = p.DisplayId.Split('%');
                                            this.TWSInstruments.Add(new Settings.TWSSubscription()
                                            {
                                                InstumentId = p.Id,
                                                Symbol      = strArray[0],
                                                Currency    = strArray[1],
                                                SecType     = p.Parametr1,
                                                Exchange    = p.Parametr2,
                                                Enabled     = p.Enabled
                                            });
                                        }
                                    }
                                    else
                                    {
                                        this.rithmicSubscriptions.Add(new Settings.rithmicSubscription()
                                        {
                                            InstumentId = p.Id,
                                            symbol      = p.DisplayId,
                                            Description = p.Description,
                                            exchange    = p.Parametr1,
                                            Enabled     = p.Enabled
                                        });
                                    }
                                }
                                else
                                {
                                    this.SaxoInstruments.Add(new Settings.SaxoValues()
                                    {
                                        InstumentId    = p.Id,
                                        InstrumentType = p.DisplayId,
                                        Name           = p.Description,
                                        Enabled        = p.Enabled
                                    });
                                }
                            }
                            else
                            {
                                this.CQGInstruments.Add(new Settings.CQGInstrument()
                                {
                                    InstumentId = p.Id,
                                    Instrument  = p.DisplayId,
                                    Enabled     = p.Enabled
                                });
                            }
                        }
                        else
                        {
                            int result = 0;
                            if (int.TryParse(p.DisplayId, out result) && !this.LmaxInstruments.ContainsKey(result))
                            {
                                this.LmaxInstruments.Add(result, new Settings.LmaxValues()
                                {
                                    InstrumentId = p.Id,
                                    Name         = p.Description,
                                    Enabled      = p.Enabled
                                });
                            }
                        }
                    }
                }
            }
            Settings.LocalSetting.rithmicSubscriptions = this.rithmicSubscriptions;
        }