private void PutReportToFtp(CodeActivityContext context, int?psId) { try { var repF = ARM_Service.REP_Export_ReportObjectClass(User_ID, ReportFormat, Report_id.Get(context), null, HierLev1_ID.Get(context), HierLev2_ID.Get(context), HierLev3_ID.Get(context), psId, JuridicalPerson_ID.Get(context), StartDateTime.Get(context), EndDateTime.Get(context), null, WcfTimeOut.Get(context)); var doc = LargeData.DownloadData(repF.Key); if (!string.IsNullOrEmpty(repF.Value.Error)) { Error.Set(context, repF.Value.Error); } else { //var fs = new FileStream("C:\\777\\1\\rep_"+p.PS_ID.ToString()+".xls", FileMode.Create, FileAccess.Write); //DataReport.Document.CopyTo(fs); //fs.Close(); PutReportToFtp(context, doc); } } catch (Exception ex) { Error.Set(context, ex.Message); if (!HideException.Get(context)) { throw ex; } } }
private static void InsertLargeDataMany(MongoClient mongoClient) { Console.WriteLine("InsertLargeDataMany"); var database = mongoClient.GetDatabase(DatabaseLargeName); var sw = new Stopwatch(); sw.Start(); var array = new LargeData[LargeCount]; var collection = database.GetCollection <LargeData>(CollectionLargeName); for (var i = 0; i < LargeCount; i++) { var data = new LargeData { Id = ObjectId.GenerateNewId(), DataBytes = new byte[LargeDataSize], Established = DateTime.UtcNow }; array[i] = data; } collection.InsertMany(array); sw.Stop(); Console.WriteLine("\tTime : {0} ms", sw.ElapsedMilliseconds); }
/* * [Description("Строка ошибки")] * [DisplayName("Ошибка")] * public OutArgument<string> Error { get; set; } * * [RequiredArgument] * [Description("Уникальный номер отчета")] * [DisplayName("Идентификатор отчета")] * [Category("Отчет")] * public InArgument<string> Report_id { get; set; } * * [RequiredArgument] * [Description("Начальная дата отчета")] * [DisplayName("Начальная дата")] * [Category("Отчет")] * public InArgument<DateTime> StartDateTime { get; set; } * * [RequiredArgument] * [Description("Конечная дата отчета")] * [DisplayName("Конечная дата")] * [Category("Отчет")] * public InArgument<DateTime> EndDateTime { get; set; } * * [Description("Формат отчета")] * [DisplayName("Формат")] * [Category("Отчет")] * public ReportExportFormat ReportFormat { get; set; } * * //-------------------------------------------------------------- * [RequiredArgument] * [Description("Адрес получателя")] * [DisplayName("Адресат")] * [Category("Электронная почта")] * public InArgument<string> To { get; set; } * * [RequiredArgument] * [Description("Адрес отправителя")] * [DisplayName("Отправитель")] * [Category("Электронная почта")] * public InArgument<string> From { get; set; } * * [RequiredArgument] * [Description("Тема письма")] * [DisplayName("Тема")] * [Category("Электронная почта")] * public InArgument<string> Subject { get; set; } * * [DisplayName("Тело письма")] * [Category("Электронная почта")] * public InArgument<string> Body { get; set; } * * [RequiredArgument] * [DefaultValue(25)] * [DisplayName("Порт")] * [Category("Электронная почта")] * public int Port { get; set; } * * [RequiredArgument] * [DisplayName("Имя пользователя")] * [Category("Электронная почта")] * public InArgument<string> UserName { get; set; } * * [RequiredArgument] * [DisplayName("Пароль")] * [Category("Электронная почта")] * public InArgument<string> Password { get; set; } * * [RequiredArgument] * [DisplayName("Почтовый сервер")] * [Category("Электронная почта")] * public InArgument<string> Host { get; set; } * * protected override void CacheMetadata(CodeActivityMetadata metadata) * { * if (Port <= 0) * metadata.AddValidationError("Значение свойства 'Порт' должно быть больше 0"); * base.CacheMetadata(metadata); * } * * * protected string GetFileExtByReportFormat() * { * string Ext = ""; * if (ReportFormat == ReportExportFormat.Csv) Ext = "csv"; * if (ReportFormat == ReportExportFormat.Excel) Ext = "xls"; * if (ReportFormat == ReportExportFormat.Excel2007) Ext = "xlsx"; * if (ReportFormat == ReportExportFormat.ImageBmp) Ext = "bmp"; * if (ReportFormat == ReportExportFormat.ImageEmf) Ext = "emf"; * if (ReportFormat == ReportExportFormat.ImageGif) Ext = "gif"; * if (ReportFormat == ReportExportFormat.ImageJpeg) Ext = "jpg"; * if (ReportFormat == ReportExportFormat.ImagePcx) Ext = "pcx"; * if (ReportFormat == ReportExportFormat.ImagePng) Ext = "png"; * if (ReportFormat == ReportExportFormat.ImageTiff) Ext = "Tiff"; * if (ReportFormat == ReportExportFormat.Mht) Ext = "mht"; * if (ReportFormat == ReportExportFormat.Ods) Ext = "ods"; * if (ReportFormat == ReportExportFormat.Odt) Ext = "odt"; * if (ReportFormat == ReportExportFormat.Pdf) Ext = "pdf"; * if (ReportFormat == ReportExportFormat.Ppt2007) Ext = "ppt"; * if (ReportFormat == ReportExportFormat.Rtf) Ext = "rtf"; * if (ReportFormat == ReportExportFormat.Text) Ext = "txt"; * if (ReportFormat == ReportExportFormat.Word2007) Ext = "docx"; * if (ReportFormat == ReportExportFormat.Xps) Ext = "xps"; * if (Ext != "") * Ext = "." + Ext; * return Ext; * } * * protected void SendEmail(CodeActivityContext context,MemoryStream AttachContent) * { * * MailMessage mailMessage = new MailMessage(); * * mailMessage.From = new MailAddress(From.Get(context)); * string STo = To.Get(context); * * STo.Split(new Char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList() * .ForEach(item => mailMessage.To.Add(item.Trim())); * * mailMessage.Subject = Subject.Get(context); * mailMessage.Body = Body.Get(context); * * SmtpClient smtpClient = new SmtpClient(); * smtpClient.Host = Host.Get(context); * smtpClient.Port = Port; * smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; * if (!String.IsNullOrEmpty(UserName.Get(context)) && !String.IsNullOrEmpty(Password.Get(context))) * smtpClient.Credentials = new System.Net.NetworkCredential(UserName.Get(context), Password.Get(context)); * * if (AttachContent != null) * { * Attachment Attach = new Attachment(AttachContent, "Отчет"+GetFileExtByReportFormat()); * mailMessage.Attachments.Add(Attach); * } * //throw new Exception("Error sending email"); // test exception * smtpClient.Send(mailMessage); * } */ protected override bool Execute(CodeActivityContext context) { Error.Set(context, null); //SectionIntegralComplexResults DataReport; KeyValuePair <Guid, TReportResult> RepF = new KeyValuePair <Guid, TReportResult>(); MemoryStream doc = null; try { string userId = null; if (!string.IsNullOrEmpty(User_ID)) { try { userId = UserHelper.GetIdByUserName(User_ID); if (string.IsNullOrEmpty(userId)) // похоже тут не имя а UserID { userId = User_ID; } } catch (Exception ex) { Error.Set(context, ex.Message); if (!HideException.Get(context)) { throw ex; } } } RepF = ARM_Service.REP_Export_Report(userId, ReportFormat, Report_id.Get(context), StartDateTime.Get(context), EndDateTime.Get(context), null, WcfTimeOut.Get(context)); doc = LargeData.DownloadData(RepF.Key); if (!string.IsNullOrEmpty(RepF.Value.Error)) { Error.Set(context, RepF.Value.Error); } else { SendEmail(context, doc); } } 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); KeyValuePair <Guid, TReportResult> RepF = new KeyValuePair <Guid, TReportResult>(); MemoryStream doc = null; try { /* * string User_ID = ""; * List<UserInfo> UInfos = ARM_Service.EXPL_Get_All_Users(); * foreach (UserInfo u in UInfos) * if (u.UserName == UserName) * { * User_ID = u.User_ID; * break; * } * if (string.IsNullOrEmpty(User_ID)) * { * Error.Set(context, "Пользователь '" + UserName+"' не найден в системе"); * return false; * } */ string userId = null; if (!string.IsNullOrEmpty(UserName)) { try { userId = UserHelper.GetIdByUserName(UserName); } catch (Exception ex) { Error.Set(context, ex.Message); if (!HideException.Get(context)) { throw ex; } } } if (string.IsNullOrEmpty(userId)) { Error.Set(context, "Пользователь '" + UserName + "' не найден в системе"); return(false); } RepF = ARM_Service.REP_Export_Report(userId, ReportFormat, Report_id.Get(context), StartDateTime.Get(context), EndDateTime.Get(context), null, WcfTimeOut.Get(context)); doc = LargeData.DownloadData(RepF.Key); if (!string.IsNullOrEmpty(RepF.Value.Error)) { Error.Set(context, RepF.Value.Error); } } catch (Exception ex) { Error.Set(context, ex.Message); if (!HideException.Get(context)) { throw ex; } } return(string.IsNullOrEmpty(Error.Get(context))); }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); ImmediatePostDataDemo johnNilsen = ObjectSpace.FindObject <ImmediatePostDataDemo>(CriteriaOperator.Parse("LastName == ?", "Nilsen")); if (johnNilsen == null) { johnNilsen = ObjectSpace.CreateObject <ImmediatePostDataDemo>(); johnNilsen.LastName = "Nilsen"; johnNilsen.FirstName = "John"; johnNilsen.BooleanProperty = true; johnNilsen.NumericProperty = 12; } ImmediatePostDataDemo maryTellitson = ObjectSpace.FindObject <ImmediatePostDataDemo>(CriteriaOperator.Parse("LastName == ?", "Tellitson")); if (maryTellitson == null) { maryTellitson = ObjectSpace.CreateObject <ImmediatePostDataDemo>(); maryTellitson.LastName = "Tellitson"; maryTellitson.FirstName = "Mary"; maryTellitson.BooleanProperty = false; maryTellitson.NumericProperty = 15; } SimpleDemo simpleDemoObj = ObjectSpace.FindObject <SimpleDemo>(CriteriaOperator.Parse("Name == ?", "SimpleDemoObject1")); if (simpleDemoObj == null) { for (int i = 1; i < 5; i++) { SimpleData simpleData = ObjectSpace.CreateObject <SimpleData>(); simpleData.Name = $"SimpleData{i}"; simpleDemoObj = ObjectSpace.CreateObject <SimpleDemo>(); simpleDemoObj.Name = $"SimpleDemoObject{i}"; simpleDemoObj.Data = simpleData; } } BusinessObjects.Country c = ObjectSpace.FindObject <BusinessObjects.Country>(CriteriaOperator.Parse("Name == ?", "France")); if (c == null) { c = ObjectSpace.CreateObject <BusinessObjects.Country>(); c.Name = "France"; City city = ObjectSpace.CreateObject <City>(); city.Name = "Paris"; c.Cities.Add(city); city = ObjectSpace.CreateObject <City>(); city.Name = "Lyon"; c.Cities.Add(city); city = ObjectSpace.CreateObject <City>(); city.Name = "Marseille"; c.Cities.Add(city); c = ObjectSpace.CreateObject <BusinessObjects.Country>(); c.Name = "USA"; city = ObjectSpace.CreateObject <City>(); city.Name = "New York"; c.Cities.Add(city); city = ObjectSpace.CreateObject <City>(); city.Name = "Los Angeles"; c.Cities.Add(city); city = ObjectSpace.CreateObject <City>(); city.Name = "Seattle"; c.Cities.Add(city); CascadeLookupBatch cascadeLookup = ObjectSpace.CreateObject <CascadeLookupBatch>(); cascadeLookup.Name = "Route 1"; cascadeLookup.Country = c; cascadeLookup.City = city; c = ObjectSpace.CreateObject <BusinessObjects.Country>(); c.Name = "Italy"; city = ObjectSpace.CreateObject <City>(); city.Name = "Rome"; c.Cities.Add(city); city = ObjectSpace.CreateObject <City>(); city.Name = "Milan"; c.Cities.Add(city); city = ObjectSpace.CreateObject <City>(); city.Name = "Venice"; c.Cities.Add(city); cascadeLookup = ObjectSpace.CreateObject <CascadeLookupBatch>(); cascadeLookup.Name = "Route 2"; cascadeLookup.Country = c; cascadeLookup.City = city; } ObjectSpace.CommitChanges(); LargeDataDemo largeDataDemoObject = ObjectSpace.FindObject <LargeDataDemo>(CriteriaOperator.Parse("Name == ?", "LargeDataDemoObject")); if (largeDataDemoObject == null) { for (int i = 1; i < 100000; i++) { LargeData obj1 = ObjectSpace.CreateObject <LargeData>(); obj1.Name = "LargeData" + i; if (i == 150) { LargeDataDemo largeDataDemo = ObjectSpace.CreateObject <LargeDataDemo>(); largeDataDemo.LargeData = obj1; largeDataDemo.Name = "LargeDataDemoObject"; } if (i % 1000 == 0) { ObjectSpace.CommitChanges(); } } } ObjectSpace.CommitChanges(); }