예제 #1
0
        /// <summary>
        /// 解析url
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        private List <TzTableValue> GetSyncData(string str)
        {
            if (string.IsNullOrEmpty(str))
            {
                return(null);
            }
            //表集合
            var tables = str.Split(']');
            List <TzTableValue> tztables = new List <TzTableValue>();

            foreach (var table in tables)
            {
                if (string.IsNullOrEmpty(table.Trim()))
                {
                    break;
                }
                TzTableValue ttv        = new TzTableValue();
                var          tableIndex = table.IndexOf('?');
                //表名
                var tableName      = table.Substring(0, tableIndex);
                var keyValuesIndex = tableIndex + 1;
                //键值对字符串
                var keyValues = table.Substring(keyValuesIndex, table.Length - keyValuesIndex);
                //键值对
                var             cloums = keyValues.Split(';');
                List <KeyValue> kvList = new List <KeyValue>();
                foreach (var cloum in cloums)
                {
                    if (string.IsNullOrEmpty(cloum.Trim()))
                    {
                        break;
                    }
                    var cloumIndex      = cloum.IndexOf(':');
                    var cloumName       = cloum.Substring(0, cloumIndex);
                    var cloumValueIndex = cloumIndex + 1;
                    var cloumValue      = cloum.Substring(cloumValueIndex, cloum.Length - cloumValueIndex);

                    KeyValue kv = new KeyValue
                    {
                        cloumName  = cloumName,
                        cloumValue = cloumValue
                    };
                    kvList.Add(kv);
                }
                ttv.Values    = kvList;
                ttv.TableName = tableName;
                tztables.Add(ttv);
            }
            return(tztables);
        }
예제 #2
0
        private List <string> SyncDataToModel(TzTableValue field, DBEntity entity)
        {
            List <string> syncFailedFields = new List <string>();

            foreach (var value in field.Values)
            {
                bool isModify = GenerateHelper.CopyDataToModel(value.cloumName, value.cloumValue, entity);
                if (isModify)
                {
                    if (entity.EntityState == EntityState.None)
                    {
                        entity.EntityState = EntityState.Update;
                    }
                    DBManager.Instance.Update(entity);
                }
                else
                {
                    syncFailedFields.Add(value.cloumName);
                }
            }
            return(syncFailedFields);
        }