Exemplo n.º 1
0
 public Exporter(PathManager mgr, TreeNode<IDataPath> pt, Configuration cfg)
 {
     this.mgr = mgr;
     this.cfg = cfg;
     this.xml = new XmlDbFile { XmlDbFolder = cfg.XmlDbFolder };
     this.fileName = cfg.OutputFile;
     if (pt.Item is Locator)
     {
         this.tname = mgr.GetPathFrom<TableName>(pt);
         this.dname = tname.DatabaseName;
         this.sname = dname.ServerName;
     }
     else if (pt.Item is TableName)
     {
         this.tname = (TableName)pt.Item;
         this.dname = tname.DatabaseName;
         this.sname = dname.ServerName;
     }
     else if (pt.Item is DatabaseName)
     {
         this.tname = null;
         this.dname = (DatabaseName)pt.Item;
         this.sname = dname.ServerName;
     }
     else if (pt.Item is ServerName)
     {
         this.tname = null;
         this.dname = null;
         this.sname = (ServerName)pt.Item;
     }
 }
Exemplo n.º 2
0
        public void Recalculates()
        {
            var dateTime1 = new DateTime(2014, 1, 1, 1, 0, 0);
            var dateTime2 = new DateTime(2014, 1, 1, 1, 1, 0);
            var dateTime3 = new DateTime(2014, 1, 1, 2, 2, 2);
            var serverNameA = new ServerName("A");
            var serverNameB = new ServerName("B");
            var serverNameC = new ServerName("C");

            System.Insert(
                new ServerStamp() { ServerName = serverNameA, Timestamp = dateTime1 },
                new ServerStamp() { ServerName = serverNameA, Timestamp = dateTime1.AddSeconds(1) },
                new ServerStamp() { ServerName = serverNameB, Timestamp = dateTime2 },
                new ServerStamp() { ServerName = serverNameB, Timestamp = dateTime2.AddSeconds(1) },
                new ServerStamp() { ServerName = serverNameC, Timestamp = dateTime3 },
                new ServerStamp() { ServerName = serverNameC, Timestamp = dateTime3.AddSeconds(1) }
                );

            Expect(System.TryGetServerAtStamp(dateTime1.AddSeconds(-1)), Null);
            Expect(System.TryGetServerAtStamp(dateTime1), EqualTo(serverNameA));
            Expect(System.TryGetServerAtStamp(dateTime1.AddSeconds(1)), EqualTo(serverNameA));

            Expect(System.TryGetServerAtStamp(dateTime2.AddSeconds(-1)), EqualTo(serverNameA));
            Expect(System.TryGetServerAtStamp(dateTime2), EqualTo(serverNameB));
            Expect(System.TryGetServerAtStamp(dateTime2.AddSeconds(1)), EqualTo(serverNameB));

            Expect(System.TryGetServerAtStamp(dateTime3.AddSeconds(-1)), EqualTo(serverNameB));
            Expect(System.TryGetServerAtStamp(dateTime3), EqualTo(serverNameC));
            Expect(System.TryGetServerAtStamp(dateTime3.AddSeconds(1)), EqualTo(serverNameC));
        }
Exemplo n.º 3
0
 internal Account Add(string name, int id, ServerName server)
 {
     OutwarHttpSocket socket = new OutwarHttpSocket();
     Account a = new Account(socket, name, id, server);
     Accounts.Add(a);
     return a;
 }
Exemplo n.º 4
0
        public TimeDetails GetForServer(ServerName serverName)
        {
            EnsureScanned();

            logHistorySaved.LastScanDate = Time.Get.LocalNowOffset;

            return logHistorySaved.GetHistoricForServer(serverName);
        }
Exemplo n.º 5
0
 public void UpdateHistoric(ServerName serverName, ServerUptimeStamped uptime)
 {
     ServerData data = GetServerData(serverName);
     if (data.LogHistory.ServerUptime.Stamp < uptime.Stamp)
     {
         data.LogHistory.ServerUptime = uptime;
         persistenceManager.FlagAsChanged();
     }
 }
Exemplo n.º 6
0
 private ServerData GetServerData(ServerName serverName)
 {
     ServerData data;
     if (!persistenceManager.Entity.ServerDatas.TryGetValue(serverName, out data))
     {
         data = new ServerData();
         persistenceManager.Entity.ServerDatas.Add(serverName, data);
         persistenceManager.FlagAsChanged();
     }
     return data;
 }
Exemplo n.º 7
0
        public string WriteSchema(ServerName sname)
        {
            var file = getSchemaFilName(sname);
            using (var writer = NewStreamWriter(file))
            {
                DataSet ds = sname.ServerSchema();
                ds.WriteXml(writer, XmlWriteMode.WriteSchema);
            }

            return file;
        }
Exemplo n.º 8
0
        public TimeDetails GetForServer(ServerName serverName)
        {
            HandleNewLiveData();

            TimeDetails details;
            if (latestData.TryGetValue(serverName, out details))
            {
                return details;
            }

            return new TimeDetails();
        }
Exemplo n.º 9
0
        public TimeDetails GetForServer(ServerName serverName)
        {
            UpdateWebData();

            TimeDetails details;
            if (dataCache.TryGetValue(serverName, out details))
            {
                return new TimeDetails() {ServerDate = details.ServerDate, ServerUptime = details.ServerUptime};
            }

            return new TimeDetails();
        }
Exemplo n.º 10
0
        public TimeDetails GetForServer(ServerName serverName)
        {
            HandleNewLiveData();

            TimeDetails details;

            if (latestData.TryGetValue(serverName, out details))
            {
                return(details);
            }

            return(new TimeDetails());
        }
Exemplo n.º 11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>.</param>
        /// <returns>
        /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
        /// </returns>
        /// <exception cref="T:System.NullReferenceException">
        /// The <paramref name="obj"/> parameter is null.
        /// </exception>
        /// ------------------------------------------------------------------------------------
        public override bool Equals(object obj)
        {
            ProjectId projB = obj as ProjectId;

            if (projB == null)
            {
                throw new ArgumentException("Argument is not a ProjectId.", "obj");
            }
            return(Type == projB.Type && ProjectInfo.ProjectsAreSame(Handle, projB.Handle) &&
                   ((ServerName == null && projB.ServerName == null) ||
                    (ServerName != null && projB.ServerName != null &&
                     ServerName.Equals(projB.ServerName, StringComparison.InvariantCultureIgnoreCase))));
        }
Exemplo n.º 12
0
 public override int GetHashCode() {
   int hash = 1;
   if (ServerName.Length != 0) hash ^= ServerName.GetHashCode();
   if (Password.Length != 0) hash ^= Password.GetHashCode();
   if (EnableTeams != false) hash ^= EnableTeams.GetHashCode();
   hash ^= teams_.GetHashCode();
   if (ScoreUpdateFrequency != 0) hash ^= ScoreUpdateFrequency.GetHashCode();
   hash ^= bannedMods_.GetHashCode();
   if (_unknownFields != null) {
     hash ^= _unknownFields.GetHashCode();
   }
   return hash;
 }
 /// <summary>
 /// Serves as a hash function for a particular type.
 /// </summary>
 /// <returns>
 /// A hash code for the current <see cref="T:System.Object"/>.
 /// </returns>
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = ServerName?.GetHashCode() ?? 0;
         hashCode = (hashCode * 397) ^ (int)Type;
         hashCode = (hashCode * 397) ^ (UserName?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Password?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)AuthenticationType;
         hashCode = (hashCode * 397) ^ (DbName?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
Exemplo n.º 14
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         ErrorPanel?.Dispose();
         ErrorMessage?.Dispose();
         MainPanel?.Dispose();
         ServerName?.Dispose();
         MemoryAllocation?.Dispose();
         RadAjaxManager?.Dispose();
         CacheGrid?.Dispose();
     }
 }
Exemplo n.º 15
0
        public bool InsertToHistoryDataTable(List <OPCItemData> itemDataList, out string errMsg)
        {
            errMsg = string.Empty;

            #region 检查数据连接设置
            if (ServerName.Trim() == string.Empty ||
                UserName.Trim() == string.Empty ||
                Password.Trim() == string.Empty ||
                NewDataTableName.Trim() == string.Empty)
            {
                errMsg = "数据库连接设置无效";
                OPCLog.Error("数据库连接设置无效");
                return(false);
            }
            if (this.m_dal == null)
            {
                switch (DatabaseType)
                {
                case OPCUtils.DatabaseType.MSSQLServer:
                    this.m_dal = new OPCClientMSSQLDAL(ServerName, DatabaseName, UserName, Password);
                    break;

                case OPCUtils.DatabaseType.Oracle:
                    this.m_dal = new OPCClientOracleDAL(ServerName, UserName, Password);
                    break;

                default:
                    break;
                }
                if (!this.m_dal.CreateConnection(out errMsg))
                {
                    return(false);
                }
            }
            #endregion
            //OPCUtils.LogDataChangeTime("数据刷新-插入历史数据-插入数据表-获取数据实体");
            List <OPCClientItemEntity> itemEntities = GetEntities(itemDataList);

            //OPCUtils.LogDataChangeTime("数据刷新-插入历史数据-插入数据表-开始插入");
            foreach (OPCClientItemEntity itemEntity in itemEntities)
            {
                //OPCUtils.LogDataChangeTime("数据刷新-插入历史数据-插入数据表-插入实体");
                string dalErr = string.Empty;
                if (!this.m_dal.InsertItem(HistoryDataTableName, itemEntity, out dalErr))
                {
                    errMsg = dalErr;
                }
            }
            //OPCUtils.LogDataChangeTime("数据刷新-插入历史数据-插入数据表-结束插入");
            return(true);
        }
Exemplo n.º 16
0
        private void createTree(IConnectionConfiguration cfg, TreeView treeView)
        {
            var L = cfg.Providers.OrderBy(x => x.ServerName.Path);

            foreach (var pvd in L)
            {
                ServerName   sname = pvd.ServerName;
                DbTreeNodeUI item  = new DbServerNodeUI(this, sname);

                treeView.Items.Add(item);
            }

            return;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies["adminid"] != null && Request.Cookies["adminid"].Value != "")
            {
                intProfile = Int32.Parse(Request.Cookies["adminid"].Value);
            }
            else
            {
                Response.Redirect("/admin/login.aspx");
            }
            oServerName = new ServerName(intProfile, dsn);

            if (Request.QueryString["detailid"] != null)
            {
                intDetail = Int32.Parse(Request.QueryString["detailid"]);
            }

            if (intDetail > 0)
            {
                hdnParent.Value = intDetail.ToString();
                lblParent.Text  = oServerName.GetComponentDetail(intDetail, "name");
                if (Request.QueryString["id"] == null)
                {
                    LoopRepeater();
                }
                else
                {
                    panAdd.Visible = true;
                    intID          = Int32.Parse(Request.QueryString["id"]);
                    if (!IsPostBack)
                    {
                        if (intID > 0)
                        {
                            DataSet ds = oServerName.GetComponentDetailScript(intID);
                            txtName.Text       = ds.Tables[0].Rows[0]["name"].ToString();
                            txtScript.Text     = ds.Tables[0].Rows[0]["script"].ToString();
                            chkEnabled.Checked = (ds.Tables[0].Rows[0]["enabled"].ToString() == "1");
                            btnAdd.Text        = "Update";
                        }
                        else
                        {
                            btnOrder.Enabled  = false;
                            btnDelete.Enabled = false;
                        }
                    }
                }
            }
            btnOrder.Attributes.Add("onclick", "return OpenWindow('SUPPORTORDER','" + hdnParent.ClientID + "','" + hdnOrder.ClientID + "&type=COMPONENT_SCRIPTS" + "',false,400,400);");
            btnDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this item?');");
        }
Exemplo n.º 18
0
 public virtual Task WriteHeader(SourceBufferWriter buf)
 {
     buf.Write(HeaderId);
     buf.Write(Protocol);
     buf.Write(NetworkProtocol);
     buf.WriteString(ServerName.AsSpan(), 260);
     buf.WriteString(ClientName.AsSpan(), 260);
     buf.WriteString(MapName.AsSpan(), 260);
     buf.WriteString(GameDirectory.AsSpan(), 260);
     buf.Write(PlaybackTime);
     buf.Write(PlaybackTicks);
     buf.Write(PlaybackFrames);
     buf.Write(SignOnLength);
     return(Task.CompletedTask);
 }
 public YouAreOnEventDetectedOnLiveLogs([NotNull] ServerName serverName, [NotNull] CharacterName characterName,
                                        bool currentServerNameChanged)
 {
     if (serverName == null)
     {
         throw new ArgumentNullException(nameof(serverName));
     }
     if (characterName == null)
     {
         throw new ArgumentNullException(nameof(characterName));
     }
     ServerName               = serverName;
     CharacterName            = characterName;
     CurrentServerNameChanged = currentServerNameChanged;
 }
Exemplo n.º 20
0
        public void UpdateWurmApiConfigDictionary(IDictionary <ServerName, WurmServerInfo> dictionary)
        {
            foreach (var serverInformation in infos)
            {
                if (string.IsNullOrWhiteSpace(serverInformation.ServerName))
                {
                    continue;
                }

                var serverName = new ServerName(serverInformation.ServerName);
                dictionary[serverName] = new WurmServerInfo(serverInformation.ServerName,
                                                            serverInformation.ServerStatsUrl ?? string.Empty,
                                                            new ServerGroup(serverInformation.ServerGroup ?? string.Empty));
            }
        }
Exemplo n.º 21
0
        public void TestHideServerName()
        {
            Dictionary <string, string> addrs = new Dictionary <string, string>();

            addrs.Add("127.0.0.1", "127.**.1");
            addrs.Add("2001:db8:85a3:8d3:1319:8a2e:370:7348", "2001:**:7348");
            addrs.Add("::1319:8a2e:370:7348", "**:7348");
            addrs.Add("::1", "**:1");

            foreach (string key in addrs.Keys)
            {
                string val = ServerName.HideServerAddr(key);
                Assert.AreEqual(addrs[key], val);
            }
        }
Exemplo n.º 22
0
        Socket BuildSocketByName(ServerName name)
        {
            var sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            var ipEP = BuildIPEndPointFromConfig(name);

            //connect and set up retry/poll
            sock.Connect(ipEP);
            if(!sock.Poll(60000,SelectMode.SelectError))
            {
                sock.Connect(ipEP);
            }

            return null;
        }
Exemplo n.º 23
0
        // Returns a connection string based on the alias' properties.
        public string GetConnectionString()
        {
            string conString = "";
            string userLabel = "user";
            string pwLabel   = "password";

            if (SourceType == SourceTypes.Access)
            {
                conString += "Provider=Microsoft.Jet.OLEDB.4.0;";
            }
            else if (SourceType == SourceTypes.SqlServer)
            {
                conString += "Provider=SQLOLEDB;";
                userLabel  = "uid";
                pwLabel    = "pwd";
            }
            else if (SourceType == SourceTypes.MySQL)
            {
                conString = "Driver={MySQL OleDb 5.1 Driver};";
            }


            if (UserName.Trim() != String.Empty)
            {
                conString += userLabel + "=" + UserName + ";";
            }

            if (Password.Trim() != String.Empty)
            {
                conString += pwLabel + "=" + Password + ";";
            }

            if ((SourceType == SourceTypes.SqlServer) && (DatabaseName.Trim() != String.Empty))
            {
                conString += "initial catalog=" + DatabaseName + ";";
            }
            else if ((SourceType == SourceTypes.MySQL) && (DatabaseName.Trim() != String.Empty))
            {
                conString += "database=" + DatabaseName + ";";
            }

            if (ServerName.Trim() != String.Empty)
            {
                conString += "server=" + ServerName;
            }

            return(conString);
        }
Exemplo n.º 24
0
 public ConfigurationForInstance(
     ServerName localServer,
     ServerName remoteServer,
     DirectoryPath localDirectoryForBackup,
     DirectoryPath localDirectoryForShare,
     DirectoryPath localDircetoryForRestore,
     ShareName localShareName,
     int endpoint_ListenerPort,
     double backupExpiresAfterDays,
     int shutDownAfterNumberOfChecksForDatabaseState,
     int switchStateAfterNumberOfChecksInPrimaryRunningNoSecondaryState,
     int shutDownAfterNumberOfChecksInSecondaryRunningNoPrimaryState,
     int mirrorMonitoringUpdateMinutes,
     int remoteServerAccessTimeoutSeconds,
     string endpoint_Name,
     int serviceStartTimeoutSec,
     int checkMirroringStateSecondInterval,
     int primaryStartupWaitNumberOfChecksForMirroringTimeout,
     int secondaryStartupWaitNumberOfChecksForMirroringTimeout,
     int backupHourInterval,
     bool backupToMirrorServer,
     BackupTime backupTime,
     int backupDelayEmergencyBackupMin
     )
 {
     _localServer            = localServer;
     _remoteServer           = remoteServer;
     _localBackupDirectory   = localDirectoryForBackup;
     _localShareDirectory    = localDirectoryForShare;
     _localRestoreDircetory  = localDircetoryForRestore;
     _localShareName         = localShareName;
     _endpoint_ListenerPort  = endpoint_ListenerPort;
     _backupExpiresAfterDays = backupExpiresAfterDays;
     ShutDownAfterNumberOfChecksForDatabaseState = shutDownAfterNumberOfChecksForDatabaseState;
     SwitchStateAfterNumberOfChecksInPrimaryRunningNoSecondaryState = switchStateAfterNumberOfChecksInPrimaryRunningNoSecondaryState;
     ShutDownAfterNumberOfChecksInSecondaryRunningNoPrimaryState    = shutDownAfterNumberOfChecksInSecondaryRunningNoPrimaryState;
     MirrorMonitoringUpdateMinutes     = mirrorMonitoringUpdateMinutes;
     _remoteServerAccessTimeoutSeconds = remoteServerAccessTimeoutSeconds;
     _endpoint_Name      = endpoint_Name;
     ServiceStartTimeout = serviceStartTimeoutSec * 1000;
     CheckMirroringStateSecondInterval = checkMirroringStateSecondInterval;
     PrimaryStartupWaitNumberOfChecksForMirroringTimeout   = primaryStartupWaitNumberOfChecksForMirroringTimeout;
     SecondaryStartupWaitNumberOfChecksForMirroringTimeout = secondaryStartupWaitNumberOfChecksForMirroringTimeout;
     BackupHourInterval             = backupHourInterval;
     _backupToMirrorServer          = backupToMirrorServer;
     _backupTime                    = backupTime;
     _backupDelayEmergencyBackupMin = backupDelayEmergencyBackupMin;
 }
Exemplo n.º 25
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Response.Cookies["loginreferrer"].Value   = "/admin/servername_components.aspx";
     Response.Cookies["loginreferrer"].Expires = DateTime.Now.AddDays(30);
     if (Request.Cookies["adminid"] != null && Request.Cookies["adminid"].Value != "")
     {
         intProfile = Int32.Parse(Request.Cookies["adminid"].Value);
     }
     else
     {
         Response.Redirect("/admin/login.aspx");
     }
     oServerName = new ServerName(intProfile, dsn);
     if (Request.QueryString["id"] == null)
     {
         if (Request.QueryString["add"] == null)
         {
             LoopRepeater();
         }
         else
         {
             panAdd.Visible = true;
         }
     }
     else
     {
         panAdd.Visible = true;
         intID          = Int32.Parse(Request.QueryString["id"]);
         if (intID > 0 && !IsPostBack)
         {
             DataSet ds = oServerName.GetComponent(intID);
             hdnId.Value                 = intID.ToString();
             txtName.Text                = ds.Tables[0].Rows[0]["name"].ToString();
             txtCode.Text                = ds.Tables[0].Rows[0]["code"].ToString();
             txtFactoryCode.Text         = ds.Tables[0].Rows[0]["factory_code"].ToString();
             txtFactoryCodeSpecific.Text = ds.Tables[0].Rows[0]["factory_code_specific"].ToString();
             txtZeusCode.Text            = ds.Tables[0].Rows[0]["zeus_code"].ToString();
             radIIS.Checked              = (ds.Tables[0].Rows[0]["iis"].ToString() == "1");
             radWeb.Checked              = (ds.Tables[0].Rows[0]["web"].ToString() == "1");
             radSQL.Checked              = (ds.Tables[0].Rows[0]["sql"].ToString() == "1");
             radDatabase.Checked         = (ds.Tables[0].Rows[0]["dbase"].ToString() == "1");
             chkResetSAN.Checked         = (ds.Tables[0].Rows[0]["reset_storage"].ToString() == "1");
             chkEnabled.Checked          = (ds.Tables[0].Rows[0]["enabled"].ToString() == "1");
         }
     }
     btnOrder.Attributes.Add("onclick", "return OpenWindow('SUPPORTORDER','" + hdnId.ClientID + "','" + hdnOrder.ClientID + "&type=SERVERNAME_C" + "',false,400,400);");
     btnDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this item?');");
 }
Exemplo n.º 26
0
        public TimeDetails GetForServer(ServerName serverName)
        {
            UpdateWebData();

            TimeDetails details;

            if (dataCache.TryGetValue(serverName, out details))
            {
                return(new TimeDetails()
                {
                    ServerDate = details.ServerDate, ServerUptime = details.ServerUptime
                });
            }

            return(new TimeDetails());
        }
Exemplo n.º 27
0
        public MainWindow()
        {
            InitializeComponent();

            // Build dictionary mapping a command to each button
            CommandButtons.Add(ButtonUp, missile.CMD_UP);
            CommandButtons.Add(ButtonDown, missile.CMD_DOWN);
            CommandButtons.Add(ButtonCW, missile.CMD_CW);
            CommandButtons.Add(ButtonCCW, missile.CMD_CCW);
            CommandButtons.Add(ButtonFire, missile.CMD_FIRE);

            // Get last server name from the registry (if available)
            ServerName.Text = (String)Registry.GetValue(RegistryKey, ServerName.Name, null);
            ServerName.Focus();
            ServerName.CaretIndex = ServerName.Text.Length;
        }
Exemplo n.º 28
0
        public PointVirtualCollcet CreatePoints(ServerName name)
        {
            PointVirtualCollcet result = new PointVirtualCollcet();

            if (name == ServerName.ModbusTCPServer)
            {
                result = PointsCollcetCreate.CreateMoudbus(_workbook, _log);
                ModbusPointsRegister.Register(result, _log);
            }
            else if (name == ServerName.ModbusRTUServer)
            {
                result = PointsCollcetCreate.CreateMoudbus(_workbook, _log);
                ModbusPointsRegister.Register(result, _log);
            }
            return(result);
        }
Exemplo n.º 29
0
        public IWurmServer GetByName(ServerName name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            WurmServer server;

            if (!nameToServerMap.TryGetValue(name, out server))
            {
                // registering unknown server
                return(RegisterServer(new WurmServerInfo(name.Original, String.Empty, wurmServerGroups.GetForServer(name))));
            }
            return(server);
        }
Exemplo n.º 30
0
        public async Task <DiscordEmbedBuilder> PersonalLogsRequest(string name, string metric, string[] serverNameInput)
        {
            DiscordEmbedBuilder embed;

            var errorEmbed = new DiscordEmbedBuilder
            {
                Color     = new DiscordColor("#3AE6DB"),
                Title     = "Ошибка запроса",
                Timestamp = DateTime.UtcNow,
            };

            try
            {
                var serverName = ServerName.WclServerNameConvert(serverNameInput);

                if (metric != "dps" && metric != "hps")
                {
                    throw new ArgumentException("Указана неверная метрика. Требуется указать либо `dps` либо `hps` \n " +
                                                "Например: `-logs dps адэльвиль гордунни`");
                }
                var encodedName     = HttpUtility.UrlPathEncode(name);
                var responseContent = WclRequest.Request(
                    "https://www.warcraftlogs.com:443/v1/rankings/character/"
                    + encodedName + "/" + serverName
                    + "/eu?metric=" + metric + "&timeframe=historical").Result;

                using var reader = new StreamReader(await responseContent.ReadAsStreamAsync());
                List <PersonalLogsStats> serializedStats;
                try
                {
                    serializedStats = PersonalLogsStats.FromJson(await reader.ReadToEndAsync());
                }
                catch
                {
                    throw new Exception("Ошибка десериализации результатов от WarcraftLogs \nПроверьте, верно ли вы ввели никнейм и сервер?\n Синтаксис: `-logs метрика имя сервер`" +
                                        "\n Например, `-logs dps адэльвиль гордунни`");
                }
                embed = CreateEmbed(serializedStats, metric);
            }
            catch (Exception e)
            {
                errorEmbed.AddField("Ошибка:", e.Message);
                Console.WriteLine(e);
                return(errorEmbed);
            }
            return(embed);
        }
Exemplo n.º 31
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (RoleId != 0L)
            {
                hash ^= RoleId.GetHashCode();
            }
            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (UserId != 0L)
            {
                hash ^= UserId.GetHashCode();
            }
            if (ServerId != 0)
            {
                hash ^= ServerId.GetHashCode();
            }
            if (ServerName.Length != 0)
            {
                hash ^= ServerName.GetHashCode();
            }
            if (Type != 0)
            {
                hash ^= Type.GetHashCode();
            }
            if (Level != 0)
            {
                hash ^= Level.GetHashCode();
            }
            if (Sex != 0)
            {
                hash ^= Sex.GetHashCode();
            }
            if (HeadImgId != 0)
            {
                hash ^= HeadImgId.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 32
0
        private TcpClientEmm BuildServerClientByName(ServerName serverName)
        {
            try
            {
                var t            = new TcpClientEmm();
                var hostNameOrIP = _serverConfigs[serverName].HostName;
                var port         = _serverConfigs[serverName].Port;
                t.Connect(hostNameOrIP, port);
                return(t);
            }
            catch (Exception ex)
            {
                LOG(string.Format("{0} {1}", ex.Message, ex.StackTrace));
            }

            return(null);
        }
Exemplo n.º 33
0
        public override bool Equals(object obj)
        {
            var item = obj as ServerData;

            if (item == null)
            {
                return(false);
            }
            else if (ServerName.Equals(item.ServerName))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 34
0
        private static bool DisplayDatabaseNodes(TreeNode <IDataPath> pt, ApplicationCommand cmd)
        {
            if (!(pt.Item is ServerName))
            {
                return(false);
            }

            ServerName sname = (ServerName)pt.Item;

            if (sname.Disconnected)
            {
                cout.WriteLine("\t? Database(s)");
            }
            else
            {
                int i     = 0;
                int count = 0;
                int h     = 0;

                List <string> values = new List <string>();
                foreach (var node in pt.Nodes)
                {
                    DatabaseName dname = (DatabaseName)node.Item;
                    ++i;

                    if (IsMatch(cmd.wildcard, dname.Path))
                    {
                        count++;
                        if (node.Nodes.Count == 0)
                        {
                            ExpandDatabaseName(node, cmd.Refresh);
                        }

                        cout.WriteLine("{0,4} {1,26} <DB> {2,10} Tables/Views", sub(i), dname.Name, node.Nodes.Count);
                        h = PagePause(cmd, ++h);

                        values.Add(dname.Name);
                    }
                }

                Assign(cmd, values);
                cout.WriteLine("\t{0} Database(s)", count);
            }

            return(true);
        }
 private void connectCallback(ServerName result)
 {
     this.Dispatcher.BeginInvoke(delegate()
     {
         serverAddressBox.IsEnabled    = true;
         connectButton.IsEnabled       = true;
         connectProgressBar.Visibility = System.Windows.Visibility.Collapsed;
         if (result == null)
         {
             connectedPanel.Visibility = System.Windows.Visibility.Collapsed;
             MessageBox.Show("Couldn't connect to server");
         }
         else if (result.servername == null)
         {
             connectedPanel.Visibility = System.Windows.Visibility.Collapsed;
             MessageBox.Show("Incorrect server response, please contact with administrator or try again later.");
         }
         else
         {
             serverNameBox.Text = result.servername;
             var servers        = new ObservableCollection <Server>(from Server s in MDEDB.Servers where s.serverName == serverNameBox.Text select s);
             if (servers.Count() > 0)
             {
                 Server server = servers[0];
                 if (server.address == serverAddressBox.Text)
                 {
                     MessageBox.Show("You already have account on this server. \n If you want to change to another one, please remove server from application. " +
                                     "All data on the device will be lost. Data on the server will remain unchanged.");
                 }
                 else
                 {
                     server.address = serverAddressBox.Text;
                     MDEDB.SubmitChanges();
                     MessageBox.Show("You already have account on this server, under other address. Address in application had been automatically changed. \n If you want to change to another account, please remove server from application. " +
                                     "All data on the device will be lost. Data on the server will remain unchanged.");
                 }
                 connectedPanel.Visibility = System.Windows.Visibility.Collapsed;
             }
             else
             {
                 connectedPanel.Visibility = System.Windows.Visibility.Visible;
             }
         }
     });
 }
Exemplo n.º 36
0
        private bool DisplayServerNodes(TreeNode <IDataPath> pt, ApplicationCommand cmd)
        {
            if (pt != RootNode)
            {
                return(false);
            }

            int i     = 0;
            int count = 0;
            int h     = 0;

            CancelableWork.CanCancel(cts =>
            {
                List <string> values = new List <string>();
                foreach (var node in pt.Nodes)
                {
                    if (cts.IsCancellationRequested)
                    {
                        return;
                    }

                    ServerName sname = (ServerName)node.Item;
                    ++i;

                    if (IsMatch(cmd.wildcard, sname.Path))
                    {
                        count++;
                        if (node.Nodes.Count == 0)
                        {
                            ExpandServerName(node, Refreshing);
                        }

                        cout.WriteLine("{0,4} {1,26} <SVR> {2,10} Databases", sub(i), sname.Path, sname.Disconnected ? "?" : node.Nodes.Count.ToString());
                        h = PagePause(cmd, ++h);

                        values.Add(sname.Path);
                    }
                }

                Assign(cmd, values);
                cout.WriteLine("\t{0} Server(s)", count);
            });

            return(true);
        }
Exemplo n.º 37
0
        public AvailableServer(ServerDetails details, ServerName name, IEnumerable <Character> characters)
        {
            Distance          = details.Distance;
            MaxCapacity       = details.MaxCapacity;
            NotRecommended    = details.NotRecommended;
            MaxCharsPerServer = details.MaxCharsPerServer;
            PingPort          = details.PingPort;
            Population        = details.Population;
            ServerID          = details.ServerID;
            ServerIP          = details.ServerIP;
            ServerPort        = details.ServerPort;
            Status            = details.Status;

            Name     = name.ServerDisplayName;
            Timezone = name.Timezone;

            Characters = characters != null?characters.ToList() : null;
        }
Exemplo n.º 38
0
 void SaveSettingDBExecute()
 {
     // Trim() remove Space from the side
     Properties.Settings.Default.Server   = ServerName.Trim();
     Properties.Settings.Default.DataBase = DataBase.Trim();
     if (OptionAuthentication1)
     {
         Properties.Settings.Default.Mode = "True";
     }
     else
     {
         Properties.Settings.Default.Mode     = "False";
         Properties.Settings.Default.UserName = UserName.Trim();
         Properties.Settings.Default.Password = Password;
     }
     Properties.Settings.Default.Save();
     ConnectionStatus();
 }
Exemplo n.º 39
0
        public static DataSet SqlServerSchema(ServerName sname, IEnumerable<DatabaseName> dnames)
        {
            StringBuilder builder = new StringBuilder();
            foreach (DatabaseName dname in dnames)
            {
                builder.AppendLine(SqlDatabaseSchema(dname));
            }

            DataSet ds = new SqlCmd(sname.Provider, builder.ToString()).FillDataSet();
            ds.DataSetName = sname.Path;
            int i = 0;
            foreach (DatabaseName dname in dnames)
            {
                ds.Tables[i++].TableName = dname.Name;
            }

            return ds;
        }
Exemplo n.º 40
0
        internal Account(OutwarHttpSocket socket, string name, int id, ServerName server)
        {
            Socket         = socket;
            Socket.Account = this;
            Name           = name;
            Id             = id;
            Server         = server;

            mRage      = -1;
            mLevel     = -1;
            mExp       = -1;
            mGold      = -1;
            NeedsLevel = false;

            Socket = socket;
            Mover  = new Mover(this, Socket);

            //DropHandlers = new List<DropHandler>();
        }
Exemplo n.º 41
0
        internal Account(OutwarHttpSocket socket, string name, int id, ServerName server)
        {
            Socket = socket;
            Socket.Account = this;
            Name = name;
            Id = id;
            Server = server;

            mRage = -1;
            mLevel = -1;
            mExp = -1;
            mGold = -1;
            NeedsLevel = false;

            Socket = socket;
            Mover = new Mover(this, Socket);

            //DropHandlers = new List<DropHandler>();
        }
Exemplo n.º 42
0
 public void chdir(ServerName serverName, DatabaseName databaseName)
 {
     string path = string.Format("\\{0}\\{1}\\", serverName.Path, databaseName.Path);
     PathName pathName = new PathName(path);
     var node = mgr.Navigate(pathName);
     if (node != null)
     {
         mgr.current = node;
     }
     else
         stdio.ErrorFormat("invalid path:" + path);
 }
Exemplo n.º 43
0
 public TimeDetails GetHistoricForServer(ServerName serverName)
 {
     ServerData data = GetServerData(serverName);
     return data.LogHistory;
 }
Exemplo n.º 44
0
 protected Job(ServerName serverName)
 {
     ServerName = serverName;
 }
Exemplo n.º 45
0
 public CurrentWurmDateTimeJob(ServerName serverName)
     : base(serverName)
 {
 }
 public bool GetConnectedServers(out IList<IServerName> serverNames)
 {
     serverNames = new List<IServerName>();
     IServerName connectedServer = new ServerName();
     //connectedServer.Name = System.Environment.MachineName;
     connectedServer.Name = Host;
     connectedServer.ServerIndex = 0;
     serverNames.Add(connectedServer);
     return true;
 }
Exemplo n.º 47
0
 public WebDataExtractionResult(ServerName serverName)
 {
     ServerName = serverName;
 }
Exemplo n.º 48
0
 private bool ParseForServerInfo(IEnumerable<LogEntry> logEntries, bool fromLiveLogs = false)
 {
     bool foundAny = false;
     foreach (var wurmLogEntry in logEntries)
     {
         if (Regex.IsMatch(wurmLogEntry.Content, @"^\d+ other players", RegexOptions.Compiled))
         {
             Match match = Regex.Match(
                 wurmLogEntry.Content,
                 @"\d+ other players are online.*\. You are on (.+) \(",
                 RegexOptions.Compiled);
             if (match.Success)
             {
                 var serverName = new ServerName(match.Groups[1].Value.ToUpperInvariant());
                 var serverStamp = new ServerStamp() { ServerName = serverName, Timestamp = wurmLogEntry.Timestamp };
                 sortedServerHistory.Insert(serverStamp);
                 foundAny = true;
                 if (fromLiveLogs)
                 {
                     currentLiveLogsServer = serverName;
                 }
             }
             else
             {
                 logger.Log(
                     LogLevel.Warn,
                     "ServerHistoryProvider found 'you are on' log line, but could not parse it. Entry: "
                     + wurmLogEntry,
                     this,
                     null);
             }
         }
     }
     return foundAny;
 }
Exemplo n.º 49
0
        public IWurmServer GetByName(ServerName name)
        {
            if (name == null) throw new ArgumentNullException("name");

            WurmServer server;
            if (!this.nameToServerMap.TryGetValue(name, out server))
            {
                throw new DataNotFoundException("No server found with name " + name);
            }
            return server;
        }
Exemplo n.º 50
0
 public CurrentUptimeJob(ServerName serverName)
     : base(serverName)
 {
 }
Exemplo n.º 51
0
 public abstract DataSet GetServerSchema(ServerName sname);
Exemplo n.º 52
0
 private string getPath(ServerName sname) => string.Format("{0}\\{1}", XmlDbFolder, sname.Path);
Exemplo n.º 53
0
 private string getSchemaFilName(ServerName sname) => string.Format("{0}\\{1}.{2}", getPath(sname), sname.Path, EXT);
Exemplo n.º 54
0
 public override DataSet GetServerSchema(ServerName sname)
 {
     return dbSchema;
 }
Exemplo n.º 55
0
 public override DataSet GetServerSchema(ServerName sname)
 {
     return InformationSchema.SqlServerSchema(sname, sname.GetDatabaseNames());
 }