Exemple #1
0
        protected void NewLinkBtn_Click(object sender, System.EventArgs e)
        {
            try
            {
                int l_ID = Convert.ToInt32(LinkID.Text);
                if (l_ID < 0 || l_ID > 999999)
                {
                    throw new Exception();
                }

                LinkID.Text = l_ID.ToString();
                if (m_LinkRow == null && l_ID >= 0)
                {
                    if (m_DS.Link.FindByID(l_ID) != null)
                    {
                        Utilities.SetError(this, "Link ID already defined in the system", null);
                        SetNewState(false, false, -1);
                    }
                    else
                    {
                        m_LinkRow    = m_DS.Link.NewLinkRow();
                        m_LinkRow.ID = l_ID;
                        m_DS.Link.AddLinkRow(m_LinkRow);
                        SetNewState(false, true, l_ID);
                    }
                }
            }
            catch
            {
                Utilities.SetError(this, "Invalid Link ID Specified", null);
                SetNewState(false, false, -1);
            }
        }
Exemple #2
0
        protected DataRow[]       GetAvailableLinks()
        {
            if (m_ProcessClassRow == null)
            {
                return(new     MultiXTpmDB.LinkRow[0]);
            }
            MultiXTpmDB.ProcessClassLinksRow[] PCLRows = m_ProcessClassRow.GetProcessClassLinksRows();
            MultiXTpmDB.LinkRow[] LinksRows            = new     MultiXTpmDB.LinkRow[m_DS.Link.Rows.Count - PCLRows.Length];
            int I = 0;

            foreach (MultiXTpmDB.LinkRow LinkRow in      m_DS.Link)
            {
                bool bAvailable = true;
                foreach (MultiXTpmDB.ProcessClassLinksRow PCLRow  in      PCLRows)
                {
                    if (PCLRow.LinkID == LinkRow.ID && PCLRow.ProcessClassID == m_ProcessClassID)
                    {
                        bAvailable = false;
                        break;
                    }
                }
                if (bAvailable)
                {
                    LinksRows[I++] = LinkRow;
                }
            }
            return(LinksRows);
        }
Exemple #3
0
 protected string  GetProtocolText(DataGridItem Container)
 {
     MultiXTpmDB.LinkRow Row = (MultiXTpmDB.LinkRow)((DataRowView)Container.DataItem).Row;
     if (Row.Raw)
     {
         return("Private");
     }
     return("MultiX");
 }
Exemple #4
0
 private void    SetNewState(bool bNewLinkID, bool bEditMode, int pLinkID)
 {
     m_bNewLink  = bNewLinkID;
     m_bEditMode = bEditMode;
     m_LinkID    = pLinkID;
     if (m_LinkID < 0)
     {
         m_LinkRow = null;
     }
     StoreInViewState();
     BindAll();
 }
Exemple #5
0
 protected string  GetAddressText(DataGridItem Container)
 {
     MultiXTpmDB.LinkRow Row = (MultiXTpmDB.LinkRow)((DataRowView)Container.DataItem).Row;
     if (Row.OpenMode == (int)MultiXTpm.MultiXOpenMode.MultiXOpenModeClient)
     {
         return(Row.IsRemoteAddressNull() || Row.RemoteAddress.Trim().Length == 0       ?       "Unknown" : Row.RemoteAddress);
     }
     if (Row.OpenMode == (int)MultiXTpm.MultiXOpenMode.MultiXOpenModeServer)
     {
         return(Row.IsLocalAddressNull() || Row.LocalAddress.Trim().Length == 0       ?       "Any" : Row.LocalAddress);
     }
     return("Unknown");
 }
Exemple #6
0
 protected DataRow[]       GetLinksDataSource()
 {
     if (m_ProcessClassRow == null)
     {
         return(new     MultiXTpmDB.LinkRow[0]);
     }
     MultiXTpmDB.ProcessClassLinksRow[] PCLRows = m_ProcessClassRow.GetProcessClassLinksRows();
     MultiXTpmDB.LinkRow[] LinksRows            = new     MultiXTpmDB.LinkRow[PCLRows.Length];
     for (int I = 0; I < PCLRows.Length; I++)
     {
         LinksRows[I] = PCLRows[I].LinkRow;
     }
     return(LinksRows);
 }
Exemple #7
0
 private void LinksGrid_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
 {
     if (!SaveData())
     {
         return;
     }
     MultiXTpmDB.LinkRow Row = m_DS.Link.FindByID((int)LinksGrid.DataKeys[e.Item.ItemIndex]);
     foreach (MultiXTpmDB.ProcessClassLinksRow LRow    in      Row.GetProcessClassLinksRows())
     {
         if (LRow.ProcessClassID == m_ProcessClassID)
         {
             LRow.Delete();
             break;
         }
     }
     BindAll();
 }
Exemple #8
0
        protected string  GetOpenModeText(DataGridItem Container)
        {
            string SSL = "";

            MultiXTpmDB.LinkRow Row = (MultiXTpmDB.LinkRow)((DataRowView)Container.DataItem).Row;
            if (Row.SSLAPI == MultiXTpm.SSL_API.OpenSSL.ToString())
            {
                SSL = "/" + Row.SSLAPI;
            }
            if (Row.OpenMode == (int)MultiXTpm.MultiXOpenMode.MultiXOpenModeClient)
            {
                return("Client/Connect" + SSL);
            }
            if (Row.OpenMode == (int)MultiXTpm.MultiXOpenMode.MultiXOpenModeServer)
            {
                return("Server/Listen" + SSL);
            }
            return("UnKnown");
        }
Exemple #9
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            m_DS        = EnvInit();
            m_LinkRow   = null;
            m_bEditMode = false;
            m_bNewLink  = false;
            m_LinkID    = -1;

            if (!IsPostBack)
            {
                if (Request["LinkID"] != null)
                {
                    if (Request["LinkID"].ToLower() == "new")
                    {
                        SetNewState(true, false, m_LinkID);
                        return;
                    }
                    m_LinkID = Convert.ToInt32(Request["LinkID"]);
                }
                else
                {
                    m_LinkID = -1;
                }

                if (m_LinkID >= 0)
                {
                    m_LinkRow = m_DS.Link.FindByID(m_LinkID);
                    if (m_LinkRow == null)
                    {
                        Utilities.SetError(this, "Link not defined in the system", null);
                    }
                }
                SetNewState(false, false, m_LinkID);
            }
            else
            {
                LoadFromViewState();
                if (m_LinkID >= 0)
                {
                    m_LinkRow = m_DS.Link.FindByID(m_LinkID);
                }
            }
        }
Exemple #10
0
        protected void ShowLinkBtn_Click(object sender, System.EventArgs e)
        {
            try
            {
                int l_ID = Convert.ToInt32(LinkID.Text);
                m_LinkRow = m_DS.Link.FindByID(l_ID);

                if (m_LinkRow == null)
                {
                    SetNewState(false, false, -1);
                    LinkID.Text = l_ID.ToString();
                    Utilities.Confirm(this, "Link not defined in the system, to add a new one, click OK", "document.all('NewLinkBtn').click()", null);
                }
                else
                {
                    SetNewState(false, false, l_ID);
                }
            }
            catch
            {
                Utilities.SetError(this, "Invalid Link ID Specified", null);
                SetNewState(false, false, -1);
            }
        }
Exemple #11
0
        private bool    SaveData()
        {
            foreach (IValidator V       in      Validators)
            {
                if (V    is      RangeValidator)
                {
                    RangeValidator RV   = (RangeValidator)V;
                    Control        Ctrl = FindControl(RV.ControlToValidate);
                    if (Ctrl != null && Ctrl    is      TextBox)
                    {
                        if (((TextBox)Ctrl).Text.Trim().Length == 0)
                        {
                            ((TextBox)Ctrl).Text = "0";
                        }
                    }
                }
                V.Validate();
                if (!V.IsValid)
                {
                    return(false);
                }
            }

            m_LinkID = Convert.ToInt32(LinkID.Text);

            if (m_bNewLink)
            {
                m_LinkRow    = m_DS.Link.NewLinkRow();
                m_LinkRow.ID = m_LinkID;
            }
            else
            if (!m_bEditMode)
            {
                throw   new     Exception("Invalid mode on save");
            }
            m_LinkRow.Description = Description.Text;
            m_LinkRow.ID          = m_LinkID;
            m_LinkRow.LinkType    = Convert.ToInt32(LinkType.SelectedValue);
            m_LinkRow.OpenMode    = Convert.ToInt32(OpenMode.SelectedValue);
            m_LinkRow.Raw         = Raw.Checked;
            if (m_LinkRow.OpenMode == (int)MultiXTpm.MultiXOpenMode.MultiXOpenModeClient)
            {
                if (IPAddress.Text.Trim().Length == 0)
                {
                    Utilities.SetError(this, "Host Name/IP Address MUST have a value", null);
                    return(false);
                }
                if (PortNumber.Text.Trim().Length == 0)
                {
                    Utilities.SetError(this, "Port Number MUST have a value", null);
                    return(false);
                }

                m_LinkRow.LocalAddress  = "";
                m_LinkRow.LocalPort     = "";
                m_LinkRow.RemoteAddress = IPAddress.Text;
                m_LinkRow.RemotePort    = PortNumber.Text;
            }
            else
            {
                m_LinkRow.LocalAddress  = IPAddress.Text;
                m_LinkRow.LocalPort     = PortNumber.Text;
                m_LinkRow.RemoteAddress = "";
                m_LinkRow.RemotePort    = "";
            }
            m_LinkRow.SSLAPI = SSLAPICombo.SelectedValue;
            if (m_LinkRow.SSLAPI == MultiXTpm.SSL_API.OpenSSL.ToString())
            {
                m_LinkRow.SSLAPI             = SSLAPICombo.SelectedValue;
                m_LinkRow.SSLCertificateFile = SSLCertificateFile.Text;
                m_LinkRow.SSLClientAuthenticationRequired = SSLClientAuthenticationRequired.Checked;
                m_LinkRow.SSLDHFile                         = SSLDHFile.Text;
                m_LinkRow.SSLPrivateKeyFile                 = SSLPrivateKeyFile.Text;
                m_LinkRow.SSLPrivateKeyPassword             = SSLPrivateKeyPassword.Text;
                m_LinkRow.SSLPrivateKeyPasswordFile         = SSLPrivateKeyPasswordFile.Text;
                m_LinkRow.SSLRSAPrivateKeyFile              = SSLRSAPrivateKeyFile.Text;
                m_LinkRow.SSLServerAuthenticationRequired   = SSLServerAuthenticationRequired.Checked;
                m_LinkRow.SSLServerNameVerificationRequired = SSLServerNameVerificationRequired.Checked;
                m_LinkRow.SSLTrustStoreDirectory            = SSLTrustStoreDirectory.Text;
                m_LinkRow.SSLTrustStoreFile                 = SSLTrustStoreFile.Text;
            }

            if (m_bNewLink)
            {
                m_LinkRow.Table.Rows.Add(m_LinkRow);
            }
            ConvertEmptyStringToNull(m_LinkRow);
            return(true);
        }
Exemple #12
0
        protected MultiXTpmDB RebuildDS(MultiXTpmDB DS, MultiXTpm.ConfigData Config, MultiXTpm.SystemStatus Status)
        {
            if (DS == null)
            {
                DS = new MultiXTpmDB();
            }

            if (Config != null)
            {
                LastConfigUpdate = Config.LastUpdate;
                DS.Group.Clear();
                DS.GroupForwardFlags.Clear();
                DS.GroupProcessClasses.Clear();
                DS.Link.Clear();
                DS.LinkParams.Clear();
                DS.Message.Clear();
                DS.Param.Clear();
                DS.ProcessClass.Clear();
                DS.ProcessClassLinks.Clear();
                DS.ProcessClassParams.Clear();
                if (Config.Groups != null)
                {
                    foreach (MultiXTpm.Group Group in Config.Groups)
                    {
                        MultiXTpmDB.GroupRow Row = DS.Group.NewGroupRow();
                        if (Group.Description != null)
                        {
                            Row.Description = Group.Description;
                        }
                        Row.ID = Group.ID;
                        DS.Group.AddGroupRow(Row);
                        if (Group.ProcessClassIDs != null)
                        {
                            foreach (int ProcessClassID in Group.ProcessClassIDs)
                            {
                                MultiXTpmDB.GroupProcessClassesRow GPRow = DS.GroupProcessClasses.NewGroupProcessClassesRow();
                                GPRow.GroupID        = Group.ID;
                                GPRow.ProcessClassID = ProcessClassID;
                                DS.GroupProcessClasses.AddGroupProcessClassesRow(GPRow);
                            }
                        }
                    }
                }
                if (Config.ProcessClasses != null)
                {
                    foreach (MultiXTpm.ProcessClass ProcessClass in Config.ProcessClasses)
                    {
                        MultiXTpmDB.ProcessClassRow Row = DS.ProcessClass.NewProcessClassRow();
                        Row.AdditionalConfigTextFile = ProcessClass.AdditionalConfigTextFile;
                        Row.AutoStart          = ProcessClass.AutoStart;
                        Row.DebugLevel         = ProcessClass.DebugLevel;
                        Row.DefaultSendTimeout = ProcessClass.DefaultSendTimeout;
                        Row.Description        = ProcessClass.Description;
                        Row.ExecCmd            = ProcessClass.ExecCmd;
                        Row.ExecParams         = ProcessClass.ExecParams;
                        Row.ExpectedPassword   = ProcessClass.ExpectedPassword;
                        Row.ID = ProcessClass.ID;
                        Row.InactivityTimer      = ProcessClass.InactivityTimer;
                        Row.MaxInstances         = ProcessClass.MaxInstances;
                        Row.MaxQueueSize         = ProcessClass.MaxQueueSize;
                        Row.MaxRecoveryQueueSize = ProcessClass.MaxRecoveryQueueSize;
                        Row.MaxSessions          = ProcessClass.MaxSessions;
                        Row.MinInstances         = ProcessClass.MinInstances;
                        Row.PasswordToSend       = ProcessClass.PasswordToSend;
                        Row.ClassName            = ProcessClass.ClassName;
                        Row.StartProcessDelay    = ProcessClass.StartProcessDelay;
                        DS.ProcessClass.AddProcessClassRow(Row);
                        if (ProcessClass.Params != null)
                        {
                            foreach (MultiXTpm.Param Param in ProcessClass.Params)
                            {
                                MultiXTpmDB.ParamRow PRow = DS.Param.NewParamRow();
                                PRow.ParamName  = Param.ParamName;
                                PRow.ParamValue = Param.ParamValue;
                                DS.Param.AddParamRow(PRow);
                                MultiXTpmDB.ProcessClassParamsRow PPRow = DS.ProcessClassParams.NewProcessClassParamsRow();
                                PPRow.ParamID        = PRow.ID;
                                PPRow.ProcessClassID = ProcessClass.ID;
                                DS.ProcessClassParams.AddProcessClassParamsRow(PPRow);
                            }
                        }
                        if (ProcessClass.LinkIDs != null)
                        {
                            foreach (int LinkID in ProcessClass.LinkIDs)
                            {
                                MultiXTpmDB.ProcessClassLinksRow LRow = DS.ProcessClassLinks.NewProcessClassLinksRow();
                                LRow.LinkID         = LinkID;
                                LRow.ProcessClassID = ProcessClass.ID;
                                DS.ProcessClassLinks.AddProcessClassLinksRow(LRow);
                            }
                        }
                    }
                }
                if (Config.Links != null)
                {
                    foreach (MultiXTpm.Link Link in Config.Links)
                    {
                        MultiXTpmDB.LinkRow Row = DS.Link.NewLinkRow();
                        Row.Description   = Link.Description;
                        Row.ID            = Link.ID;
                        Row.LinkType      = (int)Link.LinkType;
                        Row.LocalAddress  = Link.LocalAddress;
                        Row.LocalPort     = Link.LocalPort;
                        Row.OpenMode      = (int)Link.OpenMode;
                        Row.Raw           = Link.Raw;
                        Row.RemoteAddress = Link.RemoteAddress;
                        Row.RemotePort    = Link.RemotePort;
                        if (Link.SSLParams != null)
                        {
                            Row.SSLAPI             = Link.SSLParams.API.ToString();
                            Row.SSLCertificateFile = Link.SSLParams.CertificateFile;
                            Row.SSLClientAuthenticationRequired = Link.SSLParams.ClientAuthenticationRequired;
                            Row.SSLDHFile                         = Link.SSLParams.DHFile;
                            Row.SSLPrivateKeyFile                 = Link.SSLParams.PrivateKeyFile;
                            Row.SSLPrivateKeyPassword             = Link.SSLParams.PrivateKeyPassword;
                            Row.SSLPrivateKeyPasswordFile         = Link.SSLParams.PrivateKeyPasswordFile;
                            Row.SSLRSAPrivateKeyFile              = Link.SSLParams.RSAPrivateKeyFile;
                            Row.SSLServerAuthenticationRequired   = Link.SSLParams.ServerAuthenticationRequired;
                            Row.SSLServerNameVerificationRequired = Link.SSLParams.ServerNameVerificationRequired;
                            Row.SSLTrustStoreDirectory            = Link.SSLParams.TrustStoreDirectory;
                            Row.SSLTrustStoreFile                 = Link.SSLParams.TrustStoreFile;
                        }
                        DS.Link.AddLinkRow(Row);
                        if (Link.Params != null)
                        {
                            foreach (MultiXTpm.Param Param in Link.Params)
                            {
                                MultiXTpmDB.ParamRow PRow = DS.Param.NewParamRow();
                                PRow.ParamName  = Param.ParamName;
                                PRow.ParamValue = Param.ParamValue;
                                DS.Param.AddParamRow(PRow);
                                MultiXTpmDB.LinkParamsRow LPRow = DS.LinkParams.NewLinkParamsRow();
                                LPRow.ParamID = PRow.ID;
                                LPRow.LinkID  = Link.ID;
                                DS.LinkParams.AddLinkParamsRow(LPRow);
                            }
                        }
                    }
                }
                if (Config.Messages != null)
                {
                    foreach (MultiXTpm.Message Msg in Config.Messages)
                    {
                        MultiXTpmDB.MessageRow MRow = DS.Message.NewMessageRow();
                        MRow.DbProtected   = Msg.DbProtected;
                        MRow.Description   = Msg.Description;
                        MRow.ID            = Msg.ID;
                        MRow.Priority      = Msg.Priority;
                        MRow.Stateful      = Msg.Stateful;
                        MRow.Timeout       = Msg.Timeout;
                        MRow.WSDllFile     = Msg.WSDllFile;
                        MRow.WSDllFunction = Msg.WSDllFunction;
                        MRow.WSURL         = Msg.WSURL;
                        MRow.WSSoapAction  = Msg.WSSoapAction;
                        DS.Message.AddMessageRow(MRow);
                        if (Msg.ForwardFlags != null)
                        {
                            foreach (MultiXTpm.GroupForwardFlags Flags in Msg.ForwardFlags)
                            {
                                MultiXTpmDB.GroupForwardFlagsRow GFRow = DS.GroupForwardFlags.NewGroupForwardFlagsRow();
                                GFRow.GroupID          = Flags.GroupID;
                                GFRow.IgnoreResponse   = Flags.IgnoreResponse;
                                GFRow.ForwardToAll     = Flags.ForwardToAll;
                                GFRow.MessageID        = Msg.ID;
                                GFRow.ResponseRequired = Flags.ResponseRequired;
                                DS.GroupForwardFlags.AddGroupForwardFlagsRow(GFRow);
                            }
                        }
                    }
                }
                if (Config.UsersPermissions != null)
                {
                    foreach (MultiXTpm.UserPermission Perm in Config.UsersPermissions)
                    {
                        MultiXTpmDB.UserPermissionsRow Row = DS.UserPermissions.NewUserPermissionsRow();
                        Row.UserName        = Perm.UserName;
                        Row.GetWSDL         = Perm.GetWSDL;
                        Row.GetConfig       = Perm.GetConfig;
                        Row.UpdateConfig    = Perm.UpdateConfig;
                        Row.GetSystemStatus = Perm.GetSystemStatus;
                        Row.RestartProcess  = Perm.RestartProcess;
                        Row.RestartGroup    = Perm.RestartGroup;
                        Row.StartProcess    = Perm.StartProcess;
                        Row.StartGroup      = Perm.StartGroup;
                        Row.ShutdownProcess = Perm.ShutdownProcess;
                        Row.ShutdownGroup   = Perm.ShutdownGroup;
                        Row.SuspendGroup    = Perm.SuspendGroup;
                        Row.SuspendProcess  = Perm.SuspendProcess;
                        Row.ResumeGroup     = Perm.ResumeGroup;
                        Row.ResumeProcess   = Perm.ResumeProcess;
                        Row.RestartAll      = Perm.RestartAll;
                        Row.StartAll        = Perm.StartAll;
                        Row.ShutdownAll     = Perm.ShutdownAll;
                        Row.SuspendAll      = Perm.SuspendAll;
                        Row.ResumeAll       = Perm.ResumeAll;
                        DS.UserPermissions.AddUserPermissionsRow(Row);
                    }
                }
                DS.Group.AcceptChanges();
                DS.GroupForwardFlags.AcceptChanges();
                DS.GroupProcessClasses.AcceptChanges();
                DS.Link.AcceptChanges();
                DS.LinkParams.AcceptChanges();
                DS.Message.AcceptChanges();
                DS.Param.AcceptChanges();
                DS.UserPermissions.AcceptChanges();
                DS.ProcessClass.AcceptChanges();
                DS.ProcessClassLinks.AcceptChanges();
                DS.ProcessClassParams.AcceptChanges();
            }


            if (Status != null)
            {
                Session["__MultiXTpmVer"]       = Status.TpmVersion;
                Session["__MultiXTpmMultiXVer"] = Status.TpmMultiXVersion;
                Session["__MultiXTpmHostName"]  = Status.TpmHostName;
                Session["__MultiXTpmHostIP"]    = Status.TpmHostIP;

                DS.GroupStatus.Clear();
                DS.ProcessStatus.Clear();
                DS.GroupStatusProcesses.Clear();
                if (Status.GroupsStatus != null)
                {
                    foreach (MultiXTpm.GroupStatus GS in Status.GroupsStatus)
                    {
                        if (DS.Group.FindByID(GS.ID) == null)
                        {
                            continue;
                        }
                        MultiXTpmDB.GroupStatusRow Row = DS.GroupStatus.NewGroupStatusRow();
                        Row.GroupID = GS.ID;
                        Row.MaxProcessQueueEntries = GS.MaxProcessQueueEntries;
                        Row.OutQueueSize           = GS.OutQueueSize;
                        Row.QueuedItemsSize        = GS.QueuedItemsSize;
                        Row.SessionsCount          = GS.SessionsCount;
                        DS.GroupStatus.AddGroupStatusRow(Row);
                        if (GS.ProcessIDs != null)
                        {
                            foreach (int ProcessID in GS.ProcessIDs)
                            {
                                MultiXTpmDB.GroupStatusProcessesRow GSPRow = DS.GroupStatusProcesses.NewGroupStatusProcessesRow();
                                GSPRow.GroupID   = GS.ID;
                                GSPRow.ProcessID = ProcessID;
                                DS.GroupStatusProcesses.AddGroupStatusProcessesRow(GSPRow);
                            }
                        }
                    }
                }
                if (Status.ProcessesStatus != null)
                {
                    foreach (MultiXTpm.ProcessStatus PS in Status.ProcessesStatus)
                    {
                        MultiXTpmDB.ProcessStatusRow Row = DS.ProcessStatus.NewProcessStatusRow();
                        Row.ProcessClassID = PS.ProcessClassID;
                        Row.ID             = PS.ID;
                        Row.ControlStatus  = (int)PS.ControlStatus;
                        Row.IsReady        = PS.IsReady;
                        Row.LastMsgTime    = PS.LastMsgTime;
                        Row.OutQueueSize   = PS.OutQueueSize;
                        Row.SessionsCount  = PS.SessionsCount;
                        Row.AppVersion     = PS.AppVersion;
                        Row.MultiXVersion  = PS.MultiXVersion;
                        DS.ProcessStatus.AddProcessStatusRow(Row);
                    }
                }
                DS.GroupStatus.AcceptChanges();
                DS.ProcessStatus.AcceptChanges();
                DS.GroupStatusProcesses.AcceptChanges();
            }
            return(DS);
        }