コード例 #1
0
        private async Task ReloadAdGroupItemInfo()
        {
            try
            {
                await fileDb.ReadTable(FileDb.TableName.TBL_CLUSTER);

                await fileDb.ReadTable(FileDb.TableName.TBL_CLUSTER_SERVER);

                await fileDb.ReadTable(FileDb.TableName.TBL_SERVER);

                List <string> instanceNoList = new List <string>();
                foreach (var a in fileDb.TBL_SERVER.Data)
                {
                    if (a.Value.serverInstanceNo != "NULL")
                    {
                        instanceNoList.Add(a.Value.serverInstanceNo);
                    }
                }

                List <serverInstance> serverInstances = new List <serverInstance>();
                try
                {
                    serverInstances = await ServerOperation.GetServerInstanceList(instanceNoList);
                }
                catch (Exception ex)
                {
                    if (ex.Message.Contains("server not found"))
                    {
                    }
                    else
                    {
                        throw new Exception(ex.Message);
                    }
                }

                AdGroupItems.Clear();
                foreach (var cluster in fileDb.TBL_CLUSTER.Data)
                {
                    var adGroupItem = new AdGroupItem();
                    adGroupItem.IsChecked = false;
                    adGroupItem.GroupName = cluster.Key.clusterName;
                    foreach (var cluster_server in fileDb.TBL_CLUSTER_SERVER.Data)
                    {
                        if (cluster_server.Key.clusterName.Equals(adGroupItem.GroupName, StringComparison.OrdinalIgnoreCase) && cluster_server.Value.serverRole.Equals("MASTER"))
                        {
                            try
                            {
                                adGroupItem.MasterServerName = cluster_server.Key.serverName;
                                var serverInstance = serverInstances.Find(x => x.serverName == cluster_server.Key.serverName);
                                adGroupItem.MasterServerPublicIp   = serverInstance.publicIp;
                                adGroupItem.MasterServerInstanceNo = fileDb.TBL_SERVER.Data[new TBL_SERVER_KEY {
                                                                                                serverName = cluster_server.Key.serverName
                                                                                            }].serverInstanceNo;
                            }
                            catch { }
                        }
                        if (cluster_server.Key.clusterName.Equals(adGroupItem.GroupName, StringComparison.OrdinalIgnoreCase) && cluster_server.Value.serverRole.Equals("SLAVE"))
                        {
                            try
                            {
                                adGroupItem.SlaveServerName = cluster_server.Key.serverName;
                                var serverInstance = serverInstances.Find(x => x.serverName == cluster_server.Key.serverName);
                                adGroupItem.SlaveServerPublicIp   = serverInstance.publicIp;
                                adGroupItem.SlaveServerInstanceNo = fileDb.TBL_SERVER.Data[new TBL_SERVER_KEY {
                                                                                               serverName = cluster_server.Key.serverName
                                                                                           }].serverInstanceNo;
                            }
                            catch { }
                        }
                    }
                    AdGroupItems.Add(adGroupItem);
                }
            }
            catch { }
        }
コード例 #2
0
        public async Task ServerReloadAsync()
        {
            await RunCommandAsync(() => ServerReloadIsRunning, async() =>
            {
                try
                {
                    await fileDb.ReadTable(FileDb.TableName.TBL_SERVER);
                    List <string> instanceNoList = new List <string>();
                    foreach (var a in fileDb.TBL_SERVER.Data)
                    {
                        if (a.Value.serverInstanceNo != "NULL")
                        {
                            instanceNoList.Add(a.Value.serverInstanceNo);
                        }
                    }

                    List <serverInstance> serverInstances = new List <serverInstance>();
                    try
                    {
                        serverInstances = await ServerOperation.GetServerInstanceList(instanceNoList);
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message.Contains("server not found"))
                        {
                        }
                        else
                        {
                            throw new Exception(ex.Message);
                        }
                    }

                    try
                    {
                        List <string> deleteServerNameList = new List <string>();

                        AdMasterServerComboBoxItems.Clear();
                        AdSlaveServerComboBoxItems.Clear();

                        foreach (var a in fileDb.TBL_SERVER.Data)
                        {
                            var serverInstance = serverInstances.Find(x => x.serverName == a.Key.serverName);
                            if (serverInstance != null)
                            {
                                var item = new ServerInstanceItem
                                {
                                    IsChecked  = false,
                                    Name       = a.Key.serverName,
                                    PublicIp   = serverInstance.publicIp,
                                    PrivateIp  = a.Value.serverPrivateIp,
                                    ZoneNo     = a.Value.zoneNo + "(" + serverInstance.zone.zoneCode + ")",
                                    InstanceNo = a.Value.serverInstanceNo,
                                    Status     = serverInstance.serverInstanceStatus.code,
                                    Operation  = serverInstance.serverInstanceOperation.code
                                };
                                AdMasterServerComboBoxItems.Add(item);
                                AdSlaveServerComboBoxItems.Add(item);
                            }
                            else
                            {
                                deleteServerNameList.Add(a.Key.serverName);
                            }
                        }
                        foreach (var a in deleteServerNameList)
                        {
                            var p = new List <KeyValuePair <string, string> >();
                            p.Add(new KeyValuePair <string, string>("serverName", a));
                            await fileDb.DeleteTable(FileDb.TableName.TBL_SERVER, p);
                        }
                        var tempitem = new ServerInstanceItem
                        {
                            IsChecked  = false,
                            Name       = "",
                            PublicIp   = "",
                            PrivateIp  = "",
                            ZoneNo     = "",
                            InstanceNo = "",
                            Status     = "",
                            Operation  = ""
                        };
                        AdSlaveServerComboBoxItems.Add(tempitem);
                        SelectedAdMasterServerComboBoxItem = AdMasterServerComboBoxItems.FirstOrDefault();
                        SelectedAdSlaveServerComboBoxItem  = AdSlaveServerComboBoxItems.FirstOrDefault();
                    }
                    catch { }
                }
                catch
                { }
            });
        }