예제 #1
0
        public i9Message Login(i9Message RequestMessage)
        {
            i9Message response = new i9Message();

            LoginMessage oLoginMessage = (LoginMessage)i9Message.XMLDeserializeMessage(typeof(LoginMessage), RequestMessage.MsgBody);
            SQLAccess    da            = new SQLAccess();

            string    SQLLogin = "******" + SQLUtility.SQLString(oLoginMessage.UserName) + " and Password = "******"i9SysPersonnel");

            if (dt.Rows.Count <= 0)
            {
                //Just send back an empty table

                return(response);
            }

            string i9SysPersonnelID = dt.Rows[0]["i9SysPersonnelID"].ToString();

            //Give an activision code to the login user
            string UpdateSql = "UPDATE i9SysPersonnel SET ActivationGuid = '" + Guid.NewGuid() + "' WHERE i9SysPersonnelID = " + SQLUtility.SQLString(i9SysPersonnelID);

            if (da.ExecuteSQL(UpdateSql) <= 0)
            {
                //Nothing was updated.
            }

            //SyncModuleManagerToDB();


            Dictionary <string, string> tableMapping = new Dictionary <string, string>()
            {
                { "Table", "i9SysPersonnel" },
                { "Table1", "xxSecurityGroupTask" },
                { "Table2", "xxSecurityGroupModule" },
            };

            string SQL = "SELECT * FROM i9SysPersonnel WHERE i9SysPersonnelID = @i9SysPersonnelID";

            SQL = SQL + Environment.NewLine + @"
                    SELECT sgt.TaskName, sp.BadgeNumber
                    FROM i9SecurityGroup sg
                            inner join i9SecurityGroupTask sgt
                            on sgt.SecurityGroupName = sg.SecurityGroupName	
                            inner join i9SecurityGroupPersonnel sgp 
                            on sgp.i9SecurityGroupID = sg.i9SecurityGroupID
                            inner join i9SysPersonnel sp
                            on sp.i9SysPersonnelID = sgp.i9SysPersonnelID
                    WHERE sp.i9SysPersonnelID = @i9SysPersonnelID
                    Group by TaskName, BadgeNumber                        
                    order by BadgeNumber, TaskName 
                    ";

            SQL = SQL + Environment.NewLine + @"
                    SELECT sgm.ModuleName, sp.BadgeNumber
                    FROM i9SecurityGroup sg
                            inner join i9SecurityGroupModule sgm
                            on sgm.SecurityGroupName = sg.SecurityGroupName	
                            inner join i9SecurityGroupPersonnel sgp 
                            on sgp.i9SecurityGroupID = sg.i9SecurityGroupID
                            inner join i9SysPersonnel sp
                            on sp.i9SysPersonnelID = sgp.i9SysPersonnelID
                    WHERE sp.i9SysPersonnelID = @i9SysPersonnelID
                    Group by ModuleName, BadgeNumber                        
                    order by BadgeNumber, ModuleName     
                    ";

            SQL = SQL.Replace("@i9SysPersonnelID", SQLUtility.SQLString(i9SysPersonnelID));

            response.MsgBodyDataSet      = response.MsgBodyDataSet = da.GetDataSet(SQL, tableMapping);
            response.ErrorStatus.IsError = false;


            return(response);
        }
예제 #2
0
        /// <summary>
        /// Sync Module Manager To DB
        /// </summary>
        private void SyncModuleManagerToDB()
        {
            SQLAccess da = new SQLAccess();

            //DataTable dt = da.GetDataTable("SELECT * FROM i9Module WHERE ModuleKey = " + SQLUtility.SQLString(mi.i9ModuleID), "i9Module");
            DataTable dt = da.GetDataTable("SELECT * FROM i9Module", "i9Module");

            for (int i = 0; i < ModuleManager.Instance.Modules.Length - 1; i++)
            {
                ModuleItem mi = ModuleManager.Instance.Modules[i];

                bool found = false;

                if (mi.ModuleName.ToUpper() == "CRIME WATCH")
                {
                    Console.Write("");
                }


                if (mi.ModuleName.ToUpper() == "LOGIN" ||
                    mi.ModuleName.ToUpper() == "MAIN" ||
                    mi.ModuleName.ToUpper() == "MAIN MENU" ||
                    mi.ModuleName.ToUpper() == "SPLASH SCREEN")
                {
                    continue;
                }
                else
                {
                    foreach (DataRow ModuleRow in dt.Rows)
                    {
                        if (ModuleRow["ModuleName"].ToString().ToUpper() == mi.ModuleName.ToUpper())
                        {
                            found = true;
                            break;
                        }
                    }

                    if (found == false)
                    {
                        //Why am I adding a row if the table is blank this is strange
                        DataRow NewModuleRow = dt.NewRow();
                        NewModuleRow["ClassName"]      = mi.ClassName;
                        NewModuleRow["ModuleName"]     = mi.ModuleName;
                        NewModuleRow["Section"]        = mi.Section;
                        NewModuleRow["PopupPage"]      = mi.PopupPage;
                        NewModuleRow["DesktopEnabled"] = mi.DesktopEnabled;
                        NewModuleRow["MobileEnabled"]  = mi.MobileEnabled;
                        NewModuleRow["ModuleType"]     = mi.ModuleType;
                        NewModuleRow["ModuleKey"]      = mi.i9ModuleID;
                        NewModuleRow["i9ModuleID"]     = Guid.NewGuid();
                        NewModuleRow["FileName"]       = mi.FileName;
                        dt.Rows.Add(NewModuleRow);
                    }
                }
            }

            if (dt.DataSet.HasChanges())
            {
                da.SaveDataTable(dt);
            }
        }