Beispiel #1
0
                /* P R E F L I G H T */

                /*----------------------------------------------------------------------------
                *       %%Function: Preflight
                *       %%Qualified: RwpSvc.Practice:Teams:RwpTeam.Preflight
                *       %%Contact: rlittle
                *
                *  ----------------------------------------------------------------------------*/
                public RSR Preflight(TCore.Sql sql)
                {
                    List <string> plsFail = new List <string>();

                    CheckLength(m_sStatus, "Status", 255, plsFail);
                    CheckLength(m_sVenue, "Venue", 255, plsFail);
                    CheckLength(m_sField, "Field", 255, plsFail);
                    if (!s_plsWeekdays.Contains(m_sWeekday.ToUpper()))
                    {
                        plsFail.Add(String.Format("Weekday '{0}' is not valid", m_sWeekday));
                    }
                    CheckLength(m_sReserved, "Reserved", 255, plsFail);
                    CheckLength(m_sDivisions, "Divisions", 15, plsFail);
                    CheckLength(m_sType, "Type", 50, plsFail);
                    if (!s_plsTypes.Contains(m_sType.ToUpper()))
                    {
                        plsFail.Add(String.Format("Type '{0}' is not valid", m_sType));
                    }

                    if (plsFail.Count > 0)
                    {
                        return(SRFromPls("preflight failed", plsFail));
                    }

                    return(RSR.Success());
                }
Beispiel #2
0
            /*----------------------------------------------------------------------------
            *   %%Function: Preflight
            *   %%Qualified: RwpApi.CalendarLinks.CalendarLinkItem.Preflight
            *   %%Contact: rlittle
            *
            *  ----------------------------------------------------------------------------*/
            public RSR Preflight(TCore.Sql sql)
            {
                List <string> plsFail = new List <string>();

                CheckLength(m_sComment, "Comment", 255, plsFail);

                if (plsFail.Count > 0)
                {
                    return(SRFromPls("preflight failed", plsFail));
                }

                return(RSR.Success());
            }
Beispiel #3
0
            /*----------------------------------------------------------------------------
            *   %%Function: SGenerateUpdateQuery
            *   %%Qualified: RwpApi.CalendarLinks.CalendarLinkItem.SGenerateUpdateQuery
            *   %%Contact: rlittle
            *
            *  ----------------------------------------------------------------------------*/
            public string SGenerateUpdateQuery(TCore.Sql sql, bool fAdd)
            {
                if (!fAdd)
                {
                    return(null);
                }
                string sValuesTemplate = "VALUES ('{0}','{1}','{2}','{3}','{4}')";

                string sQueryBase   = s_sSqlInsert;
                string sQueryValues = String.Format(sValuesTemplate, m_guidLink.ToString(), Sql.Sqlify(m_sTeam),
                                                    Sql.Sqlify(m_sAuthority), m_dttmCreateDate.ToString("M/d/yyyy"), Sql.Sqlify(m_sComment));

                return(String.Format("{0} {1}", sQueryBase, sQueryValues));
            }
Beispiel #4
0
                /* L O A D  R W P T  F R O M  C S V */

                /*----------------------------------------------------------------------------
                *       %%Function: LoadRwptFromCsv
                *       %%Qualified: RwpSvc.Practice:Teams:CsvTeams.LoadRwptFromCsv
                *       %%Contact: rlittle
                *
                *  ----------------------------------------------------------------------------*/
                public RSR LoadRwptFromCsv(string sLine, TCore.Sql sql, out RwpTeam rwpt, out bool fAdd, out List <string> plsDiff)
                {
                    string [] rgs = LineToArray(sLine);
                    SqlWhere  sw  = new SqlWhere();

                    fAdd    = true;
                    rwpt    = new RwpTeam();
                    plsDiff = new List <string>();

                    sw.AddAliases(RwpTeam.s_mpAliases);
                    try
                    {
                        rwpt.Name = GetStringVal(rgs, "TEAMNAME");
                        if (rwpt.Name == "")
                        {
                            return(RSR.Success());
                        }

                        sw.Add(String.Format("$$rwllteams$$.TeamName = '{0}'", Sql.Sqlify(rwpt.Name)), SqlWhere.Op.And);
                        SqlReader sqlr = new SqlReader(sql);
                        if (sqlr.FExecuteQuery(sw.GetWhere(RwpTeam.s_sSqlQueryString), _sResourceConnString) &&
                            sqlr.Reader.Read())
                        {
                            sqlr.Close();
                            // found a match.  for now, this is an error
                            throw new Exception(String.Format("team name {0} already exists", rwpt.Name));
                        }
                        sqlr.Close();

                        rwpt.Division            = GetStringValNullable(rgs, "DIVISION");
                        rwpt.Password            = GetStringValNullable(rgs, "PW");
                        rwpt.Created             = GetDateValNullable(rgs, "DATECREATED");
                        rwpt.Updated             = GetDateValNullable(rgs, "DATEUPDATED");
                        rwpt.FieldsReleased      = GetIntVal(rgs, "FIELDSRELEASECOUNT");
                        rwpt.CagesReleased       = GetIntVal(rgs, "CAGESRELEASECOUNT");
                        rwpt.FieldsReleasedToday = GetIntVal(rgs, "RELEASEDFIELDSTODAY");
                        rwpt.CagesReleasedToday  = GetIntVal(rgs, "RELEASEDCAGESTODAY");
                        rwpt.ReleasedFieldsDate  = GetDateValNullable(rgs, "RELEASEDFIELDSDATE");
                        rwpt.ReleasedCagesDate   = GetDateValNullable(rgs, "RELEASEDCAGESDATE");
                        rwpt.Email1 = GetStringValNullable(rgs, "EMAIL1");
                        rwpt.Email2 = GetStringValNullable(rgs, "EMAIL2");
                    }
                    catch (Exception e)
                    {
                        return(RSR.Failed(e));
                    }

                    return(RSR.Success());
                }
Beispiel #5
0
                /* P R E F L I G H T */

                /*----------------------------------------------------------------------------
                *       %%Function: Preflight
                *       %%Qualified: RwpSvc.Practice:Teams:RwpTeam.Preflight
                *       %%Contact: rlittle
                *
                *  ----------------------------------------------------------------------------*/
                public RSR Preflight(TCore.Sql sql)
                {
                    List <string> plsFail = new List <string>();

                    CheckLength(m_sName, "TeamName", 50, plsFail);
                    CheckLength(m_sDivision, "Division", 10, plsFail);
                    CheckLength(m_sPassword, "PW", 20, plsFail);

                    if (plsFail.Count > 0)
                    {
                        return(SRFromPls("preflight failed", plsFail));
                    }

                    return(RSR.Success());
                }
Beispiel #6
0
            /* P R E F L I G H T */

            /*----------------------------------------------------------------------------
            *   %%Function: Preflight
            *   %%Qualified: RwpSvc.Practice:Teams:RwpTeam.Preflight
            *   %%Contact: rlittle
            *
            *  ----------------------------------------------------------------------------*/
            public RSR Preflight(TCore.Sql sql, out bool fTeamExists, out bool fAuthExists)
            {
                List <string> plsFail = new List <string>();

                fTeamExists = false;
                fAuthExists = false;

                CheckLength(m_sName, "TeamName", 50, plsFail);
                CheckLength(m_sDivision, "Division", 10, plsFail);

                if (!Guid.TryParse(m_sTenant, out Guid g))
                {
                    plsFail.Add($"not a valid guid: {m_sTenant}");
                }

                // check to see if the team already exists
                if (Sql.NExecuteScalar(sql, $"select count(*) from rwllteams where TeamName='{m_sName}'", null, 0) != 0)
                {
                    fTeamExists = true;
                    SqlQueryReadLine <TeamInfo> readLine = new SqlQueryReadLine <TeamInfo>(
                        (SqlReader sqlr, ref TeamInfo ti) =>
                    {
                        ti.TeamName = sqlr.Reader.GetString(0);
                        ti.Division = sqlr.Reader.GetString(1);
                    });

                    Sql.ExecuteQuery(sql, $"SELECT TeamName, Division FROM rwllteams WHERE TeamName='{m_sName}'",
                                     readLine, null);

                    if (String.Compare(m_sDivision, readLine.Value.Division) != 0)
                    {
                        plsFail.Add($"division mismatch with existing team {m_sName}: {m_sDivision} != {readLine.Value.Division}");
                    }
                }

                // check to see if the auth already exists
                if (Sql.NExecuteScalar(sql, $"select count(*) from rwllauth where PrimaryIdentity='{m_sIdentity}' AND Tenant='{m_sTenant}' AND TeamID='{m_sName}'", null, 0) != 0)
                {
                    fAuthExists = true;
                }

                if (plsFail.Count > 0)
                {
                    return(SRFromPls($"preflight failed for team {m_sName}", plsFail));
                }

                return(RSR.Success());
            }
Beispiel #7
0
            public string SGenerateUpdateQuery(TCore.Sql sql, bool fAdd)
            {
                if (!fAdd)
                {
                    return(null);
                }
                string sInsertExtra    = "";
                string sValuesExtra    = "";
                string sValuesTemplate = "VALUES ('{0}','{1}','{2}','{3}','{4}',{5},{6},{7},{8}{9})";

                // let's figure out if we're going to include ReleasedFieldsDate and ReleasedCagesDate
                if (m_dttmReleasedFieldsDate != null)
                {
                    sInsertExtra += ", ReleasedFieldsDate";
                    sValuesExtra += String.Format(",'{0}'",
                                                  m_dttmReleasedFieldsDate.Value.ToString("M/d/yyyy HH:mm"));
                }

                if (m_dttmReleasedCagesDate != null)
                {
                    sInsertExtra += ", ReleasedCagesDate";
                    sValuesExtra += String.Format(",'{0}'",
                                                  m_dttmReleasedCagesDate.Value.ToString("M/d/yyyy HH:mm"));
                }

                if (m_sEmail1 != null)
                {
                    sInsertExtra += ", Email1";
                    sValuesExtra += String.Format(",'{0}'", m_sEmail1);
                }

                if (m_sEmail2 != null)
                {
                    sInsertExtra += ", Email2";
                    sValuesExtra += String.Format(",'{0}'", m_sEmail2);
                }

                string sQueryBase   = String.Format(s_sSqlInsert, sInsertExtra);
                string sQueryValues = String.Format(sValuesTemplate, Sql.Sqlify(m_sName),
                                                    Sql.Sqlify(m_sDivision),
                                                    Sql.Sqlify(m_sPassword),
                                                    m_dttmCreated.Value.ToString("M/d/yyyy HH:mm"),
                                                    m_dttmUpdated.Value.ToString("M/d/yyyy HH:mm"),
                                                    m_cFieldsReleased, m_cCagesReleased, m_cFieldsReleasedToday,
                                                    m_cCagesReleasedToday, sValuesExtra);

                return(String.Format("{0} {1}", sQueryBase, sQueryValues));
            }
Beispiel #8
0
            /* L O A D  R W P T  F R O M  C S V */

            /*----------------------------------------------------------------------------
            *   %%Function: LoadRwptFromCsv
            *   %%Qualified: RwpSvc.Practice:Teams:CsvTeams.LoadRwptFromCsv
            *   %%Contact: rlittle
            *
            *  ----------------------------------------------------------------------------*/
            public RSR LoadRwptFromCsv(string sLine, TCore.Sql sql, out RwpTeam rwpt, out bool fAdd,
                                       out List <string> plsDiff)
            {
                string[] rgs = LineToArray(sLine);
                SqlWhere sw  = new SqlWhere();

                fAdd    = true;
                rwpt    = new RwpTeam();
                plsDiff = new List <string>();

                sw.AddAliases(RwpTeam.s_mpAliases);
                try
                {
                    rwpt.Name = GetStringVal(rgs, "TEAMNAME");
                    if (rwpt.Name == "")
                    {
                        return(RSR.Success());
                    }

                    rwpt.Division            = GetStringValNullable(rgs, "DIVISION");
                    rwpt.Password            = GetStringValNullable(rgs, "PW");
                    rwpt.Created             = GetDateValNullable(rgs, "DATECREATED");
                    rwpt.Updated             = GetDateValNullable(rgs, "DATEUPDATED");
                    rwpt.FieldsReleased      = GetIntVal(rgs, "FIELDSRELEASECOUNT");
                    rwpt.CagesReleased       = GetIntVal(rgs, "CAGESRELEASECOUNT");
                    rwpt.FieldsReleasedToday = GetIntVal(rgs, "RELEASEDFIELDSTODAY");
                    rwpt.CagesReleasedToday  = GetIntVal(rgs, "RELEASEDCAGESTODAY");
                    rwpt.ReleasedFieldsDate  = GetDateValNullable(rgs, "RELEASEDFIELDSDATE");
                    rwpt.ReleasedCagesDate   = GetDateValNullable(rgs, "RELEASEDCAGESDATE");
                    rwpt.Email1   = GetStringValNullable(rgs, "EMAIL1");
                    rwpt.Email2   = GetStringValNullable(rgs, "EMAIL2");
                    rwpt.Identity = GetStringValNullable(rgs, "IDENTITY");
                    rwpt.Tenant   = GetStringValNullable(rgs, "TENANT");
                }
                catch (Exception e)
                {
                    return(RSR.Failed(e));
                }

                return(RSR.Success());
            }
Beispiel #9
0
                "Divisions, Type{0}) "; // We will append SlotReservedDatetime, SlotReleasedDatetime, ReleaseTeam as needed

            public string SGenerateUpdateQuery(TCore.Sql sql, bool fAdd)
            {
                if (!fAdd)
                {
                    return(null);
                }
                string sInsertExtra    = "";
                string sValuesExtra    = "";
                string sValuesTemplate =
                    "VALUES ({0},{1},'{2}','{3}','{4}','{5}',{6},'{7}','{8}','{9}'{10})";

                // let's figure out if we're going to include ReserveDatetime, ReleaseDatetime, ReleaseTeam
                if (m_dttmReserved != null)
                {
                    sInsertExtra += ", SlotReservedDatetime";
                    sValuesExtra += String.Format(",'{0}'",
                                                  m_dttmReserved.Value.ToString("M/d/yyyy HH:mm"));
                }

                if (m_dttmReleased != null)
                {
                    sInsertExtra += ", SlotReleasedDatetime";
                    sValuesExtra += String.Format(",'{0}'",
                                                  m_dttmReleased.Value.ToString("M/d/yyyy HH:mm"));
                }

                if (m_sReleaseTeam != null)
                {
                    sInsertExtra += ", ReleaseTeam";
                    sValuesExtra += String.Format(",'{0}'", m_sReleaseTeam);
                }

                string sQueryBase   = String.Format(s_sSqlInsert, sInsertExtra);
                string sQueryValues = String.Format(sValuesTemplate, m_nSlot, m_flWeek, m_sStatus, Sql.Sqlify(m_sVenue),
                                                    Sql.Sqlify(m_sField), m_dttmSlotStart.ToString("M/d/yyyy HH:mm"),
                                                    m_nSlotLength, Sql.Sqlify(m_sReserved),
                                                    Sql.Sqlify(m_sDivisions), m_sType, sValuesExtra);

                return(String.Format("{0} {1}", sQueryBase, sQueryValues));
            }