C#.Net保存关键数据 [英] C#.Net Saving Critical Data

查看:63
本文介绍了C#.Net保存关键数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

我们有一个客户端应用程序,当它无法连接到服务器时,它会将忙碌的事务"存储在XML平面文件中.

然后,在恢复通信之后,事务"将从文件中拉出,并转发到服务器进行处理.

我的问题是这样的:
如果文件编写器失败或其他原因出错.保存这些关键数据的最佳方法是什么?
-------------------------------------------------- ----------------------

好的太棒了.我有一种用于创建事件的方法,但它似乎需要管理员权限.有什么办法解决吗?

Hi all.

We have an client application, that when it fails to connect to the server, it stores the "transaction" it was busy with in an XML flat file.

Then later when communication is restored the "transaction" gets pulled out of the file and forwarded to the server for processing.

My question is this:
If the File Writer Fails or something else goes wrong. What is the best way to save this critical data?
------------------------------------------------------------------------

Ok Great. I have a method that i use to create an event, but it seems to require admin permissions. Is there any way around this?

public static void writeEvent(string Source, string Log, string Event)
        {
            if (!EventLog.SourceExists(Source))
            {
                EventLog.CreateEventSource(Source, Log);
            }
            EventLog.WriteEntry(Source, Event, EventLogEntryType.Error);
        }



我这样称呼:



I call it like this:

EventComms.writeEvent("kioskApp", "Application",msg);


-------------------------------------------------- ----------------------
如果您使用的源不存在,则需要管理员权限,因此我只是在使用已存在的源.


------------------------------------------------------------------------
The admin permissions were required if you use a source that doesn''t exist, so I''m just using a source that already exists.

推荐答案

首先,我不会等待失败.在开始处理之前,我会将当前事务写入文件.更好的是,我会将每个目标记录在某个地方的数据库中.这样,您可以从数据库中最近的失败/未完成事务中取出,然后从那里开始.

如果不了解您的系统架构和流程的更多信息,我们就无法对您的故障转移机制进行第二次猜测.
First, I wouldn''t wait for a failure. I would write the current transaction to a file BEFORE starting to process it. Even better, I would log EVERY tarnsaction in a database somewhere. That way, you can just pick up at the most recent failed/incomplete transaction in the database, and go from there.

Without knowing more about your system architecture and processes, it''s impossible for us to second-guess your fail-over mechanisms.


我认为您可以将错误记录在Windows事件日志中
I think you can log the the error in Windows Event Log


这篇关于C#.Net保存关键数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆