Exemplo n.º 1
0
        public EditUI()
        {
            string msg      = "";
            string errorMsg = String.Empty;

            AddSection()
            .IsFramed()
            .WithTitle("Edit Sink Node")
            .WithColumns(new List <Column>
            {
                new Column(
                    new List <IField> {
                    Map(x => x.Name).AsSectionField <TextBox>().Required().TextFormatIs(TextFormat.name).WithLength(30),
                    Map(x => x.HostName).AsSectionField <TextBox>().Required().TextFormatIs(@"^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"),
                    Map(x => x.IpAddress).AsSectionField <TextBox>().Required().TextFormatIs(@"^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"),
                    Map(x => x.Port).AsSectionField <TextBox>().Required().TextFormatIs(@"^(6553[0-5]|655[0-2][0-9]|65[0-4](\d){2}|6[0-4](\d){3}|[1-5](\d){4}|[1-9](\d){0,3})$"),
                    Map(x => x.ID).AsSectionField <TextLabel>().ApplyMod <VisibilityMod>(m => m.Hide <SinkNode>(h => { return(true); })),
                    Map(x => x.Status).AsSectionField <DropDownList>()
                    .Of(Enum.GetValues(typeof(NodeStatus)).Cast <NodeStatus>().ToList())
                    .ListOf(x => x.ToString(), x => x)
                    .Required()
                    .LabelTextIs("Status"),
                }),
            })
            .WithFields(new List <IField> {
                AddSectionButton()
                .SubmitTo(x =>
                {
                    try
                    {
                        SinkNodeDAO sinkNodeDAO = new SinkNodeDAO();
                        SinkNode sinkNode       = sinkNodeDAO.GetById(x.ID);

                        //check for uniqueness
                        if (!sinkNodeDAO.isUniqueName(sinkNode.Name, x.Name))
                        {
                            //errorMsg = "Sink node's name must be unique";
                            errorMsg = String.Format("Sink Node Name {0} is Unique. Use Another", x.Name);
                            msg     += "Sink node's name must be unique";
                            return(false);
                        }
                        if (!sinkNodeDAO.isUniqueHostName(sinkNode.HostName, x.HostName))
                        {
                            msg += "Host name must be unique";
                            return(false);
                        }
                        if (!sinkNodeDAO.isUniquePort(sinkNode.Port, x.Port))
                        {
                            msg += "Sink node's Port must be unique";
                            return(false);
                        }
                        if (!sinkNodeDAO.isUniqueIpAddress(sinkNode.IpAddress, x.IpAddress))
                        {
                            msg += "IP Address must be unique";
                            return(false);
                        }

                        sinkNode.Name         = x.Name;
                        sinkNode.HostName     = x.HostName;
                        sinkNode.IpAddress    = x.IpAddress;
                        sinkNode.Port         = x.Port;
                        sinkNode.Status       = x.Status;
                        sinkNode.NodeType     = x.NodeType;
                        sinkNode.DateModified = DateTime.Now;
                        sinkNodeDAO.Update(sinkNode);
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        msg          += "An error occured";
                        string logMsg = "Message= " + ex.Message + " Inner Exception= " + ex.InnerException;
                        MessageLogger.LogError(logMsg);
                        return(false);
                    }
                })
                .ConfirmWith(s => String.Format("Update Sink Node {0} ", s.Name)).WithText("Update")
                .OnSuccessDisplay(s => String.Format("Sink Node \"{0}\" has been successfuly editted ", s.Name))
                .OnFailureDisplay(s => String.Format("Error editting!\n   {0} ", msg))
            });
        }
Exemplo n.º 2
0
        public AddUI()
        {
            WithTitle("Add new Sink Node");

            Map(x => x.Name).As <TextBox>()
            .WithLength(20)
            .LabelTextIs("Node Name")
            .Required()
            .TextFormatIs("^[ a-zA-Z]+$");

            Map(x => x.HostName).As <TextBox>()
            .WithLength(30)
            .LabelTextIs("Host Name")
            .Required()
            .TextFormatIs(@"^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");

            Map(x => x.IpAddress).As <TextBox>()
            .WithLength(12)
            .LabelTextIs("IP Address")
            .Required()
            .TextFormatIs(@"^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");

            Map(x => x.Port).As <TextBox>()
            .Required()
            .TextFormatIs(@"^(6553[0-5]|655[0-2][0-9]|65[0-4](\d){2}|6[0-4](\d){3}|[1-5](\d){4}|[1-9](\d){0,3})$");


            string errorMsg = "";

            AddButton()
            .WithText("Add")
            .SubmitTo(x =>
            {
                bool flag = false;


                try
                {
                    SinkNodeDAO sinkNodeDao = new SinkNodeDAO();
                    if (!sinkNodeDao.isUniqueName(x.Name))
                    {
                        errorMsg += "Name must be unique";
                        flag      = false;
                    }
                    else if (!sinkNodeDao.isUniqueHostName(x.HostName))
                    {
                        errorMsg += "Host name must be unique";
                        flag      = false;
                    }
                    else if (!sinkNodeDao.isUniqueIpAddress(x.IpAddress))
                    {
                        errorMsg += "IP address must be unique";
                        flag      = false;
                    }
                    else if (!sinkNodeDao.isUniquePort(x.Port))
                    {
                        errorMsg += "Port must be unique";
                        flag      = false;
                    }
                    SinkNode sinkNode = new SinkNode {
                        DateCreated = DateTime.Now, DateModified = DateTime.Now, Name = x.Name, HostName = x.HostName, Port = x.Port, IpAddress = x.IpAddress, NodeType = NodeType.Client, Status = NodeStatus.Active
                    };
                    new SinkNodeDAO().Insert(sinkNode);
                    flag = true;
                }
                catch (Exception ex)
                {
                    flag          = false;
                    errorMsg     += "An error occured";
                    string logMsg = "Message= " + ex.Message + " Inner Exception= " + ex.InnerException;
                    MessageLogger.LogError(errorMsg);
                }
                return(flag); //Success
            })
            .OnSuccessDisplay(x =>
            {
                return(x.Name + "Node added successfully.");
            })
            .OnFailureDisplay(x => { return("Unable to add Node\n" + errorMsg); });
        }
 public SinkNodeManager()
 {
     _db = new SinkNodeDAO();
 }
Exemplo n.º 4
0
        public IndexUI()
        {
            SinkNodeDAO sinkNodeDAO = new SinkNodeDAO();

            AddSection()
            .StretchFields(50)
            .WithTitle("Search Sink Nodes")
            .IsCollapsible()
            .IsFramed()
            .WithColumns(new List <Column>()
            {
                new Column(new List <IField>()
                {
                    Map(x => x.Name).AsSectionField <TextBox>().TextFormatIs("^[ a-zA-Z]+$")
                }),
                new Column(new List <IField>()
                {
                    Map(x => x.IpAddress).AsSectionField <TextBox>().TextFormatIs(@"^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$")
                }),
                new Column(new List <IField>()
                {
                    Map(x => x.Port).AsSectionField <TextBox>().TextFormatIs(@"^(6553[0-5]|655[0-2][0-9]\d|65[0-4](\d){2}|6[0-4](\d){3}|[1-5](\d){4}|[1-9](\d){0,3})$")
                }),
                new Column(new List <IField>()
                {
                    AddSectionButton()
                    .ApplyMod <IconMod>(x => x.WithIcon(Ext.Net.Icon.Magnifier))
                    .WithText("Search")
                    .UpdateWith(x =>
                    {
                        return(x);
                    })
                })
            });

            HasMany(x => x.AllSinkNodes)
            .As <Grid>()
            .ApplyMod <IconMod>(x => x.WithIcon(Ext.Net.Icon.Link))
            .ApplyMod <ViewDetailsMod>(y => y.Popup <DetailsUI>("Sink Node Details")
                                       .PrePopulate <SinkNode, SinkNode>(x => x))
            .Of <SinkNode>()
            .WithColumn(x => x.Name)
            .WithColumn(x => x.HostName)
            .WithColumn(x => x.IpAddress)
            .WithColumn(x => x.Port)
            .WithColumn(x => x.Status)
            .WithColumn(x => x.NodeType)
            .WithRowNumbers()
            .IsPaged <ViewSinkNodeUIModel>(10, (x, e) =>
            {
                int totalCount = 0;
                try
                {
                    var results    = String.IsNullOrEmpty(x.Name) && String.IsNullOrEmpty(x.Port.ToString()) && String.IsNullOrEmpty(x.IpAddress) ? new SinkNodeDAO().Get() : new SinkNodeDAO().Search(x, e.Start, e.Limit, out totalCount, a => a.Name.ToLower().Contains(x.Name.ToLower()) || a.IpAddress.Contains(x.IpAddress) || a.Port == x.Port);
                    x.AllSinkNodes = results.ToList();
                }
                catch (Exception ex)
                {
                    string msg = "Message= " + ex.Message + " Inner Exception= " + ex.InnerException;
                    MessageLogger.LogError(msg);
                }

                e.TotalCount = totalCount;
                return(x);
            })
            .LabelTextIs("Sink Nodes");
        }
 public SinkNodeManager(SinkNodeDAO db)
 {
     _db = db;
 }