private static UserInfo GetUserInfoByUserName(string userName) { List <UserInfo> uList = ARM_Service.EXPL_Get_All_Users(); foreach (UserInfo u in uList) { if (u.UserName.ToLower(CultureInfo.InvariantCulture) == userName.ToLower(CultureInfo.InvariantCulture)) { return(u); } } return(null); }
void ExpandCombo(object sender, EventArgs e) { ComboBox combo = (ComboBox)sender; string s = ""; if (combo.SelectedItem != null) { s = combo.SelectedItem.ToString(); } combo.Items.Clear(); List <UserInfo> UInfos = ARM_Service.EXPL_Get_All_Users(); foreach (UserInfo u in UInfos) { combo.Items.Add(u.UserName); } if (!string.IsNullOrEmpty(s)) { combo.SelectedIndex = combo.Items.IndexOf(s); } }
protected override bool Execute(CodeActivityContext context) { string Email = ""; if (string.IsNullOrEmpty(UserName)) { Error.Set(context, "Значение свойства 'Пользователь' не может быть пустым"); return(false); } bool FoundUser = 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)) { FoundUser = true; Email = u.Email; break; } } } catch (Exception ex) { Error.Set(context, ex.Message); if (!HideException.Get(context)) { throw ex; } } if (!string.IsNullOrEmpty(Error.Get(context))) { return(false); } if (!FoundUser) { Error.Set(context, "Не найден пользователь с именем '" + UserName + "'"); return(false); } if (string.IsNullOrEmpty(Email)) { Error.Set(context, "У пользователя '" + UserName + "' не определен адрес электронной почты"); return(false); } Expl_UserNotify_EMailServiceConfiguration Config = null; try { Config = ARM_Service.EXPL_Get_UserNotify_EmailServiceConfigurations().FirstOrDefault(); if (Config == null) { Error.Set(context, "Не найдено ни одной записи в таблице конфигурации почтового сервиса"); return(false); } } catch (Exception ex) { Error.Set(context, ex.Message); if (!HideException.Get(context)) { throw ex; } } UserNotify_EMailServiceConfigurationItem ConfigurationItem = null; try { ConfigurationItem = UserNotify_EMailServiceConfigurationItem.FromXElement(Config.Data); } catch (Exception ex) { Error.Set(context, "Ошибка разбора Xml : " + ex.Message); if (!HideException.Get(context)) { throw ex; } } //if (UseZipArchive) //{ // MemoryStream compresStream = new MemoryStream(); // ComponentAce.Compression.ZipForge.ZipForge zip = new ComponentAce.Compression.ZipForge.ZipForge(); // zip.FileName = attachName + ".zip"; ; // AttachContent.Position = 0; // zip.OpenArchive(compresStream, true); // zip.AddFromStream(attachName + GetFileExtByReportFormat(), AttachContent); // zip.CloseArchive(); // Attach = new Attachment(AttachContent, zip.FileName); // zip.Dispose(); //} // try { Pop3Helper.ReadAllMails(UserNotifyConfigClass.Pop3_Host, UserNotifyConfigClass.Smtp_User, UserNotifyConfigClass.Smtp_Password); var mailMessage = new System.Net.Mail.MailMessage(); mailMessage.To.Add(Email); if (string.IsNullOrEmpty(Subject.Get(context))) { mailMessage.Subject = ConfigurationItem.Smtp_Subject; } else { mailMessage.Subject = Subject.Get(context); } if (mailMessage.Subject != null) { mailMessage.Subject = mailMessage.Subject.Replace("@PsName", "") .Replace("@data", "") .Replace("@ReportName", ""); } mailMessage.Body = Body.Get(context); mailMessage.From = new System.Net.Mail.MailAddress(ConfigurationItem.Smtp_From); var smtp = new System.Net.Mail.SmtpClient(); smtp.Host = ConfigurationItem.Smtp_Host; smtp.Port = ConfigurationItem.Smtp_Port; MemoryStream a = Attach.Get(context); if (a != null) { string an = AttachName.Get(context); if (string.IsNullOrEmpty(an)) { an = "Вложение"; } Attachment at = new Attachment(a, an); mailMessage.Attachments.Add(at); } smtp.Credentials = new System.Net.NetworkCredential(ConfigurationItem.Smtp_User, ConfigurationItem.Smtp_Password); //smtp.EnableSsl = true; smtp.Send(mailMessage); } catch (Exception ex) { Error.Set(context, "Ошибка отправки письма : " + ex.Message); if (!HideException.Get(context)) { throw ex; } } return(string.IsNullOrEmpty(Error.Get(context))); }
protected override bool Execute(CodeActivityContext context) { Error.Set(context, null); int uspid = UspdId.Get(context); List <int> initial = new List <int>(); initial.Add(uspid); if (string.IsNullOrEmpty(LoginInfo.UserName) || string.IsNullOrEmpty(LoginInfo.Password)) { Error.Set(context, "Не определены параметры авторизации"); return(false); } try { string userId = null; List <UserInfo> uInfos = ARM_Service.EXPL_Get_All_Users(); foreach (UserInfo u in uInfos) { if (u.UserName == LoginInfo.UserName) { userId = u.User_ID; break; } } if (string.IsNullOrEmpty(userId)) { throw new Exception("Пользователь '" + LoginInfo.UserName + "' не найден в системе"); } DateTime actualTime = new DateTime(1, 1, 1, LivePeriod.Days, LivePeriod.Hours, LivePeriod.Minutes); short priority = 128; if (Priority == enumManualReadRequestPriority.Hight) { priority = 0; } byte requestType = (byte)RequestType; var managePu = new Expl_User_Journal_ManagePU_Request_List() { CUS_ID = 0, User_ID = userId, ManageRequestLifeDateTime = actualTime, ManageRequestStatus = 0, ManageRequestType = 21, ManageRequestPriority = priority }; var request = new USPDManage_Manual_ReadRequest() { CUS_ID = 0, RequestComment = Comment.Get(context), ManualReadType = requestType }; List <KeyValuePair <int, FailReason> > result = ARM_Service.DM_Send_Manual_ReadigUSPD_Request(LoginInfo.UserName, LoginInfo.Password, managePu, request, initial); if (result == null) { Error.Set(context, "Не удалось отправить команду"); return(false); } if (result.Count > 0) { Error.Set(context, GlobalEnumsDictionary.ConvertFailReasonToString(result[0].Value)); return(false); } } catch (Exception ex) { Error.Set(context, ex.Message); if (!HideException.Get(context)) { throw ex; } } return(string.IsNullOrEmpty(Error.Get(context))); }
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))); }