需要一些关于如何通过另一条路径复制模型的想法

发布于 2024-10-26 19:00:34 字数 1137 浏览 1 评论 0原文

所以我基本上是在这里寻找想法。我以前从未真正做过这样的事情,现在我有点困惑。这可能是一个很长的解释,所以请耐心等待,希望你们中的一些大师能给我一些帮助。

我有两个 MVC2 应用程序。两者都在相同的代码库中运行,但它们由两个不同的 URL(控制器)访问。因此,我通过转到访问一个

http://localhost/Extranet/mvc/StandardDeviationCones.cfc/mobile

,通过转到现在访问另一个链接

http://localhost/Extranet/mvc/Indications.cfc/home

,第二个链接是已经开发了一段时间的应用程序。您加载主页,浏览向导,到达表单,填写一堆信息等,同时代码在后台更新并填写 Model由您在前端选择的不同选项填充的一堆信息。我们构建了一个完整的事件框架,以便当您从下拉列表中选择一个选项或填写文本框时,Model 会以非常具体的方式更新、添加对象等。

只有在以这种确切的方式填充模型之后,您才能调用我们拥有的特定 Value() 方法。我尝试创建手动传入的对象的精确副本,除了我花了大约 6 个小时才完成的事实之外,它仍然没有价值,因为某处的某些属性没有按应有的方式设置。这个模型由大量的东西组成,所以很容易错过一些东西。

现在,这里的目标是能够在新应用 Mobile 上按下按钮,并让它在后台创建默认的 Model 状态和 Value () 它,这样我们就可以从结果中取回一个属性并将其显示在手机平台上。基本上是真实事物的令人难以置信的精简版本。问题是,即使我可以通过旧应用程序中的向导并创建对象的默认状态,但我无法手动创建它,因为其中有数百个属性,并且因为它都是设置的在前端使用事件框架,我真的无法说“自动设置此默认模型”,然后重视它,因为所有调用都是通过登录旧应用程序并使用大量 Session 来触发的 来调用它们的信息。

显然,我可以进入旧应用程序,通过向导,填写表单,然后单击“值”,然后逐步执行代码以获取值,查看传入的对象,然后基本上复制该对象然后完全通过手工逐个属性创建一个新的,但这似乎有点荒谬。

你们对我如何实现这一目标有什么想法吗?

多谢!

So I am basically looking for ideas here. I've never really had to do anything like this before, and I'm kinda stumped at the moment. This might be a long explanation here so bear with me, and hopefully some of you guru's can give me something to go off of.

I have two MVC2 Apps. Both run in the same code base, but they are accessed by two different URL's (controllers). So I access one by going to

http://localhost/Extranet/mvc/StandardDeviationCones.cfc/mobile

and the other by going to

http://localhost/Extranet/mvc/Indications.cfc/home

Now, the second link there is the app that has been in development for a while. You load up the home page, go through a wizard, reach a form, fill out a bunch of information, etc. and all the while the code is updating and filling out the Model in the background with a BUNCH of information that is populated by the different choices you are selecting on the front end. We have an entire eventing framework built so that as you as you select a choice from a dropdown, or fill in a textbox, the Model updates, adds objects, etc. in a very specific way.

Only after the model has been populated in this exact fashion are you able to call a certain Value() method that we have. I've tried to create an exact replica of the object passed in by hand, and besides the fact that it took me about 6 hours to do, it still didn't value because some property somewhere wasn't set the way it should be. There's a massive amount of things that make this Model up so it's very easy to miss something.

Now, the goal here is to be able to press a button on the new app, Mobile, and have it create a default Model state in the background and Value() it, so we can get one property back from the results and display it on the mobile phone platform. Basically an incredibly stripped down version of the real thing. The problem is, even though I can go through the wizard in the old app and create the default state of the object, there's no way I can create that by hand because there's hundreds of properties that go into it, and because it is all setup using the eventing framework on the front end, there's really no way I can say "auto setup this default model", and then value it, because all the calls are triggered by logging into the old app and using a lot of Session information to call them with.

Obviously I can go into the old app, go through the wizard, fill out the form, and click 'Value', and then step through the code on it's way to get valued, look at the object getting passed in, and basically copy that and then create a new one entirely by hand going property by property, but that seems a little ridiculous.

Do you guys have any ideas for how I would be able to accomplish this?

Thanks a lot!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

哭泣的笑容 2024-11-02 19:00:34

所以基本上你有一个巨大的模型,它是通过几个步骤创建的。您希望从不同的 mvc 应用程序获取该模型,而不需要对其进行硬编码复制。

在这种情况下,我要调查的是如何“模拟/伪造”主应用程序中的步骤,然后发送此模型。

简而言之,我只需将完成的所有步骤合并为 1 个操作,然后将其返回到您的移动应用程序。您可以使用 XML 序列化程序、JSON 或 Web 服务来完成此操作。然后,移动应用程序将向主应用程序发出请求,主应用程序仅执行一个操作来创建此默认模型,这在主应用程序中应该不难。

此外,这样当模型发生变化时,您的应用程序将是可维护的。

So basically you have a huge Model, which is created in several steps. And you want to get that model from a different mvc app without copying it hard-code.

what i would investigate in this case is how i could 'emulate/fake' the steps in your main app, and then send this model.

in short i'd just merge all the steps done into 1 action, and then return this to your mobile app. you could do this with XML serializer, or JSON, or a web service. the mobile app would then make a request to the main app, which has an action solely to make this default model, which should be not that hard in the main app.

also, this way your app will be maintainable, when something changes in the model.

别在捏我脸啦 2024-11-02 19:00:34

听起来您继承了一些非常糟糕的代码:)

由于两个应用程序都在同一代码库中运行,因此如何手动创建向导中涉及的 MVC 控制器并调用您需要为其创建默认状态的必要操作方法模型

您需要模拟一些会话和 HTTP 上下文对象,这很困难,但听起来可能比尝试直接模拟模型更容易。

Sounds like you've inherited some truly awful code :)

Since both apps are running in the same code-base, how about manually creating the MVC controllers involved in the wizard and calling the necessary action methods that you need to create a default state for the Model?

You would need to mock some of the session and HTTP context objects, which is difficult but it sounds like it might be easier than trying to mock the model directly.

许你一世情深 2024-11-02 19:00:34

您可以尝试使用 System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
在向导之后序列化模型并在移动应用程序中反序列化模型。

You could try to use System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
to serialize the model after the wizard en deserialize the model in the mobile app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文