Example #1
0
 /*----------------------------------------------------------------------------
 *   %%Function: FromCalendarLink
 *   %%Qualified: RwpApi.CalendarLinks.CalendarLinkItem.FromCalendarLink
 *   %%Contact: rlittle
 *
 *   convert a CalendarLink (from the wire) into our internal LinkItem format
 *  ----------------------------------------------------------------------------*/
 static CalendarLinkItem FromCalendarLink(CalendarLink linkItem)
 {
     return(new CalendarLinkItem()
     {
         m_guidLink = linkItem.Link, m_sTeam = linkItem.Team, m_sAuthority = linkItem.Authority,
         m_dttmCreateDate = linkItem.CreateDate, m_sComment = linkItem.Comment
     });
 }
Example #2
0
        /*----------------------------------------------------------------------------
        *       %%Function: GetCalendarLinksForTeam
        *       %%Qualified: RwpApi.CalendarLinks.GetCalendarLinksForTeam
        *       %%Contact: rlittle
        *
        *  ----------------------------------------------------------------------------*/
        public static RSR_CalendarLinks GetCalendarLinksForTeam(string sTeam)
        {
            SqlWhere          sw = new SqlWhere();
            RSR               rsr;
            RSR_CalendarLinks rci;
            CalendarLinks     links = new CalendarLinks();

            sw.AddAliases(CalendarLinkItem.s_mpAliases);
            try
            {
                sw.Add(String.Format("$$rwllcalendarlinks$$.TeamID = '{0}'", Sql.Sqlify(sTeam)), SqlWhere.Op.And);

                rsr = RSR.FromSR(Sql.ExecuteQuery(null, sw.GetWhere(RwpSlots.RwpSlot.s_sSqlQueryString), links,
                                                  Startup._sResourceConnString));

                if (!rsr.Succeeded)
                {
                    rci        = RSR_CalendarLinks.FromRSR(rsr);
                    rci.Reason = String.Format("{0} {1}", rci.Reason, Startup._sResourceConnString);
                    return(rci);
                }

                rci = RSR_CalendarLinks.FromRSR(RSR.FromSR(SR.Success()));

                List <CalendarLink> plcall = new List <CalendarLink>();

                if (links.Links != null)
                {
                    foreach (CalendarLinkItem linkItem in links.Links)
                    {
                        CalendarLink link = new CalendarLink()
                        {
                            Link       = linkItem.Link, Team = linkItem.Team, Authority = linkItem.Authority,
                            CreateDate = linkItem.CreateDate, Comment = linkItem.Comment
                        };
                        plcall.Add(link);
                    }
                }

                rci.TheValue = plcall;
                return(rci);
            }

            catch (Exception e)
            {
                rci        = RSR_CalendarLinks.FromRSR(RSR.Failed(e));
                rci.Reason = String.Format("{0} ({1})", rci.Reason, sTeam);
                return(rci);
            }
        }
Example #3
0
            /*----------------------------------------------------------------------------
            *   %%Function: AddCalendarLinkItem
            *   %%Qualified: RwpApi.CalendarLinks.CalendarLinkItem.AddCalendarLinkItem
            *   %%Contact: rlittle
            *
            *  ----------------------------------------------------------------------------*/
            public static RSR AddCalendarLinkItem(CalendarLink link)
            {
                CalendarLinkItem item = FromCalendarLink(link);
                RSR sr = item.Preflight(null);

                if (!sr.Succeeded)
                {
                    return(sr);
                }

                Sql sql;

                sr = RSR.FromSR(Sql.OpenConnection(out sql, Startup._sResourceConnString));
                if (!sr.Result)
                {
                    return(sr);
                }

                sr = RSR.FromSR(sql.BeginTransaction());
                if (!sr.Result)
                {
                    sql.Close();
                    return(sr);
                }

                try
                {
                    string sAdd = item.SGenerateUpdateQuery(sql, true);

                    SqlCommand sqlcmd = sql.CreateCommand();
                    sqlcmd.CommandText = sAdd;
                    sqlcmd.Transaction = sql.Transaction;
                    sqlcmd.ExecuteNonQuery();
                }
                catch (Exception exc)
                {
                    sql.Rollback();
                    sql.Close();
                    return(RSR.Failed(exc));
                }

                sql.Commit();
                sql.Close();
                return(RSR.Success());
            }