我现在写了一个流程的代码,流程中包括很多试剂,插件的目的是更新试剂的剩余量。下面是代码,希望好心人能帮我改一下,谢谢。
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.SdkTypeProxy;
using MyCrmService = DNAPlugin.CrmSdk;
namespace DNAPlugin
{
public class CreateDNAPlugin : IPlugin
{
// <summary>
// Plug-in for Creating DNA, update the Total Number
// field for
// </summary>
public void Execute(IPluginExecutionContext context)
{
// Create the task on the Microsoft CRM server.
MyCrmService.CrmService crmService = GetCrmService();
// Check if the input parameters property bag contains a target
// of type DynamicEntity.
if (context.MessageName == "Create")
{
DynamicEntity entity = null;
if (context.InputParameters.Properties.Contains("Target") && context.InputParameters.Properties["Target"] is DynamicEntity)
{
// Obtain the target business entity from the input parameters.
entity = (DynamicEntity)context.InputParameters.Properties["Target"];
// Verify that the entity represents a DNA.
if (context.PrimaryEntityName == MyCrmService.EntityName.new_dna.ToString())
{
//Number for the DNA
CrmFloat DNANumber1 = entity.Properties["new_usageamount1"] as CrmFloat;
CrmFloat DNANumber2 = entity.Properties["new_usageamount2"] as CrmFloat;
CrmFloat DNANumber3 = entity.Properties["new_usageamount3"] as CrmFloat;
CrmFloat DNANumber4 = entity.Properties["new_usageamount4"] as CrmFloat;
CrmFloat DNANumber5 = entity.Properties["new_usageamount5"] as CrmFloat;
CrmFloat DNANumber6 = entity.Properties["new_usageamount6"] as CrmFloat;
CrmFloat DNANumber7 = entity.Properties["new_usageamount7"] as CrmFloat;
CrmFloat DNANumber8 = entity.Properties["new_usageamount8"] as CrmFloat;
CrmFloat DNANumber9 = entity.Properties["new_usageamount9"] as CrmFloat;
CrmFloat DNANumber10 = entity.Properties["new_usageamount10"] as CrmFloat;
CrmFloat DNANumber11 = entity.Properties["new_usageamount11"] as CrmFloat;
CrmFloat DNANumber12 = entity.Properties["new_usageamount12"] as CrmFloat;
CrmFloat DNANumber13 = entity.Properties["new_usageamount13"] as CrmFloat;
CrmFloat DNANumber14 = entity.Properties["new_usageamount14"] as CrmFloat;
CrmFloat DNANumber15 = entity.Properties["new_usageamount15"] as CrmFloat;
CrmFloat DNANumber16 = entity.Properties["new_usageamount16"] as CrmFloat;
CrmFloat DNANumber17 = entity.Properties["new_usageamount17"] as CrmFloat;
CrmFloat DNANumber18 = entity.Properties["new_usageamount18"] as CrmFloat;
CrmFloat DNANumber19 = entity.Properties["new_usageamount19"] as CrmFloat;
CrmFloat DNANumber20 = entity.Properties["new_usageamount20"] as CrmFloat;
CrmFloat DNANumber21 = entity.Properties["new_usageamount21"] as CrmFloat;
CrmFloat DNANumber22 = entity.Properties["new_usageamount22"] as CrmFloat;
MyCrmService.new_reagent new_reagent1 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent2 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent3 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent4 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent5 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent6 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent7 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent8 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent9 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent10 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent11 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent12 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent13 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent14 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent15 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent16 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent17 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent18 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent19 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent20 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent21 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent22 = new MyCrmService.new_reagent();
MyCrmService.ColumnSet cols1 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols2 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols3 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols4 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols5 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols6 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols7 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols8 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols9 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols10 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols11 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols12 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols13 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols14 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols15 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols16 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols17 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols18 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols19 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols20 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols21 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols22 = new MyCrmService.ColumnSet();
cols1.Attributes = new string[] { "new_remainder" };
cols2.Attributes = new string[] { "new_remainder" };
cols3.Attributes = new string[] { "new_remainder" };
cols4.Attributes = new string[] { "new_remainder" };
cols5.Attributes = new string[] { "new_remainder" };
cols6.Attributes = new string[] { "new_remainder" };
cols7.Attributes = new string[] { "new_remainder" };
cols8.Attributes = new string[] { "new_remainder" };
cols9.Attributes = new string[] { "new_remainder" };
cols10.Attributes = new string[] { "new_remainder" };
cols11.Attributes = new string[] { "new_remainder" };
cols12.Attributes = new string[] { "new_remainder" };
cols13.Attributes = new string[] { "new_remainder" };
cols14.Attributes = new string[] { "new_remainder" };
cols15.Attributes = new string[] { "new_remainder" };
cols16.Attributes = new string[] { "new_remainder" };
cols17.Attributes = new string[] { "new_remainder" };
cols18.Attributes = new string[] { "new_remainder" };
cols19.Attributes = new string[] { "new_remainder" };
cols20.Attributes = new string[] { "new_remainder" };
cols21.Attributes = new string[] { "new_remainder" };
cols22.Attributes = new string[] { "new_remainder" };
Guid new_nameid1 = ((Lookup)entity.Properties["new_nameid1"]).Value;
Guid new_nameid2 = ((Lookup)entity.Properties["new_nameid2"]).Value;
Guid new_nameid3 = ((Lookup)entity.Properties["new_nameid3"]).Value;
Guid new_nameid4 = ((Lookup)entity.Properties["new_nameid4"]).Value;
Guid new_nameid5 = ((Lookup)entity.Properties["new_nameid5"]).Value;
Guid new_nameid6 = ((Lookup)entity.Properties["new_nameid6"]).Value;
Guid new_nameid7 = ((Lookup)entity.Properties["new_nameid7"]).Value;
Guid new_nameid8 = ((Lookup)entity.Properties["new_nameid8"]).Value;
Guid new_nameid9 = ((Lookup)entity.Properties["new_nameid9"]).Value;
Guid new_nameid10 = ((Lookup)entity.Properties["new_nameid10"]).Value;
Guid new_nameid11 = ((Lookup)entity.Properties["new_nameid11"]).Value;
Guid new_nameid12 = ((Lookup)entity.Properties["new_nameid12"]).Value;
Guid new_nameid13 = ((Lookup)entity.Properties["new_nameid13"]).Value;
Guid new_nameid14 = ((Lookup)entity.Properties["new_nameid14"]).Value;
Guid new_nameid15 = ((Lookup)entity.Properties["new_nameid15"]).Value;
Guid new_nameid16 = ((Lookup)entity.Properties["new_nameid16"]).Value;
Guid new_nameid17 = ((Lookup)entity.Properties["new_nameid17"]).Value;
Guid new_nameid18 = ((Lookup)entity.Properties["new_nameid18"]).Value;
Guid new_nameid19 = ((Lookup)entity.Properties["new_nameid19"]).Value;
Guid new_nameid20 = ((Lookup)entity.Properties["new_nameid20"]).Value;
Guid new_nameid21 = ((Lookup)entity.Properties["new_nameid21"]).Value;
Guid new_nameid22 = ((Lookup)entity.Properties["new_nameid22"]).Value;
new_reagent1 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid1, cols1) as MyCrmService.new_reagent;
new_reagent2 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid2, cols2) as MyCrmService.new_reagent;
new_reagent3 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid3, cols3) as MyCrmService.new_reagent;
new_reagent4 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid4, cols4) as MyCrmService.new_reagent;
new_reagent5 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid5, cols5) as MyCrmService.new_reagent;
new_reagent6 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid6, cols6) as MyCrmService.new_reagent;
new_reagent7 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid7, cols7) as MyCrmService.new_reagent;
new_reagent8 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid8, cols8) as MyCrmService.new_reagent;
new_reagent9 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid9, cols9) as MyCrmService.new_reagent;
new_reagent10 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid10, cols10) as MyCrmService.new_reagent;
new_reagent11 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid11, cols11) as MyCrmService.new_reagent;
new_reagent12 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid12, cols12) as MyCrmService.new_reagent;
new_reagent13 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid13, cols13) as MyCrmService.new_reagent;
new_reagent14 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid14, cols14) as MyCrmService.new_reagent;
new_reagent15 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid15, cols15) as MyCrmService.new_reagent;
new_reagent16 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid16, cols16) as MyCrmService.new_reagent;
new_reagent17 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid17, cols17) as MyCrmService.new_reagent;
new_reagent18 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid18, cols18) as MyCrmService.new_reagent;
new_reagent19 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid19, cols19) as MyCrmService.new_reagent;
new_reagent20 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid20, cols20) as MyCrmService.new_reagent;
new_reagent21 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid21, cols21) as MyCrmService.new_reagent;
new_reagent22 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid22, cols22) as MyCrmService.new_reagent;
// Update the Contract Total
if (new_reagent1.new_remainder == null)
{
new_reagent1.new_remainder = new MyCrmService.CrmFloat();
new_reagent1.new_remainder.Value = 0;
}
if (new_reagent2.new_remainder == null)
{
new_reagent2.new_remainder = new MyCrmService.CrmFloat();
new_reagent2.new_remainder.Value = 0;
}
if (new_reagent3.new_remainder == null)
{
new_reagent3.new_remainder = new MyCrmService.CrmFloat();
new_reagent3.new_remainder.Value = 0;
}
if (new_reagent4.new_remainder == null)
{
new_reagent4.new_remainder = new MyCrmService.CrmFloat();
new_reagent4.new_remainder.Value = 0;
}
if (new_reagent5.new_remainder == null)
{
new_reagent5.new_remainder = new MyCrmService.CrmFloat();
new_reagent5.new_remainder.Value = 0;
}
if (new_reagent6.new_remainder == null)
{
new_reagent6.new_remainder = new MyCrmService.CrmFloat();
new_reagent6.new_remainder.Value = 0;
}
if (new_reagent7.new_remainder == null)
{
new_reagent7.new_remainder = new MyCrmService.CrmFloat();
new_reagent7.new_remainder.Value = 0;
}
if (new_reagent8.new_remainder == null)
{
new_reagent8.new_remainder = new MyCrmService.CrmFloat();
new_reagent8.new_remainder.Value = 0;
}
if (new_reagent9.new_remainder == null)
{
new_reagent9.new_remainder = new MyCrmService.CrmFloat();
new_reagent9.new_remainder.Value = 0;
}
if (new_reagent10.new_remainder == null)
{
new_reagent10.new_remainder = new MyCrmService.CrmFloat();
new_reagent10.new_remainder.Value = 0;
}
if (new_reagent11.new_remainder == null)
{
new_reagent11.new_remainder = new MyCrmService.CrmFloat();
new_reagent11.new_remainder.Value = 0;
}
if (new_reagent12.new_remainder == null)
{
new_reagent12.new_remainder = new MyCrmService.CrmFloat();
new_reagent12.new_remainder.Value = 0;
}
if (new_reagent13.new_remainder == null)
{
new_reagent13.new_remainder = new MyCrmService.CrmFloat();
new_reagent13.new_remainder.Value = 0;
}
if (new_reagent14.new_remainder == null)
{
new_reagent14.new_remainder = new MyCrmService.CrmFloat();
new_reagent14.new_remainder.Value = 0;
}
if (new_reagent15.new_remainder == null)
{
new_reagent15.new_remainder = new MyCrmService.CrmFloat();
new_reagent15.new_remainder.Value = 0;
}
if (new_reagent16.new_remainder == null)
{
new_reagent16.new_remainder = new MyCrmService.CrmFloat();
new_reagent16.new_remainder.Value = 0;
}
if (new_reagent17.new_remainder == null)
{
new_reagent17.new_remainder = new MyCrmService.CrmFloat();
new_reagent17.new_remainder.Value = 0;
}
if (new_reagent18.new_remainder == null)
{
new_reagent18.new_remainder = new MyCrmService.CrmFloat();
new_reagent18.new_remainder.Value = 0;
}
if (new_reagent19.new_remainder == null)
{
new_reagent19.new_remainder = new MyCrmService.CrmFloat();
new_reagent19.new_remainder.Value = 0;
}
if (new_reagent20.new_remainder == null)
{
new_reagent20.new_remainder = new MyCrmService.CrmFloat();
new_reagent20.new_remainder.Value = 0;
}
if (new_reagent21.new_remainder == null)
{
new_reagent21.new_remainder = new MyCrmService.CrmFloat();
new_reagent21.new_remainder.Value = 0;
}
if (new_reagent22.new_remainder == null)
{
new_reagent22.new_remainder = new MyCrmService.CrmFloat();
new_reagent22.new_remainder.Value = 0;
}
double new_remainder1 = new_reagent1.new_remainder.Value - DNANumber1.Value;
double new_remainder2 = new_reagent2.new_remainder.Value - DNANumber2.Value;
double new_remainder3 = new_reagent3.new_remainder.Value - DNANumber3.Value;
double new_remainder4 = new_reagent4.new_remainder.Value - DNANumber4.Value;
double new_remainder5 = new_reagent5.new_remainder.Value - DNANumber5.Value;
double new_remainder6 = new_reagent6.new_remainder.Value - DNANumber6.Value;
double new_remainder7 = new_reagent7.new_remainder.Value - DNANumber7.Value;
double new_remainder8 = new_reagent8.new_remainder.Value - DNANumber8.Value;
double new_remainder9 = new_reagent9.new_remainder.Value - DNANumber9.Value;
double new_remainder10 = new_reagent10.new_remainder.Value - DNANumber10.Value;
double new_remainder11 = new_reagent11.new_remainder.Value - DNANumber11.Value;
double new_remainder12 = new_reagent12.new_remainder.Value - DNANumber12.Value;
double new_remainder13 = new_reagent13.new_remainder.Value - DNANumber13.Value;
double new_remainder14 = new_reagent14.new_remainder.Value - DNANumber14.Value;
double new_remainder15 = new_reagent15.new_remainder.Value - DNANumber15.Value;
double new_remainder16 = new_reagent16.new_remainder.Value - DNANumber16.Value;
double new_remainder17 = new_reagent17.new_remainder.Value - DNANumber17.Value;
double new_remainder18 = new_reagent18.new_remainder.Value - DNANumber18.Value;
double new_remainder19 = new_reagent19.new_remainder.Value - DNANumber19.Value;
double new_remainder20 = new_reagent20.new_remainder.Value - DNANumber20.Value;
double new_remainder21 = new_reagent21.new_remainder.Value - DNANumber21.Value;
double new_remainder22 = new_reagent22.new_remainder.Value - DNANumber22.Value;
if (new_remainder1 < 0)
{
new_remainder1 = 0;
}
new_reagent1.new_remainder.Value = new_remainder1;
crmService.Update(new_reagent1);
if (new_remainder2 < 0)
{
new_remainder2 = 0;
}
new_reagent2.new_remainder.Value = new_remainder2;
crmService.Update(new_reagent2);
if (new_remainder3 < 0)
{
new_remainder3 = 0;
}
new_reagent3.new_remainder.Value = new_remainder3;
crmService.Update(new_reagent3);
if (new_remainder4 < 0)
{
new_remainder4 = 0;
}
new_reagent4.new_remainder.Value = new_remainder4;
crmService.Update(new_reagent4);
if (new_remainder5 < 0)
{
new_remainder5 = 0;
}
new_reagent5.new_remainder.Value = new_remainder5;
crmService.Update(new_reagent5);
if (new_remainder6 < 0)
{
new_remainder6 = 0;
}
new_reagent6.new_remainder.Value = new_remainder6;
crmService.Update(new_reagent6);
if (new_remainder7 < 0)
{
new_remainder7 = 0;
}
new_reagent7.new_remainder.Value = new_remainder7;
crmService.Update(new_reagent7);
if (new_remainder8 < 0)
{
new_remainder8 = 0;
}
new_reagent8.new_remainder.Value = new_remainder8;
crmService.Update(new_reagent8);
if (new_remainder9 < 0)
{
new_remainder9 = 0;
}
new_reagent9.new_remainder.Value = new_remainder9;
crmService.Update(new_reagent9);
if (new_remainder10 < 0)
{
new_remainder10 = 0;
}
new_reagent10.new_remainder.Value = new_remainder10;
crmService.Update(new_reagent10);
if (new_remainder11 < 0)
{
new_remainder11 = 0;
}
new_reagent11.new_remainder.Value = new_remainder11;
crmService.Update(new_reagent11);
if (new_remainder12 < 0)
{
new_remainder12 = 0;
}
new_reagent12.new_remainder.Value = new_remainder12;
crmService.Update(new_reagent12);
if (new_remainder13 < 0)
{
new_remainder13 = 0;
}
new_reagent13.new_remainder.Value = new_remainder13;
crmService.Update(new_reagent13);
if (new_remainder14 < 0)
{
new_remainder14 = 0;
}
new_reagent14.new_remainder.Value = new_remainder14;
crmService.Update(new_reagent14);
if (new_remainder15 < 0)
{
new_remainder15 = 0;
}
new_reagent15.new_remainder.Value = new_remainder15;
crmService.Update(new_reagent15);
if (new_remainder16 < 0)
{
new_remainder16 = 0;
}
new_reagent16.new_remainder.Value = new_remainder16;
crmService.Update(new_reagent16);
if (new_remainder17 < 0)
{
new_remainder17 = 0;
}
new_reagent17.new_remainder.Value = new_remainder17;
crmService.Update(new_reagent17);
if (new_remainder18 < 0)
{
new_remainder18 = 0;
}
new_reagent18.new_remainder.Value = new_remainder18;
crmService.Update(new_reagent18);
if (new_remainder19 < 0)
{
new_remainder19 = 0;
}
new_reagent19.new_remainder.Value = new_remainder19;
crmService.Update(new_reagent19);
if (new_remainder20 < 0)
{
new_remainder20 = 0;
}
new_reagent20.new_remainder.Value = new_remainder20;
crmService.Update(new_reagent20);
if (new_remainder21 < 0)
{
new_remainder21 = 0;
}
new_reagent21.new_remainder.Value = new_remainder21;
crmService.Update(new_reagent21);
if (new_remainder22 < 0)
{
new_remainder22 = 0;
}
new_reagent22.new_remainder.Value = new_remainder22;
crmService.Update(new_reagent22);
}
}
}
if (context.MessageName == "Delete")
{
DynamicEntity preEntity = null;
preEntity = (DynamicEntity)context.PreEntityImages["PreImageEntity"];
// Verify that the entity represents a DNA.
if (context.PrimaryEntityName == MyCrmService.EntityName.new_dna.ToString())
{
//Numbers for the Electrophoresis
CrmFloat DNANumber1 = preEntity.Properties["new_usageamount1"] as CrmFloat;
CrmFloat DNANumber2 = preEntity.Properties["new_usageamount2"] as CrmFloat;
CrmFloat DNANumber3 = preEntity.Properties["new_usageamount3"] as CrmFloat;
CrmFloat DNANumber4 = preEntity.Properties["new_usageamount4"] as CrmFloat;
CrmFloat DNANumber5 = preEntity.Properties["new_usageamount5"] as CrmFloat;
CrmFloat DNANumber6 = preEntity.Properties["new_usageamount6"] as CrmFloat;
CrmFloat DNANumber7 = preEntity.Properties["new_usageamount7"] as CrmFloat;
CrmFloat DNANumber8 = preEntity.Properties["new_usageamount8"] as CrmFloat;
CrmFloat DNANumber9 = preEntity.Properties["new_usageamount9"] as CrmFloat;
CrmFloat DNANumber10 = preEntity.Properties["new_usageamount10"] as CrmFloat;
CrmFloat DNANumber11 = preEntity.Properties["new_usageamount11"] as CrmFloat;
CrmFloat DNANumber12 = preEntity.Properties["new_usageamount12"] as CrmFloat;
CrmFloat DNANumber13 = preEntity.Properties["new_usageamount13"] as CrmFloat;
CrmFloat DNANumber14 = preEntity.Properties["new_usageamount14"] as CrmFloat;
CrmFloat DNANumber15 = preEntity.Properties["new_usageamount15"] as CrmFloat;
CrmFloat DNANumber16 = preEntity.Properties["new_usageamount16"] as CrmFloat;
CrmFloat DNANumber17 = preEntity.Properties["new_usageamount17"] as CrmFloat;
CrmFloat DNANumber18 = preEntity.Properties["new_usageamount18"] as CrmFloat;
CrmFloat DNANumber19 = preEntity.Properties["new_usageamount19"] as CrmFloat;
CrmFloat DNANumber20 = preEntity.Properties["new_usageamount20"] as CrmFloat;
CrmFloat DNANumber21 = preEntity.Properties["new_usageamount21"] as CrmFloat;
CrmFloat DNANumber22 = preEntity.Properties["new_usageamount22"] as CrmFloat;
MyCrmService.new_reagent new_reagent1 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent2 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent3 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent4 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent5 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent6 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent7 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent8 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent9 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent10 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent11 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent12 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent13 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent14 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent15 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent16 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent17 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent18 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent19 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent20 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent21 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent22 = new MyCrmService.new_reagent();
MyCrmService.ColumnSet cols1 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols2 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols3 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols4 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols5 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols6 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols7 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols8 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols9 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols10 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols11 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols12 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols13 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols14 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols15 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols16 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols17 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols18 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols19 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols20 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols21 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols22 = new MyCrmService.ColumnSet();
cols1.Attributes = new string[] { "new_remainder" };
cols2.Attributes = new string[] { "new_remainder" };
cols3.Attributes = new string[] { "new_remainder" };
cols4.Attributes = new string[] { "new_remainder" };
cols5.Attributes = new string[] { "new_remainder" };
cols6.Attributes = new string[] { "new_remainder" };
cols7.Attributes = new string[] { "new_remainder" };
cols8.Attributes = new string[] { "new_remainder" };
cols9.Attributes = new string[] { "new_remainder" };
cols10.Attributes = new string[] { "new_remainder" };
cols11.Attributes = new string[] { "new_remainder" };
cols12.Attributes = new string[] { "new_remainder" };
cols13.Attributes = new string[] { "new_remainder" };
cols14.Attributes = new string[] { "new_remainder" };
cols15.Attributes = new string[] { "new_remainder" };
cols16.Attributes = new string[] { "new_remainder" };
cols17.Attributes = new string[] { "new_remainder" };
cols18.Attributes = new string[] { "new_remainder" };
cols19.Attributes = new string[] { "new_remainder" };
cols20.Attributes = new string[] { "new_remainder" };
cols21.Attributes = new string[] { "new_remainder" };
cols22.Attributes = new string[] { "new_remainder" };
Guid new_nameid1 = ((Lookup)preEntity.Properties["new_nameid1"]).Value;
Guid new_nameid2 = ((Lookup)preEntity.Properties["new_nameid2"]).Value;
Guid new_nameid3 = ((Lookup)preEntity.Properties["new_nameid3"]).Value;
Guid new_nameid4 = ((Lookup)preEntity.Properties["new_nameid4"]).Value;
Guid new_nameid5 = ((Lookup)preEntity.Properties["new_nameid5"]).Value;
Guid new_nameid6 = ((Lookup)preEntity.Properties["new_nameid6"]).Value;
Guid new_nameid7 = ((Lookup)preEntity.Properties["new_nameid7"]).Value;
Guid new_nameid8 = ((Lookup)preEntity.Properties["new_nameid8"]).Value;
Guid new_nameid9 = ((Lookup)preEntity.Properties["new_nameid9"]).Value;
Guid new_nameid10 = ((Lookup)preEntity.Properties["new_nameid10"]).Value;
Guid new_nameid11 = ((Lookup)preEntity.Properties["new_nameid11"]).Value;
Guid new_nameid12 = ((Lookup)preEntity.Properties["new_nameid12"]).Value;
Guid new_nameid13 = ((Lookup)preEntity.Properties["new_nameid13"]).Value;
Guid new_nameid14 = ((Lookup)preEntity.Properties["new_nameid14"]).Value;
Guid new_nameid15 = ((Lookup)preEntity.Properties["new_nameid15"]).Value;
Guid new_nameid16 = ((Lookup)preEntity.Properties["new_nameid16"]).Value;
Guid new_nameid17 = ((Lookup)preEntity.Properties["new_nameid17"]).Value;
Guid new_nameid18 = ((Lookup)preEntity.Properties["new_nameid18"]).Value;
Guid new_nameid19 = ((Lookup)preEntity.Properties["new_nameid19"]).Value;
Guid new_nameid20 = ((Lookup)preEntity.Properties["new_nameid20"]).Value;
Guid new_nameid21 = ((Lookup)preEntity.Properties["new_nameid21"]).Value;
Guid new_nameid22 = ((Lookup)preEntity.Properties["new_nameid22"]).Value;
new_reagent1 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid1, cols1) as MyCrmService.new_reagent;
new_reagent2 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid2, cols2) as MyCrmService.new_reagent;
new_reagent3 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid3, cols3) as MyCrmService.new_reagent;
new_reagent4 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid4, cols4) as MyCrmService.new_reagent;
new_reagent5 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid5, cols5) as MyCrmService.new_reagent;
new_reagent6 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid6, cols6) as MyCrmService.new_reagent;
new_reagent7 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid7, cols7) as MyCrmService.new_reagent;
new_reagent8 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid8, cols8) as MyCrmService.new_reagent;
new_reagent9 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid9, cols9) as MyCrmService.new_reagent;
new_reagent10 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid10, cols10) as MyCrmService.new_reagent;
new_reagent11 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid11, cols11) as MyCrmService.new_reagent;
new_reagent12 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid12, cols12) as MyCrmService.new_reagent;
new_reagent13 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid13, cols13) as MyCrmService.new_reagent;
new_reagent14 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid14, cols14) as MyCrmService.new_reagent;
new_reagent15 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid15, cols15) as MyCrmService.new_reagent;
new_reagent16 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid16, cols16) as MyCrmService.new_reagent;
new_reagent17 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid17, cols17) as MyCrmService.new_reagent;
new_reagent18 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid18, cols18) as MyCrmService.new_reagent;
new_reagent19 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid19, cols19) as MyCrmService.new_reagent;
new_reagent20 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid20, cols20) as MyCrmService.new_reagent;
new_reagent21 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid21, cols21) as MyCrmService.new_reagent;
new_reagent22 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid22, cols22) as MyCrmService.new_reagent;
// Update the Reagent Total Numbers
double new_remainder1 = new_reagent1.new_remainder.Value + DNANumber1.Value;
double new_remainder2 = new_reagent2.new_remainder.Value + DNANumber2.Value;
double new_remainder3 = new_reagent3.new_remainder.Value + DNANumber3.Value;
double new_remainder4 = new_reagent4.new_remainder.Value + DNANumber4.Value;
double new_remainder5 = new_reagent5.new_remainder.Value + DNANumber5.Value;
double new_remainder6 = new_reagent6.new_remainder.Value + DNANumber6.Value;
double new_remainder7 = new_reagent7.new_remainder.Value + DNANumber7.Value;
double new_remainder8 = new_reagent8.new_remainder.Value + DNANumber8.Value;
double new_remainder9 = new_reagent9.new_remainder.Value + DNANumber9.Value;
double new_remainder10 = new_reagent10.new_remainder.Value + DNANumber10.Value;
double new_remainder11 = new_reagent11.new_remainder.Value + DNANumber11.Value;
double new_remainder12 = new_reagent12.new_remainder.Value + DNANumber12.Value;
double new_remainder13 = new_reagent13.new_remainder.Value + DNANumber13.Value;
double new_remainder14 = new_reagent14.new_remainder.Value + DNANumber14.Value;
double new_remainder15 = new_reagent15.new_remainder.Value + DNANumber15.Value;
double new_remainder16 = new_reagent16.new_remainder.Value + DNANumber16.Value;
double new_remainder17 = new_reagent17.new_remainder.Value + DNANumber17.Value;
double new_remainder18 = new_reagent18.new_remainder.Value + DNANumber18.Value;
double new_remainder19 = new_reagent19.new_remainder.Value + DNANumber19.Value;
double new_remainder20 = new_reagent20.new_remainder.Value + DNANumber20.Value;
double new_remainder21 = new_reagent21.new_remainder.Value + DNANumber21.Value;
double new_remainder22 = new_reagent22.new_remainder.Value + DNANumber22.Value;
new_reagent1.new_remainder.Value = new_remainder1;
crmService.Update(new_reagent1);
new_reagent2.new_remainder.Value = new_remainder2;
crmService.Update(new_reagent2);
new_reagent3.new_remainder.Value = new_remainder3;
crmService.Update(new_reagent3);
new_reagent4.new_remainder.Value = new_remainder4;
crmService.Update(new_reagent4);
new_reagent5.new_remainder.Value = new_remainder5;
crmService.Update(new_reagent5);
new_reagent6.new_remainder.Value = new_remainder6;
crmService.Update(new_reagent6);
new_reagent7.new_remainder.Value = new_remainder7;
crmService.Update(new_reagent7);
new_reagent8.new_remainder.Value = new_remainder8;
crmService.Update(new_reagent8);
new_reagent9.new_remainder.Value = new_remainder9;
crmService.Update(new_reagent9);
new_reagent10.new_remainder.Value = new_remainder10;
crmService.Update(new_reagent10);
new_reagent11.new_remainder.Value = new_remainder11;
crmService.Update(new_reagent11);
new_reagent12.new_remainder.Value = new_remainder12;
crmService.Update(new_reagent12);
new_reagent13.new_remainder.Value = new_remainder13;
crmService.Update(new_reagent13);
new_reagent14.new_remainder.Value = new_remainder14;
crmService.Update(new_reagent14);
new_reagent15.new_remainder.Value = new_remainder15;
crmService.Update(new_reagent15);
new_reagent16.new_remainder.Value = new_remainder16;
crmService.Update(new_reagent16);
new_reagent17.new_remainder.Value = new_remainder17;
crmService.Update(new_reagent17);
new_reagent18.new_remainder.Value = new_remainder18;
crmService.Update(new_reagent18);
new_reagent19.new_remainder.Value = new_remainder19;
crmService.Update(new_reagent19);
new_reagent20.new_remainder.Value = new_remainder20;
crmService.Update(new_reagent20);
new_reagent21.new_remainder.Value = new_remainder21;
crmService.Update(new_reagent21);
new_reagent22.new_remainder.Value = new_remainder22;
crmService.Update(new_reagent22);
}
}
if (context.MessageName == "Update")
{
DynamicEntity postEntity = null;
DynamicEntity preEntity = null;
postEntity = (DynamicEntity)context.PostEntityImages["PostImageEntity"];
preEntity = (DynamicEntity)context.PreEntityImages["PreImageEntity"];
if (context.PrimaryEntityName == MyCrmService.EntityName.new_dna.ToString())
{
//Moneys for the Electrophoresis
CrmFloat preDNANumber1 = preEntity.Properties["new_usageamount1"] as CrmFloat;
CrmFloat postDNANumber1 = postEntity.Properties["new_usageamount1"] as CrmFloat;
CrmFloat preDNANumber2 = preEntity.Properties["new_usageamount2"] as CrmFloat;
CrmFloat postDNANumber2 = postEntity.Properties["new_usageamount2"] as CrmFloat;
CrmFloat preDNANumber3 = preEntity.Properties["new_usageamount3"] as CrmFloat;
CrmFloat postDNANumber3 = postEntity.Properties["new_usageamount3"] as CrmFloat;
CrmFloat preDNANumber4 = preEntity.Properties["new_usageamount4"] as CrmFloat;
CrmFloat postDNANumber4 = postEntity.Properties["new_usageamount4"] as CrmFloat;
CrmFloat preDNANumber5 = preEntity.Properties["new_usageamount5"] as CrmFloat;
CrmFloat postDNANumber5 = postEntity.Properties["new_usageamount5"] as CrmFloat;
CrmFloat preDNANumber6 = preEntity.Properties["new_usageamount6"] as CrmFloat;
CrmFloat postDNANumber6 = postEntity.Properties["new_usageamount6"] as CrmFloat;
CrmFloat preDNANumber7 = preEntity.Properties["new_usageamount7"] as CrmFloat;
CrmFloat postDNANumber7 = postEntity.Properties["new_usageamount7"] as CrmFloat;
CrmFloat preDNANumber8 = preEntity.Properties["new_usageamount8"] as CrmFloat;
CrmFloat postDNANumber8 = postEntity.Properties["new_usageamount8"] as CrmFloat;
CrmFloat preDNANumber9 = preEntity.Properties["new_usageamount9"] as CrmFloat;
CrmFloat postDNANumber9 = postEntity.Properties["new_usageamount9"] as CrmFloat;
CrmFloat preDNANumber10 = preEntity.Properties["new_usageamount10"] as CrmFloat;
CrmFloat postDNANumber10 = postEntity.Properties["new_usageamount10"] as CrmFloat;
CrmFloat preDNANumber11 = preEntity.Properties["new_usageamount11"] as CrmFloat;
CrmFloat postDNANumber11 = postEntity.Properties["new_usageamount11"] as CrmFloat;
CrmFloat preDNANumber12 = preEntity.Properties["new_usageamount12"] as CrmFloat;
CrmFloat postDNANumber12 = postEntity.Properties["new_usageamount12"] as CrmFloat;
CrmFloat preDNANumber13 = preEntity.Properties["new_usageamount13"] as CrmFloat;
CrmFloat postDNANumber13 = postEntity.Properties["new_usageamount13"] as CrmFloat;
CrmFloat preDNANumber14 = preEntity.Properties["new_usageamount14"] as CrmFloat;
CrmFloat postDNANumber14 = postEntity.Properties["new_usageamount14"] as CrmFloat;
CrmFloat preDNANumber15 = preEntity.Properties["new_usageamount15"] as CrmFloat;
CrmFloat postDNANumber15 = postEntity.Properties["new_usageamount15"] as CrmFloat;
CrmFloat preDNANumber16 = preEntity.Properties["new_usageamount16"] as CrmFloat;
CrmFloat postDNANumber16 = postEntity.Properties["new_usageamount16"] as CrmFloat;
CrmFloat preDNANumber17 = preEntity.Properties["new_usageamount17"] as CrmFloat;
CrmFloat postDNANumber17 = postEntity.Properties["new_usageamount17"] as CrmFloat;
CrmFloat preDNANumber18 = preEntity.Properties["new_usageamount18"] as CrmFloat;
CrmFloat postDNANumber18 = postEntity.Properties["new_usageamount18"] as CrmFloat;
CrmFloat preDNANumber19 = preEntity.Properties["new_usageamount19"] as CrmFloat;
CrmFloat postDNANumber19 = postEntity.Properties["new_usageamount19"] as CrmFloat;
CrmFloat preDNANumber20 = preEntity.Properties["new_usageamount20"] as CrmFloat;
CrmFloat postDNANumber20 = postEntity.Properties["new_usageamount20"] as CrmFloat;
CrmFloat preDNANumber21 = preEntity.Properties["new_usageamount21"] as CrmFloat;
CrmFloat postDNANumber21 = postEntity.Properties["new_usageamount21"] as CrmFloat;
CrmFloat preDNANumber22 = preEntity.Properties["new_usageamount22"] as CrmFloat;
CrmFloat postDNANumber22 = postEntity.Properties["new_usageamount22"] as CrmFloat;
MyCrmService.new_reagent new_reagent1 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent2 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent3 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent4 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent5 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent6 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent7 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent8 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent9 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent10 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent11 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent12 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent13 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent14 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent15 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent16 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent17 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent18 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent19 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent20 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent21 = new MyCrmService.new_reagent();
MyCrmService.new_reagent new_reagent22 = new MyCrmService.new_reagent();
MyCrmService.ColumnSet cols1 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols2 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols3 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols4 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols5 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols6 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols7 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols8 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols9 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols10 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols11 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols12 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols13 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols14 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols15 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols16 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols17 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols18 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols19 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols20 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols21 = new MyCrmService.ColumnSet();
MyCrmService.ColumnSet cols22 = new MyCrmService.ColumnSet();
cols1.Attributes = new string[] { "new_remainder" };
cols2.Attributes = new string[] { "new_remainder" };
cols3.Attributes = new string[] { "new_remainder" };
cols4.Attributes = new string[] { "new_remainder" };
cols5.Attributes = new string[] { "new_remainder" };
cols6.Attributes = new string[] { "new_remainder" };
cols7.Attributes = new string[] { "new_remainder" };
cols8.Attributes = new string[] { "new_remainder" };
cols9.Attributes = new string[] { "new_remainder" };
cols10.Attributes = new string[] { "new_remainder" };
cols11.Attributes = new string[] { "new_remainder" };
cols12.Attributes = new string[] { "new_remainder" };
cols13.Attributes = new string[] { "new_remainder" };
cols14.Attributes = new string[] { "new_remainder" };
cols15.Attributes = new string[] { "new_remainder" };
cols16.Attributes = new string[] { "new_remainder" };
cols17.Attributes = new string[] { "new_remainder" };
cols18.Attributes = new string[] { "new_remainder" };
cols19.Attributes = new string[] { "new_remainder" };
cols20.Attributes = new string[] { "new_remainder" };
cols21.Attributes = new string[] { "new_remainder" };
cols22.Attributes = new string[] { "new_remainder" };
Guid new_nameid1 = ((Lookup)preEntity.Properties["new_nameid1"]).Value;
Guid new_nameid2 = ((Lookup)preEntity.Properties["new_nameid2"]).Value;
Guid new_nameid3 = ((Lookup)preEntity.Properties["new_nameid3"]).Value;
Guid new_nameid4 = ((Lookup)preEntity.Properties["new_nameid4"]).Value;
Guid new_nameid5 = ((Lookup)preEntity.Properties["new_nameid5"]).Value;
Guid new_nameid6 = ((Lookup)preEntity.Properties["new_nameid6"]).Value;
Guid new_nameid7 = ((Lookup)preEntity.Properties["new_nameid7"]).Value;
Guid new_nameid8 = ((Lookup)preEntity.Properties["new_nameid8"]).Value;
Guid new_nameid9 = ((Lookup)preEntity.Properties["new_nameid9"]).Value;
Guid new_nameid10 = ((Lookup)preEntity.Properties["new_nameid10"]).Value;
Guid new_nameid11 = ((Lookup)preEntity.Properties["new_nameid11"]).Value;
Guid new_nameid12 = ((Lookup)preEntity.Properties["new_nameid12"]).Value;
Guid new_nameid13 = ((Lookup)preEntity.Properties["new_nameid13"]).Value;
Guid new_nameid14 = ((Lookup)preEntity.Properties["new_nameid14"]).Value;
Guid new_nameid15 = ((Lookup)preEntity.Properties["new_nameid15"]).Value;
Guid new_nameid16 = ((Lookup)preEntity.Properties["new_nameid16"]).Value;
Guid new_nameid17 = ((Lookup)preEntity.Properties["new_nameid17"]).Value;
Guid new_nameid18 = ((Lookup)preEntity.Properties["new_nameid18"]).Value;
Guid new_nameid19 = ((Lookup)preEntity.Properties["new_nameid19"]).Value;
Guid new_nameid20 = ((Lookup)preEntity.Properties["new_nameid20"]).Value;
Guid new_nameid21 = ((Lookup)preEntity.Properties["new_nameid21"]).Value;
Guid new_nameid22 = ((Lookup)preEntity.Properties["new_nameid22"]).Value;
new_reagent1 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid1, cols1) as MyCrmService.new_reagent;
new_reagent2 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid2, cols2) as MyCrmService.new_reagent;
new_reagent3 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid3, cols3) as MyCrmService.new_reagent;
new_reagent4 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid4, cols4) as MyCrmService.new_reagent;
new_reagent5 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid5, cols5) as MyCrmService.new_reagent;
new_reagent6 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid6, cols6) as MyCrmService.new_reagent;
new_reagent7 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid7, cols7) as MyCrmService.new_reagent;
new_reagent8 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid8, cols8) as MyCrmService.new_reagent;
new_reagent9 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid9, cols9) as MyCrmService.new_reagent;
new_reagent10 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid10, cols10) as MyCrmService.new_reagent;
new_reagent11 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid11, cols11) as MyCrmService.new_reagent;
new_reagent12 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid12, cols12) as MyCrmService.new_reagent;
new_reagent13 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid13, cols13) as MyCrmService.new_reagent;
new_reagent14 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid14, cols14) as MyCrmService.new_reagent;
new_reagent15 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid15, cols15) as MyCrmService.new_reagent;
new_reagent16 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid16, cols16) as MyCrmService.new_reagent;
new_reagent17 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid17, cols17) as MyCrmService.new_reagent;
new_reagent18 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid18, cols18) as MyCrmService.new_reagent;
new_reagent19 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid19, cols19) as MyCrmService.new_reagent;
new_reagent20 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid20, cols20) as MyCrmService.new_reagent;
new_reagent21 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid21, cols21) as MyCrmService.new_reagent;
new_reagent22 = crmService.Retrieve(MyCrmService.EntityName.new_reagent.ToString(), new_nameid22, cols22) as MyCrmService.new_reagent;
// Update the new_reagent TotalNumbers
if (new_reagent1.new_remainder == null)
{
new_reagent1.new_remainder = new MyCrmService.CrmFloat();
new_reagent1.new_remainder.Value = 0;
}
if (new_reagent2.new_remainder == null)
{
new_reagent2.new_remainder = new MyCrmService.CrmFloat();
new_reagent2.new_remainder.Value = 0;
}
if (new_reagent3.new_remainder == null)
{
new_reagent3.new_remainder = new MyCrmService.CrmFloat();
new_reagent3.new_remainder.Value = 0;
}
if (new_reagent4.new_remainder == null)
{
new_reagent4.new_remainder = new MyCrmService.CrmFloat();
new_reagent4.new_remainder.Value = 0;
}
if (new_reagent5.new_remainder == null)
{
new_reagent5.new_remainder = new MyCrmService.CrmFloat();
new_reagent5.new_remainder.Value = 0;
}
if (new_reagent6.new_remainder == null)
{
new_reagent6.new_remainder = new MyCrmService.CrmFloat();
new_reagent6.new_remainder.Value = 0;
}
if (new_reagent7.new_remainder == null)
{
new_reagent7.new_remainder = new MyCrmService.CrmFloat();
new_reagent7.new_remainder.Value = 0;
}
if (new_reagent8.new_remainder == null)
{
new_reagent8.new_remainder = new MyCrmService.CrmFloat();
new_reagent8.new_remainder.Value = 0;
}
if (new_reagent9.new_remainder == null)
{
new_reagent9.new_remainder = new MyCrmService.CrmFloat();
new_reagent9.new_remainder.Value = 0;
}
if (new_reagent10.new_remainder == null)
{
new_reagent10.new_remainder = new MyCrmService.CrmFloat();
new_reagent10.new_remainder.Value = 0;
}
if (new_reagent11.new_remainder == null)
{
new_reagent11.new_remainder = new MyCrmService.CrmFloat();
new_reagent11.new_remainder.Value = 0;
}
if (new_reagent12.new_remainder == null)
{
new_reagent12.new_remainder = new MyCrmService.CrmFloat();
new_reagent12.new_remainder.Value = 0;
}
if (new_reagent13.new_remainder == null)
{
new_reagent13.new_remainder = new MyCrmService.CrmFloat();
new_reagent13.new_remainder.Value = 0;
}
if (new_reagent14.new_remainder == null)
{
new_reagent14.new_remainder = new MyCrmService.CrmFloat();
new_reagent14.new_remainder.Value = 0;
}
if (new_reagent15.new_remainder == null)
{
new_reagent15.new_remainder = new MyCrmService.CrmFloat();
new_reagent15.new_remainder.Value = 0;
}
if (new_reagent16.new_remainder == null)
{
new_reagent16.new_remainder = new MyCrmService.CrmFloat();
new_reagent16.new_remainder.Value = 0;
}
if (new_reagent17.new_remainder == null)
{
new_reagent17.new_remainder = new MyCrmService.CrmFloat();
new_reagent17.new_remainder.Value = 0;
}
if (new_reagent18.new_remainder == null)
{
new_reagent18.new_remainder = new MyCrmService.CrmFloat();
new_reagent18.new_remainder.Value = 0;
}
if (new_reagent19.new_remainder == null)
{
new_reagent19.new_remainder = new MyCrmService.CrmFloat();
new_reagent19.new_remainder.Value = 0;
}
if (new_reagent20.new_remainder == null)
{
new_reagent20.new_remainder = new MyCrmService.CrmFloat();
new_reagent20.new_remainder.Value = 0;
}
if (new_reagent21.new_remainder == null)
{
new_reagent21.new_remainder = new MyCrmService.CrmFloat();
new_reagent21.new_remainder.Value = 0;
}
if (new_reagent22.new_remainder == null)
{
new_reagent22.new_remainder = new MyCrmService.CrmFloat();
new_reagent22.new_remainder.Value = 0;
}
double new_remainder1 = new_reagent1.new_remainder.Value + preDNANumber1.Value - postDNANumber1.Value;
double new_remainder2 = new_reagent2.new_remainder.Value + preDNANumber2.Value - postDNANumber2.Value;
double new_remainder3 = new_reagent3.new_remainder.Value + preDNANumber3.Value - postDNANumber3.Value;
double new_remainder4 = new_reagent4.new_remainder.Value + preDNANumber4.Value - postDNANumber4.Value;
double new_remainder5 = new_reagent5.new_remainder.Value + preDNANumber5.Value - postDNANumber5.Value;
double new_remainder6 = new_reagent6.new_remainder.Value + preDNANumber6.Value - postDNANumber6.Value;
double new_remainder7 = new_reagent7.new_remainder.Value + preDNANumber7.Value - postDNANumber7.Value;
double new_remainder8 = new_reagent8.new_remainder.Value + preDNANumber8.Value - postDNANumber8.Value;
double new_remainder9 = new_reagent9.new_remainder.Value + preDNANumber9.Value - postDNANumber9.Value;
double new_remainder10 = new_reagent10.new_remainder.Value + preDNANumber10.Value - postDNANumber10.Value;
double new_remainder11 = new_reagent11.new_remainder.Value + preDNANumber11.Value - postDNANumber11.Value;
double new_remainder12 = new_reagent12.new_remainder.Value + preDNANumber12.Value - postDNANumber12.Value;
double new_remainder13 = new_reagent13.new_remainder.Value + preDNANumber13.Value - postDNANumber13.Value;
double new_remainder14 = new_reagent14.new_remainder.Value + preDNANumber14.Value - postDNANumber14.Value;
double new_remainder15 = new_reagent15.new_remainder.Value + preDNANumber15.Value - postDNANumber15.Value;
double new_remainder16 = new_reagent16.new_remainder.Value + preDNANumber16.Value - postDNANumber16.Value;
double new_remainder17 = new_reagent17.new_remainder.Value + preDNANumber17.Value - postDNANumber17.Value;
double new_remainder18 = new_reagent18.new_remainder.Value + preDNANumber18.Value - postDNANumber18.Value;
double new_remainder19 = new_reagent19.new_remainder.Value + preDNANumber19.Value - postDNANumber19.Value;
double new_remainder20 = new_reagent20.new_remainder.Value + preDNANumber20.Value - postDNANumber20.Value;
double new_remainder21 = new_reagent21.new_remainder.Value + preDNANumber21.Value - postDNANumber21.Value;
double new_remainder22 = new_reagent22.new_remainder.Value + preDNANumber22.Value - postDNANumber22.Value;
new_reagent1.new_remainder.Value = new_remainder1;
crmService.Update(new_reagent1);
new_reagent2.new_remainder.Value = new_remainder2;
crmService.Update(new_reagent2);
new_reagent3.new_remainder.Value = new_remainder3;
crmService.Update(new_reagent3);
new_reagent4.new_remainder.Value = new_remainder4;
crmService.Update(new_reagent4);
new_reagent5.new_remainder.Value = new_remainder5;
crmService.Update(new_reagent5);
new_reagent6.new_remainder.Value = new_remainder6;
crmService.Update(new_reagent6);
new_reagent7.new_remainder.Value = new_remainder7;
crmService.Update(new_reagent7);
new_reagent8.new_remainder.Value = new_remainder8;
crmService.Update(new_reagent8);
new_reagent9.new_remainder.Value = new_remainder9;
crmService.Update(new_reagent9);
new_reagent10.new_remainder.Value = new_remainder10;
crmService.Update(new_reagent10);
new_reagent11.new_remainder.Value = new_remainder11;
crmService.Update(new_reagent11);
new_reagent12.new_remainder.Value = new_remainder12;
crmService.Update(new_reagent12);
new_reagent13.new_remainder.Value = new_remainder13;
crmService.Update(new_reagent13);
new_reagent14.new_remainder.Value = new_remainder14;
crmService.Update(new_reagent14);
new_reagent15.new_remainder.Value = new_remainder15;
crmService.Update(new_reagent15);
new_reagent16.new_remainder.Value = new_remainder16;
crmService.Update(new_reagent16);
new_reagent17.new_remainder.Value = new_remainder17;
crmService.Update(new_reagent17);
new_reagent18.new_remainder.Value = new_remainder18;
crmService.Update(new_reagent18);
new_reagent19.new_remainder.Value = new_remainder19;
crmService.Update(new_reagent19);
new_reagent20.new_remainder.Value = new_remainder20;
crmService.Update(new_reagent20);
new_reagent21.new_remainder.Value = new_remainder21;
crmService.Update(new_reagent21);
new_reagent22.new_remainder.Value = new_remainder22;
crmService.Update(new_reagent22);
}
}
}
/// <summary>
/// Creates a CrmService
/// </summary>
/// <returns>A valid CrmService for the current user</returns>
private MyCrmService.CrmService GetCrmService()
{
// Setup the Authentication Token
MyCrmService.CrmAuthenticationToken token = new MyCrmService.CrmAuthenticationToken();
token.OrganizationName = "test";
{
MyCrmService.CrmService crmService = new MyCrmService.CrmService();
crmService.Credentials = System.Net.CredentialCache.DefaultCredentials;
crmService.CrmAuthenticationTokenValue = token;
return crmService;
}
}
}
}
赶快优化吧,代码看着头晕,太长了
装箱/拆箱?
一开始想多了,还想到了反射,回头发现就是创建对象的代码多了些,用object数组来实现就可以了。
object[] x = new object[10];
x[0] = new Moops.Info.Model.catalog_info();
自己写的一个东西,X[0]就是一个catalog_info对象了,使用时强制(catalog_info)x[0]就ok了。
楼主的代码至少可以压缩到原来的10%
那么多重复的定义代码请恕我实在是没有勇气仔细看,也不清楚LZ水平,冒昧地提供一点点思路吧
第一,多次重复的对象定义,显然是要用数组来解决的,如果普通的一维数组不能满足要求,请尝试使用ArrayList,如果需要更高的数组性能,请使用泛型数组List<T>,不需要装箱拆箱操作,也是类型安全的,如果希望使用键值对的形式存储数据,也可以使用HashTable或者Dictionary<T>,后者更加推荐
然后用循环重复实例化对象
第二,重复的If……else语句,理论上大部分可以通过面向对象,以多态的方式消除。但我不清楚LZ程序的逻辑,也就说不清楚是否需要或者适合用面向对象来重构,而且估计通过上面说的第一点,if……else的数量可以大大减少,最后是否需要写出类和接口,看实际需求
最后请恕我刚熬了个通宵没精神看这么一大串代码,可以的话请尝试按照我的思路来重构