Example #1
0
    protected void cmdOverwrite_Click(object sender, EventArgs e)
    {
        panAlert.Visible         = true;
        panDatabaseAlert.Visible = false;

        DatabaseMgr dm        = new DatabaseMgr();
        bool        didDelete = dm.DeleteMeet(meetID);

        if (didDelete)
        {
            bool didAdd = dm.AddMeet(newMeet, Session["Username"].ToString());
            if (didAdd)
            {
                Session["ActiveMeet"] = newMeet;

                //Open MeetHub here
                Response.Redirect("MeetHub.aspx");
            }
            else
            {
                lblAlert.Text = "Meet deleted from database, but error adding new database entry";
            }
        }
        else
        {
            lblAlert.Text = "Error deleting existing meet from database";
        }
    }
	// it looks like most of the classes using the DatabaseManager have callbacks that only use the string 'data' to process, so we could cache these strings
	// based on the parameter set passed in, like 'LoadCases','Owner', or 'LoadCase', 'caseName', and the string containing the data we want to use for offline session

	public void DBCallOffline(string URL, WWWForm form, DatabaseMgr.Callback callback){

		// if we can find a match in our list of cached responses, send it back
		// first, find the arguments
		string strFormData = Encoding.UTF8.GetString(form.data, 0, form.data.Length);  //"command=cmd&param=paramvalue"

		string[] fields = strFormData.Split ('&');
		string command = "";
		string param1 = "";
		string[] pair;
		if (fields [0].Contains ("=")) {
			pair = fields [0].Split ('=');
			command = pair [1];
			if (fields.Length > 1 && fields[1].Contains("=")){
				pair = fields [1].Split ('=');
				param1 = pair [1].Replace("+"," ");

			}
		}
		string data = "";
		foreach (CachedDBResult result in OfflineDBResults) {
			if (result.command == command && result.param1 == param1){
				data = result.data;
				break;
			}
		}

		// don't use coroutine here because the timescale might be 0 and
		// then we will never return...		
		//StartCoroutine(CallbackAfterDelay(callback,data)); 

		// do callback
		if ( callback != null )
			callback(true,data,"",null);
	}
Example #3
0
        public questStatus GetDatabaseViews(DatabaseId databaseId, out List <BootstrapTreenodeViewModel> dbViewNodeList)
        {
            // Initialize
            questStatus status = null;

            dbViewNodeList = null;


            // Get db tables
            List <DBTable> dbTableList = null;
            DatabaseMgr    databaseMgr = new DatabaseMgr(this.UserSession);

            status = databaseMgr.GetDatabaseTables(databaseId, out dbTableList);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }

            // Format into bootstrap nodes
            dbViewNodeList = new List <BootstrapTreenodeViewModel>();
            foreach (DBTable dbTable in dbTableList)
            {
                BootstrapTreenodeViewModel bootstrapTreenodeViewModel = null;
                status = FormatBootstrapTreeviewNode(dbTable, out bootstrapTreenodeViewModel);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                dbViewNodeList.Add(bootstrapTreenodeViewModel);
            }
            return(new questStatus(Severity.Success));
        }
Example #4
0
        public IEnumerable <UserInfo> GetAllUsers()
        {
            DatabaseMgr            dbgetAll = new DatabaseMgr();
            IEnumerable <UserInfo> allUsers = dbgetAll.GetAllUsers();

            return(allUsers);
        }
Example #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DatabaseMgr            dm          = new DatabaseMgr();
        Dictionary <int, Meet> listOfMeets = dm.ListOfMeets(Session["Username"].ToString());

        foreach (int key in listOfMeets.Keys)
        {
            lstMeets.Items.Add(new ListItem(listOfMeets[key].dateOfMeet.ToString() + " @ " + listOfMeets[key].location, key.ToString()));
        }
    }
Example #6
0
    protected void cmdOpen_Click(object sender, EventArgs e)
    {
        DatabaseMgr dm         = new DatabaseMgr();
        Meet        meetToOpen = dm.FindMeet(Convert.ToInt32(lstMeets.SelectedValue));

        Session["ActiveMeet"] = meetToOpen;

        //Open MeetHub here
        Response.Redirect("MeetHub.aspx");
    }
Example #7
0
        public questStatus ReadTablesetConfiguration(TablesetId tablesetId, out TablesetConfiguration tablesetConfiguration)
        {
            // Initialize
            questStatus status = null;

            tablesetConfiguration = null;


            // Read tableset configuration
            status = _dbTablesetMgr.ReadTablesetConfiguration(tablesetId, out tablesetConfiguration);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }

            // Read database entities
            DatabaseId       databaseId       = new DatabaseId(tablesetConfiguration.Database.Id);
            DatabaseEntities databaseEntities = null;
            DatabaseMgr      databaseMgr      = new DatabaseMgr(this.UserSession);

            status = databaseMgr.ReadDatabaseEntities(databaseId, out databaseEntities);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }


            // Sort out what's assigned and not assigned to the tableset.
            List <Table> nonAssignedTableList = new List <Table>();
            List <View>  nonAssignedViewList  = new List <View>();

            foreach (Table table in databaseEntities.TableList)
            {
                TablesetTable tablesetTable = tablesetConfiguration.TablesetTables.Find(delegate(TablesetTable ts) { return(ts.Schema == table.Schema && ts.Name == table.Name); });
                if (tablesetTable == null)
                {
                    nonAssignedTableList.Add(table);
                }
            }
            tablesetConfiguration.DBTableList = nonAssignedTableList;

            // Load database views and columns into configuration NOT assigned to tableset.
            foreach (View view in databaseEntities.ViewList)
            {
                TablesetView tablesetView = tablesetConfiguration.TablesetViews.Find(delegate(TablesetView tv) { return(tv.Schema == view.Schema && tv.Name == view.Name); });
                if (tablesetView == null)
                {
                    nonAssignedViewList.Add(view);
                }
            }
            tablesetConfiguration.DBViewList = nonAssignedViewList;


            return(new questStatus(Severity.Success));
        }
Example #8
0
    void Awake()
    {
        _inst = this;
        DontDestroyOnLoad(gameObject);

        _cacheData = new Dictionary <string, Dictionary <string, object> >();
        _tmpData   = new Dictionary <string, Dictionary <string, object> >();

        //            ab = ResMgr.Inst.getAB("cfgdata.ab");

        CacahData();
    }
Example #9
0
        public void AddUser(UserInfo user)
        {
            DatabaseMgr dbmgr = new DatabaseMgr();

            if (dbmgr.AddUser(user))
            {
                Console.WriteLine("Success");
            }
            else
            {
                Console.WriteLine("Failure");
            }
        }
Example #10
0
        public void LoginUser(UserInfo user)
        {
            DatabaseMgr dbmgr = new DatabaseMgr();

            user = dbmgr.loginUser(user);
            if (user != null)
            {
                Console.WriteLine("Logged in");
            }
            else
            {
                Console.WriteLine("Account credentials are wrong");
            }
        }
Example #11
0
        public questStatus Delete(DatabaseId databaseId)
        {
            // Initialize
            questStatus status = null;


            // Delete
            DatabaseMgr databaseMgr = new DatabaseMgr(this.UserSession);

            status = databaseMgr.Delete(databaseId);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Example #12
0
        //TablesetConfigurationViewModel
        #endregion


        #region Public Methods

        /*==================================================================================================================================
        * Public Methods
        *=================================================================================================================================*/

        #region CRUD
        //----------------------------------------------------------------------------------------------------------------------------------
        // CRUD
        //----------------------------------------------------------------------------------------------------------------------------------
        public questStatus GetDatabaseEntities(DatabaseId databaseId, out List <BootstrapTreenodeViewModel> dbTableNodeList, out List <BootstrapTreenodeViewModel> dbViewNodeList)
        {
            // Initialize
            questStatus status = null;

            dbTableNodeList = null;
            dbViewNodeList  = null;


            // Read database entities
            DatabaseEntities databaseEntities = null;
            DatabaseMgr      databaseMgr      = new DatabaseMgr(this.UserSession);

            status = databaseMgr.ReadDatabaseEntities(databaseId, out databaseEntities);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }

            // Transfer model
            // Tables
            dbTableNodeList = new List <BootstrapTreenodeViewModel>();
            foreach (Table dbTable in databaseEntities.TableList)
            {
                BootstrapTreenodeViewModel bootstrapTreenodeViewModel = null;
                status = FormatBootstrapTreeviewNode(dbTable, out bootstrapTreenodeViewModel);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                dbTableNodeList.Add(bootstrapTreenodeViewModel);
            }

            // Views
            dbViewNodeList = new List <BootstrapTreenodeViewModel>();
            foreach (View dbView in databaseEntities.ViewList)
            {
                BootstrapTreenodeViewModel bootstrapTreenodeViewModel = null;
                status = FormatBootstrapTreeviewNode(dbView, out bootstrapTreenodeViewModel);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                dbViewNodeList.Add(bootstrapTreenodeViewModel);
            }
            return(new questStatus(Severity.Success));
        }
Example #13
0
        public questStatus RefreshSchema(DatabaseEditorViewModel databaseEditorViewModel)
        {
            // Initialize
            questStatus status = null;


            // Refresh schema
            DatabaseId  databaseId  = new DatabaseId(databaseEditorViewModel.Id);
            DatabaseMgr databaseMgr = new DatabaseMgr(this.UserSession);

            status = databaseMgr.RefreshSchema(databaseId);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Example #14
0
        /*==================================================================================================================================
        * Public Methods
        *=================================================================================================================================*/

        #region CRUD
        //----------------------------------------------------------------------------------------------------------------------------------
        // CRUD
        //----------------------------------------------------------------------------------------------------------------------------------
        public questStatus Save(DatabaseEditorViewModel databaseEditorViewModel)
        {
            // Initialize
            questStatus status = null;


            // Transfer model
            Quest.Functional.MasterPricing.Database database = new Quest.Functional.MasterPricing.Database();
            BufferMgr.TransferBuffer(databaseEditorViewModel, database);


            // Determine if this is a create or update
            DatabaseMgr databaseMgr = new DatabaseMgr(this.UserSession);

            if (databaseEditorViewModel.Id < BaseId.VALID_ID)
            {
                // Create
                DatabaseId databaseId = null;
                status = databaseMgr.Create(database, out databaseId);
                if (!questStatusDef.IsSuccess(status))
                {
                    if (databaseId != null && databaseId.Id >= BaseId.VALID_ID)
                    {
                        databaseEditorViewModel.Id = databaseId.Id;
                    }
                    FormatErrorMessage(status, databaseEditorViewModel);
                    return(status);
                }
                databaseEditorViewModel.Id = databaseId.Id;
            }
            else
            {
                // Update
                status = databaseMgr.Update(database);
                if (!questStatusDef.IsSuccess(status))
                {
                    FormatErrorMessage(status, databaseEditorViewModel);
                    return(status);
                }
            }
            return(new questStatus(Severity.Success));
        }
Example #15
0
        public questStatus RefreshSchema(DatabasesListViewModel databasesListViewModel)
        {
            // Initialize
            questStatus status = null;


            // Refresh schema(s)
            foreach (DatabaseLineItemViewModel databaseLineItemViewModel in databasesListViewModel.Items)
            {
                DatabaseId  databaseId  = new DatabaseId(databaseLineItemViewModel.Id);
                DatabaseMgr databaseMgr = new DatabaseMgr(this.UserSession);
                status = databaseMgr.RefreshSchema(databaseId);
                if (!questStatusDef.IsSuccess(status))
                {
                    // TODO: DATABASE-SPECIFIC ERROR MESSAGE TO KNOW WHICH DATABASE FAILED.
                    return(status);
                }
            }
            return(new questStatus(Severity.Success));
        }
Example #16
0
    protected void cmdOpen_Click(object sender, EventArgs e)
    {
        panAlert.Visible         = true;
        panDatabaseAlert.Visible = false;

        DatabaseMgr dm         = new DatabaseMgr();
        Meet        openedMeet = dm.FindMeet(meetID);

        if (openedMeet != null)
        {
            Session["ActiveMeet"] = openedMeet;

            //Open MeetHub here
            Response.Redirect("MeetHub.aspx");
        }
        else
        {
            lblAlert.Text = "Unknown error loading meet from database";
        }
    }
Example #17
0
    public static DatabaseMgr GetInstance()
    {
        if (instance == null)
        {
            //UnityEngine.Debug.LogError("DatabaseMgr.GetInstance() : Script not attached!");
            // instance = new DatabaseMgr();  can't use 'new' to create a component, use AddCOmponent
			instance = FindObjectOfType(typeof(DatabaseMgr)) as DatabaseMgr;
			if (instance == null){
				Brain brainComponent = FindObjectOfType(typeof(Brain)) as Brain;
				if (brainComponent != null){
					instance = brainComponent.gameObject.AddComponent<DatabaseMgr>();
				}
				else
				{
					UnityEngine.Debug.LogError("DatabaseMgr.GetInstance() : script not present!!");
				}
			}			
        }
        return instance;
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        Dictionary <string, string> boysNames = new Dictionary <string, string>();

        boysNames.Add("BLN", "Baldwin");
        boysNames.Add("TJ", "Thomas Jefferson");
        boysNames.Add("WHS", "Washington HS");

        Dictionary <string, string> girlsNames = new Dictionary <string, string>();

        girlsNames.Add("PLM", "Plum");
        girlsNames.Add("GWY", "Gateway");
        girlsNames.Add("KCH", "Knoch");

        Teams teams          = new Teams(boysNames, girlsNames);
        Meet  myMeetNoEvents = new Meet(new DateTime(2017, 04, 13), "Baldwin HS", "Windy", teams);

        DatabaseMgr dbm    = new DatabaseMgr();
        int         meetID = dbm.FindMeetId(myMeetNoEvents);

        dbm.DeleteMeet(meetID);
    }
	public void DBCall(string URL, WWWForm form, DatabaseMgr.Callback callback)
	{
		// if we are offline then do trauma offline container
		if (TraumaOfflineAssetContainer.GetInstance () != null &&
		    TraumaOfflineAssetContainer.GetInstance ().bUseOfflineAssets ) {
			TraumaOfflineAssetContainer.GetInstance ().DBCallOffline (GameMgr.GetInstance().DatabaseURL, form, callback);
		} else {
			DatabaseMgr.GetInstance().DBCall(GameMgr.GetInstance().DatabaseURL,form,callback);
		}
	}
	public void LoadCaseConfiguration( string name, DatabaseMgr.Callback callback )
	{
		if ( UsingLocalData == true )
		{
			// load local case if available
			CaseInfo localCase = LoadCaseInfo(name);
			if ( localCase != null )
			{
				// set local data
				Data = localCase.CaseOptionData;
				// prepare
				PrepareCaseForStart();
				// do callback
				if ( callback != null )
					callback(true,null,null,null);
			}
		}
		else
		{
			// check to see if we have local data, if so just copy the data
			loadCaseCallback = callback;	
			
			WWWForm form = new WWWForm();
			form.AddField("command", "loadCase");
			form.AddField("name", name);
			loadTime = Time.time;
			// if we are offline then do trauma offline container
			if (TraumaOfflineAssetContainer.GetInstance () != null &&
			    TraumaOfflineAssetContainer.GetInstance ().bUseOfflineAssets ) {
				TraumaOfflineAssetContainer.GetInstance ().DBCallOffline (GameMgr.GetInstance().DatabaseURL, form, loadCase);
			} else {
				DBCall(GameMgr.GetInstance().DatabaseURL,form,loadCase);
			}
		}
	}
	public void LoadCaseConfiguration( CaseInfo ci, DatabaseMgr.Callback callback )
	{
		if ( ci != null )
			LoadCaseConfiguration(ci.name,callback);
	}
	public void LoadUserAssignedCases( DatabaseMgr.Callback callback )
	{
		// first try to load local CaseInfo.xml....if available then just use that
		if ( LoadXML("XML/CaseInfo") != null )
		{
			// we have a local file, we're ok
			if ( callback != null )
				callback(true,null,null,null);
			return;
		}
		
		loadCasesCallback = callback;
		
		WWWForm form = new WWWForm();
		form.AddField("command", "loadUserAssignedCasesWithData");	// command without data is loadUserAssignedCases
		form.AddField("username", LoginMgr.GetInstance().Username);
		
		// if we are offline then do trauma offline container
		if (TraumaOfflineAssetContainer.GetInstance () != null &&
		    TraumaOfflineAssetContainer.GetInstance ().bUseOfflineAssets ) {
			TraumaOfflineAssetContainer.GetInstance ().DBCallOffline (GameMgr.GetInstance().DatabaseURL, form, loadCases);
		} else {
			DBCall(GameMgr.GetInstance().DatabaseURL,form,loadCases);
		}
	}
	public void LoadCaseConfigurations( DatabaseMgr.Callback callback )
	{
		if ( UsingLocalData == true )
		{
			// first try to load local CaseInfo.xml....if available then just use that
			if ( LoadXML("XML/CaseInfo") != null )
			{
				// we have a local file, we're ok
				callback(true,null,null,null);
				return;
			}
		}
		else
		{
			loadCasesCallback = callback;
			
			WWWForm form = new WWWForm();
			form.AddField("command", "loadCases");
			form.AddField("owner", LoginMgr.GetInstance().Username);
			// if we are offline then do trauma offline container
			if (TraumaOfflineAssetContainer.GetInstance () != null &&
			    TraumaOfflineAssetContainer.GetInstance ().bUseOfflineAssets ) {
				TraumaOfflineAssetContainer.GetInstance ().DBCallOffline (GameMgr.GetInstance().DatabaseURL, form, loadCases);
			} else {
				DBCall(GameMgr.GetInstance().DatabaseURL,form,loadCases);
			}
		}
	}
	public void LMSLoginWithPing( string username, string password, DatabaseMgr.Callback Callback )
	{
		UnityEngine.Debug.Log ("LMSLoginWithPing(" + username + ")");
		// start off assuming logon is invalid
		LMSLogout ();	
		// start login coroutine
		StartCoroutine(lmsLoginWithPing(username,password,Callback));
	}
Example #25
0
	public void Awake(){
		instance=this;			
	}
    protected void Button2_Click(object sender, EventArgs e)
    {
        Performance myPerformance1 = new Performance("A", "AA", 1.1m);
        Performance myPerformance2 = new Performance("B", "BB", 2.2m);
        Performance myPerformance3 = new Performance("C", "CC", 3.3m);
        Performance myPerformance4 = new Performance("D", "AA", 4.1m);
        Performance myPerformance5 = new Performance("E", "BB", 5.2m);
        Performance myPerformance6 = new Performance("F", "CC", 6.3m);

        List <Performance> myPerformancesA = new List <Performance>();

        myPerformancesA.Add(myPerformance1);
        myPerformancesA.Add(myPerformance2);
        myPerformancesA.Add(myPerformance3);

        List <Performance> myPerformancesB = new List <Performance>();

        myPerformancesB.Add(myPerformance4);
        myPerformancesB.Add(myPerformance5);
        myPerformancesB.Add(myPerformance6);

        Dictionary <string, List <Performance> > myPerformances = new Dictionary <string, List <Performance> >();

        myPerformances.Add("Boy's 100", myPerformancesA);
        myPerformances.Add("Boy's 200", myPerformancesB);

        Dictionary <string, string> boysNames = new Dictionary <string, string>();

        boysNames.Add("BLN", "Baldwin");
        boysNames.Add("TJ", "Thomas Jefferson");
        boysNames.Add("WHS", "Washington HS");

        Dictionary <string, string> girlsNames = new Dictionary <string, string>();

        girlsNames.Add("PLM", "Plum");
        girlsNames.Add("GWY", "Gateway");
        girlsNames.Add("KCH", "Knoch");

        Teams teams = new Teams(boysNames, girlsNames);

        Meet myMeetNoEvents = new Meet(new DateTime(2017, 04, 13), "Baldwin HS", "Windy", teams, myPerformances);

        DatabaseMgr dbm = new DatabaseMgr();

        dbm.AddMeet(myMeetNoEvents, "NoUsername");

        /*TableRow meetRow = new TableRow();
         * tblMeets.Rows.Add(meetRow);
         *
         * TableCell idCell = new TableCell();
         * idCell.Text = "1";
         * meetRow.Cells.Add(idCell);
         *
         * TableCell dateOfMeetCell = new TableCell();
         * dateOfMeetCell.Text = myMeetNoEvents.dateOfMeet.ToString();
         * meetRow.Cells.Add(dateOfMeetCell);
         *
         * TableCell locationCell = new TableCell();
         * locationCell.Text = myMeetNoEvents.location;
         * meetRow.Cells.Add(locationCell);
         *
         * TableCell weatherCell = new TableCell();
         * weatherCell.Text = myMeetNoEvents.weatherConditions;
         * meetRow.Cells.Add(weatherCell);
         *
         * for (int i = 0; i < myMeetNoEvents.schoolNames.boySchoolNames.Count; i++)
         * {
         *  TableRow boysRow = new TableRow();
         *  tblBoysTeams.Rows.Add(boysRow);
         *
         *  TableCell boysId = new TableCell();
         *  boysId.Text = (i + 1).ToString();
         *  boysRow.Cells.Add(boysId);
         *
         *  TableCell abbrCell = new TableCell();
         *  abbrCell.Text = myMeetNoEvents.schoolNames.boySchoolNames.ElementAt(i).Key;
         *  boysRow.Cells.Add(abbrCell);
         *
         *  TableCell tNameCell = new TableCell();
         *  tNameCell.Text = myMeetNoEvents.schoolNames.boySchoolNames.ElementAt(i).Value;
         *  boysRow.Cells.Add(tNameCell);
         *
         *  TableCell meetKeyBoys = new TableCell();
         *  meetKeyBoys.Text = idCell.Text;
         *  boysRow.Cells.Add(meetKeyBoys);
         * }
         *
         * for (int i = 0; i < myMeetNoEvents.schoolNames.girlSchoolNames.Count; i++)
         * {
         *  TableRow girlsRow = new TableRow();
         *  tblGirlsTeams.Rows.Add(girlsRow);
         *
         *  TableCell girlsId = new TableCell();
         *  girlsId.Text = (i + 1).ToString();
         *  girlsRow.Cells.Add(girlsId);
         *
         *  TableCell abbrCell = new TableCell();
         *  abbrCell.Text = myMeetNoEvents.schoolNames.girlSchoolNames.ElementAt(i).Key;
         *  girlsRow.Cells.Add(abbrCell);
         *
         *  TableCell tNameCell = new TableCell();
         *  tNameCell.Text = myMeetNoEvents.schoolNames.girlSchoolNames.ElementAt(i).Value;
         *  girlsRow.Cells.Add(tNameCell);
         *
         *  TableCell meetKeygirls = new TableCell();
         *  meetKeygirls.Text = idCell.Text;
         *  girlsRow.Cells.Add(meetKeygirls);
         * }
         *
         * if (myMeetNoEvents != null && myMeetNoEvents.performances != null)
         * {
         *  foreach (string eventName in myMeetNoEvents.performances.Keys)
         *
         *  //for (int i = 0; i < myMeetNoEvents.performances.Keys; i++)
         *  {
         *      foreach (Performance perf in myMeetNoEvents.performances[eventName])
         *      {
         *          TableRow perfRow = new TableRow();
         *          tblPerformances.Rows.Add(perfRow);
         *
         *          TableCell perfId = new TableCell();
         *          perfId.Text = (100).ToString();
         *          perfRow.Cells.Add(perfId);
         *
         *          TableCell athleteCell = new TableCell();
         *          athleteCell.Text = perf.athleteName;
         *          perfRow.Cells.Add(athleteCell);
         *
         *          TableCell tNameCell = new TableCell();
         *          tNameCell.Text = perf.schoolName;
         *          perfRow.Cells.Add(tNameCell);
         *
         *          TableCell genderCell = new TableCell();
         *          if (eventName.ToUpper().Contains("BOY"))
         *          {
         *              genderCell.Text = "Boy's";
         *          }
         *          else if (eventName.ToUpper().Contains("GIRL"))
         *          {
         *              genderCell.Text = "Girl's";
         *          }
         *          else
         *          {
         *              genderCell.Text = "";
         *          }
         *          perfRow.Cells.Add(genderCell);
         *
         *          TableCell eventCell = new TableCell();
         *          eventCell.Text = eventName;
         *          perfRow.Cells.Add(eventCell);
         *
         *          TableCell heatCell = new TableCell();
         *          heatCell.Text = perf.heatNum.ToString();
         *          perfRow.Cells.Add(heatCell);
         *
         *          TableCell perfCell = new TableCell();
         *          perfCell.Text = perf.performance.ToString();
         *          perfRow.Cells.Add(perfCell);
         *
         *          TableCell meetKeyPerf = new TableCell();
         *          meetKeyPerf.Text = idCell.Text;
         *          perfRow.Cells.Add(meetKeyPerf);
         *
         *      }
         *  }
         * }*/
    }
	IEnumerator lmsLoginWithPing( string username, string password, DatabaseMgr.Callback Callback )
	{
		//string URL="http://192.168.12.148/api3/corwin/r2d0/statefull/auth/";
		//string bodyString = "{\"action\":\"NoOrg\",\"params\":{\"username\":\"" + username + "\",\"password\":\"" + password + "\"},\"authKey\":null}";
		
		string url = "http://" + URL + "statefull/auth";
		//string bodyString = "{\"action\":\"User\",\"params\":{\"user_name\":\"" + username + "\",\"password\":\"" + password + "\"},\"authKey\":null}";
		
		// make JSON
		JSONObject j = new JSONObject(JSONObject.Type.OBJECT);
		//number
		j.AddField("action", "NoOrg");
		// make param area
		JSONObject arr = new JSONObject(JSONObject.Type.ARRAY);
		j.AddField("params", arr);
		// add params
		arr.AddField ("username",username);
		arr.AddField ("password", password );
		// add authkey
		string keyNoQuotes = pingAuthKey.Replace ("\"","");
		j.AddField ("authKey",keyNoQuotes);

		// get bodystring
		string bodyString = j.print();
		
		WWW download = new WWW(url,Encoding.ASCII.GetBytes(bodyString));

		yield return download;
		
		//Application.ExternalCall("Debug","LMSIntegration.lmsLoginWithPing() : URL=" + url + " : bodyString=" + bodyString + " : text=" + download.text + " : error=" + download.error );
	
		string DBResult="";
		string DBErrorString;
		
		if (download.error != null)
		{
			LMSDebug ("LMSIntegration.lmsLoginWithPing(" + username + "," + password + ") url=<" + url + "> bodyString=<" + bodyString + "> error=<" + download.error + ">"); 
			// save the error
			DBResult = null;
			DBErrorString = download.error;
			// do callback
			if (Callback != null)
				Callback(false, DBResult, DBErrorString, download);
			// do global callback
			if (DatabaseMgr.GetInstance() != null && DatabaseMgr.GetInstance().ErrorCallback != null )
				DatabaseMgr.GetInstance().ErrorCallback(false,DBResult,DBErrorString,download);
		}
		else
		{
			LMSDebug ("LMSIntegration.lmsLoginWithPing(" + username + "," + password + ") url=<" + url + "> bodyString=<" + bodyString + "> text=<" + download.text + ">");			
			if ( download.text == null )
			{
				DBResult = "invalid";
				UnityEngine.Debug.LogError ("LMSIntegration.LMSLoginWithPing() : download.text is null!");
			}
			else
			{
				JSONObject decoder = new JSONObject(download.text);
				if ( CheckReturn(decoder) == true )
				{
					JSONObject authkey = decoder.GetField ("authKey");
					if ( authkey != null )
					{
#if !UNITY_WEBPLAYER
						// get response headers
						GetCookies(download);
#endif
						// get authkey
						pingAuthKey = authkey.print ();
						LMSPing (pingAuthKey);
						DBResult = "ok";
					}
					else
					{
						DBResult = "invalid";
						UnityEngine.Debug.LogError ("LMSIntegration.LMSLoginWithPing() : username=<" + username + "> password=<" + password + "> result=" + download.text);
					}
				}
				else
				{
					DBResult = "invalid";
					UnityEngine.Debug.LogError ("LMSIntegration.LMSLoginWithPing() : username=<" + username + "> password=<" + password + "> result=" + download.text);
				}
			}
			// save the results
			DBErrorString = "";
			// do callback
			if (Callback != null)
				Callback(true, DBResult, DBErrorString, download);
		}
	}
Example #28
0
        public questStatus SaveTablesetConfiguration(TablesetConfiguration tablesetConfiguration, out TablesetId tablesetId)
        {
            // Initialize
            questStatus status = null;

            tablesetId = null;
            DbMgrTransaction trans           = null;
            bool             bFiltersRemoved = false;
            questStatus      status2         = null;

            try
            {
                // BEGIN TRANSACTION
                status = BeginTransaction("SaveTablesetConfiguration" + Guid.NewGuid().ToString(), out trans);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }


                /*
                 * Update tableset info.
                 */
                // Read the tableset
                TablesetsMgr tablesetsMgr = new TablesetsMgr(this.UserSession);
                TablesetId   _tablesetId  = new TablesetId(tablesetConfiguration.Tableset.Id);
                Tableset     _tableset    = null;
                status = tablesetsMgr.Read(trans, _tablesetId, out _tableset);
                if (!questStatusDef.IsSuccess(status))
                {
                    RollbackTransaction(trans);
                    return(status);
                }


                /*
                 * Remove all tableset entities.
                 */
                status = ClearTablesetEntities(trans, _tablesetId);
                if (!questStatusDef.IsSuccess(status))
                {
                    RollbackTransaction(trans);
                    return(status);
                }


                // TESTING ONLY:  COMMIT TRANSACTION
                bool bKlugie = false;
                if (bKlugie)
                {
                    status = CommitTransaction(trans);
                    if (!questStatusDef.IsSuccess(status))
                    {
                        return(status);
                    }
                }


                /*
                 * Get database entites.
                 */
                DatabaseId       databaseId       = new DatabaseId(tablesetConfiguration.Database.Id);
                DatabaseMgr      databaseMgr      = new DatabaseMgr(this.UserSession);
                DatabaseEntities databaseEntities = null;
                status = databaseMgr.ReadDatabaseEntities(databaseId, out databaseEntities);
                if (!questStatusDef.IsSuccess(status))
                {
                    RollbackTransaction(trans);
                    return(status);
                }


                #region Save tableset info.

                /*
                 * Save tableset info.
                 */
                DbTablesetColumnsMgr dbTablesetColumnsMgr = new DbTablesetColumnsMgr(this.UserSession);

                // Save table info.
                DbTablesetTablesMgr  dbTablesetTablesMgr = new DbTablesetTablesMgr(this.UserSession);
                List <TablesetTable> tablesetTableList   = new List <TablesetTable>();
                foreach (TablesetTable tablesetTable in tablesetConfiguration.TablesetTables)
                {
                    Table _table = databaseEntities.TableList.Find(delegate(Table t) { return(t.Schema == tablesetTable.Schema && t.Name == tablesetTable.Name); });
                    if (_table == null)
                    {
                        RollbackTransaction(trans);
                        return(new questStatus(Severity.Error, String.Format("ERROR: tableset table [{0}].[{1}] not found in database metainfo.  Try refreshing database schema info",
                                                                             tablesetTable.Schema, tablesetTable.Name)));
                    }
                    tablesetTable.TablesetId = _tableset.Id;
                    tablesetTable.Table      = _table;
                    tablesetTableList.Add(tablesetTable);


                    // Create tableset table.
                    TablesetTableId tablesetTableId = null;
                    status = dbTablesetTablesMgr.Create(trans, tablesetTable, out tablesetTableId);
                    if (!questStatusDef.IsSuccess(status))
                    {
                        RollbackTransaction(trans);
                        return(status);
                    }

                    foreach (Column column in _table.ColumnList)
                    {
                        Column _column = _table.ColumnList.Find(delegate(Column c) { return(c.Name == column.Name); });
                        if (_column == null)
                        {
                            RollbackTransaction(trans);
                            return(new questStatus(Severity.Error, String.Format("ERROR: column [{0}] not found in table [{1}].[{2}] in database metainfo.  Try refreshing database schema info",
                                                                                 column.Name, _table.Schema, _table.Name)));
                        }

                        TablesetColumn tablesetColumn = new TablesetColumn();
                        tablesetColumn.EntityTypeId     = EntityType.Table;
                        tablesetColumn.TableSetEntityId = tablesetTableId.Id;
                        tablesetColumn.Name             = column.Name;

                        TablesetColumnId tablesetColumnId = null;
                        status = dbTablesetColumnsMgr.Create(trans, tablesetColumn, out tablesetColumnId);
                        if (!questStatusDef.IsSuccess(status))
                        {
                            RollbackTransaction(trans);
                            return(status);
                        }
                    }
                }

                // Save view info.
                DbTablesetViewsMgr  dbTablesetViewsMgr = new DbTablesetViewsMgr(this.UserSession);
                List <TablesetView> tablesetViewList   = new List <TablesetView>();
                foreach (TablesetView tablesetView in tablesetConfiguration.TablesetViews)
                {
                    View _view = databaseEntities.ViewList.Find(delegate(View v) { return(v.Schema == tablesetView.Schema && v.Name == tablesetView.Name); });
                    if (_view == null)
                    {
                        RollbackTransaction(trans);
                        return(new questStatus(Severity.Error, String.Format("ERROR: tableset view [{0}].[{1}] not found in database metainfo.  Try refreshing database schema info",
                                                                             tablesetView.Schema, tablesetView.Name)));
                    }
                    tablesetView.TablesetId = _tableset.Id;
                    tablesetView.View       = _view;
                    tablesetViewList.Add(tablesetView);

                    // Create tableset view.
                    TablesetViewId tablesetViewId = null;
                    status = dbTablesetViewsMgr.Create(trans, tablesetView, out tablesetViewId);
                    if (!questStatusDef.IsSuccess(status))
                    {
                        RollbackTransaction(trans);
                        return(status);
                    }

                    foreach (Column column in _view.ColumnList)
                    {
                        Column _column = _view.ColumnList.Find(delegate(Column c) { return(c.Name == column.Name); });
                        if (_column == null)
                        {
                            RollbackTransaction(trans);
                            return(new questStatus(Severity.Error, String.Format("ERROR: column [{0}] not found in view [{1}].[{2}] in database metainfo.  Try refreshing database schema info",
                                                                                 column.Name, _view.Schema, _view.Name)));
                        }

                        TablesetColumn tablesetColumn = new TablesetColumn();
                        tablesetColumn.EntityTypeId     = EntityType.View;
                        tablesetColumn.TableSetEntityId = tablesetViewId.Id;
                        tablesetColumn.Name             = column.Name;

                        TablesetColumnId tablesetColumnId = null;
                        status = dbTablesetColumnsMgr.Create(trans, tablesetColumn, out tablesetColumnId);
                        if (!questStatusDef.IsSuccess(status))
                        {
                            RollbackTransaction(trans);
                            return(status);
                        }
                    }
                }
                #endregion


                // Update tableset.
                bFiltersRemoved      = false;
                _tableset.DatabaseId = tablesetConfiguration.Database.Id;
                status2 = tablesetsMgr.Update(trans, _tableset);
                if (!questStatusDef.IsSuccess(status2))
                {
                    if (questStatusDef.IsWarning(status2))
                    {
                        bFiltersRemoved = true;
                    }
                    else
                    {
                        RollbackTransaction(trans);
                        return(status);
                    }
                }


                // COMMIT TRANSACTION
                status = CommitTransaction(trans);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }

                // Return the tableset id
                tablesetId = new TablesetId(tablesetConfiguration.Tableset.Id);
            }
            catch (System.Exception ex)
            {
                if (trans != null)
                {
                    RollbackTransaction(trans);
                }
                return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                                     this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                     ex.InnerException != null ? ex.InnerException.Message : ex.Message)));
            }
            if (bFiltersRemoved)
            {
                return(status2);
            }
            return(new questStatus(Severity.Success));
        }
	//
	// LOGIN  METHODS
	// passes username ,password, and callback
	//
	//
	public void LMSLogin( string username, string password, DatabaseMgr.Callback Callback )
	{
		StartCoroutine(lmsLogin(username,password,Callback));
	}
    protected void Button3_Click(object sender, EventArgs e)
    {
        DatabaseMgr dbm = new DatabaseMgr();

        dbm.ResetPrimaryKeys();
    }
Example #31
0
    protected void cmdCreate_Click(object sender, EventArgs e)
    {
        panAlert.Visible = true;
        if (txtLocation.Text == "")
        {
            lblAlert.Text = "Please enter a location";
        }
        else if (txtWeather.Text == "")
        {
            lblAlert.Text = "Please enter weather conditions";
        }
        else if (string.IsNullOrWhiteSpace(txtBoysTeam1.Text) || string.IsNullOrWhiteSpace(txtBoysAbbr1.Text))
        {
            lblAlert.Text = "Please enter team name information for boy's team #1";
        }
        else if ((string.IsNullOrWhiteSpace(txtBoysTeam2.Text) && !string.IsNullOrWhiteSpace(txtBoysAbbr2.Text)) || (!string.IsNullOrWhiteSpace(txtBoysTeam2.Text) && string.IsNullOrWhiteSpace(txtBoysAbbr2.Text)))
        {
            lblAlert.Text = "Invalid name information for boy's team #2";
        }
        else if ((string.IsNullOrWhiteSpace(txtBoysTeam3.Text) && !string.IsNullOrWhiteSpace(txtBoysAbbr3.Text)) || (!string.IsNullOrWhiteSpace(txtBoysTeam3.Text) && string.IsNullOrWhiteSpace(txtBoysAbbr3.Text)))
        {
            lblAlert.Text = "Invalid name information for boy's team #3";
        }
        else if ((string.IsNullOrWhiteSpace(txtBoysTeam4.Text) && !string.IsNullOrWhiteSpace(txtBoysAbbr4.Text)) || (!string.IsNullOrWhiteSpace(txtBoysTeam4.Text) && string.IsNullOrWhiteSpace(txtBoysAbbr4.Text)))
        {
            lblAlert.Text = "Invalid name information for boy's team #4";
        }
        else if ((string.IsNullOrWhiteSpace(txtBoysTeam5.Text) && !string.IsNullOrWhiteSpace(txtBoysAbbr5.Text)) || (!string.IsNullOrWhiteSpace(txtBoysTeam5.Text) && string.IsNullOrWhiteSpace(txtBoysAbbr5.Text)))
        {
            lblAlert.Text = "Invalid name information for boy's team #5";
        }
        else if ((string.IsNullOrWhiteSpace(txtBoysTeam6.Text) && !string.IsNullOrWhiteSpace(txtBoysAbbr6.Text)) || (!string.IsNullOrWhiteSpace(txtBoysTeam6.Text) && string.IsNullOrWhiteSpace(txtBoysAbbr6.Text)))
        {
            lblAlert.Text = "Invalid name information for boy's team #6";
        }
        else if (string.IsNullOrWhiteSpace(txtGirlsTeam1.Text) || string.IsNullOrWhiteSpace(txtGirlsAbbr1.Text))
        {
            lblAlert.Text = "Please enter team name information for girl's team #1";
        }
        else if ((string.IsNullOrWhiteSpace(txtGirlsTeam2.Text) && !string.IsNullOrWhiteSpace(txtGirlsAbbr2.Text)) || (!string.IsNullOrWhiteSpace(txtGirlsTeam2.Text) && string.IsNullOrWhiteSpace(txtGirlsAbbr2.Text)))
        {
            lblAlert.Text = "Invalid name information for girl's team #2";
        }
        else if ((string.IsNullOrWhiteSpace(txtGirlsTeam3.Text) && !string.IsNullOrWhiteSpace(txtGirlsAbbr3.Text)) || (!string.IsNullOrWhiteSpace(txtGirlsTeam3.Text) && string.IsNullOrWhiteSpace(txtGirlsAbbr3.Text)))
        {
            lblAlert.Text = "Invalid name information for girl's team #3";
        }
        else if ((string.IsNullOrWhiteSpace(txtGirlsTeam4.Text) && !string.IsNullOrWhiteSpace(txtGirlsAbbr4.Text)) || (!string.IsNullOrWhiteSpace(txtGirlsTeam4.Text) && string.IsNullOrWhiteSpace(txtGirlsAbbr4.Text)))
        {
            lblAlert.Text = "Invalid name information for girl's team #4";
        }
        else if ((string.IsNullOrWhiteSpace(txtGirlsTeam5.Text) && !string.IsNullOrWhiteSpace(txtGirlsAbbr5.Text)) || (!string.IsNullOrWhiteSpace(txtGirlsTeam5.Text) && string.IsNullOrWhiteSpace(txtGirlsAbbr5.Text)))
        {
            lblAlert.Text = "Invalid name information for girl's team #5";
        }
        else if ((string.IsNullOrWhiteSpace(txtGirlsTeam6.Text) && !string.IsNullOrWhiteSpace(txtGirlsAbbr6.Text)) || (!string.IsNullOrWhiteSpace(txtGirlsTeam6.Text) && string.IsNullOrWhiteSpace(txtGirlsAbbr6.Text)))
        {
            lblAlert.Text = "Invalid name information for girl's team #6";
        }
        else
        {
            string meetLocation = txtLocation.Text;

            int month = 1;
            if (ddlMonth.Text == "February")
            {
                month = 2;
            }
            else if (ddlMonth.Text == "March")
            {
                month = 3;
            }
            else if (ddlMonth.Text == "April")
            {
                month = 4;
            }
            else if (ddlMonth.Text == "May")
            {
                month = 5;
            }
            else if (ddlMonth.Text == "June")
            {
                month = 6;
            }
            else if (ddlMonth.Text == "July")
            {
                month = 7;
            }
            else if (ddlMonth.Text == "August")
            {
                month = 8;
            }
            else if (ddlMonth.Text == "September")
            {
                month = 9;
            }
            else if (ddlMonth.Text == "October")
            {
                month = 10;
            }
            else if (ddlMonth.Text == "November")
            {
                month = 11;
            }
            else if (ddlMonth.Text == "December")
            {
                month = 12;
            }

            DateTime meetDateTime   = new DateTime(Convert.ToInt32(ddlYear.Text), month, Convert.ToInt32(ddlDay.Text));
            string   meetWeather    = txtWeather.Text;
            string   boysTeam1Abbr  = txtBoysAbbr1.Text.Trim();
            string   boysTeam1Name  = txtBoysTeam1.Text.Trim();
            string   boysTeam2Abbr  = txtBoysAbbr2.Text.Trim();
            string   boysTeam2Name  = txtBoysTeam2.Text.Trim();
            string   boysTeam3Abbr  = txtBoysAbbr3.Text.Trim();
            string   boysTeam3Name  = txtBoysTeam3.Text.Trim();
            string   boysTeam4Abbr  = txtBoysAbbr4.Text.Trim();
            string   boysTeam4Name  = txtBoysTeam4.Text.Trim();
            string   boysTeam5Abbr  = txtBoysAbbr5.Text.Trim();
            string   boysTeam5Name  = txtBoysTeam5.Text.Trim();
            string   boysTeam6Abbr  = txtBoysAbbr6.Text.Trim();
            string   boysTeam6Name  = txtBoysTeam6.Text.Trim();
            string   girlsTeam1Abbr = txtGirlsAbbr1.Text.Trim();
            string   girlsTeam1Name = txtGirlsTeam1.Text.Trim();
            string   girlsTeam2Abbr = txtGirlsAbbr2.Text.Trim();
            string   girlsTeam2Name = txtGirlsTeam2.Text.Trim();
            string   girlsTeam3Abbr = txtGirlsAbbr3.Text.Trim();
            string   girlsTeam3Name = txtGirlsTeam3.Text.Trim();
            string   girlsTeam4Abbr = txtGirlsAbbr4.Text.Trim();
            string   girlsTeam4Name = txtGirlsTeam4.Text.Trim();
            string   girlsTeam5Abbr = txtGirlsAbbr5.Text.Trim();
            string   girlsTeam5Name = txtGirlsTeam5.Text.Trim();
            string   girlsTeam6Abbr = txtGirlsAbbr6.Text.Trim();
            string   girlsTeam6Name = txtGirlsTeam6.Text.Trim();

            List <string> boysNames = new List <string>();
            if (!string.IsNullOrWhiteSpace(boysTeam1Name))
            {
                boysNames.Add(boysTeam1Name);
            }
            if (!string.IsNullOrWhiteSpace(boysTeam2Name))
            {
                boysNames.Add(boysTeam2Name);
            }
            if (!string.IsNullOrWhiteSpace(boysTeam3Name))
            {
                boysNames.Add(boysTeam3Name);
            }
            if (!string.IsNullOrWhiteSpace(boysTeam4Name))
            {
                boysNames.Add(boysTeam4Name);
            }
            if (!string.IsNullOrWhiteSpace(boysTeam5Name))
            {
                boysNames.Add(boysTeam5Name);
            }
            if (!string.IsNullOrWhiteSpace(boysTeam6Name))
            {
                boysNames.Add(boysTeam6Name);
            }

            List <string> boysAbbrs = new List <string>();
            if (!string.IsNullOrWhiteSpace(boysTeam1Abbr))
            {
                boysAbbrs.Add(boysTeam1Abbr);
            }
            if (!string.IsNullOrWhiteSpace(boysTeam2Abbr))
            {
                boysAbbrs.Add(boysTeam2Abbr);
            }
            if (!string.IsNullOrWhiteSpace(boysTeam3Abbr))
            {
                boysAbbrs.Add(boysTeam3Abbr);
            }
            if (!string.IsNullOrWhiteSpace(boysTeam4Abbr))
            {
                boysAbbrs.Add(boysTeam4Abbr);
            }
            if (!string.IsNullOrWhiteSpace(boysTeam5Abbr))
            {
                boysAbbrs.Add(boysTeam5Abbr);
            }
            if (!string.IsNullOrWhiteSpace(boysTeam6Abbr))
            {
                boysAbbrs.Add(boysTeam6Abbr);
            }

            List <string> girlsNames = new List <string>();
            if (!string.IsNullOrWhiteSpace(girlsTeam1Name))
            {
                girlsNames.Add(girlsTeam1Name);
            }
            if (!string.IsNullOrWhiteSpace(girlsTeam2Name))
            {
                girlsNames.Add(girlsTeam2Name);
            }
            if (!string.IsNullOrWhiteSpace(girlsTeam3Name))
            {
                girlsNames.Add(girlsTeam3Name);
            }
            if (!string.IsNullOrWhiteSpace(girlsTeam4Name))
            {
                girlsNames.Add(girlsTeam4Name);
            }
            if (!string.IsNullOrWhiteSpace(girlsTeam5Name))
            {
                girlsNames.Add(girlsTeam5Name);
            }
            if (!string.IsNullOrWhiteSpace(girlsTeam6Name))
            {
                girlsNames.Add(girlsTeam6Name);
            }

            List <string> girlsAbbrs = new List <string>();
            if (!string.IsNullOrWhiteSpace(girlsTeam1Abbr))
            {
                girlsAbbrs.Add(girlsTeam1Abbr);
            }
            if (!string.IsNullOrWhiteSpace(girlsTeam2Abbr))
            {
                girlsAbbrs.Add(girlsTeam2Abbr);
            }
            if (!string.IsNullOrWhiteSpace(girlsTeam3Abbr))
            {
                girlsAbbrs.Add(girlsTeam3Abbr);
            }
            if (!string.IsNullOrWhiteSpace(girlsTeam4Abbr))
            {
                girlsAbbrs.Add(girlsTeam4Abbr);
            }
            if (!string.IsNullOrWhiteSpace(girlsTeam5Abbr))
            {
                girlsAbbrs.Add(girlsTeam5Abbr);
            }
            if (!string.IsNullOrWhiteSpace(girlsTeam6Abbr))
            {
                girlsAbbrs.Add(girlsTeam6Abbr);
            }

            if (boysNames.Distinct().Count() != boysNames.Count())
            {
                lblAlert.Text = "All Boy's names must be unique";
            }
            else if (boysAbbrs.Distinct().Count() != boysAbbrs.Count())
            {
                lblAlert.Text = "All Boy's abbrs must be unique";
            }
            else if (girlsNames.Distinct().Count() != girlsNames.Count())
            {
                lblAlert.Text = "All Girl's names must be unique";
            }
            else if (girlsAbbrs.Distinct().Count() != girlsAbbrs.Count())
            {
                lblAlert.Text = "All Girl's abbrs must be unique";
            }
            else
            {
                Dictionary <string, string> boysTeams = new Dictionary <string, string>();
                boysTeams.Add(boysTeam1Abbr, boysTeam1Name);
                if (!string.IsNullOrWhiteSpace(boysTeam2Abbr))
                {
                    boysTeams.Add(boysTeam2Abbr, boysTeam2Name);
                }
                if (!string.IsNullOrWhiteSpace(boysTeam3Abbr))
                {
                    boysTeams.Add(boysTeam3Abbr, boysTeam3Name);
                }
                if (!string.IsNullOrWhiteSpace(boysTeam4Abbr))
                {
                    boysTeams.Add(boysTeam4Abbr, boysTeam4Name);
                }
                if (!string.IsNullOrWhiteSpace(boysTeam5Abbr))
                {
                    boysTeams.Add(boysTeam5Abbr, boysTeam5Name);
                }
                if (!string.IsNullOrWhiteSpace(boysTeam6Abbr))
                {
                    boysTeams.Add(boysTeam6Abbr, boysTeam6Name);
                }

                Dictionary <string, string> girlsTeams = new Dictionary <string, string>();
                girlsTeams.Add(girlsTeam1Abbr, girlsTeam1Name);
                if (!string.IsNullOrWhiteSpace(girlsTeam2Abbr))
                {
                    girlsTeams.Add(girlsTeam2Abbr, girlsTeam2Name);
                }
                if (!string.IsNullOrWhiteSpace(girlsTeam3Abbr))
                {
                    girlsTeams.Add(girlsTeam3Abbr, girlsTeam3Name);
                }
                if (!string.IsNullOrWhiteSpace(girlsTeam4Abbr))
                {
                    girlsTeams.Add(girlsTeam4Abbr, girlsTeam4Name);
                }
                if (!string.IsNullOrWhiteSpace(girlsTeam5Abbr))
                {
                    girlsTeams.Add(girlsTeam5Abbr, girlsTeam5Name);
                }
                if (!string.IsNullOrWhiteSpace(girlsTeam6Abbr))
                {
                    girlsTeams.Add(girlsTeam6Abbr, girlsTeam6Name);
                }

                Teams newTeams = new Teams(boysTeams, girlsTeams);

                newMeet = new Meet(meetDateTime, meetLocation, meetWeather, newTeams);

                if (newMeet.validate())
                {
                    DatabaseMgr dm = new DatabaseMgr();
                    meetID = dm.FindMeetId(newMeet);

                    if (meetID < 0)
                    {
                        panAlert.GroupingText = "Problem loading meet database. Please try again later";
                    }
                    else
                    {
                        if (meetID == 0) //Meet does not exist in database
                        {
                            bool didAdd = dm.AddMeet(newMeet, Session["Username"].ToString());
                            if (didAdd)
                            {
                                Session["ActiveMeet"] = newMeet;

                                //Open MeetHub here
                                Response.Redirect("MeetHub.aspx");
                            }
                            else
                            {
                                lblAlert.Text = "Problem addign meet to database, please try again later";
                            }
                        }
                        else
                        {
                            panAlert.Visible         = false;
                            panDatabaseAlert.Visible = true;

                            lblDatabaseAlert.Text = "Meet already exists, do you wish to overwrite existing meet, or open existing meet?";
                            cmdCreate.Visible     = false;
                        }
                    }
                }
                else
                {
                    lblAlert.Text = "Unknown problem creating this meet. Data was invalid.";
                }
            }
        }
    }
Example #32
0
	public void CheckLoginWithPing( string username, string password, DatabaseMgr.Callback callback )
	{
		this.username = username;
		this.password = password;
		
		// check for built-in admin
		if ( username == AdminName && password == AdminPassword )
		{
			admin = true;
			validLogin = true;
			if ( callback != null )
				callback(true,"","",null);
			return;
		}
		
		checkLoginCallback = callback;
		
		LMSIntegration.GetInstance().LMSLoginWithPing(username,password,LoginCallback);
	}
Example #33
0
 public DatabaseMgr() // don't use constructors for MonoBehavior derived classes, use Awake or Start to initialize
 {
     instance = this;
 }
	IEnumerator CallbackAfterDelay(DatabaseMgr.Callback callback, string data){

		yield return new WaitForSeconds(0.1f);
		callback(true, data, "", null); // could tell them we are offline...
	}
Example #35
0
	public void GetLogins( DatabaseMgr.Callback callback )
	{
		WWWForm form = new WWWForm();
		form.AddField("command","loadLogins");
		DatabaseMgr.GetInstance().DBCall(GameMgr.GetInstance().DatabaseURL,form,getLoginsCallback);				
		loginsCallback = callback;
	}
Example #36
0
	public void CreateUser( string username, string password, string first, string last, bool admin, bool tutorial, DatabaseMgr.Callback createCallback )
	{
		// create empty case list
		Serializer<List<string>> serializer = new Serializer<List<string>>();
		string emptyCaseList = serializer.ToString(new List<string>());
		
		// create user in logins
		WWWForm form = new WWWForm();
		form.AddField("command","createUser");
		form.AddField("username",username);
		form.AddField("password",password);
		form.AddField("first",first);
		form.AddField("last",last);
		form.AddField("admin",(admin==true)?"1":"0");
		form.AddField("tutorial",(tutorial==true)?"1":"0");
		form.AddField("data",emptyCaseList);
		DatabaseMgr.GetInstance().DBCall(GameMgr.GetInstance().DatabaseURL,form,createCallback);		
	}
Example #37
0
	public void CheckLogin( string username, string password, DatabaseMgr.Callback callback )
	{
		this.username = username;
		this.password = password;

		// check for built-in admin
		if ( username == AdminName && password == AdminPassword )
		{
			admin = true;
			validLogin = true;
			if ( callback != null )
				callback(true,"","",null);
			return;
		}

		if ( AllowGuest == true && username == "guest" )
		{
			admin = false;
			validLogin = true;
			if ( callback != null )
				callback(true,"","",null);
			return;
		}

		checkLoginCallback = callback;

#if USE_LMS_LOGIN
		LMSIntegration.GetInstance().LMSLoginWithPing(username,password,LoginCallback);
#else

		WWWForm form = new WWWForm();
		form.AddField("command","login");
        form.AddField("username", username);
        form.AddField("password", password);
		DatabaseMgr.GetInstance().DBCall(GameMgr.GetInstance().DatabaseURL,form,LoginCallback);		
#endif
	}
Example #38
0
		public DBCallInfo( string url, WWWForm form, DatabaseMgr.Callback callback )
		{
			URL = url;
			Form = form;
			Callback = callback;
		}		
	IEnumerator lmsLogin( string username, string password, DatabaseMgr.Callback Callback )
	{
		string url = "http://www.sitelms.org/restapi/auth";
		//string bodyString = "{\"action\":\"User\",\"params\":{\"user_name\":\"" + username + "\",\"password\":\"" + password + "\"},\"authKey\":null}";
		
		// make JSON
		JSONObject j = new JSONObject(JSONObject.Type.OBJECT);
		//number
		j.AddField("action", "User");
		// make param area
		JSONObject arr = new JSONObject(JSONObject.Type.ARRAY);
		j.AddField("params", arr);
		// add params
		arr.AddField ("user_name",username);
		arr.AddField ("password", password );
		// add authkey
		string keyNoQuotes = pingAuthKey.Replace ("\"","");
		j.AddField ("authKey",keyNoQuotes);
		// get bodystring
		string bodyString = j.print();
		
		// Create a download object
		WWW download = new WWW(url,Encoding.ASCII.GetBytes(bodyString));
		yield return download;
		
		//Application.ExternalCall("Debug","LMSIntegration.lmsLogin() : URL=" + url + " : bodyString=" + bodyString );
		
		string DBResult;
		string DBErrorString;
		
		if (download.error != null)
		{
			DBResult = "";
			DBErrorString = download.error;
			// do callback
			if (Callback != null)
				Callback(false, DBResult, DBErrorString, download);
			// do global callback
			if (DatabaseMgr.GetInstance().ErrorCallback != null )
				DatabaseMgr.GetInstance().ErrorCallback(false,DBResult,DBErrorString,download);
		}
		else
		{
			if ( download.text == null )
			{
				DBResult = "invalid";
				UnityEngine.Debug.LogError ("LMSIntegration.LMSLogin() : download.text is null!");
			}
			else
			{
				JSONObject decoder = new JSONObject(download.text);
				if ( CheckReturn(decoder) == true )
				{
					JSONObject authkey = decoder.GetField ("authKey");
					if ( authkey != null )
					{
						if ( authkey.print () != "null" )
						{
							DBResult = "ok";
							UnityEngine.Debug.LogError ("LMSIntegration.LMSLogin() : authKey=" + authkey.print () + " : valid");
						}
						else
						{
							DBResult = "invalid";
							UnityEngine.Debug.LogError ("LMSIntegration.LMSLogin() : authKey=" + authkey.print () + " : not valid");
						}
					}
					else
					{
						DBResult = "invalid";
						UnityEngine.Debug.LogError ("LMSIntegration.LMSLogin() : username=<" + username + "> password=<" + password + "> result=" + download.text);
					}
				}
				else
				{
					DBResult = "invalid";
					UnityEngine.Debug.LogError ("LMSIntegration.LMSLogin() : username=<" + username + "> password=<" + password + "> result=" + download.text);
				}
			}
			// save the results
			DBErrorString = "";
			// do callback
			if (Callback != null)
				Callback(true, DBResult, DBErrorString, download);
		}
	}