コード例 #1
0
        public override bool NewRightClick(int i, int j)
        {
            Tile        below      = Framing.GetTileSafely(i, j - 1);
            Tile        above      = Framing.GetTileSafely(i, j + 1);
            int         aboveCheck = above.type == Type ? 2 : 0;
            int         belowCheck = below.type == Type ? 1 : 0;
            int         newJ       = j + aboveCheck + belowCheck;
            LaunchPoint l          = new LaunchPoint(new Vector2(i, newJ), ((StarSailorMod)mod).GenerateName(), mod, ModContent.GetInstance <DimensionManager>().currentDimension);
            string      error      = l.CheckValidity();

            if (error == "")
            {
                Player p = Main.player[Main.myPlayer];
                if (p.selectedItem == 58)
                {
                    Main.NewText("Throwing your items at the launch pad does nothing, you dingus!");
                }
                else
                {
                    l = ModContent.GetInstance <LaunchPointManager>().GetCorrectLaunchPoint(l);

                    ModContent.GetInstance <LaunchPointManager>().AddLaunchPoint(l);
                    ModContent.GetInstance <LaunchPointManager>().currentLaunchPoint = l;

                    p.mount.SetMount(ModContent.GetInstance <Rocket>().Type, p);
                    ((StarSailorMod)mod).inLaunchGui       = true;
                    ((StarSailorMod)mod).updateButtonsFlag = true;
                }
            }
            else
            {
                Main.NewText(error);
            }
            return(base.NewRightClick(i, j));
        }
コード例 #2
0
        } // UploadToolBokkContent

        /// <summary>
        /// This method handles the uploading of data from the xml file to the sql server database
        /// </summary>
        private void UploadScormContent()
        {
            int           intModuleID;               // The current Module ID
            int           intCourseID;               // The current Course ID
            Module        objModule;                 // Used to access the Module Details
            DataTable     dtbModule;                 // Datatable containing Module Details
            DirectoryInfo dirNewContentSource;       // Directory info about the source directory
            DirectoryInfo dirNewContentDestination;  // Directory info about the destination directory
            DirectoryInfo dirNewContentDestination2; // Directory info about the destination directory
            DirectoryInfo dirOldContentDestination;  // Directory info about the destination directory


            string strContentType;              // The content type, Quiz or a Lesson
            string strUploadType;               // The Upload Type, a correction or an update
            string strNewContentDestination;    //
            string strOldContentDestination;    //
            string strFilename = "";
            string strQFS      = "";

            // Retrieve the Module ID from the query string and Course ID from the database
            intModuleID = int.Parse(Request.QueryString["ModuleID"].ToString());

            // Get module details
            objModule   = new Module();
            dtbModule   = objModule.GetModule(intModuleID, UserContext.UserData.OrgID);
            intCourseID = int.Parse(dtbModule.Rows[0]["CourseID"].ToString());

            // Verify that the ASP.NET user has the necessary permission to the content
            // destination folder before beginning content upload
            string        strContentDestinationTest = ConfigurationSettings.AppSettings["ImportSCORMDestinationDirectory"] + "/Test";
            DirectoryInfo dirContentDestinationTest = new DirectoryInfo(WebTool.MapToPhysicalPath(strContentDestinationTest));

            try
            {
                // Try to create a test folder, will throw an IOException if insufficient permissions
                dirContentDestinationTest.Create();
                // Tidy up
                dirContentDestinationTest.Delete(true);
            }
            catch (Exception ex)
            {
                this.lblMessage.Text     = ex.Message;
                this.lblMessage.CssClass = "WarningMessage";
            }
            String LaunchPoint;

            // LaunchPoint = txtLocation.Text;
            //Code by joseph
            //if (LaunchPoint.Contains("launchpage.html"))
            //{
            //    string strContentDestinationNew = ConfigurationSettings.AppSettings["ImportSCORMDestinationDirectory"];// +"/AdaptiveFiles";
            //    DirectoryInfo dirContentDestination = new DirectoryInfo(WebTool.MapToPhysicalPath(strContentDestinationNew));

            //    strNewContentDestination = strContentDestinationNew + "/" + intCourseID + "/" + intModuleID.ToString();
            //    if (!System.IO.Directory.Exists(dirContentDestination + "\\" + intCourseID + "\\" + intModuleID))
            //    {

            //        System.IO.Directory.CreateDirectory(dirContentDestination + "\\" + intCourseID + "\\" + intModuleID);
            //        string strContentDestination = dirContentDestination + "\\" + intCourseID + "\\" + intModuleID.ToString();
            //       //
            //        System.IO.File.Copy(strContentDestination, strNewContentDestination, true);
            //    }
            //    else
            //    {
            //        string strContentDestination = dirContentDestination + "/" + intCourseID + "/" + intModuleID.ToString();
            //        //

            //    }
            //}
            //else
            //{
            //end
            try
            {
                // Create a directory info object for the specified path
                LaunchPoint         = txtLocation.Text;
                dirNewContentSource = dirContentDestinationTest;
                if (LaunchPoint.Contains("launchpage.html"))
                {
                    LaunchPoint = LaunchPoint.Split('/')[0].ToString();
                    FileInfo LessonLaunchPoint = new FileInfo(Server.MapPath("/General/") + "Scorm/Publishing/" + LaunchPoint);
                    strFilename         = "launchpage.html";
                    dirNewContentSource = new DirectoryInfo(LessonLaunchPoint.Directory.FullName + "/" + LaunchPoint.Split('/')[0].ToString());
                    LaunchPoint         = txtLocation.Text;
                }
                else
                {
                    LaunchPoint = LaunchPoint.Substring(0, LaunchPoint.IndexOf("?"));
                    FileInfo LessonLaunchPoint = new FileInfo(Server.MapPath("/General/") + "Scorm/Publishing/" + LaunchPoint);
                    strFilename         = LessonLaunchPoint.Name;
                    dirNewContentSource = new DirectoryInfo(LessonLaunchPoint.Directory.FullName);
                    LaunchPoint         = txtLocation.Text;
                }
                strQFS      = LaunchPoint.Substring(LaunchPoint.IndexOf("?") + 5, LaunchPoint.Length - LaunchPoint.IndexOf("?") - 5);
                LaunchPoint = LaunchPoint.Substring(0, LaunchPoint.IndexOf("?"));
            }
            catch (Exception ex)
            {
                this.lblMessage.Text     = ex.Message;
                this.lblMessage.CssClass = "WarningMessage";
                return;
            }

            // Check that the supplied path exists
            if (dirNewContentSource.Exists)
            {
                // Construct the path on the web server where the new SCORM files will be placed
                strNewContentDestination  = ConfigurationSettings.AppSettings["ImportSCORMDestinationDirectory"].ToString();
                strNewContentDestination += "/" + intCourseID.ToString() + "/" + intModuleID.ToString();
                if (!LaunchPoint.Contains("launchpage.html"))
                {
                    strNewContentDestination += "/" + "lesson";
                }
                // Construct the path on the web server where the OLD SCORM files will be moved to (if they exist)
                strOldContentDestination  = ConfigurationSettings.AppSettings["ImportSCORMDestinationDirectory"].ToString();
                strOldContentDestination += "/Superseded/" + intCourseID.ToString() + "/" + intModuleID.ToString();

                if (!LaunchPoint.Contains("launchpage.html"))
                {
                    strOldContentDestination += "/" + "lesson";
                }
                strOldContentDestination = WebTool.MapToPhysicalPath(strOldContentDestination);

                //strNewContentDestination = txtLocation.Text;



                //strNewContentDestination = WebTool.MapToPhysicalPath(strNewContentDestination);



                // Ensure the destination directory on the web server exists
                dirNewContentDestination2 = new DirectoryInfo(WebTool.MapToPhysicalPath(strNewContentDestination));
                if (dirNewContentDestination2.Exists)
                {
                    // Delete the contents of the current content destination folder
                    try
                    {
                        dirOldContentDestination = new DirectoryInfo(strOldContentDestination);
                        dirOldContentDestination.Create();
                        dirNewContentDestination2.MoveTo(strOldContentDestination + "/" + DateTime.Now.Ticks);
                    }
                    catch (Exception ex)
                    {
                        this.lblMessage.Text     = ex.Message;
                        this.lblMessage.CssClass = "WarningMessage";
                        return;
                    }
                }

                dirNewContentDestination = new DirectoryInfo(WebTool.MapToPhysicalPath(strNewContentDestination));
                // Copy the source Toolbook files into the destination directory
                try
                {
                    // Create the content destination folder
                    dirNewContentDestination.Create();

                    // Copy the Toolbook files to the required destination on the web server
                    WebTool.CopyDirectory(dirNewContentSource.FullName, dirNewContentDestination.FullName);
                }
                catch (Exception ex)
                {
                    this.lblMessage.Text     = ex.Message;
                    this.lblMessage.CssClass = "WarningMessage";
                    new ErrorHandler.ErrorLog(ex, Bdw.Application.Salt.Data.ErrorLevel.High, "UploadToolbookContent.aspx", "UploadContent", "dirNewContentDestination.Create()");
                    return;
                }

                try
                {
                    string contentdest;
                    if (LaunchPoint.Contains("launchpage.html"))
                    {
                        contentdest = strNewContentDestination + "/shared/" + strFilename;
                    }
                    else
                    {
                        contentdest = strNewContentDestination + "/" + strFilename;
                    }
                    using (StoredProcedure sp = new StoredProcedure("prcSCORMimport",
                                                                    //								  StoredProcedure.CreateInputParam("@intLessonID", SqlDbType.Int, intLessonID),
                                                                    StoredProcedure.CreateInputParam("@intModuleID", SqlDbType.Int, intModuleID),
                                                                    //								  StoredProcedure.CreateInputParam("@strToolbookID", SqlDbType.VarChar,50, strToolbookID),
                                                                    // StoredProcedure.CreateInputParam("@strToolLocation", SqlDbType.VarChar, 100, strNewContentDestination + "/" + strFilename),By Joseph
                                                                    StoredProcedure.CreateInputParam("@strToolLocation", SqlDbType.VarChar, 100, contentdest),
                                                                    StoredProcedure.CreateInputParam("@strQFSLocation", SqlDbType.VarChar, 100, strNewContentDestination + "/" + strQFS),
                                                                    //                                  StoredProcedure.CreateInputParam("@strToolLocation", SqlDbType.VarChar, 100, dirNewContentDestination.FullName + "/" + strFilename),
                                                                    StoredProcedure.CreateInputParam("@DatePublished", SqlDbType.DateTime, dirNewContentSource.LastWriteTime),
                                                                    StoredProcedure.CreateInputParam("@intUserID", SqlDbType.VarChar, 1000, UserContext.UserID),
                                                                    StoredProcedure.CreateInputParam("@SCORMsource", SqlDbType.VarChar, 100, LaunchPoint)
                                                                    )
                           )
                    {
                        sp.ExecuteNonQuery();
                    }
                }
                catch (Exception)
                {
                    throw;
                }



                // Display a success message
                this.lblMessage.Text = ResourceManager.GetString("LessonUpload");

                this.lblMessage.CssClass = "SuccessMessage";
            }
            else
            {
                this.lblMessage.Text     = String.Format(ResourceManager.GetString("lblMessage5"), Request.ServerVariables["SERVER_NAME"]);//"The specified physical path does not exist on " + Request.ServerVariables["SERVER_NAME"];
                this.lblMessage.CssClass = "WarningMessage";
                return;
            }
            //}
        } // UploadScormContent