// *** Start programmer edit section *** (Buildings CustomMembers) /// <summary> /// CalculateSumArea - метод, который пересчитывает и записывает в базу данных сумму занимаемой площади всеми объектами теплопотребления для данного здания. /// PKbuild - PrimaryKey здания, для которого надо пересчитать /// </summary> public static void CalculateSumArea(string PKbuild, ObjectsHeat oh) { var ldef = SQLWhereLanguageDef.LanguageDef; ICSSoft.STORMNET.Business.LoadingCustomizationStruct lcs = ICSSoft.STORMNET.Business.LoadingCustomizationStruct.GetSimpleStruct(typeof(ObjectsHeat), "ObjectsHeatE"); lcs.LimitFunction = ldef.GetFunction(ldef.funcSQL, "Buildings = \'{0}\'", PKbuild); ICSSoft.STORMNET.DataObject[] objs = ICSSoft.STORMNET.Business.DataServiceProvider.DataService.LoadObjects(lcs); double sumArea = 0.0; foreach (ObjectsHeat el in objs) { if (!el.__PrimaryKey.ToString().Equals(oh.__PrimaryKey.ToString())) { sumArea += el.Area; } } sumArea += oh.Area; try { var ds = (SQLDataService)DataServiceProvider.DataService; var b = new Buildings(); b.SetExistObjectPrimaryKey(PKbuild); ds.LoadObject(b); b.SumArea = sumArea; ds.UpdateObject(b); } catch (Exception e) { throw new Exception("Ошибка: " + Environment.NewLine + e.Message); } }
// *** Start programmer edit section *** (UseDllCodeDecode CustomMembers) // *** End programmer edit section *** (UseDllCodeDecode CustomMembers) // *** Start programmer edit section *** (OnUpdateObjectsHeat CustomAttributes) // *** End programmer edit section *** (OnUpdateObjectsHeat CustomAttributes) public virtual ICSSoft.STORMNET.DataObject[] OnUpdateObjectsHeat(IIS.Product_51172.ObjectsHeat UpdatedObject) { // *** Start programmer edit section *** (OnUpdateObjectsHeat) DataObject[] result = new DataObject[1]; ObjectsHeat oh = UpdatedObject; ArrayList retObjs = new ArrayList(); if (UpdatedObject.GetStatus() == ICSSoft.STORMNET.ObjectStatus.Created || UpdatedObject.GetStatus() == ICSSoft.STORMNET.ObjectStatus.Altered) { if (Array.IndexOf(UpdatedObject.GetAlteredPropertyNames(), "Area") >= 0) { var PKbuild = oh.Buildings.__PrimaryKey.ToString(); Buildings.CalculateSumArea(PKbuild, oh); } oh.QRcode = Generator.Encode(oh.NameObjectsHeat, oh.DateReg, (uint)oh.Clients.account); retObjs.Add(oh); } result = new DataObject[retObjs.Count]; retObjs.CopyTo(result, 0); return(result); // *** End programmer edit section *** (OnUpdateObjectsHeat) }