示例#1
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            _se = new ServerEnum();
            foreach (string key in _se.Keys)
            {
                cbxServerType.Items.Add(key);
                txtAssembly.Text = _se[key];
            }
            if (cbxServerType.Items.Count > 0)
            {
                cbxServerType.SelectedIndex = 0;
            }


            cbxVerifyWay.Items.Add("");

            _ve = new VerifyEnum();
            foreach (string key in _ve.Keys)
            {
                cbxVerifyWay.Items.Add(key);
                //txtVerifyAssembly.Text = _ve[key];
            }
            if (cbxVerifyWay.Items.Count > 0)
            {
                cbxVerifyWay.SelectedIndex = 0;
            }


            _sm.LoadFromFile();


            ReindData();

            SyncSelRowData();
        }
示例#2
0
 public Type GetPacketHandler(string packet, ServerEnum serverType)
 {
     return(serverType switch
     {
         ServerEnum.Main => (_mainRequestHandlers.ContainsKey(packet) ? _mainRequestHandlers[packet] : null),
         ServerEnum.Game => (_gameRequestHandlers.ContainsKey(packet) ? _gameRequestHandlers[packet] : null),
         ServerEnum.Chat => (_chatRequestHandlers.ContainsKey(packet) ? _chatRequestHandlers[packet] : null),
         _ => null
     });
示例#3
0
        static public IDBQuery GetLocalDBHelper(string dbServerAlias, IDBQuery dbSys, ref string strErr)
        {
            strErr = "";

            if (string.IsNullOrEmpty(dbServerAlias))
            {
                return(dbSys);
            }

            if (_sm == null)
            {
                _sm = new ServerManager();
                _sm.LoadFromFile();
            }

            ServerInfo si = _sm.FindAlias(dbServerAlias);


            if (si == null)
            {
                strErr = "未找到对应的服务器配置信息。";
                return(null);
            }

            if (string.IsNullOrEmpty(si.ServerDriverFile))
            {
                strErr = "未配置数据访问程序集。";
                return(null);
            }

            IDBProvider dbProvider = ServerEnum.GetDBProvider(si.ServerDriverFile);

            if (dbProvider == null)
            {
                strErr = "数据访问实例 [" + si.ServerDriverFile + "] 创建失败。";
                return(null);
            }


            dbProvider.Init(si.ServerIP, si.ServerPort, si.ServerInstance, si.GrantAccount, si.GrantPwd);

            IDbConnection dc = dbProvider.Open(ref strErr);

            if (dc == null)
            {
                strErr = "数据服务访问失败:" + strErr;
                return(null);
            }

            return(dbProvider);
        }
示例#4
0
 private List <Order> GetOrderFromJtoken(JToken jtoken, ServerEnum server)
 {
     return(jtoken?.Select(order => new Order
                           (
                               id: order[0].Value <int>(),
                               price: order[3].Value <decimal>(),
                               amount: order[4].Value <decimal>(),
                               speed: order[6].Value <decimal>(),
                               workers: order[5].Value <int>(),
                               type: order[1].Value <int>(),
                               active: order[2].Value <int>(),
                               server: server
                           )).ToList());
 }
示例#5
0
        private void ExpandEntireNetwork(TreeNode network)
        {
            TreeNode nodeNN;

            if (network.FirstNode.Text != ENTIRE_NETWORK_DUMMY)
            {
                return;                 // already expanded.  The dummy node is called Network Node
            }
            network.FirstNode.Remove();

            ServerEnum servers = new ServerEnum(ResourceScope.RESOURCE_GLOBALNET, ResourceType.RESOURCETYPE_DISK, ResourceUsage.RESOURCEUSAGE_ALL, ResourceDisplayType.RESOURCEDISPLAYTYPE_NETWORK, "");

            foreach (string server in servers)
            {
                string name = server.Substring(0, server.IndexOf("|", 1));
                if (server.IndexOf("NETWORK", 1) > 0)
                {
                    nodeNN = new TreeNode
                    {
                        Tag              = name,
                        Text             = name,
                        ImageKey         = "NetworkNode",
                        SelectedImageKey = "NetworkNode"
                    };
                    network.Nodes.Add(nodeNN);
                }
                else
                {
                    TreeNode nodemN = new TreeNode
                    {
                        Tag              = name,
                        Text             = name,
                        ImageKey         = "Network",
                        SelectedImageKey = "Network"
                    };
                    network.LastNode.Nodes.Add(nodemN);

                    TreeNode nodemNc = new TreeNode
                    {
                        Tag              = NETWORK_DUMMY,
                        Text             = NETWORK_DUMMY,
                        ImageKey         = "MyComputer",
                        SelectedImageKey = "MyComputer"
                    };
                    nodemN.Nodes.Add(nodemNc);
                }
            }
        }
示例#6
0
        private void ExpandNetworkNode(TreeNode parent)
        {
            if (parent.FirstNode.Text != NETWORK_DUMMY)
            {
                return;                 // already expanded
            }
            parent.FirstNode.Remove();
            ServerEnum servers = new ServerEnum(ResourceScope.RESOURCE_GLOBALNET, ResourceType.RESOURCETYPE_DISK, ResourceUsage.RESOURCEUSAGE_ALL, ResourceDisplayType.RESOURCEDISPLAYTYPE_SERVER, parent.Text);

            foreach (string serverName in servers)
            {
                if (serverName.Length < 6 || string.Compare(serverName.Substring(serverName.Length - 6, 6), "-share") != 0)
                {
                    string   name       = serverName;             //.Substring(s1.IndexOf("\\",2))
                    TreeNode serverNode = new TreeNode
                    {
                        Tag              = serverName,
                        Text             = serverName.Substring(2),
                        ImageKey         = "MyComputer",
                        SelectedImageKey = "MyComputer"
                    };
                    parent.Nodes.Add(serverNode);
                    foreach (string sub in servers)                     // look for items to display within this server (?)
                    {
                        if (sub.Length > 6 && sub.Substring(sub.Length - 6, 6) == "-share" && name.Length <= sub.Length)
                        {
                            try
                            {
                                if (sub.Substring(0, name.Length + 1) == name + Path.DirectorySeparatorChar)
                                {
                                    TreeNode folder = new TreeNode
                                    {
                                        Tag              = sub.Substring(0, sub.Length - 6),
                                        Text             = sub.Substring(name.Length + 1, sub.Length - name.Length - 7),
                                        ImageKey         = "SharedFolder",
                                        SelectedImageKey = "SharedFolder"
                                    };
                                    serverNode.Nodes.Add(folder);
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                }
            }
        }
示例#7
0
        public static IServer GetServer(ServerEnum serverEnum)
        {
            IServer server = null;

            switch (serverEnum)
            {
            case ServerEnum.SQLserver:
                server = new SqlServer();
                break;

            case ServerEnum.AccessServer:
                server = new AccessServer();
                break;
            }
            return(server);
        }
示例#8
0
        private void butVerify_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtAssembly.Text))
                {
                    MessageBox.Show("未指定对应的服务驱动文件,不能进行验证。", "提示");
                    return;
                }

                IDBProvider dbProvide = ServerEnum.GetDBProvider(txtAssembly.Text);

                if (dbProvide != null)
                {
                    dbProvide.Init(txtIp.Text, int.Parse(txtPort.Text), txtInstance.Text, txtUserAccount.Text, txtUserPwd.Text);

                    string        strError = "";
                    IDbConnection dc       = dbProvide.Open(ref strError);

                    if (dc == null)
                    {
                        MessageBox.Show("验证失败:" + strError, "提示");
                    }
                    else
                    {
                        MessageBox.Show("验证成功。", "提示");
                    }

                    return;
                }
                else
                {
                    MessageBox.Show("数据访问实例创建失败。", "提示");
                }
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }
示例#9
0
        // Constructor

        //
        //    Discover
        //    ========
        //
        //    Base class over-ride to perform the actual work
        //
        public override int Discover()
        {
            try
            {
                ServerEnum servers = new ServerEnum(ResourceScope.RESOURCE_GLOBALNET
                                                    , ResourceType.RESOURCETYPE_DISK
                                                    , ResourceUsage.RESOURCEUSAGE_ALL
                                                    , ResourceDisplayType.RESOURCEDISPLAYTYPE_SERVER);

                // The data is returned in an array list with the name encapsulated in the form
                // domain\\PC which we have to split and add to our own list
                foreach (Server server in servers)
                {
                    string strComputer = server.Name.ToString();
                    string strDomain   = server.Domain.ToString();

                    // Skip any where we have no domain
                    if (strDomain == "")
                    {
                        continue;
                    }

                    // ...and add this to our list
                    string         thisIp     = IpAddress(strComputer);
                    DiscoveredItem item       = new DiscoveredItem(strComputer, strDomain, thisIp);
                    bool           bCancelled = Add(item);
                    if (bCancelled)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                return(-1);                                                             // Server probably doesn't exist
            }

            return(0);
        }
示例#10
0
        public Order(int id, decimal price, decimal amount, decimal speed, int workers, int type, int active, ServerEnum server = ServerEnum.Unknown)
        {
            Server = server;

            _id      = id;
            _price   = price;
            _amount  = amount;
            _speed   = speed;
            _workers = workers;
            _active  = active == 1;

            if (type == 0)
            {
                _type = OrderTypeEnum.Standart;
            }
            else if (type == 1)
            {
                _type = OrderTypeEnum.Fixed;
            }

            //MarketLogger.Information("counstructor: {@orderId})", Id);
        }
示例#11
0
        private void frmThridDBConfig_Load(object sender, EventArgs e)
        {
            try
            {
                _se = new ServerEnum();
                foreach (string key in _se.Keys)
                {
                    cbxServerType.Items.Add(key);
                    txtAssembly.Text = _se[key];
                }
                if (cbxServerType.Items.Count > 0)
                {
                    cbxServerType.SelectedIndex = 0;
                }


                RefreshSetting();
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }
示例#12
0
        public Connection(Bot bot, string city)
        {
            Bot  = bot;
            city = city.Replace(".timezero.ru", "");

            _serverType = city switch
            {
                "main" => ServerEnum.Main,
                "test" => ServerEnum.Main,
                "city1" => ServerEnum.Game,
                "city2" => ServerEnum.Game,
                "city3" => ServerEnum.Game,
                "city4" => ServerEnum.Game,
                "localhost" => ServerEnum.Game,
                "chat" => ServerEnum.Chat,
                "chat2" => ServerEnum.Chat,
                _ => ServerEnum.Main
            };

            _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            _socket.Connect(new IPEndPoint(Dns.GetHostAddresses(city + ".timezero.ru")[0], 5190));

            Start();
        }
示例#13
0
        private void backgroundWorker2_netscanner_DoWork(object sender, DoWorkEventArgs ev)
        {
            Program.netscan_in_progress = true;

            /*
             *      var nb = new NetworkBrowser();
             *      var doms = nb.GetNetworkDomains();
             *      //doms.Add("WORKGROUP");
             *      foreach (var domain in doms)
             *      {
             *              var comps = nb.GetNetworkComputers(domain);
             *              foreach (var computer in comps)
             *              {
             *                      var sc = new ShareCollection();
             *                      ShareCollection shares = ShareCollection.GetShares("\\\\" + computer); // no domain used here. computers need to be unique!?!?
             *                      foreach (Share share in shares) if (share.IsFileSystem && share.ShareType == ShareType.Disk)
             *                              {
             *                                      var drive = new NetworkDrive(share);
             *                                      Program.visibleNetworkDrives.Add(drive); //new Drive "\\\\" + computer + "\\" + share.NetName + " (" + share.Remark + ")"
             *                                      backgroundWorker2_netscanner.ReportProgress(50);
             *                              }
             *              }
             *      }
             */

            // approach #2: ServerEnum
            ServerEnum shares = new ServerEnum(ResourceScope.RESOURCE_GLOBALNET,
                                               ResourceType.RESOURCETYPE_DISK,
                                               ResourceUsage.RESOURCEUSAGE_ALL,
                                               ResourceDisplayType.RESOURCEDISPLAYTYPE_SHARE);
            List <Share> foundshares = new List <Share>();

            foreach (string servershare in Program.additional_netshares)
            {
                string[] split = servershare.Split(new char[1] {
                    '\\'
                });
                try {
                    Share share = ShareCollection.GetNetShareInfo(split[2], split[3]);
                    add_unique_share(foundshares, share);
                }
                catch (Exception e) {
                }
            }

            foreach (string servershare in shares)
            {
                string[] split = servershare.Split(new char[1] {
                    '\\'
                });
                try {
                    Share share = ShareCollection.GetNetShareInfo(split[2], split[3]);
                    add_unique_share(foundshares, share);
                }
                catch (Exception e) {
                }
            }

            lock (Program.visibleNetworkDrives) {
                Program.visibleNetworkDrives.Clear();

                foreach (Share share in foundshares)
                {
                    var drive = new NetworkDrive(share);
                    Program.visibleNetworkDrives.Add(drive);                     //new Drive "\\\\" + computer + "\\" + share.NetName + " (" + share.Remark + ")"
                }

                Program.netscan_in_progress = false;
            }
        }
示例#14
0
        protected static void PopulateEntity(SqlDataReader reader, ServerEntity entity, Dictionary <string, PropertyInfo> propMap)
        {
            for (int i = 0; i < reader.FieldCount; i++)
            {
                String columnName = reader.GetName(i);

                // Special case for when we select a range of values with an EntityBroker, just ignore
                if (columnName.Equals("RowNum"))
                {
                    continue;
                }

                if (columnName.Equals("GUID"))
                {
                    Guid uid = reader.GetGuid(i);
                    entity.SetKey(new ServerEntityKey(entity.Name, uid));
                    continue;
                }

                if (columnName.Equals(entity.Name) && columnName.Contains("Enum"))
                {
                    columnName = "Enum";
                }

                PropertyInfo prop;

                if (!propMap.TryGetValue(columnName, out prop))
                {
                    throw new EntityNotFoundException("Unable to match column to property: " + columnName, null);
                }

                if (columnName.Contains("GUID"))
                {
                    columnName = columnName.Replace("GUID", "Key");
                }

                if (reader.IsDBNull(i))
                {
                    prop.SetValue(entity, null, null);
                    continue;
                }

                Type propType = prop.PropertyType;
                if (propType == typeof(String))
                {
                    prop.SetValue(entity, reader.GetString(i), null);
                }
                else if (propType == typeof(ServerEntityKey))
                {
                    Guid uid = reader.GetGuid(i);
                    prop.SetValue(entity, new ServerEntityKey(columnName.Replace("Key", String.Empty), uid), null);
                }
                else if (propType == typeof(DateTime))
                {
                    prop.SetValue(entity, reader.GetDateTime(i), null);
                }
                else if (propType == typeof(DateTime?))
                {
                    if (reader.IsDBNull(i))
                    {
                        prop.SetValue(entity, null, null);
                    }
                    else
                    {
                        prop.SetValue(entity, reader.GetDateTime(i), null);
                    }
                }
                else if (propType == typeof(bool))
                {
                    prop.SetValue(entity, reader.GetBoolean(i), null);
                }
                else if (propType == typeof(Int32))
                {
                    prop.SetValue(entity, reader.GetInt32(i), null);
                }
                else if (propType == typeof(Int16))
                {
                    prop.SetValue(entity, reader.GetInt16(i), null);
                }
                else if (propType == typeof(double))
                {
                    prop.SetValue(entity, reader.GetDouble(i), null);
                }
                else if (propType == typeof(Decimal))
                {
                    prop.SetValue(entity, reader.GetDecimal(i), null);
                }
                else if (propType == typeof(float))
                {
                    prop.SetValue(entity, reader.GetFloat(i), null);
                }
                else if (propType == typeof(XmlDocument))
                {
                    SqlXml xml = reader.GetSqlXml(i);
                    if (xml != null && !xml.IsNull)
                    {
                        XmlReader xmlReader = xml.CreateReader();
                        if (xmlReader != null)
                        {
                            XmlDocument xmlDoc = new XmlDocument();
                            xmlDoc.Load(xmlReader);
                            prop.SetValue(entity, xmlDoc, null);
                        }
                        else
                        {
                            prop.SetValue(entity, null, null);
                        }
                    }
                    else
                    {
                        prop.SetValue(entity, null, null);
                    }
                }
                else if (typeof(ServerEnum).IsAssignableFrom(propType))
                {
                    short           enumVal   = reader.GetInt16(i);
                    ConstructorInfo construct = prop.PropertyType.GetConstructor(new Type[0]);
                    ServerEnum      val       = (ServerEnum)construct.Invoke(null);
                    val.SetEnum(enumVal);
                    prop.SetValue(entity, val, null);
                }
                else
                {
                    throw new EntityNotFoundException("Unsupported property type: " + propType, null);
                }
            }
        }
示例#15
0
 public SimpleServer(ServerEnum serverType)
 {
     socketListener  = new Socket(AddressFamily.InterNetwork, serverType == ServerEnum.P2PServer ? SocketType.Dgram : SocketType.Stream, serverType == ServerEnum.P2PServer ? ProtocolType.Udp : ProtocolType.Tcp);
     this.serverType = serverType;
 }
 string IServerEnumDescriptionTranslator.GetLocalizedDescription(ServerEnum serverEnum)
 {
     return GetLocalizedDescription(serverEnum);
 }
 public static string GetLocalizedLongDescription(ServerEnum enumValue)
 {
     return GetLocalizedText(GetLongDescriptionResKey(enumValue.Name, enumValue.Lookup));
 }
示例#18
0
        static public IDBQuery GetThridDBHelper(string dbServerAlias, IDBQuery dbSys, ref string strErr, bool blnForceRefresh = false)
        {
            strErr = "";

            if (string.IsNullOrEmpty(dbServerAlias))
            {
                return(dbSys);
            }

            if (_thridDbBuffer == null)
            {
                _thridDbBuffer = new Dictionary <string, IDBQuery>();
            }

            if (blnForceRefresh)
            {
                //如果是强制刷新,则先移除缓存对象
                if (_thridDbBuffer.ContainsKey(dbServerAlias))
                {
                    _thridDbBuffer.Remove(dbServerAlias);
                }
            }

            if (_thridDbBuffer.ContainsKey(dbServerAlias))
            {
                return(_thridDbBuffer[dbServerAlias]);
            }
            else
            {
                SQL sql = CreateSQL("查询三方数据源信息", "Select 数据源ID, 数据源别名,数据源信息 From 影像数据源信息 where 数据源别名=:数据源别名");
                sql.AddParameter("数据源别名", DbType.String, dbServerAlias);

                DataTable dtThridDb = dbSys.ExecuteSQL(sql);
                if (dtThridDb == null || dtThridDb.Rows.Count <= 0)
                {
                    return(dbSys);
                }

                ThridDBSourceData thridDbSource = new ThridDBSourceData();
                thridDbSource.BindRowData(dtThridDb.Rows[0]);


                IDBProvider dbProvider = ServerEnum.GetDBProvider(thridDbSource.数据源信息.驱动文件);
                if (dbProvider == null)
                {
                    strErr = "数据访问实例 [" + thridDbSource.数据源信息.驱动文件 + "] 创建失败,将返回默认数据提供对象。";
                    return(null);
                }


                dbProvider.Init(thridDbSource.数据源信息.务器IP, thridDbSource.数据源信息.端口, thridDbSource.数据源信息.数据实例,
                                thridDbSource.数据源信息.授权账号, ThridDBSourceModel.DecryPwd(thridDbSource.数据源信息.授权密码));

                IDbConnection dc = dbProvider.Open(ref strErr);

                if (dc == null)
                {
                    strErr = "数据服务访问失败:" + strErr;
                    return(null);
                }

                //缓存有效的数据源链接对象
                if (dbProvider != null)
                {
                    _thridDbBuffer.Add(dbServerAlias, dbProvider);
                }

                return(dbProvider);
            }
        }
示例#19
0
        public frmHisDBConfig()
        {
            InitializeComponent();

            _se = new ServerEnum();
        }
示例#20
0
 public static APIBalance GetBalance(this ServerEnum server)
 {
     return(APIWrapper.GetBalance(server == ServerEnum.Europe ? 0 : 1));
 }
示例#21
0
 public static int OrderCreate(this ServerEnum server, AlgoNiceHashEnum currentAlgo, double amount, double price, double limit, Pool pool)
 {
     return(APIWrapper.OrderCreate(server == ServerEnum.Europe ? 0 : 1, (int)currentAlgo, amount, price, limit, pool));
 }
示例#22
0
 public static List <Order> GetMyOrders(this ServerEnum server, AlgoNiceHashEnum currentAlgo)
 {
     return(APIWrapper.GetMyOrders(server == ServerEnum.Europe ? 0 : 1, (byte)currentAlgo));
 }
示例#23
0
 public static string GetLocalizedLongDescription(ServerEnum enumValue)
 {
     return(GetLocalizedText(GetLongDescriptionResKey(enumValue.Name, enumValue.Lookup)));
 }
示例#24
0
 string IServerEnumDescriptionTranslator.GetLocalizedDescription(ServerEnum serverEnum)
 {
     return(GetLocalizedDescription(serverEnum));
 }
示例#25
0
 public SimpleClient(Socket socket, ServerEnum serverType)
 {
     Init();
     serverConnected = serverType;
     Start(socket);
 }