示例#1
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="Path"></param>
 private void init(string Path)
 {
     if (!MapDict.ContainsKey(Path))
     {
         AddDict(Path, AddTable(ReadCSV(Path)));
     }
 }
示例#2
0
 /// <summary>
 /// 把数据表(DataTable)添加到字典里
 /// </summary>
 /// <param name="DictKey"></param>
 /// <param name="table"></param>
 private void AddDict(string DictKey, DataTable table)
 {
     if (!MapDict.ContainsKey(DictKey))
     {
         MapDict.Add(DictKey, table);
         AddIdList(DictKey, table);
     }
 }
示例#3
0
    /// <summary>
    /// 添加一个内容;并创建一个
    /// </summary>
    /// <param name="path">路径</param>
    /// <param name="id">id号</param>
    /// <param name="attriab">属性</param>
    /// <param name="NewWord">新内容</param>
    public void SetWord(string path, int id, string attriab, string NewWord = "null")
    {
        path = Application.streamingAssetsPath + "/" + path;

        init(path);
        int rowsLine     = GetRowNumber(path, id);
        int columnNumber = GetColumnNumber(path, attriab);

        DataTable dt;

        if (MapDict.ContainsKey(path))
        {
            dt = MapDict[path];
        }
        else
        {
            return;
        }


        if (rowsLine >= 0)   //存在该行
        {
            MapDict[path].Rows[rowsLine][columnNumber] = NewWord;
        }
        else                 //不存在该行
        {
            object[] obj = new object[dt.Columns.Count];
            for (int i = 0; i < obj.Length; i++)
            {
                if (i == 0)
                {
                    obj[i] = id;
                }
                else if (i == columnNumber)
                {
                    obj[i] = NewWord;
                }
                else
                {
                    obj[i] = "";
                }
            }
            DataRow row = dt.NewRow();
            row.ItemArray = obj;
            dt.Rows.Add(row);
        }

        MapDict[path] = dt;

        //重新生成CSV文件
        CreateCSV(path, dt);
    }
示例#4
0
 /// <summary>
 /// 清除单个文件
 /// </summary>
 /// <param name="Path"></param>
 public void Clearn(string Path)
 {
     Path = Application.streamingAssetsPath + "/" + Path;
     if (MapDict.ContainsKey(Path))
     {
         MapDict[Path].Clear();
         MapDict.Remove(Path);
     }
     if (IDList.ContainsKey(Path))
     {
         IDList[Path].Clear();
         IDList.Remove(Path);
     }
 }
示例#5
0
    /// <summary>
    /// 删除一行
    /// </summary>
    /// <returns>是否删除成功</returns>
    public string DeleteOneLine(string path, int id)
    {
        path = Application.streamingAssetsPath + "/" + path;
        init(path);
        DataTable dt;

        if (MapDict.ContainsKey(path))
        {
            dt = MapDict[path];

            MapDict[path].Rows[GetRowNumber(path, id)].Delete();
            MapDict[path].AcceptChanges();
            CreateCSV(path, dt);

            return("文件[" + path + "],id号:" + id.ToString() + ",删除成功!!");
        }
        return("文件[" + path + "],表不存在!!");
    }
示例#6
0
 /// <summary>
 /// 全部清除
 /// </summary>
 public void ClearnAll()
 {
     MapDict.Clear();
     IDList.Clear();
 }