コード例 #1
0
 public void RetrieveOrganization()
 {
     OrganizationObjects = new OrganizationData().GetAllOrganization(Configuration.SavedConfig);
     new Util().UpdateConfigFile(Configuration.SavedConfig, OrganizationObjects[0].OrganizationUri.ToString(),
                                 "Uri");
     new Util().UpdateConfigFile(Configuration.SavedConfig, OrganizationObjects[0].FriendlyName, "Org");
 }
コード例 #2
0
    public async Task CanDeleteOrphanedEventsByStack()
    {
        var organization = OrganizationData.GenerateSampleOrganization(_billingManager, _plans);
        await _organizationRepository.AddAsync(organization, o => o.ImmediateConsistency());

        var project = await _projectRepository.AddAsync(ProjectData.GenerateSampleProject(), o => o.ImmediateConsistency());

        var stack = await _stackRepository.AddAsync(StackData.GenerateSampleStack(), o => o.ImmediateConsistency());

        await _eventRepository.AddAsync(EventData.GenerateEvents(5000, organization.Id, project.Id, stack.Id), o => o.ImmediateConsistency());

        var orphanedEvents = EventData.GenerateEvents(10000, organization.Id, project.Id).ToList();

        orphanedEvents.ForEach(e => e.StackId = ObjectId.GenerateNewId().ToString());

        await _eventRepository.AddAsync(orphanedEvents, o => o.ImmediateConsistency());

        var eventCount = await _eventRepository.CountAsync(o => o.IncludeSoftDeletes().ImmediateConsistency());

        Assert.Equal(15000, eventCount);

        await GetService <CleanupOrphanedDataJob>().RunAsync();

        eventCount = await _eventRepository.CountAsync(o => o.IncludeSoftDeletes().ImmediateConsistency());

        Assert.Equal(5000, eventCount);
    }
コード例 #3
0
ファイル: GeoTests.cs プロジェクト: ysq5202121/Exceptionless
        public async Task WillSetLocationFromEnvironmentInfoInfo()
        {
            var resolver = await GetResolverAsync(Log);

            if (resolver is NullGeoIpService)
            {
                return;
            }

            var plugin = new GeoPlugin(resolver, _options);
            var ev     = new PersistentEvent();

            ev.SetEnvironmentInfo(new EnvironmentInfo {
                IpAddress = $"127.0.0.1,{GREEN_BAY_IP}"
            });
            await plugin.EventBatchProcessingAsync(new List <EventContext> {
                new EventContext(ev, OrganizationData.GenerateSampleOrganization(_billingManager, _plans), ProjectData.GenerateSampleProject())
            });

            Assert.NotNull(ev.Geo);

            var location = ev.GetLocation();

            Assert.Equal("US", location?.Country);
            Assert.Equal("WI", location?.Level1);
            Assert.Equal("Green Bay", location?.Locality);
        }
コード例 #4
0
        public async Task SendOrganizationPaymentFailedAsync() {
            var user = UserData.GenerateSampleUser();
            var organization = OrganizationData.GenerateSampleOrganization(_billingManager, _plans);

            await _mailer.SendOrganizationPaymentFailedAsync(user, organization);
            await RunMailJobAsync();
        }
コード例 #5
0
        public async Task SendOrganizationMonthlyOverageNoticeAsync() {
            var user = UserData.GenerateSampleUser();
            var organization = OrganizationData.GenerateSampleOrganization(_billingManager, _plans);

            await _mailer.SendOrganizationNoticeAsync(user, organization, true, false);
            await RunMailJobAsync();
        }
コード例 #6
0
        private async Task <CreateOrganizationResult> CreateOrganizationAsync(
            CreateOrganization createOrganization,
            CancellationToken cancellationToken)
        {
            if (!createOrganization.IsValid)
            {
                return(new CreateOrganizationResult(new ValidationError("Missing ID")));
            }

            using (IDocumentSession session = _documentStore.OpenSession())
            {
                var data = new OrganizationData
                {
                    Id = createOrganization.Id
                };

                session.Store(data);

                await session.SaveChangesAsync(cancellationToken);
            }

            _logger.Information("Created organization with id {Id}", createOrganization.Id);

            return(new CreateOrganizationResult());
        }
コード例 #7
0
        private WebHookDataContext GetWebHookDataContext(Version version)
        {
            string json = File.ReadAllText(Path.GetFullPath(Path.Combine("..", "..", "..", "ErrorData", "1477.expected.json")));

            var settings = GetService <JsonSerializerSettings>();

            settings.Formatting = Formatting.Indented;

            var ev = JsonConvert.DeserializeObject <PersistentEvent>(json, settings);

            ev.OrganizationId = TestConstants.OrganizationId;
            ev.ProjectId      = TestConstants.ProjectId;
            ev.StackId        = TestConstants.StackId;
            ev.Id             = TestConstants.EventId;

            var context = new WebHookDataContext(version, ev, OrganizationData.GenerateSampleOrganization(GetService <BillingManager>(), GetService <BillingPlans>()), ProjectData.GenerateSampleProject())
            {
                Stack = StackData.GenerateStack(id: TestConstants.StackId, organizationId: TestConstants.OrganizationId, projectId: TestConstants.ProjectId, title: _formatter.GetStackTitle(ev), signatureHash: "722e7afd4dca4a3c91f4d94fec89dfdc")
            };

            context.Stack.Tags = new TagSet {
                "Test"
            };
            context.Stack.FirstOccurrence = context.Stack.LastOccurrence = ev.Date.UtcDateTime;

            return(context);
        }
コード例 #8
0
        public async Task WillSetMultipleFromEmptyGeo()
        {
            var plugin = new GeoPlugin(await GetResolverAsync(Log));

            var ev            = new PersistentEvent();
            var greenBayEvent = new PersistentEvent();

            greenBayEvent.SetEnvironmentInfo(new EnvironmentInfo {
                IpAddress = GREEN_BAY_IP
            });
            var irvingEvent = new PersistentEvent();

            irvingEvent.SetEnvironmentInfo(new EnvironmentInfo {
                IpAddress = IRVING_IP
            });
            await plugin.EventBatchProcessingAsync(new List <EventContext> {
                new EventContext(ev, OrganizationData.GenerateSampleOrganization(), ProjectData.GenerateSampleProject()),
                new EventContext(greenBayEvent, OrganizationData.GenerateSampleOrganization(), ProjectData.GenerateSampleProject()),
                new EventContext(irvingEvent, OrganizationData.GenerateSampleOrganization(), ProjectData.GenerateSampleProject())
            });

            Assert.Equal(GREEN_BAY_COORDINATES, greenBayEvent.Geo);
            var location = greenBayEvent.GetLocation();

            Assert.Equal("US", location?.Country);
            Assert.Equal("WI", location?.Level1);
            Assert.Equal("Green Bay", location?.Locality);

            Assert.Equal(IRVING_COORDINATES, irvingEvent.Geo);
            location = irvingEvent.GetLocation();
            Assert.Equal("US", location?.Country);
            Assert.Equal("TX", location?.Level1);
            Assert.Equal("Irving", location?.Locality);
        }
コード例 #9
0
        public async Task WillSetFromSingleGeo()
        {
            var plugin = new GeoPlugin(await GetResolverAsync(Log));

            var contexts = new List <EventContext> {
                new EventContext(new PersistentEvent {
                    Geo = GREEN_BAY_IP
                }, OrganizationData.GenerateSampleOrganization(), ProjectData.GenerateSampleProject()),
                new EventContext(new PersistentEvent {
                    Geo = GREEN_BAY_IP
                }, OrganizationData.GenerateSampleOrganization(), ProjectData.GenerateSampleProject())
            };

            await plugin.EventBatchProcessingAsync(contexts);

            foreach (var context in contexts)
            {
                Assert.Equal(GREEN_BAY_COORDINATES, context.Event.Geo);

                var location = context.Event.GetLocation();
                Assert.Equal("US", location?.Country);
                Assert.Equal("WI", location?.Level1);
                Assert.Equal("Green Bay", location?.Locality);
            }
        }
コード例 #10
0
        private void CreateData()
        {
            foreach (Organization organization in OrganizationData.GenerateSampleOrganizations())
            {
                if (organization.Id == TestConstants.OrganizationId3)
                {
                    _billingManager.ApplyBillingPlan(organization, BillingManager.FreePlan, UserData.GenerateSampleUser());
                }
                else
                {
                    _billingManager.ApplyBillingPlan(organization, BillingManager.SmallPlan, UserData.GenerateSampleUser());
                }

                _organizationRepository.Add(organization);
            }

            foreach (Project project in ProjectData.GenerateSampleProjects())
            {
                var organization = _organizationRepository.GetById(project.OrganizationId);
                organization.ProjectCount += 1;
                _organizationRepository.Save(organization);

                _projectRepository.Add(project);
            }
        }
コード例 #11
0
 private Task CreateTestOrganizationAndProjectsAsync()
 {
     return(Task.WhenAll(
                _organizationRepository.AddAsync(OrganizationData.GenerateSampleOrganizations(GetService <BillingManager>(), GetService <BillingPlans>()), o => o.ImmediateConsistency()),
                _projectRepository.AddAsync(ProjectData.GenerateSampleProjects(), o => o.ImmediateConsistency())
                ));
 }
コード例 #12
0
        public List <OrganizationData> GetOrganizations()
        {
            var resultList           = new List <OrganizationData>();
            var dataReader           = new CsvDataReader();
            var csvResult            = dataReader.ReadData(_filePath);
            var columnNames          = csvResult.ColumnNames;
            var indexOfId            = columnNames.ToList().IndexOf("Id");
            var indexOfName          = columnNames.ToList().IndexOf("Name");
            var indexOfAddress       = columnNames.ToList().IndexOf("Adress");
            var indexOfEmail         = columnNames.ToList().IndexOf("Email");
            var indexOfContactPerson = columnNames.ToList().IndexOf("Contact Person");

            foreach (var row in csvResult.Rows)
            {
                var volunteer = new OrganizationData()
                {
                    Id            = row[indexOfId],
                    Name          = row[indexOfName],
                    Address       = row[indexOfAddress],
                    Email         = row[indexOfEmail],
                    ContactPerson = row[indexOfContactPerson]
                };
                resultList.Add(volunteer);
            }
            return(resultList);
        }
コード例 #13
0
ファイル: GeoTests.cs プロジェクト: ysq5202121/Exceptionless
        public async Task WillSetFromSingleGeo()
        {
            var resolver = await GetResolverAsync(Log);

            if (resolver is NullGeoIpService)
            {
                return;
            }

            var plugin = new GeoPlugin(resolver, _options);

            var contexts = new List <EventContext> {
                new EventContext(new PersistentEvent {
                    Geo = GREEN_BAY_IP
                }, OrganizationData.GenerateSampleOrganization(_billingManager, _plans), ProjectData.GenerateSampleProject()),
                new EventContext(new PersistentEvent {
                    Geo = GREEN_BAY_IP
                }, OrganizationData.GenerateSampleOrganization(_billingManager, _plans), ProjectData.GenerateSampleProject())
            };

            await plugin.EventBatchProcessingAsync(contexts);

            foreach (var context in contexts)
            {
                AssertCoordinatesAreEqual(GREEN_BAY_COORDINATES, context.Event.Geo);

                var location = context.Event.GetLocation();
                Assert.Equal("US", location?.Country);
                Assert.Equal("WI", location?.Level1);
                Assert.Equal("Green Bay", location?.Locality);
            }
        }
コード例 #14
0
 private Task CreateOrganizationAndProjectsAsync()
 {
     return(Task.WhenAll(
                _organizationRepository.AddAsync(OrganizationData.GenerateSampleOrganizations(), o => o.ImmediateConsistency()),
                _projectRepository.AddAsync(ProjectData.GenerateSampleProjects(), o => o.ImmediateConsistency())
                ));
 }
コード例 #15
0
        protected override void DataPortal_Insert()
        {
            using (var dalManager = DataFactoryManager.GetManager())
            {
                var dalFactory = dalManager.GetProvider <IOrganizationDataFactory>();

                var data = new OrganizationData();

                using (this.BypassPropertyChecks)
                {
                    this.ModifiedBy   = ((IBusinessIdentity)Csla.ApplicationContext.User.Identity).UserId;
                    this.ModifiedDate = DateTime.Now;
                    this.CreatedBy    = this.ModifiedBy;
                    this.CreatedDate  = this.ModifiedDate;

                    this.Insert(data);

                    data = dalFactory.Insert(data);

                    this.OrganizationId = data.OrganizationId;
                }

                // this.FieldManager.UpdateChildren(data);
            }
        }
コード例 #16
0
        private WebHookDataContext GetWebHookDataContext(Version version)
        {
            var json = File.ReadAllText(Path.GetFullPath(@"..\..\ErrorData\1477.expected.json"));

            var settings = new JsonSerializerSettings {
                MissingMemberHandling = MissingMemberHandling.Ignore,
                ContractResolver      = new ExtensionContractResolver()
            };

            var ev = JsonConvert.DeserializeObject <PersistentEvent>(json, settings);

            ev.OrganizationId = TestConstants.OrganizationId;
            ev.ProjectId      = TestConstants.ProjectId;
            ev.StackId        = TestConstants.StackId;

            var context = new WebHookDataContext(version, ev, OrganizationData.GenerateSampleOrganization(), ProjectData.GenerateSampleProject());

            context.Stack      = StackData.GenerateStack(id: TestConstants.StackId, organizationId: TestConstants.OrganizationId, projectId: TestConstants.ProjectId, title: _formattingPluginManager.GetStackTitle(ev), signatureHash: "722e7afd4dca4a3c91f4d94fec89dfdc");
            context.Stack.Tags = new TagSet {
                "Test"
            };
            context.Stack.FirstOccurrence = context.Stack.LastOccurrence = ev.Date.DateTime;

            return(context);
        }
コード例 #17
0
        public override void UpdateConnection(IOrganizationService newService, ConnectionDetail connectionDetail, string actionName, object parameter)
        {
            toolStripButtonExport.Enabled = false;
            if (actionName == "TargetOrganization")
            {
                TargetService = newService;
                SetConnectionLabel(connectionDetail, labelTargetEnvironment);
                Controller.TargetService = TargetService;
                Controller.Target        = connectionDetail;
                TargetOrgData            = new OrganizationData();
                LoadOrganizationData(TargetService, TargetOrgData);
            }
            else
            {
                SourceService = newService;
                SetConnectionLabel(connectionDetail, labelSourceEnvironment);
                Controller.SourceService = SourceService;
                Controller.Source        = connectionDetail;
                SourceOrgData            = new OrganizationData();
                LoadOrganizationData(SourceService, SourceOrgData);
            }

            buttonCompare.Visible         = TargetService != null && SourceService != null;
            checkBoxCompareByName.Visible = buttonCompare.Visible;
            checkBoxCompareByGuid.Visible = buttonCompare.Visible;
        }
コード例 #18
0
        private async Task <List <PersistentEvent> > CreateSessionEventsAsync()
        {
            var startDate = SystemClock.OffsetUtcNow.SubtractHours(1);
            var events    = new List <PersistentEvent> {
                EventData.GenerateSessionStartEvent(occurrenceDate: startDate, userIdentity: "1"),
                EventData.GenerateSessionEndEvent(occurrenceDate: startDate.AddMinutes(10), userIdentity: "1"),
                EventData.GenerateSessionStartEvent(occurrenceDate: startDate.AddMinutes(10), userIdentity: "2"),
                EventData.GenerateSessionEndEvent(occurrenceDate: startDate.AddMinutes(30), userIdentity: "2"),
                EventData.GenerateSessionStartEvent(occurrenceDate: startDate.AddMinutes(20), userIdentity: "3"),
                EventData.GenerateSessionEndEvent(occurrenceDate: startDate.AddMinutes(50), userIdentity: "3")
            };

            await _pipeline.RunAsync(events, OrganizationData.GenerateSampleOrganization(_billingManager, _plans), ProjectData.GenerateSampleProject());

            await _configuration.Client.RefreshAsync(Indices.All);

            var results = await _eventRepository.GetByFilterAsync(null, null, EventIndexType.Alias.Date, null, DateTime.MinValue, DateTime.MaxValue, null);

            Assert.Equal(6, results.Total);
            Assert.Equal(3, results.Documents.Where(e => !String.IsNullOrEmpty(e.GetSessionId())).Select(e => e.GetSessionId()).Distinct().Count());

            var sessionStarts = results.Documents.Where(e => e.IsSessionStart()).ToList();

            Assert.Equal(TimeSpan.FromMinutes(20).TotalSeconds, (int)(sessionStarts.Sum(e => e.Value.GetValueOrDefault()) / sessionStarts.Count));

            return(events);
        }
コード例 #19
0
        /// <summary>
        /// 根据条件筛选所有Organization指定页码的数据(分页型)
        /// </summary>
        /// <param name="organization">实体对象</param>
        /// <param name="pageparams">分页对象</param>
        /// <param name="totalCount">符合条件的记录总数量</param>
        /// <returns></returns>
        public DataSet GetData(EntityOrganization organization, PageParams pageparams, out int totalCount)
        {
            #region
            DBConditions querybusinessparams = new DBConditions(pageparams);
            querybusinessparams.Add(OrganizationData.organizationId, EnumSqlType.sqlint,
                                    EnumCondition.Equal, organization.organizationId);
            querybusinessparams.Add(OrganizationData.userid, EnumSqlType.sqlint,
                                    EnumCondition.Equal, organization.userid);
            querybusinessparams.Add(OrganizationData.organizationName, EnumSqlType.nvarchar,
                                    EnumCondition.Equal, organization.organizationName);
            querybusinessparams.Add(OrganizationData.currentId, EnumSqlType.sqlint,
                                    EnumCondition.Equal, organization.currentId);
            querybusinessparams.Add(OrganizationData.parentId, EnumSqlType.sqlint,
                                    EnumCondition.Equal, organization.parentId);
            querybusinessparams.Add(OrganizationData.usable, EnumSqlType.bit,
                                    EnumCondition.Equal, organization.usable);
            querybusinessparams.Add(OrganizationData.writeIp, EnumSqlType.nvarchar,
                                    EnumCondition.Equal, organization.writeIp);
            querybusinessparams.Add(OrganizationData.writeTime, EnumSqlType.datetime,
                                    EnumCondition.Equal, organization.writeTime);
            OrganizationData organizationdata = new OrganizationData();
            totalCount = this._organizationclass.GetSingleT(organizationdata, querybusinessparams);
            return(organizationdata);

            #endregion
        }
コード例 #20
0
 /// <summary>
 ///     保存完成后期处理(Insert或Update)
 /// </summary>
 /// <param name="entity"></param>
 protected sealed override void OnDataSaved(OrganizationData entity)
 {
     using (var proxy = new RedisProxy(RedisProxy.DbComboCache))
     {
         proxy.RemoveKey(comboKey);
     }
 }
コード例 #21
0
ファイル: GeoTests.cs プロジェクト: rujianwang/Exceptionless
        public async Task WillNotSetFromMultipleGeo()
        {
            var plugin = new GeoPlugin(await GetResolverAsync(Log), _options);

            var ev            = new PersistentEvent();
            var greenBayEvent = new PersistentEvent {
                Geo = GREEN_BAY_IP
            };
            var irvingEvent = new PersistentEvent {
                Geo = IRVING_IP
            };
            await plugin.EventBatchProcessingAsync(new List <EventContext> {
                new EventContext(ev, OrganizationData.GenerateSampleOrganization(_billingManager, _plans), ProjectData.GenerateSampleProject()),
                new EventContext(greenBayEvent, OrganizationData.GenerateSampleOrganization(_billingManager, _plans), ProjectData.GenerateSampleProject()),
                new EventContext(irvingEvent, OrganizationData.GenerateSampleOrganization(_billingManager, _plans), ProjectData.GenerateSampleProject())
            });

            Assert.Equal(GREEN_BAY_COORDINATES, greenBayEvent.Geo);
            var location = greenBayEvent.GetLocation();

            Assert.Equal("US", location?.Country);
            Assert.Equal("WI", location?.Level1);
            Assert.Equal("Green Bay", location?.Locality);

            Assert.Equal(IRVING_COORDINATES, irvingEvent.Geo);
            location = irvingEvent.GetLocation();
            Assert.Equal("US", location?.Country);
            Assert.Equal("TX", location?.Level1);
            Assert.Equal("Irving", location?.Locality);
        }
コード例 #22
0
ファイル: MailerTests.cs プロジェクト: mcquaiga/Exceptionless
        public Task SendPaymentFailedAsync()
        {
            var          mailer       = IoC.GetInstance <Mailer>();
            User         user         = UserData.GenerateSampleUser();
            Organization organization = OrganizationData.GenerateSampleOrganization();

            return(mailer.SendPaymentFailedAsync(user, organization));
        }
コード例 #23
0
        public async Task CreateOrganizationAndProjectsAsync()
        {
            await _organizationRepository.AddAsync(OrganizationData.GenerateSampleOrganizations());

            await _projectRepository.AddAsync(ProjectData.GenerateSampleProjects());

            await _configuration.Client.RefreshAsync(Indices.All);
        }
コード例 #24
0
        public void SendPaymentFailed()
        {
            var          mailer       = IoC.GetInstance <Mailer>();
            User         user         = UserData.GenerateSampleUser();
            Organization organization = OrganizationData.GenerateSampleOrganization();

            mailer.SendPaymentFailed(user, organization);
        }
コード例 #25
0
        public void SendAddedToOrganization()
        {
            var          mailer       = IoC.GetInstance <Mailer>();
            User         user         = UserData.GenerateSampleUser();
            Organization organization = OrganizationData.GenerateSampleOrganization();

            mailer.SendAddedToOrganization(user, organization, user);
        }
コード例 #26
0
        private void f(object A_0, EventArgs A_1)
        {
            OrganizationData item = (OrganizationData)this.comboBox1.Items[this.comboBox1.SelectedIndex];

            this.organizationData = item;
            this.a(item.Id);
            this.a(item);
        }
コード例 #27
0
    public DataBindings()
    {
        Organization         = new OrganizationData();
        Organization.Address = "123 Test Street";

        Contact         = new ContactData();
        Contact.Address = "456 Test Street";
    }
コード例 #28
0
        public async Task SendPaymentFailedAsync()
        {
            User         user         = UserData.GenerateSampleUser();
            Organization organization = OrganizationData.GenerateSampleOrganization();
            await _mailer.SendPaymentFailedAsync(user, organization);

            await RunMailJobAsync();
        }
コード例 #29
0
        /// <summary>
        /// 保存organizationdata数据集数据
        /// </summary>
        /// <param name="organizationdata">数据集对象</param>
        /// <returns>返回保存后的响应信息</returns>
        public String SaveOrganization(OrganizationData organizationdata)
        {
            #region
            OrganizationClass organizationclass = new OrganizationClass();
            return(base.Save(organizationdata, organizationclass));

            #endregion
        }
コード例 #30
0
 /// <summary>
 /// 载入数据
 /// </summary>
 /// <param name="reader">数据读取器</param>
 /// <param name="entity">读取数据的实体</param>
 public override void SimpleLoad(MySqlDataReader reader, OrganizationData entity)
 {
     using (new EditScope(entity.__EntityStatus, EditArrestMode.All, false))
     {
         entity._id = (int)reader.GetInt32(0);
         if (!reader.IsDBNull(1))
         {
             entity._type = (OrganizationType)reader.GetInt32(1);
         }
         if (!reader.IsDBNull(2))
         {
             entity._code = reader.GetString(2).ToString();
         }
         if (!reader.IsDBNull(3))
         {
             entity._fullname = reader.GetString(3).ToString();
         }
         if (!reader.IsDBNull(4))
         {
             entity._shortname = reader.GetString(4).ToString();
         }
         if (!reader.IsDBNull(5))
         {
             entity._treename = reader.GetString(5).ToString();
         }
         entity._orglevel = (int)reader.GetInt32(6);
         entity._parentid = (int)reader.GetInt32(7);
         entity._orgid    = (int)reader.GetInt32(8);
         if (!reader.IsDBNull(9))
         {
             entity._memo = reader.GetString(9).ToString();
         }
         if (!reader.IsDBNull(10))
         {
             entity._datastate = (DataStateType)reader.GetInt32(10);
         }
         entity._isfreeze = (bool)reader.GetBoolean(11);
         entity._authorid = (int)reader.GetInt32(12);
         if (!reader.IsDBNull(13))
         {
             try{ entity._adddate = reader.GetMySqlDateTime(13).Value; }catch {}
         }
         entity._lastreviserid = (int)reader.GetInt32(14);
         if (!reader.IsDBNull(15))
         {
             try{ entity._lastmodifydate = reader.GetMySqlDateTime(15).Value; }catch {}
         }
         if (!reader.IsDBNull(16))
         {
             entity._auditstate = (AuditStateType)reader.GetInt32(16);
         }
         entity._auditorid = (int)reader.GetInt32(17);
         if (!reader.IsDBNull(18))
         {
             try{ entity._auditdate = reader.GetMySqlDateTime(18).Value; }catch {}
         }
     }
 }
コード例 #31
0
        public OrganizationData Fetch(OrganizationData data)
        {
            data.CreatedByUser = MockDb.Users
                .Where(row => row.UserId == data.CreatedBy)
                .Single();

            data.ModifiedByUser = MockDb.Users
                .Where(row => row.UserId == data.ModifiedBy)
                .Single();

            return data;
        }
コード例 #32
0
        public OrganizationData Fetch(OrganizationDataCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                         .GetManager(Database.ApplicationConnection, false))
            {
                var organization = this.Fetch(ctx, criteria)
                    .Single();

                var organizationData = new OrganizationData();

                this.Fetch(organization, organizationData);

                return organizationData;
            }
        }
コード例 #33
0
        public OrganizationData Insert(OrganizationData data)
        {
            if (MockDb.Organizations.Count() == 0)
            {
                data.OrganizationId = 1;
            }
            else
            {
                data.OrganizationId = MockDb.Organizations.Select(row => row.OrganizationId).Max() + 1;
            }

            MockDb.Organizations.Add(data);

            return data;
        }
コード例 #34
0
        public OrganizationData[] FetchLookupInfoList(OrganizationDataCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                          .GetManager(Database.ApplicationConnection, false))
            {
                var organizations = this.Fetch(ctx, criteria)
                    .AsEnumerable();

                var organizationDataList = new List<OrganizationData>();

                foreach (var organization in organizations)
                {
                    var organizationData = new OrganizationData();

                    this.Fetch(organization, organizationData);

                    organizationDataList.Add(organizationData);
                }

                return organizationDataList.ToArray();
            }
        }
コード例 #35
0
        public OrganizationData Update(OrganizationData data)
        {
            var organization = MockDb.Organizations
                .Where(row => row.OrganizationId == data.OrganizationId)
                .Single();

            Csla.Data.DataMapper.Map(data, organization);

            return data;
        }
コード例 #36
0
        public OrganizationData Update(OrganizationData data)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                         .GetManager(Database.ApplicationConnection, false))
            {
                var organization =
                    new Organization
                    {
                        OrganizationId = data.OrganizationId
                    };

                ctx.ObjectContext.Organizations.Attach(organization);

                DataMapper.Map(data, organization);

                ctx.ObjectContext.SaveChanges();

                return data;
            }
        }
コード例 #37
0
        private void Fetch(Organization organization, OrganizationData organizationData)
        {
            DataMapper.Map(organization, organizationData);

            organizationData.CreatedByUser = new UserData();
            DataMapper.Map(organization.CreatedByUser, organizationData.CreatedByUser);

            organizationData.ModifiedByUser = new UserData();
            DataMapper.Map(organization.ModifiedByUser, organizationData.ModifiedByUser);
        }
コード例 #38
0
        public OrganizationData Insert(OrganizationData data)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                           .GetManager(Database.ApplicationConnection, false))
            {
                var organization = new Organization();

                DataMapper.Map(data, organization);

                ctx.ObjectContext.AddToOrganizations(organization);

                ctx.ObjectContext.SaveChanges();

                data.OrganizationId = organization.OrganizationId;

                return data;
            }
        }
コード例 #39
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String smsSid = Request.Form["SmsSid"].ToString();
            String status = Request.Form["SmsStatus"].ToString().ToLower();
            SmsHistory history;

            //
            // Check if this is a received message.
            //
            if (status == "received")
            {
                OrganizationData orgData = new OrganizationData();
                LookupCollection validNumbers = new LookupCollection(new Guid("11B4ADEC-CB8C-4D01-B99E-7A0FFE2007B5"));
                LookupCollection twilioHandlers = new LookupCollection(new Guid("FC1BA7E8-C22A-48CF-8A30-5DF640049373"));
                String body = Request.Form["Body"].ToString();
                String from = Request.Form["From"].ToString();
                String to = Request.Form["To"].ToString();
                String baseUrl;
                StringBuilder sb = new StringBuilder();
                List<String> possiblyFrom = new List<String>();
                Boolean handled = false;
                PersonCollection col = new PersonCollection();
                Lookup lkTo = null;

                //
                // Look for the twilio phone number, if not found ignore the incoming message.
                //
                to = TwilioSMS.CleanPhone(to);
                foreach (Lookup lk in validNumbers)
                {
                    if (lk.Active && to == TwilioSMS.CleanPhone(lk.Qualifier))
                    {
                        lkTo = lk;
                        break;
                    }
                }
                if (lkTo == null)
                    return;

                //
                // Load all person records that match the phone number.
                //
                from = TwilioSMS.CleanPhone(from);
                if (from.StartsWith("1"))
                    col.LoadByPhone(from.Substring(1));
                else
                    col.LoadByPhone(from);

                //
                // Build a list of ID numbers for the person IDs that this could be from.
                //
                foreach (Person p in col)
                {
                    possiblyFrom.Add(p.PersonID.ToString());
                }

                //
                // See if we can find a stored procedure that wants to handle this message.
                //
                try
                {
                    foreach (Lookup handler in twilioHandlers)
                    {
                        ArrayList parms = new ArrayList();
                        SqlParameter outStatus = new SqlParameter("@OutStatus", SqlDbType.Int);
                        SqlParameter outMessage = new SqlParameter("@OutMessage", SqlDbType.VarChar, 2000);

                        if (handler.Active == false)
                            continue;

                        //
                        // Check if this handler is for us.
                        //
                        if (Convert.ToInt32(handler.Qualifier) != lkTo.LookupID && lkTo.LookupID != -1)
                            continue;

                        //
                        // Check if there is a match on the regular expression.
                        //
                        if (!Regex.IsMatch(body, handler.Qualifier2, RegexOptions.IgnoreCase))
                            continue;

                        outStatus.Direction = ParameterDirection.Output;
                        outMessage.Direction = ParameterDirection.Output;
                        parms.Add(new SqlParameter("@FromNumber", from));
                        parms.Add(new SqlParameter("@PossiblyFrom", String.Join(",", possiblyFrom.ToArray())));
                        parms.Add(new SqlParameter("@ToNumber", to));
                        parms.Add(new SqlParameter("@ToNumberID", lkTo.LookupID));
                        parms.Add(new SqlParameter("@Message", body));
                        parms.Add(outStatus);
                        parms.Add(outMessage);

                        orgData.ExecuteNonQuery(handler.Qualifier3, parms);

                        //
                        // See if a response should be sent.
                        //
                        if ((int)outStatus.Value == 1)
                        {
                            if (!String.IsNullOrEmpty((String)outMessage.Value))
                            {
                                int len = outMessage.Value.ToString().Length;

                                if (len > 160)
                                    len = 160;
                                Response.Clear();
                                Response.ContentType = "text/plain";
                                Response.Write(outMessage.Value.ToString().Substring(0, len));

                                //
                                // Set the base url.
                                //
                                baseUrl = ArenaContext.Current.AppSettings["ApplicationURLPath"];
                                if (!baseUrl.EndsWith("/"))
                                    baseUrl = baseUrl + "/";
                                baseUrl = String.Format("{0}default.aspx?page={1}", baseUrl, personDetailPageId);

                                //
                                // If there is a valid e-mail address to forward the text to then build up an e-mail
                                // message and send an e-mail.
                                //
                                if (!String.IsNullOrEmpty(handler.Qualifier4))
                                {
                                    try
                                    {
                                        sb.AppendFormat("<p>Received a text message from {0} to {1} ({2})</p>", from, to, lkTo.Value);
                                        sb.AppendFormat("<p>Message: {0}</p>", body);

                                        if (col.Count > 0)
                                        {
                                            sb.Append("<p>Possibly received from:<br /><ul>");
                                            foreach (Person p in col)
                                            {
                                                sb.AppendFormat("<li><a href=\"{0}&guid={1}\">{2}</a></li>", baseUrl, p.PersonGUID.ToString(), Server.HtmlEncode(p.FullName));
                                            }
                                            sb.Append("</ul></p>");
                                        }

                                        ArenaSendMail.SendMail(String.Empty, String.Empty, handler.Qualifier4, "Received SMS message", sb.ToString());
                                    }
                                    catch (System.Exception ex)
                                    {
                                        try
                                        {
                                            new Arena.DataLayer.Core.ExceptionHistoryData().AddUpdate_Exception(ex,
                                                ArenaContext.Current.Organization.OrganizationID,
                                                "HDC.Twilio", ArenaContext.Current.ServerUrl);
                                        }
                                        catch { }
                                    }
                                }

                                Response.End();
                            }

                            handled = true;
                            break;
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    if (ex.Message != "Thread was being aborted.")
                    {
                        new Arena.DataLayer.Core.ExceptionHistoryData().AddUpdate_Exception(ex,
                            ArenaContext.Current.Organization.OrganizationID,
                            "HDC.Twilio", ArenaContext.Current.ServerUrl);
                    }
                }

                //
                // If the message has already been handled, we don't need to send any replies or
                // e-mail anybody.
                //
                if (!handled)
                {
                    //
                    // Set the base url.
                    //
                    baseUrl = ArenaContext.Current.AppSettings["ApplicationURLPath"];
                    if (!baseUrl.EndsWith("/"))
                        baseUrl = baseUrl + "/";
                    baseUrl = String.Format("{0}default.aspx?page={1}", baseUrl, personDetailPageId);

                    //
                    // If there is a valid e-mail address to forward the text to then build up an e-mail
                    // message and send an e-mail.
                    //
                    if (!String.IsNullOrEmpty(lkTo.Qualifier2))
                    {
                        try
                        {
                            sb.AppendFormat("<p>Received a text message from {0} to {1} ({2})</p>", from, to, lkTo.Value);
                            sb.AppendFormat("<p>Message: {0}</p>", body);

                            if (col.Count > 0)
                            {
                                sb.Append("<p>Possibly received from:<br /><ul>");
                                foreach (Person p in col)
                                {
                                    sb.AppendFormat("<li><a href=\"{0}&guid={1}\">{2}</a></li>", baseUrl, p.PersonGUID.ToString(), Server.HtmlEncode(p.FullName));
                                }
                                sb.Append("</ul></p>");
                            }

                            ArenaSendMail.SendMail(String.Empty, String.Empty, lkTo.Qualifier2, "Received SMS message", sb.ToString());
                        }
                        catch (System.Exception ex)
                        {
                            try
                            {
                                new Arena.DataLayer.Core.ExceptionHistoryData().AddUpdate_Exception(ex,
                                    ArenaContext.Current.Organization.OrganizationID,
                                    "HDC.Twilio", ArenaContext.Current.ServerUrl);
                            }
                            catch { }
                        }
                    }

                    //
                    // If there is an auto-reply message in the lookup then send back that message.
                    //
                    if (!String.IsNullOrEmpty(lkTo.Qualifier8))
                    {
                        try
                        {
                            int len = lkTo.Qualifier8.Length;

                            if (len > 160)
                                len = 160;
                            Response.Clear();
                            Response.ContentType = "text/plain";
                            Response.Write(lkTo.Qualifier8.Substring(0, len));
                            Response.End();
                        }
                        catch (System.Exception ex)
                        {
                            try
                            {
                                if (ex.Message != "Thread was being aborted.")
                                {
                                    new Arena.DataLayer.Core.ExceptionHistoryData().AddUpdate_Exception(ex,
                                        ArenaContext.Current.Organization.OrganizationID,
                                        "HDC.Twilio", ArenaContext.Current.ServerUrl);
                                }
                            }
                            catch { }
                        }
                    }
                }
            }
            else
            {
                //
                // This (should be) a status response to an outgoing message.
                //
                history = new SmsHistory(smsSid);
                if (history.SmsHistoryId != -1)
                {
                    try
                    {
                        if (status == "sent")
                        {
                            new PersonCommunicationData().SavePersonCommunication(history.CommunicationId, history.PersonId, DateTime.Now, "Success");
                        }
                        else
                        {
                            new PersonCommunicationData().SavePersonCommunication(history.CommunicationId, history.PersonId, DateTime.Now, "Failed");
                        }
                    }
                    catch (System.Exception)
                    {
                    }

                    history.Delete();
                }
            }
        }