예제 #1
0
 /// <summary>
 /// 相对路径
 /// </summary>
 /// <returns></returns>
 public static string GetRelativePath()
 {
     if (!UpdateMode && !DebugMode)
     {
         if (relative_Path == null)
         {
             if (Application.platform == RuntimePlatform.WindowsPlayer ||
                 Application.platform == RuntimePlatform.WebGLPlayer || Application.platform == RuntimePlatform.WindowsEditor)
             {
                 relative_Path = DataPath;
             }
             else
             {
                 relative_Path = "jar:file://" + System.Environment.CurrentDirectory.Replace("\\", "/") + "/" + AssetDir + "/";
             }
         }
         return(relative_Path);
     }
     else
     {
         if (relative_Path == null)
         {
             if (Application.platform == RuntimePlatform.Android)
             {
                 relative_Path = "jar:file://" + DataPath.Replace("\\", "/");
             }
             else
             {
                 relative_Path = "file:///" + DataPath.Replace("\\", "/");
             }
         }
         return(relative_Path);
     }
 }
예제 #2
0
        // string AssetPathwww;
        public EditorDevice()
        {
            AssetPath  = Application.streamingAssetsPath + "/";
            DataPath   = "file://" + Directory.GetCurrentDirectory() + "/Assets/Data/";
            DataPath   = DataPath.Replace("\\", "/");
            ResPath    = "Assets/Resources_Bundle/";
            ResPathWWW = "file://" + Application.streamingAssetsPath + "/res/";
            // printPath();
            // string path = "D:/unity_work/qgame/dev/client/cygame/Assets/Data/config/HeroCfg.dat";//DataPath+"/config/CorpsWishCfg.dat";

            // WWW www = new WWW(path);
            //// Log.Info(path);
            // while (!www.isDone)
            // {

            // }
            // if (string.IsNullOrEmpty(www.error))
            // {
            //     Debug.Log("niceeeeee");
            // }
            // else
            // {
            //     Debug.Log(www.error);
            // }
        }
예제 #3
0
 public static void DeleteDataFile()
 {
     try
     {
         File.Move(DataPath, DataPath.Replace(".json", DateTime.Now.Ticks.ToString() + ".json"));
     }
     catch (Exception ex)
     {
         WriteErrorToLog(ex);
     }
 }
예제 #4
0
        public bool DataRestore(string BackupFile, bool Data = true, bool TransactionLog = false)
        {
            string DataName, LogName, DataPath, LogPath, DBName;

            try
            {
                DataName = LogPath = LogName = DataPath = string.Empty;
                using (SqlConnection conn = new SqlConnection(GlobalClass.DataConnectionString))
                {
                    conn.Open();
                    DBName = conn.Database;
                    conn.ChangeDatabase("Master");

                    using (SqlCommand cmd = conn.CreateCommand())
                    {
                        IEnumerable <string> pids = conn.Query <string>("SELECT CAST(SPID AS VARCHAR(3)) FROM SYSPROCESSES S JOIN SYSDATABASES D ON S.dbid = D.dbid WHERE D.name = '" + DBName + "'");
                        foreach (string spid in pids)
                        {
                            conn.Execute("KILL " + spid);
                        }
                        if (Data)
                        {
                            cmd.CommandText = "RESTORE FILELISTONLY FROM Disk='" + BackupFile + "'";
                            SqlDataReader dr = cmd.ExecuteReader();
                            while (dr.Read())
                            {
                                if (dr["Type"].ToString() == "D")
                                {
                                    DataName = dr["LogicalName"].ToString();
                                    DataPath = dr["PhysicalName"].ToString();
                                    DataPath = DataPath.Replace(DataPath.Split('\\').Last(), string.Empty);
                                }
                                else
                                {
                                    LogName = dr["LogicalName"].ToString();
                                    LogPath = dr["PhysicalName"].ToString();
                                    LogPath = LogPath.Replace(LogPath.Split('\\').Last(), string.Empty);
                                }
                            }
                            dr.Close();

                            cmd.CommandText = @"RESTORE DATABASE " + DBName + " FROM Disk='" + BackupFile + @"' WITH REPLACE,
                                                     MOVE '" + DataName + "' TO '" + DataPath + DBName + @".mdf',
                                                    MOVE '" + LogName + "' TO '" + LogPath + DBName + ".ldf';";
                            cmd.ExecuteNonQuery();
                        }
                        else
                        {
                            cmd.CommandText = "RESTORE LOG " + DBName + " FROM DISK = '" + BackupFile + "' WITH REPLACE";
                            cmd.ExecuteNonQuery();
                        }
                    }
                }
                MessageBox.Show("Database restore successfully completed.", "Data Restore", MessageBoxButton.OK, MessageBoxImage.Information);
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(GlobalClass.GetRootException(ex).Message, "Data Restore", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
        }