.NET中单向同步的可扩展解决方案有哪些?(What are the extensible solutions for one-way sync in .NET?)
我有一个项目,除了用户输入的数据外,我还有外部数据源:
- SQL Server
- 网页服务
在这两种情况下,我都不必跟踪更改,获取所有数据,然后只需将其合并即可。 外部数据无法在应用程序中编辑(仅参考),因此这里的合并意味着只需防止复制。
作为开发人员,我希望能够定义转换规则,以便它们是可扩展的,可测试的并且可以重用业务规则/逻辑。 作为管理员,我需要能够定义同步计划并轻松查看同步日志/状态。
是否有现成的解决方案可以解决所有这些问题?
I've a project where in addition to user-entered data I'll have external data sources:
- SQL Server
- Web Services
In both cases I do not have to track changes, getting all data and then just merging it is ok. The external data can't be edited within the application (only referenced), so merging here means just duplication prevention.
As a developer I want to be able to define transformation rules so that they are extensible, testable and can reuse business rules/logic. As an admin, I need an ability to define the sync schedule and easily see sync log/status.
Is there an existing solution that takes care of all that?
原文:https://stackoverflow.com/questions/5600460
最满意答案
您没有正确使用
$.each()
。 尝试这个:$ .each($('[id $ =“ - subtotal”]'),function(key,element){subtotal = some_math;
id = some_ID_Number; data ['id-'+ String(id)] = subtotal});
- 您应该将
data
声明为对象,而不是数组。 数组只能有数字键。 对象可以包含包含其他字符的键。 如果是console.log(data)
您将看到数据如果是对象则将包含数据,如果初始化为数组,则将为空。 所以试试这个:var data = {}; $.each($('*'), function() { subtotal = Math.random() * 100; id = Math.random() * 100; data['id-' + String(id)] = subtotal }); console.log(data);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
You are not using
$.each()
correctly. Try this:$.each($('[id$="-subtotal"]'), function (key, element) { subtotal = some_math;
id = some_ID_Number; data['id-' + String(id)] = subtotal });
- You should declare
data
as an object, not an array. An array can only have numeric keys. An object can have keys that contain other characters. If youconsole.log(data)
you will see thatdata
will contain data if it's an object, and will be empty if initialized as an array. So try this:var data = {}; $.each($('*'), function() { subtotal = Math.random() * 100; id = Math.random() * 100; data['id-' + String(id)] = subtotal }); console.log(data);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
相关问答
更多-
通过本地客户端程序获取服务器mysql数据库信息[2023-04-27]
ajax -
使用AJAX检索发送到控制器操作的数据(关联数组)(Retrieve data (associative array) sent to controller's action with AJAX)[2021-05-10]
您的代码至少存在一个问题: dataType不是您要发送到服务器的类型,而是您期望从服务器返回的内容。 您必须指定contentType才能让服务器知道您要向其发送的数据类型: contentType: "application/json; charset=utf-8" 此外,你可能需要改变 data: { fieldsEdited: JSON.stringify(fieldsEdited) }, 至 data: JSON.stringify(fieldsEdited), 甚至只是为了 data: f ... -
关联数组将成为json_encode的javascript对象 正常数组如数组(1,2,3)== json_encode ==> [1,2,3] 关联数组,如数组('name'=> 1,'name2'=> 2)== json_encode ==> {name:1,name2:2} 所以结果[index]将不再起作用。 最好的方法是发送一个包含两个数组的Object: PHP: array( 'classes' => array('name1','name2') , 'ids' => array(1,2)); ...
-
为了确保您在php端获得正确值的正确数字键,我认为您将不得不通过正则表达式提取输入的名称并手动分配。 例如,在每个循环内: var parsedName = this.name.match(/^my_array\[(\d+)\]\[(.*)\]$/); my_array[parsedName[1]] = my_array[parsedName[1]] || {}; my_array[parsedName[1]][parsedName[2]] = $(this).val(); To ensure you g ...
-
您的警告可以在JavaScript中构建如下: var warnings = { warning1: { id: 1, type: 'info' }, warning2: { id: 2, type: 'danger' } } 然后将warnings对象作为JSON发送到PHP中的服务器。 您可以像这样解析它: $json = json_decode(filter_input(INPUT_POST, 'w ...
-
你会想要一个对象数组(JS没有关联数组) var products = $(".product-name a").map(function() { return { name: $(this).text() } }).get(); .map参考: http : //api.jquery.com/jquery.map/ You would want an array of objects (JS doesn't have associative arrays) var products = $(". ...
-
您没有正确使用$.each() 。 尝试这个: $ .each($('[id $ =“ - subtotal”]'),function(key,element){subtotal = some_math; id = some_ID_Number; data ['id-'+ String(id)] = subtotal}); 您应该将data声明为对象,而不是数组。 数组只能有数字键。 对象可以包含包含其他字符的键。 如果是console.log(data)您将看到数据如果是对象则将包含数据,如果初始化为数组 ...
-
您应该异步获取数据,并确保在您决定对返回的数据执行某些操作时完成ajax函数: function getSelectedDates(lead_id, month) { return $.ajax({ url: window.location.href, dataType: 'json', data: { gf_lm_ajax: 1, get: 'lead_reminder_get_dates', ...
-
传递关联的对象数组(Pass associative array of objects)[2022-05-10]
我解决了它将关联数组转换为非关联数组: function NormalizeItemsArray() { var result = new Array(); for (var i in items) { i = items[i]; var item = new Item(); item.ItemId = i.ItemId; item.Title = i.Title; item.Questions = new A ... -
如果使用JSON.stringify(guests)工作,为什么不将它与其他不需要字符串化的参数组合成另一个JSON对象? data = { "id": 10, "Guests": JSON.stringify(guests) }; 或者,您可以构造一个javascript对象,将它们组合在一起并调用stringify。 If using JSON.stringify(guests) works, why not combine it into another JSON object with your ...