Exemplo n.º 1
0
        public static int GetSQLTourArrayList(List <Tour> sqlTours)
        {
            string strErrorMsg;
            //int version = -1;
            DateTime dtBeginDateTime;
            DateTime dtEndDateTime;
            int      OrdCol;
            Guid     tourguid;
            string   tourtitle;
            string   workflowstatuscode;
            DateTime toursubmitteddatetime;
            DateTime tourapproveddatetime;
            DateTime tourrejecteddatetime;
            string   tourapprovedrejectedbyname;
            string   tourdescription;
            string   tourattributionandcredits;
            string   authorname;
            string   authoremailaddress;
            string   authorurl;
            string   authorsecondaryemailaddress;
            string   authorcontactphonenumber;
            string   authorcontacttext;
            string   organizationname;
            string   organizationurl;
            string   tourkeywordlist;
            string   tourithlist;
            string   tourastroobjectlist;
            string   tourexplicittourlinklist;
            int      lengthinsecs;
            double   averageRating;

            strErrorMsg = "";
            SqlConnection myConnection5 = GetConnectionWWTTours();

            dtBeginDateTime = Convert.ToDateTime("1/1/1900");
            dtEndDateTime   = Convert.ToDateTime("1/1/2100");

            try
            {
                myConnection5.Open();

                SqlCommand Cmd = null;
                Cmd                = new SqlCommand();
                Cmd.CommandType    = CommandType.StoredProcedure;
                Cmd.CommandTimeout = 20;
                Cmd.Connection     = myConnection5;

                Cmd.CommandText = "spGetWWTToursForDateRange";

                SqlParameter CustParm = new SqlParameter("@pBeginDateTime", SqlDbType.DateTime);
                CustParm.Value = dtBeginDateTime;
                Cmd.Parameters.Add(CustParm);

                SqlParameter CustParm2 = new SqlParameter("@pEndDateTime", SqlDbType.DateTime);
                CustParm2.Value = dtEndDateTime;
                Cmd.Parameters.Add(CustParm2);

                System.Data.SqlClient.SqlDataReader MySQLReader;
                MySQLReader = Cmd.ExecuteReader();
                while (MySQLReader.Read())
                {
                    OrdCol   = MySQLReader.GetOrdinal("TourGUID");
                    tourguid = MySQLReader.GetGuid(OrdCol);
                    OrdCol   = MySQLReader.GetOrdinal("TourTitle");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        tourtitle = MySQLReader.GetString(OrdCol);
                    }
                    else
                    {
                        tourtitle = null;
                    }

                    OrdCol = MySQLReader.GetOrdinal("WorkFlowStatusCode");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        workflowstatuscode = MySQLReader.GetString(OrdCol);
                    }
                    else
                    {
                        workflowstatuscode = null;
                    }

                    OrdCol = MySQLReader.GetOrdinal("TourSubmittedDateTime");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        toursubmitteddatetime = Convert.ToDateTime(MySQLReader.GetSqlDateTime(OrdCol).ToString());
                    }
                    else
                    {
                        toursubmitteddatetime = DateTime.MinValue;
                    }

                    OrdCol = MySQLReader.GetOrdinal("TourApprovedDateTime");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        tourapproveddatetime = Convert.ToDateTime(MySQLReader.GetSqlDateTime(OrdCol).ToString());
                    }
                    else
                    {
                        tourapproveddatetime = DateTime.MinValue;
                    }

                    OrdCol = MySQLReader.GetOrdinal("TourRejectedDateTime");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        tourrejecteddatetime = Convert.ToDateTime(MySQLReader.GetSqlDateTime(OrdCol).ToString());
                    }
                    else
                    {
                        tourrejecteddatetime = DateTime.MinValue;
                    }

                    OrdCol = MySQLReader.GetOrdinal("TourApprovedRejectedByName");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        tourapprovedrejectedbyname = MySQLReader.GetString(OrdCol);
                    }
                    else
                    {
                        tourapprovedrejectedbyname = null;
                    }

                    OrdCol = MySQLReader.GetOrdinal("TourDescription");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        tourdescription = MySQLReader.GetString(OrdCol);
                    }
                    else
                    {
                        tourdescription = null;
                    }

                    OrdCol = MySQLReader.GetOrdinal("TourAttributionAndCredits");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        tourattributionandcredits = MySQLReader.GetString(OrdCol);
                    }
                    else
                    {
                        tourattributionandcredits = null;
                    }

                    OrdCol = MySQLReader.GetOrdinal("AuthorName");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        authorname = MySQLReader.GetString(OrdCol);
                    }
                    else
                    {
                        authorname = null;
                    }

                    OrdCol = MySQLReader.GetOrdinal("AuthorEmailAddress");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        authoremailaddress = MySQLReader.GetString(OrdCol);
                    }
                    else
                    {
                        authoremailaddress = null;
                    }

                    OrdCol = MySQLReader.GetOrdinal("AuthorURL");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        authorurl = MySQLReader.GetString(OrdCol);
                    }
                    else
                    {
                        authorurl = null;
                    }

                    OrdCol = MySQLReader.GetOrdinal("AuthorSecondaryEmailAddress");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        authorsecondaryemailaddress = MySQLReader.GetString(OrdCol);
                    }
                    else
                    {
                        authorsecondaryemailaddress = null;
                    }

                    OrdCol = MySQLReader.GetOrdinal("AuthorContactPhoneNumber");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        authorcontactphonenumber = MySQLReader.GetString(OrdCol);
                    }
                    else
                    {
                        authorcontactphonenumber = null;
                    }

                    OrdCol = MySQLReader.GetOrdinal("AuthorContactText");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        authorcontacttext = MySQLReader.GetString(OrdCol);
                    }
                    else
                    {
                        authorcontacttext = null;
                    }

                    OrdCol = MySQLReader.GetOrdinal("OrganizationName");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        organizationname = MySQLReader.GetString(OrdCol);
                    }
                    else
                    {
                        organizationname = null;
                    }

                    OrdCol = MySQLReader.GetOrdinal("OrganizationURL");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        organizationurl = MySQLReader.GetString(OrdCol);
                    }
                    else
                    {
                        organizationurl = null;
                    }

                    OrdCol = MySQLReader.GetOrdinal("TourKeywordList");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        tourkeywordlist = MySQLReader.GetString(OrdCol);
                    }
                    else
                    {
                        tourkeywordlist = null;
                    }

                    OrdCol = MySQLReader.GetOrdinal("TourITHList");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        tourithlist = MySQLReader.GetString(OrdCol);
                    }
                    else
                    {
                        tourithlist = null;
                    }

                    OrdCol = MySQLReader.GetOrdinal("TourAstroObjectList");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        tourastroobjectlist = MySQLReader.GetString(OrdCol);
                    }
                    else
                    {
                        tourastroobjectlist = null;
                    }

                    OrdCol = MySQLReader.GetOrdinal("TourExplicitTourLinkList");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        tourexplicittourlinklist = MySQLReader.GetString(OrdCol);
                    }
                    else
                    {
                        tourexplicittourlinklist = null;
                    }

                    OrdCol = MySQLReader.GetOrdinal("LengthInSecs");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        lengthinsecs = MySQLReader.GetInt32(OrdCol);
                    }
                    else
                    {
                        lengthinsecs = -1;
                    }

                    OrdCol = MySQLReader.GetOrdinal("AverageRating");
                    if (MySQLReader[OrdCol] != DBNull.Value)
                    {
                        averageRating = MySQLReader.GetDouble(OrdCol);
                    }
                    else
                    {
                        averageRating = 0;
                    }
                    //OrdCol = MySQLReader.GetOrdinal("TourXML");
                    //if (MySQLReader[OrdCol] != DBNull.Value)
                    //{
                    //    tourxml = MySQLReader.GetString(OrdCol);
                    //}
                    //else
                    //{
                    //    tourxml = null;
                    //}



                    Tour loadTour = new Tour();

                    loadTour.TourGuid  = tourguid;
                    loadTour.TourTitle = tourtitle;
                    if (workflowstatuscode != null)
                    {
                        loadTour.WorkFlowStatusCode = workflowstatuscode;
                    }
                    if (toursubmitteddatetime != null)
                    {
                        loadTour.TourSubmittedDateTime = toursubmitteddatetime;
                    }
                    if (tourapproveddatetime != null)
                    {
                        loadTour.TourApprovedDateTime = tourapproveddatetime;
                    }
                    if (tourrejecteddatetime != null)
                    {
                        loadTour.TourRejectedDateTime = tourrejecteddatetime;
                    }

                    //loadTour.TourApprovedRejectedByName = tourapprovedrejectedbyname;
                    loadTour.TourDescription           = tourdescription;
                    loadTour.TourAttributionAndCredits = tourattributionandcredits;
                    loadTour.AuthorName                  = authorname;
                    loadTour.AuthorEmailAddress          = authoremailaddress;
                    loadTour.AuthorURL                   = authorurl;
                    loadTour.AuthorSecondaryEmailAddress = authorsecondaryemailaddress;
                    loadTour.AuthorContactPhoneNumber    = authorcontactphonenumber;
                    loadTour.AuthorContactText           = authorcontacttext;
                    loadTour.OrganizationName            = organizationname;
                    loadTour.OrganizationURL             = organizationurl;
                    loadTour.TourKeywordList             = tourkeywordlist;
                    loadTour.TourITHList                 = tourithlist;
                    loadTour.TourAstroObjectList         = tourastroobjectlist;
                    loadTour.TourExplicitTourLinkList    = tourexplicittourlinklist;
                    loadTour.LengthInSecs                = lengthinsecs;
                    loadTour.AverageRating               = averageRating;
                    //loadTour.TourXML = tourxml;

                    sqlTours.Add(loadTour);
                }
            }
            catch (InvalidCastException)
            { }

            catch (Exception ex)
            {
                //throw ex.GetBaseException();
                strErrorMsg = ex.Message;
                return(-1);
            }
            finally
            {
                if (myConnection5.State == ConnectionState.Open)
                {
                    myConnection5.Close();
                }
            }

            return(0);
        }
Exemplo n.º 2
0
            public WWTTour(string TourXML, byte[] TourBlob, byte[] TourThumbnail, byte[] AuthorThumbnail)
            {
                strErrorMsg = "";
                SqlConnection myConnection5 = Database.GetConnectionWWTTours();


                // cut file stuff from here

                try
                {
                    //
                    SqlCommand Cmd5 = null;

                    Cmd5                = new SqlCommand();
                    Cmd5.Connection     = myConnection5;
                    Cmd5.CommandType    = CommandType.StoredProcedure;
                    Cmd5.CommandTimeout = 10000;

                    SqlParameter CustParm = Cmd5.CreateParameter();
                    CustParm.SqlDbType     = SqlDbType.NVarChar;
                    CustParm.ParameterName = "@pInputXMLStream";
                    Cmd5.Parameters.Add(CustParm);
                    CustParm.Value = TourXML;

                    Cmd5.CommandText = "spImportTour";
                    myConnection5.Open();

                    ds = new WWTToursDataset();
                    System.Data.SqlClient.SqlDataReader MySQLReader;

                    MySQLReader = Cmd5.ExecuteReader();


                    while (MySQLReader.Read())
                    {
                        int OrdTourGUID = MySQLReader.GetOrdinal("TourGUID");
                        outTourGuid       = MySQLReader.GetGuid(OrdTourGUID);
                        outTourGuidString = outTourGuid.ToString();

                        int OrdTourTitle = MySQLReader.GetOrdinal("TourTitle");
                        outTourTitle = MySQLReader.GetString(OrdTourTitle);
                    }


                    List <Tour> SelectedTours = new List <Tour>();

                    cacheTour                       = new Tour();
                    cacheTour.TourGuid              = outTourGuid;
                    cacheTour.TourTitle             = outTourTitle;
                    cacheTour.WorkFlowStatusCode    = "0";
                    cacheTour.TourSubmittedDateTime = System.DateTime.Now;

                    SelectedTours.Add(cacheTour);
                    ds2 = SelectedTours;
                }
                catch (Exception ex)
                {
                    throw
                        WWTWebService.RaiseException("ImportTour", "http://WWTWebServices", ex.Message, "2000", "ImportTour", WWTWebService.FaultCode.Client);
                }
                finally
                {
                    if (myConnection5.State == ConnectionState.Open)
                    {
                        myConnection5.Close();
                    }
                }

                try
                {
                    // Tour Thumbnail

                    string strTourUNC = GetToursUNC();
                    TourGUIDString = outTourGuidString;  // WAS :  GetTourGUIDFromXML(TourXML);
                    string NewFileName = "fail";

                    if (TourThumbnail.Length > 0)
                    {
                        NewFileName = strTourUNC + "\\" + TourGUIDString + "_TourThumb.bin";
                        Stream       t = new FileStream(NewFileName, FileMode.Create);
                        BinaryWriter b = new BinaryWriter(t);
                        b.Write(TourThumbnail);
                        t.Close();
                    }

                    // Tour Blob
                    if (TourBlob.Length > 0)
                    {
                        NewFileName = strTourUNC + "\\" + TourGUIDString + ".bin";
                        Stream       t2 = new FileStream(NewFileName, FileMode.Create);
                        BinaryWriter b2 = new BinaryWriter(t2);
                        b2.Write(TourBlob);
                        t2.Close();
                    }


                    // Author Thumbnail

                    if (AuthorThumbnail.Length > 0)
                    {
                        NewFileName = strTourUNC + "\\" + TourGUIDString + "_AuthorThumb.bin";
                        Stream       t3 = new FileStream(NewFileName, FileMode.Create);
                        BinaryWriter b3 = new BinaryWriter(t3);
                        b3.Write(AuthorThumbnail);
                        t3.Close();
                    }
                }
                catch (Exception ex)
                {
                    throw
                        WWTWebService.RaiseException("ImportTour", "http://WWTWebServices", ex.Message, "1000", "ImportTour", WWTWebService.FaultCode.Client);
                }
            }