コード例 #1
0
        public override Task DoWork(CodeFileBuilder pCodeFileBuilder, ISheetConnector pConnector, TypeData[] arrSheetData, Action <string> OnPrintWorkProcess)
        {
            //TypeDataList pTypeDataList = JsonSaveManager.LoadData<TypeDataList>($"{GetRelative_To_AbsolutePath(strExportPath)}/{nameof(TypeDataList)}.json", OnPrintWorkProcess);
            //if (pTypeDataList == null)
            //    pTypeDataList = new TypeDataList(pConnector.strSheetID);

            // 로컬 데이터에 있는 TypeData와 현재 TypeData가 일치하지 않음.
            // 무조건 현재 TypeData기준으로 작업하기
            TypeDataList pTypeDataList = new TypeDataList(pConnector.strSheetID);

            pTypeDataList.listTypeData = arrSheetData.ToList();

            List <Task> listTask = new List <Task>();

            foreach (var pSheet in arrSheetData)
            {
                if (pSheet.eType == ESheetType.Enum)
                {
                    continue;
                }

                listTask.Add(ProcessJson(pConnector, OnPrintWorkProcess, pSheet, pTypeDataList));
            }

            Task.WaitAll(listTask.ToArray(), new TimeSpan(3000));

            return(Task.Run(() =>
            {
                pTypeDataList.listTypeData.Sort((x, y) => x.iOrder.CompareTo(y.iOrder));
                JsonSaveManager.SaveData(pTypeDataList, $"{GetRelative_To_AbsolutePath(strExportPath)}/{nameof(TypeDataList)}.json");
            }));
        }
コード例 #2
0
        public static Dictionary <string, SaveData_SpreadSheet> LoadSheet(Action <string> OnError)
        {
            Dictionary <string, SaveData_SpreadSheet> mapSaveSheet = new Dictionary <string, SaveData_SpreadSheet>();
            List <SaveData_SpreadSheet> listSheet = JsonSaveManager.LoadData_List <SaveData_SpreadSheet>(const_strSaveFolderPath, OnError);

            for (int i = 0; i < listSheet.Count; i++)
            {
                var pData = listSheet[i];
                if (string.IsNullOrEmpty(pData.strSheetID))
                {
                    continue;
                }

                if (mapSaveSheet.ContainsKey(pData.strSheetID))
                {
                    SaveData_SpreadSheet pSheetAlreadyAdded = mapSaveSheet[pData.strSheetID];
                    if (pSheetAlreadyAdded.date_LastEdit < pData.date_LastEdit)
                    {
                        mapSaveSheet[pData.strSheetID] = pData;
                    }
                }
                else
                {
                    mapSaveSheet.Add(pData.strSheetID, pData);
                }
            }

            return(mapSaveSheet);
        }
コード例 #3
0
        public static Config LoadConfig()
        {
            List <Config> listConfig = JsonSaveManager.LoadData_List <Config>(const_strSaveFolderPath);

            if (listConfig.Count > 0)
            {
                return(listConfig[0]);
            }
            else
            {
                return(new Config());
            }
        }
コード例 #4
0
        public override void DoWork(CodeFileBuilder pCodeFileBuilder, SpreadSheetConnector pConnector, IEnumerable <TypeData> listSheetData, Action <string> OnPrintWorkProcess)
        {
            TypeDataList pTypeDataList = new TypeDataList(pConnector.strFileName);

            foreach (var pSheet in listSheetData)
            {
                if (pSheet.eType == ESheetType.Enum)
                {
                    continue;
                }

                JObject pJson_Instance = new JObject();
                JArray  pArray         = new JArray();

                Dictionary <string, FieldTypeData> mapFieldData  = pSheet.listFieldData.Where(p => p.bIsVirtualField == false).ToDictionary(p => p.strFieldName);
                Dictionary <int, string>           mapMemberName = new Dictionary <int, string>();
                Dictionary <int, string>           mapMemberType = new Dictionary <int, string>();
                int iColumnStartIndex = -1;

                pSheet.ParsingSheet(pConnector,
                                    ((IList <object> listRow, string strText, int iRowIndex, int iColumnIndex) =>
                {
                    if (strText.Contains(':')) // 변수 타입 파싱
                    {
                        if (mapMemberName.ContainsKey(iColumnIndex))
                        {
                            return;
                        }

                        string[] arrText = strText.Split(':');
                        mapMemberName.Add(iColumnIndex, arrText[0]);
                        mapMemberType.Add(iColumnIndex, arrText[1]);

                        if (iColumnStartIndex == -1)
                        {
                            iColumnStartIndex = iColumnIndex;
                        }

                        return;
                    }

                    if (iColumnIndex != iColumnStartIndex)
                    {
                        return;
                    }

                    JObject pObject = new JObject();

                    // 실제 변수값
                    for (int i = iColumnIndex; i < listRow.Count; i++)
                    {
                        if (mapMemberName.ContainsKey(i))
                        {
                            if (mapFieldData.TryGetValue(mapMemberName[i], out var pFieldTypeData) == false)
                            {
                                OnPrintWorkProcess?.Invoke($"{pSheet.strSheetName} - mapFieldData.ContainsKey({mapMemberName[i]}) Fail");
                                continue;
                            }

                            string strFieldName = pFieldTypeData.strFieldName;
                            string strValue = (string)listRow[i];
                            pObject.Add(strFieldName, strValue);
                        }
                    }

                    pArray.Add(pObject);
                }));

                if (pArray.Count == 0)
                {
                    continue;
                }

                pJson_Instance.Add("array", pArray);

                string strFileName = $"{pSheet.strFileName}.json";
                JsonSaveManager.SaveData(pJson_Instance, $"{GetRelative_To_AbsolutePath(strExportPath)}/{strFileName}");

                pTypeDataList.listTypeData.Add(pSheet);
            }

#if !UNITY_EDITOR
            JsonSaveManager.SaveData(pTypeDataList, $"{GetRelative_To_AbsolutePath(strExportPath)}/{nameof(TypeDataList)}.json");
#endif
        }
コード例 #5
0
 public static void SaveSheet_Async(SaveData_SpreadSheet pSheet, Action <bool> OnFinishAsync)
 {
     JsonSaveManager.SaveData_Async(pSheet, GetFilePath(pSheet.GetFileName()), OnFinishAsync);
 }
コード例 #6
0
 public static void SaveSheet(SaveData_SpreadSheet pSheet)
 {
     JsonSaveManager.SaveData(pSheet, GetFilePath(pSheet.GetFileName()));
 }
コード例 #7
0
 public static void SaveConfig_Async(Config pData, Action <bool> OnFinishAsync)
 {
     JsonSaveManager.SaveData_Async(pData, GetFilePath("Config"), OnFinishAsync);
 }
コード例 #8
0
 public static void SaveConfig(Config pData)
 {
     JsonSaveManager.SaveData(pData, GetFilePath("Config"));
 }
コード例 #9
0
 public static void SaveConfig(string strFilePath, object pData)
 {
     JsonSaveManager.SaveData(pData, GetFilePath(strFilePath));
 }
コード例 #10
0
        private Task ProcessJson(ISheetConnector pConnector, Action <string> OnPrintWorkProcess, TypeData pSheet,
                                 TypeDataList pTypeDataList)
        {
            JObject pJson_Instance = new JObject();
            JArray  pArray         = new JArray();

            Dictionary <string, FieldTypeData> mapFieldData  = pSheet.listFieldData.Where(p => p.bIsVirtualField == false).ToDictionary(p => p.strFieldName);
            Dictionary <int, string>           mapMemberName = new Dictionary <int, string>();
            int iColumnStartIndex = -1;

            return(pSheet.ParsingSheet_UseTask(pConnector,
                                               ((listRow, strText, iRowIndex, iColumnIndex) =>
            {
                if (strText.Contains(':'))     // 변수 타입 파싱
                {
                    if (mapMemberName.ContainsKey(iColumnIndex))
                    {
                        return;
                    }

                    string[] arrText = strText.Split(':');
                    mapMemberName.Add(iColumnIndex, arrText[0]);
                    // mapMemberType.Add(iColumnIndex, arrText[1]);

                    if (iColumnStartIndex == -1)
                    {
                        iColumnStartIndex = iColumnIndex;
                    }

                    return;
                }

                if (iColumnIndex != iColumnStartIndex)
                {
                    return;
                }

                JObject pObject = new JObject();

                // 실제 변수값
                for (int i = iColumnIndex; i < listRow.Count; i++)
                {
                    if (mapMemberName.ContainsKey(i) == false)
                    {
                        continue;
                    }

                    if (mapFieldData.TryGetValue(mapMemberName[i], out FieldTypeData pFieldTypeData) == false)
                    {
                        OnPrintWorkProcess?.Invoke($"{pSheet.strSheetName}({pSheet.strSheetID}) - mapFieldData.ContainsKey({mapMemberName[i]}) Fail");
                        continue;
                    }

                    string strFieldName = pFieldTypeData.strFieldName;
                    string strValue = (string)listRow[i];
                    pObject.Add(strFieldName, strValue);
                }

                pArray.Add(pObject);
            })).ContinueWith((pTask) =>
            {
                pJson_Instance.Add("array", pArray);

                string strFileName = $"{pSheet.strFileName}.json";
                JsonSaveManager.SaveData(pJson_Instance, $"{GetRelative_To_AbsolutePath(strExportPath)}/{strFileName}");

                var pAlreadyExist = pTypeDataList.listTypeData.FirstOrDefault(p => p.strSheetID == pSheet.strSheetID);
                if (pAlreadyExist != null)
                {
                    pTypeDataList.listTypeData.Remove(pAlreadyExist);
                }

                pTypeDataList.listTypeData.Add(pSheet);
            }));
        }