protected override bool Execute(CodeActivityContext context) { Error.Set(context, null); EnumGroupTPPowerReportMode?typecalc = null; if (GroupTPPowerReportMode == GroupTPPowerReportMode.OpenPeriod) { typecalc = EnumGroupTPPowerReportMode.OpenPeriod; } if (GroupTPPowerReportMode == GroupTPPowerReportMode.ClosedCurrPeriod) { typecalc = EnumGroupTPPowerReportMode.ClosedCurrPeriod; } if (GroupTPPowerReportMode == GroupTPPowerReportMode.ClosedNextPeriod) { typecalc = EnumGroupTPPowerReportMode.ClosedNextPeriod; } if (GroupTPPowerReportMode == GroupTPPowerReportMode.ClosedPrevPeriod) { typecalc = EnumGroupTPPowerReportMode.ClosedPrevPeriod; } string userName = UserName;//.Get(context); string userID = null; if (string.IsNullOrEmpty(userName)) { Error.Set(context, "Значение свойства 'Пользователь' не может быть пустым"); return(false); } try { List <UserInfo> UList = ARM_Service.EXPL_Get_All_Users(); foreach (UserInfo u in UList) { if (u.UserName.ToLower(System.Globalization.CultureInfo.InvariantCulture) == userName.ToLower(System.Globalization.CultureInfo.InvariantCulture)) { userID = u.User_ID; break; } } } catch (Exception ex) { Error.Set(context, ex.Message); if (!HideException.Get(context)) { throw ex; } } if (!string.IsNullOrEmpty(Error.Get(context))) { return(false); } if (string.IsNullOrEmpty(userID)) { Error.Set(context, "Не найден пользователь с именем '" + UserName + "'"); return(false); } List <int> listIDs = ListIDs.Get(context); if (listIDs == null) { Error.Set(context, "Неопределен список идентификаторов"); return(false); } List <ID_TypeHierarchy> idList = new List <ID_TypeHierarchy>(); foreach (int id in listIDs) { ID_TypeHierarchy idTypeHier = new ID_TypeHierarchy(); idTypeHier.ID = id; idTypeHier.TypeHierarchy = TypeIDs; idList.Add(idTypeHier); } MemoryStream doc = null; try { SectionIntegralComplexResults res; if (ReportType == enumReportType.ReportReplacementOfMeters) { //TODO часовой пояс res = ARM_Service.Rep_ReplacementOfAccountingFacilities(idList, StartDateTime.Get(context), EndDateTime.Get(context), ReportType, typecalc, userName, null); } else { //TODO часовой пояс res = ARM_Service.REP_OverflowControl(idList, StartDateTime.Get(context), EndDateTime.Get(context), ReportType, typecalc, userName, null, null, false, 3, ",", enumTimeDiscreteType.DBHours, null); } if (res.Document != null) { res.Document.Position = 0; var ms = CompressUtility.DecompressGZip(res.Document); ms.Position = 0; Document.Set(context, ms); //File.WriteAllBytes(@"C:\12\test_SysRep.xls",ms.ToArray()); } switch (res.AdapterType) { case TExportExcelAdapterType.toXLS: FileExtention.Set(context, "xls"); break; case TExportExcelAdapterType.toXLSx: FileExtention.Set(context, "xlsx"); break; case TExportExcelAdapterType.toHTML: FileExtention.Set(context, "html"); break; case TExportExcelAdapterType.toPDF: FileExtention.Set(context, "pdf"); break; } if (res.Errors != null) { Error.Set(context, res.Errors.ToString()); } } catch (Exception ex) { Error.Set(context, ex.Message); if (!HideException.Get(context)) { throw ex; } } return(string.IsNullOrEmpty(Error.Get(context))); }