Beispiel #1
0
        protected void updateGroupDetailsButton_Click( object sender, EventArgs e )
        {
            // group name
              this.groupTable[0].Name = this.groupNameTextBox.Text;

              { // public/unlisted
            string newIsPublicValueStr = this.publicOptionRadioButtonList.SelectedValue;

            if ( newIsPublicValueStr == "public" )
              this.groupTable[0].IsPublic = true;
            else if ( newIsPublicValueStr == "unlisted" )
              this.groupTable[0].IsPublic = false;
            else
              throw new InvalidOperationException( string.Format( "Unknown public option value '{0}'", newIsPublicValueStr ) );
              }

              bool shouldShowForAllGroups = false;
              { // User messages
            string newShowMessagesStr = this.showMessagesRadioButtonList.SelectedValue;

            shouldShowForAllGroups = newShowMessagesStr == "setForAll";

            if ( newShowMessagesStr == "show" || shouldShowForAllGroups )
              this.groupTable[0].DisplayUserMessages = true;
            else if ( newShowMessagesStr == "hide" )
              this.groupTable[0].DisplayUserMessages = false;
            else
              throw new InvalidOperationException( string.Format( "Unknown user messages option value '{0}'", newShowMessagesStr ) );
              }

              try
              {
            this.groupAdapter.Update( this.groupTable );

            this.headerMultiView.SetActiveView( this.headerDisplayView );

            if ( shouldShowForAllGroups )
            {
              TrackerDataSetTableAdapters.ProcsAdapter procAdapter = new TrackerDataSetTableAdapters.ProcsAdapter( );
              procAdapter.ShowUserMessagesInAllGroupsForUser( Global.UserId );

              Global.ShowUserMessagesByDefault = true;
            }

            if ( this.groupTable[0].DisplayUserMessages && Global.UserMessagesSettingIsNew )
            {
              Global.UserMessagesSettingIsNew = false;
            }

            Service.ServiceFacade.ResetGroupsDefCache( );
              }
              catch ( Exception exc )
              {
            if ( Global.IsSqlDuplicateError( exc ) )
              UpdateGroupMsg = string.Format( "You already have a group named '{0}'", this.groupNameTextBox.Text );
            else
              UpdateGroupMsg = exc.Message;
              }
        }
        private static int GetDefaultEventId( )
        {
            TrackerDataSetTableAdapters.ProcsAdapter procsAdapter = new TrackerDataSetTableAdapters.ProcsAdapter( );
              int? defaultEventId = null;
              procsAdapter.EnsureDefaultTask( Global.UserId, ref defaultEventId );

              return defaultEventId.Value;
        }
Beispiel #3
0
        protected void Page_PreInit( object sender, EventArgs e )
        {
            string strGroupId = Request.QueryString["group"];
              int groupId;

              if ( strGroupId != null && int.TryParse( strGroupId, out groupId ) )
              {
            // To make sure that there is no hacking, check that the event
            // belongs to the current user before setting this.EventId property:
            if ( Global.IsAuthenticated )
            {
              this.groupTable = groupAdapter.GetDataByGroupId( groupId );
              if ( this.groupTable.Count > 0 )
              {
            if ( Global.UserId == groupTable[0].UserId ||
                 Global.IsAdmin ||
                 Global.IsSpotIdReader )
            {
              this.isReadOnly = Global.UserId != groupTable[0].UserId;

              GroupId = this.groupTable[0].Id;
              if ( !this.groupTable[0].IsEventIdNull( ) )
                AssignedTaskId = this.groupTable[0].EventId;
            }
              }
            }
              }

              if ( GroupId == 0 )
              {
            Response.Redirect( "~/default.aspx", true );
              }
              else
              {
            if ( Global.IsSimpleEventsModel )
            {
              TrackerDataSetTableAdapters.ProcsAdapter procsAdapter =
            new TrackerDataSetTableAdapters.ProcsAdapter( );

              int? loadedWptsCount = null;
              procsAdapter.GetDefaultEventParams( Global.UserId, ref DefEventId, ref loadedWptsCount, ref DefEventTaskWptCount );
            }

            if ( !IsPostBack )
            {
              this.trackersGridView.Sort( "Name", System.Web.UI.WebControls.SortDirection.Ascending );
            }
              }
        }
Beispiel #4
0
        private static UserProfileData GetUserProfile( )
        {
            UserProfileData userProfile;

              bool isReady = false;
              lock ( UserProfiles )
              {
            isReady = UserProfiles.TryGetValue( UserId, out userProfile );
              }

              if ( !isReady )
              {
            TrackerDataSetTableAdapters.ProcsAdapter procAdapters =
              new TrackerDataSetTableAdapters.ProcsAdapter( );
            int? notUsed = null;

            bool? tempEventsModel = null;
            bool? showUserMessagesByDefault = null;
            bool? userMessagesSettingIsNew = null;
            string tempCoordFormat = null;
            string defHemisphereNS = null;
            string defHemisphereEW = null;

            procAdapters.GetUserProfile(
              UserId,
              ref notUsed,
              ref tempEventsModel,
              ref tempCoordFormat,
              ref defHemisphereNS,
              ref defHemisphereEW,
              ref showUserMessagesByDefault,
              ref userMessagesSettingIsNew
            );

            userProfile = new UserProfileData( );
            userProfile.IsSimpleEventsModel = tempEventsModel.Value;
            userProfile.CoordFormat = ( CoordFormat ) Enum.Parse( typeof( CoordFormat ), tempCoordFormat );
            userProfile.DefHemisphereNS = defHemisphereNS[0];
            userProfile.DefHemisphereEW = defHemisphereEW[0];
            userProfile.ShowUserMessagesByDefault = showUserMessagesByDefault.Value;
            userProfile.UserMessagesSettingIsNew = userMessagesSettingIsNew.Value;

            lock ( UserProfiles )
            {
              UserProfileData otherValues;
              if ( UserProfiles.TryGetValue( UserId, out otherValues ) )
              { // someone else added the value while we've been on DB call
            userProfile = otherValues;
              }
              else
              {
            UserProfiles.Add( UserId, userProfile );
              }
            }
              }

              return userProfile;
        }
Beispiel #5
0
        private static DefEventStat GetDefEventStat( )
        {
            DefEventStat defEventStat = HttpContext.Current.Items["DefEventStat"] as DefEventStat;

              if ( defEventStat == null )
              {
            int? loadedWptsCount = null;
            int? taskWptsCount = null;
            int? defEventIdUnused = null;

            TrackerDataSetTableAdapters.ProcsAdapter procsAdapter =
              new TrackerDataSetTableAdapters.ProcsAdapter( );
            procsAdapter.GetDefaultEventParams( Global.UserId, ref defEventIdUnused, ref loadedWptsCount, ref taskWptsCount );

            defEventStat = new DefEventStat( );
            defEventStat.LoadedWptsCount = loadedWptsCount.HasValue ? loadedWptsCount.Value : 0;
            defEventStat.TaskWptsCount = taskWptsCount.HasValue ? taskWptsCount.Value : 0;

            HttpContext.Current.Items["DefEventStat"] = defEventStat;
              }

              return defEventStat;
        }
Beispiel #6
0
        protected void assignGroupsButton_Click(object sender, EventArgs e)
        {
            if (groupsPanelMultiView.GetActiveView() == defaultGroupPanelView)
              {
            groupsPanelMultiView.SetActiveView(expandedGroupPanelView);
              }

              if (assignedTaskMultiView.GetActiveView() != assignedTaskEditView)
              {
            assignedTaskMultiView.SetActiveView(assignedTaskEditView);

            // If "default Event controls" was in edit mode, cancel any changes and return it to the read mode:
            defaultEventControlsMultiView.SetActiveView(defaultEventReadView);
              }
              else
              {
            bool isChanged = false;
            if (sender == assignGroupsSaveButton)
            {
              TrackerDataSetTableAdapters.GroupTableAdapter groupTableAdapter = new TrackerDataSetTableAdapters.GroupTableAdapter();
              TrackerDataSet.GroupDataTable userGroups = groupTableAdapter.GetDataByUserId(Global.UserId);

              int tempAssignedGroupsCount = 0;
              foreach (ListItem li in assignedGroupsCheckBoxList.Items)
              {
            int groupId = int.Parse(li.Value);
            TrackerDataSet.GroupRow groupRow = userGroups.FindById(groupId);

            // Note that the content of assignedGroupsCheckBoxList came from the ViewState, and the group
            // can be actually deleted by that time (or replaced in ViewState by another user's group). So check
            // if it's valid group to prevent NullReferenceExcpetion:
            if (groupRow == null)
              continue;

            if (li.Selected)
            {
              tempAssignedGroupsCount++;
              if (groupRow.IsEventIdNull() ||
                   groupRow.EventId != EventId)
                groupRow.EventId = EventId;
            }
            else
            {
              if (!groupRow.IsEventIdNull() &&
                   groupRow.EventId == EventId)
              {
                groupRow.SetEventIdNull();
              }
            }
              }

              int updatedRecords = groupTableAdapter.Update(userGroups);
              _assignedGroupsCount = tempAssignedGroupsCount;
              isChanged = updatedRecords > 0;
              if (isChanged)
              {
            TrackerDataSetTableAdapters.ProcsAdapter procsAdapter = new TrackerDataSetTableAdapters.ProcsAdapter();
            procsAdapter.SetEventAsDefault(EventId);

            // We just set event as default in the DB - now we need to update this.IsEventDefault that is used in the markup
            IsEventDefault = true;
              }
            }

            SetAssignedGroupsReadView();
            SetNoGroupWarningVisibility();
            if (isChanged)
            {
              assignedGroupsGridView.DataBind();
            }
              }
        }
Beispiel #7
0
        protected void defaultButton_Click(object sender, EventArgs e)
        {
            if (defaultEventControlsMultiView.GetActiveView() == defaultEventReadView)
              {
            defaultEventControlsMultiView.SetActiveView(defaultEventEditView);
            defaultCheckBox.Checked = IsEventDefault;

            SetAssignedGroupsReadView();
              }
              else
              {
            if (sender == defaultSaveButton)
            {
              // We can't just set this.eventRow.IsDefault and call adapter.Update, because there is more
              // complicated DB logic in setting this value, which is done in SetEventDefaultFlag. Sp
              // call that stored proc here:
              bool isDefaultValue = defaultCheckBox.Checked;
              TrackerDataSetTableAdapters.ProcsAdapter procAdapters = new TrackerDataSetTableAdapters.ProcsAdapter();

              if (defaultCheckBox.Checked)
            procAdapters.SetEventAsDefault(EventId);
              else
            procAdapters.SetEventAsNonDefault(EventId);

              // We need to update this.IsEventDefault that is used in the markup
              IsEventDefault = isDefaultValue;
            }

            // If "groups assignment" was in edit mode, cancel any changes and return it to the read mode:
            defaultEventControlsMultiView.SetActiveView(defaultEventReadView);
              }
        }
Beispiel #8
0
        protected void Page_Load( object sender, EventArgs e )
        {
            int eventId = 0;
              try
              {
            GroupId = Convert.ToInt32( this.Request.Params["group"] );

            if ( GroupId != 1 ) // 1 is demo group
            {
              TrackerDataSetTableAdapters.GroupTableAdapter groupAdapter =
            new FlyTrace.TrackerDataSetTableAdapters.GroupTableAdapter( );

              TrackerDataSet.GroupDataTable groupTable = groupAdapter.GetDataByGroupId( GroupId );
              if ( groupTable.Count == 0 )
              {
            throw new ApplicationException( );
              }

              TrackerDataSet.GroupRow groupRow = groupTable[0];

              GroupName = groupRow.Name;

              OwnerId = groupRow.UserId;

              TrackerDataSetTableAdapters.ProcsAdapter procsAdapter = new TrackerDataSetTableAdapters.ProcsAdapter( );
              procsAdapter.UpdateGroupViewsNum( GroupId );

              if ( !groupRow.IsEventIdNull( ) )
              {
            eventId = groupRow.EventId;
              }

              if ( !groupRow.IsNewestLatNull( ) && !groupRow.IsNewestLonNull( ) )
              {
            MapCenterLat = groupRow.NewestLat;
            MapCenterLon = groupRow.NewestLon;
              }
            }
              }
              catch
              {
            Response.Redirect( "~/default.aspx", true );
            return;
              }

              string taskArrayDeclaration;

              if ( eventId == 0 )
              {
            taskArrayDeclaration = "null";
              }
              else
              {
            try
            { // task
              TrackerDataSetTableAdapters.TaskWaypointTableAdapter taskWaypointAdapter =
            new FlyTrace.TrackerDataSetTableAdapters.TaskWaypointTableAdapter( );
              TrackerDataSet.TaskWaypointDataTable taskWaypointTable = taskWaypointAdapter.GetDataByEventId( eventId );

              taskArrayDeclaration = "";
              foreach ( TrackerDataSet.TaskWaypointRow row in taskWaypointTable )
              {
            if ( taskArrayDeclaration != "" )
              taskArrayDeclaration += ",";

            taskArrayDeclaration +=
              string.Format(
                CultureInfo.GetCultureInfo( "en-US" ),
                "'{0}',{1},{2},{3}",
                row.Name, row.Lat, row.Lon, row.Radius );
              }
            }
            catch
            {
              taskArrayDeclaration = "null";
              // ignore any error, task is just an additional feature
            }
              }
              Page.ClientScript.RegisterArrayDeclaration( "_task", taskArrayDeclaration );
        }