Exemple #1
0
    public bool EditShowcase(string caseID, string caseName, int mapIdx, string pptFolderPath, int percentage, int expTime, bool echoEffect)
    {
        bool res = LoadShowcaseBinaryFromLocal();

        if (!res)
        {
            return(false);
        }

        if (!_showcaseTable.ContainsKey(caseID))
        {
            return(false);
        }

        showcase_Data tempShowcase = (showcase_Data)_showcaseTable [caseID];

        tempShowcase._showcaseName         = caseName;
        tempShowcase._mapIdx               = (ushort)mapIdx;
        tempShowcase._pptFolderPath        = pptFolderPath;
        tempShowcase._percentageOfAudience = (ushort)percentage;
        tempShowcase._expetedTime_min      = (ushort)expTime;
        tempShowcase._updatedDate          = System.DateTime.Now;
        tempShowcase._isEchoEffect         = echoEffect;

        _showcaseTable [caseID] = tempShowcase;

        SaveShowcasesBinaryInLocal();
        return(true);
    }
    public showcase_Data[] GetAllShowcases(){
		bool res = LoadShowcaseBinaryFromLocal ();
        if(!res) return null;

        showcase_Data[] arr = new showcase_Data[_showcaseTable.Count];
		int index = 0;
        foreach (KeyValuePair<string, showcase_Data> pair in _showcaseTable){
            arr[index] = (showcase_Data)pair.Value;
            index++;
        }
			
		Array.Sort (arr, DateTime_Compare);
        return arr;
    }
Exemple #3
0
    public string AddShowcase(string caseName, int mapIdx, string pptFolderPath, int percentage, int expTime)
    {
        bool res = LoadShowcaseBinaryFromLocal();

        if (!res)
        {
            return(null);
        }

        string        tempId       = System.DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss");
        showcase_Data tempShowcase = new showcase_Data(tempId, caseName, (ushort)mapIdx, pptFolderPath, (ushort)percentage, (ushort)expTime);

        _showcaseTable.Add(tempId, tempShowcase);

        SaveShowcasesBinaryInLocal();
        return(tempId);
    }
Exemple #4
0
    public showcase_Data[] GetAllShowcases()
    {
        bool res = LoadShowcaseBinaryFromLocal();

        if (!res)
        {
            return(null);
        }

        showcase_Data[] arr   = new showcase_Data[_showcaseTable.Count];
        int             index = 0;

        foreach (KeyValuePair <string, showcase_Data> pair in _showcaseTable)
        {
            arr[index] = (showcase_Data)pair.Value;
            index++;
        }

        Array.Sort(arr, DateTime_Compare);
        return(arr);
    }
Exemple #5
0
    public bool EditShowcase_path(string caseID, string pptFolderPath)
    {
        bool res = LoadShowcaseBinaryFromLocal();

        if (!res)
        {
            return(false);
        }

        if (!_showcaseTable.ContainsKey(caseID))
        {
            return(false);
        }

        showcase_Data tempShowcase = (showcase_Data)_showcaseTable [caseID];

        tempShowcase._pptFolderPath = pptFolderPath;
        tempShowcase._updatedDate   = System.DateTime.Now;

        _showcaseTable [caseID] = tempShowcase;

        SaveShowcasesBinaryInLocal();
        return(true);
    }
Exemple #6
0
    /*
     * public bool End(){
     *          bool res = SaveShowcasesBinaryInLocal ();
     *          _showcaseTable.Clear ();
     *          return res;
     *  }
     */

    //Purpose for DateTime Sorting
    private int DateTime_Compare(showcase_Data x, showcase_Data y)
    {
        return(System.DateTime.Compare(y._updatedDate, x._updatedDate));
    }
Exemple #7
0
    private bool LoadShowcaseBinaryFromLocal()
    {
                #if UNITY_EDITOR
        string loadPath = Application.dataPath + "/" + _binaryFileName + ".bytes";
                #elif UNITY_ANDROID
        string loadPath = Application.persistentDataPath + "/" + _binaryFileName + ".bytes";
                #endif

        if (File.Exists(loadPath))
        {
            try{
                using (BinaryReader r = new BinaryReader(File.Open(loadPath, FileMode.Open))) {
                    //1. Header checking in order to check file corruption
                    string tempHeader = r.ReadString();
                    if (tempHeader != _fileHeaderValidChecker)
                    {
                        return(false);
                    }
                    //2. numOfshowcase
                    _numOfShowcase = r.ReadInt32();

                    //3. Load Showcases
                    if (_showcaseTable == null)
                    {
                        _showcaseTable = new Dictionary <string, showcase_Data>();
                    }
                    else
                    {
                        _showcaseTable.Clear();
                    }

                    for (int i = 0; i < _numOfShowcase; ++i)
                    {
                        showcase_Data tempCase = new showcase_Data();
                        tempCase._showcaseID           = r.ReadString();
                        tempCase._showcaseName         = r.ReadString();
                        tempCase._mapIdx               = (ushort)r.ReadInt16();
                        tempCase._pptFolderPath        = r.ReadString();
                        tempCase._percentageOfAudience = (ushort)r.ReadInt16();
                        tempCase._expetedTime_min      = (ushort)r.ReadInt16();
                        //string -> DateTime
                        string strToDateTime = r.ReadString();
                        tempCase._updatedDate  = System.Convert.ToDateTime(strToDateTime);
                        tempCase._isEchoEffect = r.ReadBoolean();

                        _showcaseTable.Add(tempCase._showcaseID, tempCase);
                    }

                    //4. End
                    string tempfooter = r.ReadString();
                    if (tempHeader != _fileHeaderValidChecker)
                    {
                        _showcaseTable.Clear();
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }catch {
                return(false);
            }
        }
        else
        {
            return(false);
        }
    }
    public string AddShowcase(string caseName, int mapIdx, string pptFolderPath, int percentage, int expTime ){
        bool res = LoadShowcaseBinaryFromLocal();
        if (!res) return null;

        string tempId = System.DateTime.Now.ToString ("yyyy_MM_dd_hh_mm_ss");
		showcase_Data tempShowcase = new showcase_Data(tempId, caseName, (ushort)mapIdx, pptFolderPath, (ushort)percentage, (ushort)expTime);
		_showcaseTable.Add (tempId, tempShowcase);

		SaveShowcasesBinaryInLocal ();
		return tempId;
	}
    /*
    public bool End(){
		bool res = SaveShowcasesBinaryInLocal ();
		_showcaseTable.Clear ();
		return res;
	}
	*/

	//Purpose for DateTime Sorting 
	private int DateTime_Compare(showcase_Data x, showcase_Data y){
		return System.DateTime.Compare (y._updatedDate, x._updatedDate);
	}
	private bool LoadShowcaseBinaryFromLocal(){
		#if UNITY_EDITOR
		string loadPath = Application.dataPath + "/" + _binaryFileName + ".bytes";
		#elif UNITY_ANDROID 
		string loadPath = Application.persistentDataPath + "/" + _binaryFileName + ".bytes";
		#endif

		if (File.Exists (loadPath)) {
			try{
				using (BinaryReader r = new BinaryReader (File.Open (loadPath, FileMode.Open))) {
					//1. Header checking in order to check file corruption
					string tempHeader = r.ReadString ();
					if (tempHeader != _fileHeaderValidChecker)
						return false;
					//2. numOfshowcase
					_numOfShowcase = r.ReadInt32 ();

					//3. Load Showcases
					if(_showcaseTable == null){
						_showcaseTable = new Dictionary<string, showcase_Data>();
					}else{
						_showcaseTable.Clear();
					}
						
					for (int i = 0; i < _numOfShowcase; ++i) {

						showcase_Data tempCase = new showcase_Data ();
						tempCase._showcaseID = r.ReadString ();
						tempCase._showcaseName = r.ReadString ();
						tempCase._mapIdx = (ushort)r.ReadInt16 ();
						tempCase._pptFolderPath = r.ReadString ();
						tempCase._percentageOfAudience = (ushort)r.ReadInt16 ();
						tempCase._expetedTime_min = (ushort)r.ReadInt16 ();
						//string -> DateTime
						string strToDateTime = r.ReadString ();
						tempCase._updatedDate = System.Convert.ToDateTime(strToDateTime);
						tempCase._isEchoEffect = r.ReadBoolean();

						_showcaseTable.Add (tempCase._showcaseID, tempCase);
					}

					//4. End
					string tempfooter = r.ReadString ();
					if (tempHeader != _fileHeaderValidChecker) {
						_showcaseTable.Clear ();
						return false;
					} else {
						return true;
					}
				}
			}catch{
				return false;
			}

		} else {
			return false;
		}
	}