示例#1
0
        public bool AddMeetingResource(string strMeetingID, MeetingResource mtgRes)
        {
            // Quick error checks
            if (strMeetingID == null || strMeetingID.Length == 0)
            {
                throw new ArgumentException("Invalid meeting ID", "strMeetingID");
            }
            if (mtgRes == null)
            {
                throw new ArgumentNullException("mtgRes", "Invalid resource to add");
            }

            if (this.IsResourceInMeeting(mtgRes.ID, strMeetingID))
            {
                return(true);
            }

            bool bRetVal = false;

            try
            {
                StringBuilder strQueryBuilder = new StringBuilder();
                strQueryBuilder.Append(" INSERT INTO ");
                strQueryBuilder.Append(Constants.MEETING_RESOURCES_TABLENAME);
                strQueryBuilder.Append("(");
                strQueryBuilder.Append(Constants.MTG_ID);
                strQueryBuilder.Append(",");
                strQueryBuilder.Append(Constants.RES_ID);
                strQueryBuilder.Append(",");
                strQueryBuilder.Append(Constants.RES_STATE);
                strQueryBuilder.Append(",");
                strQueryBuilder.Append(Constants.RES_OWNER);
                strQueryBuilder.Append(")");
                strQueryBuilder.Append(" VALUES ");
                strQueryBuilder.Append("(");
                strQueryBuilder.Append("'" + QueryService.MakeQuotesafe(strMeetingID) + "'");
                strQueryBuilder.Append(",");
                strQueryBuilder.Append("'" + QueryService.MakeQuotesafe(mtgRes.ID) + "'");
                strQueryBuilder.Append(",");
                strQueryBuilder.Append("'" + QueryService.MakeQuotesafe(mtgRes.State.ToString()) + "'");
                strQueryBuilder.Append(",");
                strQueryBuilder.Append("'" + QueryService.MakeQuotesafe(mtgRes.Owner) + "'");
                strQueryBuilder.Append(")");

                int nRowsAffected = QueryService.ExecuteNonQuery(this.DBConnect, strQueryBuilder.ToString());
                if (nRowsAffected == 1)
                {
                    bRetVal = true;
                }
            }
            catch (Exception /*e*/)
            {
            }
            finally
            {
            }

            return(bRetVal);
        }
示例#2
0
        public Hashtable GetSharedResources(string strMeetingID, string strOwner)
        {
            // Quick error checks
            if (strMeetingID == null || strMeetingID.Length == 0)
            {
                throw new ArgumentException("Invalid meeting ID", "strMeetingID");
            }
            if (strOwner == null || strOwner.Length == 0)
            {
                throw new ArgumentException("Invalid owner", "strOwner");
            }

            Hashtable      resources = new Hashtable();
            OdbcDataReader dr        = null;

            try
            {
                StringBuilder strQueryBuilder = new StringBuilder();
                strQueryBuilder.Append(" SELECT ");
                strQueryBuilder.Append(Constants.MEETING_RESOURCES_TABLENAME + "." + Constants.RES_ID);
                strQueryBuilder.Append(",");
                strQueryBuilder.Append(Constants.MEETING_RESOURCES_TABLENAME + "." + Constants.RES_OWNER);
                strQueryBuilder.Append(",");
                strQueryBuilder.Append(Constants.MEETING_RESOURCES_TABLENAME + "." + Constants.RES_STATE);
                strQueryBuilder.Append(",");
                strQueryBuilder.Append(Constants.RESOURCES_TABLENAME + "." + Constants.RES_URL);
                strQueryBuilder.Append(",");
                strQueryBuilder.Append(Constants.RESOURCES_TABLENAME + "." + Constants.RES_NAME);
                strQueryBuilder.Append(" FROM ");
                strQueryBuilder.Append(Constants.MEETING_RESOURCES_TABLENAME);
                strQueryBuilder.Append(",");
                strQueryBuilder.Append(Constants.RESOURCES_TABLENAME);
                strQueryBuilder.Append(" WHERE ");
                strQueryBuilder.Append(Constants.MEETING_RESOURCES_TABLENAME + "." + Constants.MTG_ID);
                strQueryBuilder.Append("=");
                strQueryBuilder.Append("'" + QueryService.MakeQuotesafe(strMeetingID) + "'");
                strQueryBuilder.Append(" AND ");
                strQueryBuilder.Append(Constants.MEETING_RESOURCES_TABLENAME + "." + Constants.RES_ID);
                strQueryBuilder.Append("=");
                strQueryBuilder.Append(Constants.RESOURCES_TABLENAME + "." + Constants.RES_ID);
                strQueryBuilder.Append(" AND ");
                strQueryBuilder.Append(Constants.MEETING_RESOURCES_TABLENAME + "." + Constants.RES_STATE);
                strQueryBuilder.Append("=");
                strQueryBuilder.Append("'" + QueryService.MakeQuotesafe(enuResourceState.Shared.ToString()) + "'");
                strQueryBuilder.Append(" AND ");
                strQueryBuilder.Append(Constants.MEETING_RESOURCES_TABLENAME + "." + Constants.RES_OWNER);
                strQueryBuilder.Append("=");
                strQueryBuilder.Append("'" + QueryService.MakeQuotesafe(strOwner) + "'");

                dr = QueryService.ExecuteReader(this.DBConnect, strQueryBuilder.ToString());

                if (dr == null)
                {
                    throw new Exception("Null data reader returned from query");
                }

                // Scroll thru list returned
                while (dr.Read())
                {
                    Resource res = new Resource();
                    res.ID   = (string)dr[Constants.RES_ID];
                    res.Name = (string)dr[Constants.RES_NAME];
                    res.Url  = (string)dr[Constants.RES_URL];

                    MeetingResource mtgRes = new MeetingResource(res, strMeetingID, strOwner);
                    mtgRes.State = (enuResourceState)enuResourceState.Parse(typeof(enuResourceState), (string)dr[Constants.RES_STATE], true);

                    if (resources[mtgRes.ID] == null)
                    {
                        resources.Add(mtgRes.ID, mtgRes);
                    }
                }
            }
            catch (Exception /*e*/)
            {
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
            }

            return(resources);
        }